From 9e3c80a3ae38c111c138aa9e7c70f1abb5d1424f Mon Sep 17 00:00:00 2001 From: Marti Bolivar Date: Wed, 15 Jun 2011 16:29:19 -0400 Subject: usb: Move some board-specific configuration to Wirish. Create new BOARD_USB_DISC_DEV and BOARD_USB_DISC_BIT board-specific values. Use these as arguments to setupUSB() and disableUSB(). This helps make the USB stack more generic, and goes towards the resolution of an important FIXME. Signed-off-by: Marti Bolivar --- wirish/boards.cpp | 2 +- wirish/boards/maple.h | 5 +++++ wirish/boards/maple_RET6.h | 3 +++ wirish/boards/maple_mini.h | 3 +++ wirish/boards/maple_native.h | 3 +++ wirish/boards/olimex_stm32_h103.h | 4 ++++ wirish/usb_serial.cpp | 4 ++-- 7 files changed, 21 insertions(+), 3 deletions(-) (limited to 'wirish') diff --git a/wirish/boards.cpp b/wirish/boards.cpp index 5cdc4d1..1b921ac 100644 --- a/wirish/boards.cpp +++ b/wirish/boards.cpp @@ -58,7 +58,7 @@ void init(void) { afio_init(); setupADC(); setupTimers(); - setupUSB(); + setupUSB(BOARD_USB_DISC_DEV, BOARD_USB_DISC_BIT); boardInit(); } diff --git a/wirish/boards/maple.h b/wirish/boards/maple.h index e26de99..a986884 100644 --- a/wirish/boards/maple.h +++ b/wirish/boards/maple.h @@ -84,4 +84,9 @@ #define BOARD_JTDO_PIN 42 #define BOARD_NJTRST_PIN 43 +/* USB configuration. BOARD_USB_DISC_DEV is the GPIO port containing + * the USB_DISC pin, and BOARD_USB_DISC_BIT is that pin's bit. */ +#define BOARD_USB_DISC_DEV GPIOC +#define BOARD_USB_DISC_BIT 12 + #endif diff --git a/wirish/boards/maple_RET6.h b/wirish/boards/maple_RET6.h index 352d565..9e7ce9d 100644 --- a/wirish/boards/maple_RET6.h +++ b/wirish/boards/maple_RET6.h @@ -85,4 +85,7 @@ #define BOARD_JTDO_PIN 42 #define BOARD_NJTRST_PIN 43 +#define BOARD_USB_DISC_DEV GPIOC +#define BOARD_USB_DISC_BIT 12 + #endif diff --git a/wirish/boards/maple_mini.h b/wirish/boards/maple_mini.h index 7bf7016..40f507b 100644 --- a/wirish/boards/maple_mini.h +++ b/wirish/boards/maple_mini.h @@ -70,4 +70,7 @@ #define BOARD_JTDO_PIN 19 #define BOARD_NJTRST_PIN 18 +#define BOARD_USB_DISC_DEV GPIOB +#define BOARD_USB_DISC_BIT 9 + #endif diff --git a/wirish/boards/maple_native.h b/wirish/boards/maple_native.h index f575bfb..7c09014 100644 --- a/wirish/boards/maple_native.h +++ b/wirish/boards/maple_native.h @@ -77,4 +77,7 @@ #define BOARD_JTDO_PIN 104 #define BOARD_NJTRST_PIN 105 +#define BOARD_USB_DISC_DEV GPIOB +#define BOARD_USB_DISC_BIT 8 + #endif diff --git a/wirish/boards/olimex_stm32_h103.h b/wirish/boards/olimex_stm32_h103.h index e2d5236..d2b5fcc 100644 --- a/wirish/boards/olimex_stm32_h103.h +++ b/wirish/boards/olimex_stm32_h103.h @@ -85,4 +85,8 @@ #define BOARD_JTDO_PIN 44 #define BOARD_NJTRST_PIN 45 +/* USB configuration */ +#define BOARD_USB_DISC_DEV GPIOC +#define BOARD_USB_DISC_BIT 11 + #endif diff --git a/wirish/usb_serial.cpp b/wirish/usb_serial.cpp index 0a2be43..927f7fc 100644 --- a/wirish/usb_serial.cpp +++ b/wirish/usb_serial.cpp @@ -39,11 +39,11 @@ USBSerial::USBSerial(void) { } void USBSerial::begin(void) { - setupUSB(); + setupUSB(BOARD_USB_DISC_DEV, BOARD_USB_DISC_BIT); } void USBSerial::end(void) { - disableUSB(); + disableUSB(BOARD_USB_DISC_DEV, BOARD_USB_DISC_BIT); } void USBSerial::write(uint8 ch) { -- cgit v1.2.3