aboutsummaryrefslogtreecommitdiffstats
path: root/wirish
diff options
context:
space:
mode:
Diffstat (limited to 'wirish')
-rw-r--r--wirish/include/wirish/usb_serial.h5
-rw-r--r--wirish/rules.mk4
-rw-r--r--wirish/stm32f1/boards_setup.cpp10
-rw-r--r--wirish/usb_serial.cpp9
4 files changed, 20 insertions, 8 deletions
diff --git a/wirish/include/wirish/usb_serial.h b/wirish/include/wirish/usb_serial.h
index 81e9e97..f36671b 100644
--- a/wirish/include/wirish/usb_serial.h
+++ b/wirish/include/wirish/usb_serial.h
@@ -25,13 +25,14 @@
*****************************************************************************/
/**
- * @brief Wirish virtual serial port
+ * @brief Wirish USB virtual serial port (SerialUSB).
*/
#ifndef _WIRISH_USB_SERIAL_H_
#define _WIRISH_USB_SERIAL_H_
#include <wirish/Print.h>
+#include <wirish/boards.h>
/**
* @brief Virtual serial terminal.
@@ -58,7 +59,9 @@ public:
uint8 pending();
};
+#if BOARD_HAVE_SERIALUSB
extern USBSerial SerialUSB;
+#endif
#endif
diff --git a/wirish/rules.mk b/wirish/rules.mk
index 147857a..6d96cbe 100644
--- a/wirish/rules.mk
+++ b/wirish/rules.mk
@@ -26,6 +26,9 @@ cppSRCS_$(d) += HardwareSerial.cpp
cppSRCS_$(d) += HardwareTimer.cpp
cppSRCS_$(d) += Print.cpp
cppSRCS_$(d) += pwm.cpp
+ifeq ($(MCU_SERIES), stm32f1)
+cppSRCS_$(d) += usb_serial.cpp # HACK: this is currently STM32F1 only.
+endif
cppSRCS_$(d) += wirish_analog.cpp
cppSRCS_$(d) += wirish_digital.cpp
cppSRCS_$(d) += wirish_math.cpp
@@ -36,7 +39,6 @@ cppSRCS_$(d) += $(MCU_SERIES)/wirish_digital.cpp
cppSRCS_$(d) += $(WIRISH_BOARD_PATH)/board.cpp
# TODO: revise these appropriately for F2 and put them back in:
# HardwareSPI.cpp
-# usb_serial.cpp
# ext_interrupts.cpp
sFILES_$(d) := $(sSRCS_$(d):%=$(d)/%)
diff --git a/wirish/stm32f1/boards_setup.cpp b/wirish/stm32f1/boards_setup.cpp
index 423e5ec..1dec579 100644
--- a/wirish/stm32f1/boards_setup.cpp
+++ b/wirish/stm32f1/boards_setup.cpp
@@ -38,9 +38,9 @@
#include <libmaple/gpio.h>
#include <libmaple/timer.h>
-#include <libmaple/usb_cdcacm.h>
-#include <board/board.h>
+#include <wirish/boards.h>
+#include <wirish/usb_serial.h>
// Allow boards to provide a PLL multiplier. This is useful for
// e.g. STM32F100 value line MCUs, which use slower multipliers.
@@ -80,10 +80,8 @@ namespace wirish {
}
void board_setup_usb(void) {
-#if 0
-# if STM32_HAVE_USB
- usb_cdcacm_enable(BOARD_USB_DISC_DEV, BOARD_USB_DISC_BIT);
-# endif
+#if BOARD_HAVE_SERIALUSB
+ SerialUSB.begin();
#endif
}
}
diff --git a/wirish/usb_serial.cpp b/wirish/usb_serial.cpp
index 388c739..a01900f 100644
--- a/wirish/usb_serial.cpp
+++ b/wirish/usb_serial.cpp
@@ -40,14 +40,21 @@
#define USB_TIMEOUT 50
USBSerial::USBSerial(void) {
+#if !BOARD_HAVE_SERIALUSB
+ ASSERT(0);
+#endif
}
void USBSerial::begin(void) {
+#if BOARD_HAVE_SERIALUSB
usb_cdcacm_enable(BOARD_USB_DISC_DEV, BOARD_USB_DISC_BIT);
+#endif
}
void USBSerial::end(void) {
+#if BOARD_HAVE_SERIALUSB
usb_cdcacm_disable(BOARD_USB_DISC_DEV, BOARD_USB_DISC_BIT);
+#endif
}
void USBSerial::write(uint8 ch) {
@@ -117,4 +124,6 @@ uint8 USBSerial::getRTS(void) {
return usb_cdcacm_get_rts();
}
+#if BOARD_HAVE_SERIALUSB
USBSerial SerialUSB;
+#endif