diff --git a/source/board/artemis_dk.c b/source/board/artemis_dk.c index c91de44bad..b2701905de 100644 --- a/source/board/artemis_dk.c +++ b/source/board/artemis_dk.c @@ -52,15 +52,6 @@ static void prerun_board_config(void) set_board_id(board_version); } -// USB HID override function return 1 if the activity is trivial or response is null -uint8_t usbd_hid_no_activity(uint8_t *buf) -{ - if (buf[0] == ID_DAP_Vendor3 && buf[1] == 0) - return 1; - else - return 0; -} - const board_info_t g_board_info = { .info_version = 0x1, .family_id = kAmbiq_ama3b1kk_FamilyID, diff --git a/source/board/microbit.c b/source/board/microbit.c index a3e0b46dc3..605164594d 100644 --- a/source/board/microbit.c +++ b/source/board/microbit.c @@ -69,15 +69,6 @@ static void prerun_board_config(void) { set_board_id(board_version); } -// USB HID override function return 1 if the activity is trivial or response is null -uint8_t usbd_hid_no_activity(uint8_t *buf) -{ - if(buf[0] == ID_DAP_Vendor3 && buf[1] == 0) - return 1; - else - return 0; -} - extern target_cfg_t target_device_nrf51822_16; const board_info_t g_board_info = { diff --git a/source/board/microbitv2/microbitv2.c b/source/board/microbitv2/microbitv2.c index 6523025a33..427e4e3268 100644 --- a/source/board/microbitv2/microbitv2.c +++ b/source/board/microbitv2/microbitv2.c @@ -457,15 +457,6 @@ uint8_t board_detect_incompatible_image(const uint8_t *data, uint32_t size) return result == 0; } -// USB HID override function return 1 if the activity is trivial or response is null -uint8_t usbd_hid_no_activity(uint8_t *buf) -{ - if(buf[0] == ID_DAP_Vendor3 && buf[1] == 0) - return 1; - else - return 0; -} - // This function is called before the rest of target_set_state code, so it will // reset the micro:bit specific features state before the target state is executed static uint8_t target_set_state_microbit(target_state_t state) diff --git a/source/daplink/cmsis-dap/DAP_queue.c b/source/daplink/cmsis-dap/DAP_queue.c index 4f7e452557..d743ba9c0f 100644 --- a/source/daplink/cmsis-dap/DAP_queue.c +++ b/source/daplink/cmsis-dap/DAP_queue.c @@ -21,6 +21,9 @@ #include #include "DAP_queue.h" +#include "daplink_vendor_commands.h" +#include "main_interface.h" + void DAP_queue_init(DAP_queue * queue) { queue->recv_idx = 0; @@ -48,6 +51,20 @@ BOOL DAP_queue_get_send_buf(DAP_queue * queue, uint8_t ** buf, int * len) return (__FALSE); } +/* + * Overridable function to determine if the DAP activity should trigger or + * not the HID LED to flash. + * Parameters: buf: buffer with DAP request + * Return Value: 1 if DAP activity should blink the HID LED, 0 otherwise + */ +__WEAK uint8_t DAP_activity_blink(const uint8_t *buf) +{ + // Skip UART and MSD DAPLink Vendor DAP commands as they already produce LED blinks + return (buf[0] == ID_DAP_UART_Read || + buf[0] == ID_DAP_UART_Write || + buf[0] == ID_DAP_MSD_Write) ? 0 : 1; +} + /* * Execute a request and store result to the DAP_queue * Parameters: queue - DAP queue, reqbuf = buffer with DAP request, len = of the request buffer, retbuf = buffer to peek on the result of the DAP operation @@ -59,6 +76,10 @@ BOOL DAP_queue_execute_buf(DAP_queue * queue, const uint8_t *reqbuf, int len, ui { uint32_t rsize; if (queue->free_count > 0) { + if (DAP_activity_blink(reqbuf)) { + main_blink_hid_led(MAIN_LED_FLASH); + } + if (len > DAP_PACKET_SIZE) { len = DAP_PACKET_SIZE; } diff --git a/source/usb/bulk/usbd_bulk.c b/source/usb/bulk/usbd_bulk.c index 916af91a34..a0d3ac8561 100644 --- a/source/usb/bulk/usbd_bulk.c +++ b/source/usb/bulk/usbd_bulk.c @@ -78,7 +78,6 @@ void USBD_BULK_EP_BULKOUT_Event(U32 event) if ((DataInReceLen >= USBD_Bulk_BulkBufSize) || (bytes_rece < usbd_bulk_maxpacketsize[USBD_HighSpeed])) { if (DAP_queue_execute_buf(&DAP_Cmd_queue, USBD_Bulk_BulkOutBuf, DataInReceLen, &rbuf)) { - main_blink_hid_led(MAIN_LED_FLASH); //Trigger the BULKIn for the reply if (USB_ResponseIdle) { USBD_BULK_EP_BULKIN_Event(0); diff --git a/source/usb/hid/usbd_user_hid.c b/source/usb/hid/usbd_user_hid.c index bd2fe107ab..b2ccb05f7d 100644 --- a/source/usb/hid/usbd_user_hid.c +++ b/source/usb/hid/usbd_user_hid.c @@ -28,8 +28,6 @@ #include "DAP.h" #include "util.h" #include "DAP_queue.h" -#include "daplink.h" -#include DAPLINK_MAIN_HEADER #if (USBD_HID_OUTREPORT_MAX_SZ > DAP_PACKET_SIZE) @@ -97,18 +95,10 @@ int usbd_hid_get_report(U8 rtype, U8 rid, U8 *buf, U8 req) return (0); } -// USB HID override function return 1 if the activity is trivial or response is null -__attribute__((weak)) -uint8_t usbd_hid_no_activity(U8 *buf) -{ - return 0; -} - // USB HID Callback: when data is received from the host void usbd_hid_set_report(U8 rtype, U8 rid, U8 *buf, int len, U8 req) { uint8_t * rbuf; - main_led_state_t led_next_state = MAIN_LED_FLASH; switch (rtype) { case HID_REPORT_OUTPUT: if (len == 0) { @@ -122,10 +112,6 @@ void usbd_hid_set_report(U8 rtype, U8 rid, U8 *buf, int len, U8 req) // execute and store to DAP_queue if (DAP_queue_execute_buf(&DAP_Cmd_queue, buf, len, &rbuf)) { - if(usbd_hid_no_activity(rbuf) == 1){ - //revert HID LED to default if the response is null - led_next_state = MAIN_LED_DEF; - } if (USB_ResponseIdle) { hid_send_packet(); USB_ResponseIdle = 0; @@ -133,9 +119,6 @@ void usbd_hid_set_report(U8 rtype, U8 rid, U8 *buf, int len, U8 req) } else { util_assert(0); } - - main_blink_hid_led(led_next_state); - break; case HID_REPORT_FEATURE: