Skip to content

Commit 4980276

Browse files
authored
Merge pull request #4199 from adbridge/usb_prs
USB: bus reset for KL25Z fix, USBSerial update
2 parents 1c77628 + 2e2fe37 commit 4980276

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)