aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbnewbold <bnewbold@robocracy.org>2010-07-22 18:24:51 -0400
committerbnewbold <bnewbold@robocracy.org>2010-07-22 18:24:51 -0400
commit99c251b8462e7bc304e9e4a52bfc378d22804291 (patch)
tree051bdb863c92d9447191b92a49877e4dff141758
parent05f137fab9f4604ca3c7e8bb415c4b29db40ae5e (diff)
downloadlibrambutan-99c251b8462e7bc304e9e4a52bfc378d22804291.tar.gz
librambutan-99c251b8462e7bc304e9e4a52bfc378d22804291.zip
added isConnected() to serialusb
-rw-r--r--libmaple/usb/usb.c8
-rw-r--r--libmaple/usb/usb.h2
-rw-r--r--wirish/usb_serial.cpp12
-rw-r--r--wirish/usb_serial.h1
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();
};