From 07a04255da4442fb0790130ac65c648d0884255a Mon Sep 17 00:00:00 2001 From: amit verma Date: Thu, 25 Feb 2021 23:13:21 +0530 Subject: [PATCH 1/2] initial break request handling --- src/class/cdc/cdc_device.c | 11 +++++++++++ src/class/cdc/cdc_device.h | 3 +++ 2 files changed, 14 insertions(+) diff --git a/src/class/cdc/cdc_device.c b/src/class/cdc/cdc_device.c index 58f485a5..5a74b487 100644 --- a/src/class/cdc/cdc_device.c +++ b/src/class/cdc/cdc_device.c @@ -396,6 +396,17 @@ bool cdcd_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_request_t if ( tud_cdc_line_state_cb ) tud_cdc_line_state_cb(itf, dtr, rts); } break; + case CDC_REQUEST_SEND_BREAK: + if (stage == CONTROL_STAGE_SETUP) + { + tud_control_status(rhport, request); + } + else if (stage == CONTROL_STAGE_ACK) + { + TU_LOG2(" Send Break\r\n"); + if ( tud_cdc_send_break_cb ) tud_cdc_send_break_cb(itf, request->wValue); + } + break; default: return false; // stall unsupported request } diff --git a/src/class/cdc/cdc_device.h b/src/class/cdc/cdc_device.h index 62dcd3c0..d10fe68d 100644 --- a/src/class/cdc/cdc_device.h +++ b/src/class/cdc/cdc_device.h @@ -133,6 +133,9 @@ static inline bool tud_cdc_write_clear (void); // Invoked when received new data TU_ATTR_WEAK void tud_cdc_rx_cb(uint8_t itf); +// Invoked when received send break +TU_ATTR_WEAK void tud_cdc_send_break_cb(uint8_t itf, uint16_t wait_ms); + // Invoked when received `wanted_char` TU_ATTR_WEAK void tud_cdc_rx_wanted_cb(uint8_t itf, char wanted_char); From 55a46a5c3b7ad3afb70a995954baa6148381b3a5 Mon Sep 17 00:00:00 2001 From: boggyb Date: Fri, 26 Feb 2021 11:00:34 +0530 Subject: [PATCH 2/2] Update cdc_device.h Minor api callback change as requested --- src/class/cdc/cdc_device.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/class/cdc/cdc_device.h b/src/class/cdc/cdc_device.h index d10fe68d..0885922c 100644 --- a/src/class/cdc/cdc_device.h +++ b/src/class/cdc/cdc_device.h @@ -133,9 +133,6 @@ static inline bool tud_cdc_write_clear (void); // Invoked when received new data TU_ATTR_WEAK void tud_cdc_rx_cb(uint8_t itf); -// Invoked when received send break -TU_ATTR_WEAK void tud_cdc_send_break_cb(uint8_t itf, uint16_t wait_ms); - // Invoked when received `wanted_char` TU_ATTR_WEAK void tud_cdc_rx_wanted_cb(uint8_t itf, char wanted_char); @@ -148,6 +145,9 @@ TU_ATTR_WEAK void tud_cdc_line_state_cb(uint8_t itf, bool dtr, bool rts); // Invoked when line coding is change via SET_LINE_CODING TU_ATTR_WEAK void tud_cdc_line_coding_cb(uint8_t itf, cdc_line_coding_t const* p_line_coding); +// Invoked when received send break +TU_ATTR_WEAK void tud_cdc_send_break_cb(uint8_t itf, uint16_t duration_ms); + //--------------------------------------------------------------------+ // Inline Functions //--------------------------------------------------------------------+