From 68c94e1199c7d4aee62bf3d4d26362fed8b46f7f Mon Sep 17 00:00:00 2001 From: hathach Date: Thu, 25 Apr 2019 00:57:55 +0700 Subject: [PATCH] move tud_cdc_line_state_cb --- .../Adafruit_USBDev_CDC.cpp | 21 +++++++++++++++++++ cores/nRF5/usb/usb.c | 16 -------------- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/cores/nRF5/usb/Adafruit_TinyUSB_core/Adafruit_USBDev_CDC.cpp b/cores/nRF5/usb/Adafruit_TinyUSB_core/Adafruit_USBDev_CDC.cpp index 7b87d879..c9623ce5 100644 --- a/cores/nRF5/usb/Adafruit_TinyUSB_core/Adafruit_USBDev_CDC.cpp +++ b/cores/nRF5/usb/Adafruit_TinyUSB_core/Adafruit_USBDev_CDC.cpp @@ -117,4 +117,25 @@ size_t Adafruit_USBDev_CDC::write(const uint8_t *buffer, size_t size) return size - remain; } +extern "C" +{ + +// Invoked when cdc when line state changed e.g connected/disconnected +// Use to reset to DFU when disconnect with 1200 bps +void tud_cdc_line_state_cb(uint8_t itf, bool dtr, bool rts) +{ + (void) itf; // interface ID, not used + + // DTR = false is counted as disconnected + if ( !dtr ) + { + cdc_line_coding_t coding; + tud_cdc_get_line_coding(&coding); + + if ( coding.bit_rate == 1200 ) enterSerialDfu(); + } +} + +} + #endif // NRF52840_XXAA diff --git a/cores/nRF5/usb/usb.c b/cores/nRF5/usb/usb.c index 83855451..254eea1b 100644 --- a/cores/nRF5/usb/usb.c +++ b/cores/nRF5/usb/usb.c @@ -117,20 +117,4 @@ static void usb_device_task(void* param) } } -// Invoked when cdc when line state changed e.g connected/disconnected -// Use to reset to DFU when disconnect with 1200 bps -void tud_cdc_line_state_cb(uint8_t itf, bool dtr, bool rts) -{ - (void) itf; // interface ID, not used - - // DTR = false is counted as disconnected - if ( !dtr ) - { - cdc_line_coding_t coding; - tud_cdc_get_line_coding(&coding); - - if ( coding.bit_rate == 1200 ) enterSerialDfu(); - } -} - #endif