Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions source/board/artemis_dk.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 0 additions & 9 deletions source/board/microbit.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
9 changes: 0 additions & 9 deletions source/board/microbitv2/microbitv2.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
21 changes: 21 additions & 0 deletions source/daplink/cmsis-dap/DAP_queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@

#include <string.h>
#include "DAP_queue.h"
#include "daplink_vendor_commands.h"
#include "main_interface.h"

void DAP_queue_init(DAP_queue * queue)
{
queue->recv_idx = 0;
Expand Down Expand Up @@ -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
Expand All @@ -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;
}
Expand Down
1 change: 0 additions & 1 deletion source/usb/bulk/usbd_bulk.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
17 changes: 0 additions & 17 deletions source/usb/hid/usbd_user_hid.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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) {
Expand All @@ -122,20 +112,13 @@ 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;
}
} else {
util_assert(0);
}

main_blink_hid_led(led_next_state);

break;

case HID_REPORT_FEATURE:
Expand Down