Skip to content

Commit 2e2fe37

Browse files
committed
bus reset for KL25Z fix, USBSerial update
1. added call to busReset() to KL25Z HAL; now the USB stack survives if you disconnect the cable, similar to LPC40 2. busReset callback to update terminal_connected in USBCDC 3. new bool USBSerial::connected() to read protected terminal_connected property, useful when you want to check if the terminal is ready from main app
1 parent 247238d commit 2e2fe37

File tree

5 files changed

+19
-0
lines changed

5 files changed

+19
-0
lines changed

features/unsupported/USBDevice/USBDevice/USBHAL_KL25Z.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,9 @@ void USBHAL::usbisr(void) {
455455
USB0->ERREN = 0xFF; // enable error interrupt sources
456456
USB0->ADDR = 0x00; // set default address
457457

458+
// reset bus for USBDevice layer
459+
busReset();
460+
458461
return;
459462
}
460463

features/unsupported/USBDevice/USBSerial/USBCDC.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ USBCDC::USBCDC(uint16_t vendor_id, uint16_t product_id, uint16_t product_release
3838
USBDevice::connect(connect_blocking);
3939
}
4040

41+
void USBCDC::USBCallback_busReset(void) {
42+
terminal_connected = false;
43+
};
44+
4145
bool USBCDC::USBCallback_request(void) {
4246
/* Called in ISR context */
4347

features/unsupported/USBDevice/USBSerial/USBCDC.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ class USBCDC: public USBDevice {
116116
virtual bool USBCallback_request();
117117
virtual void USBCallback_requestCompleted(uint8_t *buf, uint32_t length);
118118
virtual bool USBCallback_setConfiguration(uint8_t configuration);
119+
virtual void USBCallback_busReset(void);
119120
volatile bool terminal_connected;
120121

121122
};

features/unsupported/USBDevice/USBSerial/USBSerial.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,7 @@ bool USBSerial::EPBULK_OUT_callback() {
6666
uint8_t USBSerial::available() {
6767
return buf.available();
6868
}
69+
70+
bool USBSerial::connected() {
71+
return terminal_connected;
72+
}

features/unsupported/USBDevice/USBSerial/USBSerial.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,13 @@ class USBSerial: public USBCDC, public Stream {
8383
*/
8484
uint8_t available();
8585

86+
/**
87+
* Check if the terminal is connected.
88+
*
89+
* @returns connection status
90+
*/
91+
bool connected();
92+
8693
/** Determine if there is a character available to read
8794
*
8895
* @returns

0 commit comments

Comments
 (0)