diff options
-rw-r--r-- | libmaple/usb/usb.c | 8 | ||||
-rw-r--r-- | libmaple/usb/usb.h | 2 | ||||
-rw-r--r-- | wirish/usb_serial.cpp | 12 | ||||
-rw-r--r-- | wirish/usb_serial.h | 1 |
4 files changed, 23 insertions, 0 deletions
diff --git a/libmaple/usb/usb.c b/libmaple/usb/usb.c index 881c7f9..23cde00 100644 --- a/libmaple/usb/usb.c +++ b/libmaple/usb/usb.c @@ -459,6 +459,14 @@ uint8 usbGetRTS() { return ((line_dtr_rts & CONTROL_LINE_RTS) != 0); } +uint8 usbIsConfigured() { + return (bDeviceState == CONFIGURED); +} + +uint8 usbIsConnected() { + return (bDeviceState != UNCONNECTED); +} + uint16 usbGetPending() { return countTx; } diff --git a/libmaple/usb/usb.h b/libmaple/usb/usb.h index e0d4231..ec179b1 100644 --- a/libmaple/usb/usb.h +++ b/libmaple/usb/usb.h @@ -57,6 +57,8 @@ typedef enum uint8 usbReceiveBytes(uint8* recvBuf, uint8 len); uint8 usbGetDTR(void); uint8 usbGetRTS(void); + uint8 usbIsConnected(void); + uint8 usbIsConfigured(void); uint16 usbGetPending(void); void usbSendHello(void); diff --git a/wirish/usb_serial.cpp b/wirish/usb_serial.cpp index 08cda55..c066112 100644 --- a/wirish/usb_serial.cpp +++ b/wirish/usb_serial.cpp @@ -103,5 +103,17 @@ uint8 USBSerial::pending(void) { return usbGetPending(); } +uint8 USBSerial::getDTR(void) { + return usbGetDTR(); +} + +uint8 USBSerial::getRTS(void) { + return usbGetRTS(); +} + +uint8 USBSerial::isConnected(void) { + return (usbIsConnected() && usbIsConfigured()); +} + USBSerial SerialUSB; diff --git a/wirish/usb_serial.h b/wirish/usb_serial.h index abb362b..7c87c04 100644 --- a/wirish/usb_serial.h +++ b/wirish/usb_serial.h @@ -50,6 +50,7 @@ class USBSerial : public Print { uint8 getRTS(); uint8 getDTR(); + uint8 isConnected(); uint8 pending(); }; |