diff --git a/right/src/buspal/bus_pal_hardware.c b/right/src/buspal/bus_pal_hardware.c index c58fbaa..a498ae5 100644 --- a/right/src/buspal/bus_pal_hardware.c +++ b/right/src/buspal/bus_pal_hardware.c @@ -5,11 +5,12 @@ #include "bootloader_config.h" #include "microseconds/microseconds.h" #include "i2c.h" +#include "peripherials/test_led.h" bool usb_hid_poll_for_activity(const peripheral_descriptor_t *self); static status_t usb_device_full_init(const peripheral_descriptor_t *self, serial_byte_receive_func_t function); static void usb_device_full_shutdown(const peripheral_descriptor_t *self); -static void usb_msc_pump(const peripheral_descriptor_t *self); + status_t usb_hid_packet_init(const peripheral_descriptor_t *self); static void usb_hid_packet_abort_data_phase(const peripheral_descriptor_t *self); static status_t usb_hid_packet_finalize(const peripheral_descriptor_t *self); @@ -50,8 +51,6 @@ static i2c_user_config_t s_i2cUserConfig = {.slaveAddress = 0x10, //!< The slave static i2c_master_handle_t s_i2cHandle; -uint32_t g_calculatedBaudRate; - bool usb_clock_init(void) { SIM->CLKDIV2 = (uint32_t)0x0UL; /* Update USB clock prescalers */ @@ -243,6 +242,7 @@ void usb_device_full_shutdown(const peripheral_descriptor_t *self) void usb_msc_pump(const peripheral_descriptor_t *self) { s_dHidActivity = true; + TEST_LED_OFF(); } status_t usb_hid_packet_init(const peripheral_descriptor_t *self) diff --git a/right/src/buspal/bus_pal_hardware.h b/right/src/buspal/bus_pal_hardware.h index 1d0a38d..3df5e45 100644 --- a/right/src/buspal/bus_pal_hardware.h +++ b/right/src/buspal/bus_pal_hardware.h @@ -23,5 +23,6 @@ bool usb_hid_poll_for_activity(const peripheral_descriptor_t *self); status_t usb_hid_packet_init(const peripheral_descriptor_t *self); status_t usb_hid_packet_read(const peripheral_descriptor_t *self, uint8_t **packet, uint32_t *packetLength, packet_type_t packetType); status_t usb_hid_packet_write(const peripheral_descriptor_t *self, const uint8_t *packet, uint32_t byteCount,packet_type_t packetType); +extern void usb_msc_pump(const peripheral_descriptor_t *self); #endif diff --git a/right/src/buspal/command.c b/right/src/buspal/command.c index 047d1d4..e9eed6c 100644 --- a/right/src/buspal/command.c +++ b/right/src/buspal/command.c @@ -1,6 +1,7 @@ #include "command.h" #include "crc16.h" #include "bus_pal_hardware.h" +#include "peripherials/test_led.h" command_processor_data_t g_commandData; buspal_state_t g_buspalState = kBuspal_Idle; @@ -25,12 +26,15 @@ void handleUsbBusPalCommand() while (1) { + usb_msc_pump(g_peripherals); bootloader_command_pump(); + usb_msc_pump(g_peripherals); } } static void handle_config_i2c(uint8_t *packet, uint32_t packetLength) { +// TEST_LED_OFF(); configure_i2c_packet_t *command = (configure_i2c_packet_t *)packet; configure_i2c_address(command->address); configure_i2c_speed(command->speed); @@ -384,19 +388,19 @@ status_t bootloader_command_pump() status = usb_hid_packet_read(&g_peripherals[0], &g_commandData.packet, &g_commandData.packetLength, kPacketType_Command); - +//if (g_commandData.packet[12] == 0x64) TEST_LED_OFF(); if (status != kStatus_Success) { debug_printf("Error: readPacket returned status 0x%x\r\n", status); break; } +// TEST_LED_OFF(); if (g_commandData.packetLength == 0) { // No command packet is available. Return success. break; } - cmdPacket = (command_packet_t *)g_commandData.packet; cmdTag = cmdPacket->commandTag; diff --git a/right/src/buspal/command.h b/right/src/buspal/command.h index 0fe872d..82b7521 100644 --- a/right/src/buspal/command.h +++ b/right/src/buspal/command.h @@ -49,6 +49,8 @@ typedef struct CommandInterface { // Default command interface. extern command_interface_t g_commandInterface; +void handleUsbBusPalCommand(); + // Initialize the command processor component. status_t bootloader_command_init(void); diff --git a/right/src/main.c b/right/src/main.c index 0d82270..38ca582 100644 --- a/right/src/main.c +++ b/right/src/main.c @@ -11,6 +11,7 @@ #include "usb_interfaces/usb_interface_media_keyboard.h" #include "bus_pal_hardware.h" #include "bootloader_config.h" +#include "command.h" key_matrix_t KeyMatrix = { .colNum = KEYBOARD_MATRIX_COLS_NUM, @@ -90,13 +91,13 @@ void main() { InitClock(); #ifdef ENABLE_BUSPAL init_hardware(); + handleUsbBusPalCommand(); #else LedDriver_InitAllLeds(1); InitBridgeProtocolScheduler(); KeyMatrix_Init(&KeyMatrix); UpdateUsbReports(); InitUsb(); -#endif // deserialize_Layer(testData, 0); @@ -104,4 +105,5 @@ void main() { UpdateUsbReports(); asm("wfi"); } +#endif }