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
pull/4199/head
Anna Bridge 2017-04-19 15:38:51 +01:00
parent 247238d993
commit 2e2fe377b3
5 changed files with 19 additions and 0 deletions

View File

@ -455,6 +455,9 @@ void USBHAL::usbisr(void) {
USB0->ERREN = 0xFF; // enable error interrupt sources
USB0->ADDR = 0x00; // set default address
// reset bus for USBDevice layer
busReset();
return;
}

View File

@ -38,6 +38,10 @@ USBCDC::USBCDC(uint16_t vendor_id, uint16_t product_id, uint16_t product_release
USBDevice::connect(connect_blocking);
}
void USBCDC::USBCallback_busReset(void) {
terminal_connected = false;
};
bool USBCDC::USBCallback_request(void) {
/* Called in ISR context */

View File

@ -116,6 +116,7 @@ protected:
virtual bool USBCallback_request();
virtual void USBCallback_requestCompleted(uint8_t *buf, uint32_t length);
virtual bool USBCallback_setConfiguration(uint8_t configuration);
virtual void USBCallback_busReset(void);
volatile bool terminal_connected;
};

View File

@ -66,3 +66,7 @@ bool USBSerial::EPBULK_OUT_callback() {
uint8_t USBSerial::available() {
return buf.available();
}
bool USBSerial::connected() {
return terminal_connected;
}

View File

@ -83,6 +83,13 @@ public:
*/
uint8_t available();
/**
* Check if the terminal is connected.
*
* @returns connection status
*/
bool connected();
/** Determine if there is a character available to read
*
* @returns