Skip to content

Commit 68c94e1

Browse files
committed
move tud_cdc_line_state_cb
1 parent e02b3ff commit 68c94e1

File tree

2 files changed

+21
-16
lines changed

2 files changed

+21
-16
lines changed

cores/nRF5/usb/Adafruit_TinyUSB_core/Adafruit_USBDev_CDC.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,4 +117,25 @@ size_t Adafruit_USBDev_CDC::write(const uint8_t *buffer, size_t size)
117117
return size - remain;
118118
}
119119

120+
extern "C"
121+
{
122+
123+
// Invoked when cdc when line state changed e.g connected/disconnected
124+
// Use to reset to DFU when disconnect with 1200 bps
125+
void tud_cdc_line_state_cb(uint8_t itf, bool dtr, bool rts)
126+
{
127+
(void) itf; // interface ID, not used
128+
129+
// DTR = false is counted as disconnected
130+
if ( !dtr )
131+
{
132+
cdc_line_coding_t coding;
133+
tud_cdc_get_line_coding(&coding);
134+
135+
if ( coding.bit_rate == 1200 ) enterSerialDfu();
136+
}
137+
}
138+
139+
}
140+
120141
#endif // NRF52840_XXAA

cores/nRF5/usb/usb.c

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -117,20 +117,4 @@ static void usb_device_task(void* param)
117117
}
118118
}
119119

120-
// Invoked when cdc when line state changed e.g connected/disconnected
121-
// Use to reset to DFU when disconnect with 1200 bps
122-
void tud_cdc_line_state_cb(uint8_t itf, bool dtr, bool rts)
123-
{
124-
(void) itf; // interface ID, not used
125-
126-
// DTR = false is counted as disconnected
127-
if ( !dtr )
128-
{
129-
cdc_line_coding_t coding;
130-
tud_cdc_get_line_coding(&coding);
131-
132-
if ( coding.bit_rate == 1200 ) enterSerialDfu();
133-
}
134-
}
135-
136120
#endif

0 commit comments

Comments
 (0)