Skip to content

Commit fddefc1

Browse files
author
rogerclarkmelbourne
committed
Separated USB Serial functionality definitions from the BOOTLOADER_maple definition, so that generic boards can use USB serial without needing to have the bootloader and the disconnect hardware. NOTE. I have only tested the SERIAL_USB on the F103ZE board, it may not work on other generic boards
1 parent badf705 commit fddefc1

18 files changed

Lines changed: 99 additions & 159 deletions

File tree

STM32F1/boards.txt

Lines changed: 47 additions & 134 deletions
Large diffs are not rendered by default.

STM32F1/cores/maple/HardwareSerial.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
BOARD_USART##n##_TX_PIN, \
4848
BOARD_USART##n##_RX_PIN)
4949

50-
#ifdef BOOTLOADER_maple
50+
#ifdef SERIAL_USB
5151
#if BOARD_HAVE_USART1
5252
DEFINE_HWSERIAL(Serial1, 1);
5353
#endif

STM32F1/cores/maple/HardwareSerial.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ class HardwareSerial : public Stream {
164164
#endif
165165
};
166166

167-
#ifdef BOOTLOADER_maple
167+
#ifdef SERIAL_USB
168168
#if BOARD_HAVE_USART1
169169
extern HardwareSerial Serial1;
170170
#endif

STM32F1/cores/maple/usb_serial.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,7 @@ uint8 USBSerial::getRTS(void) {
203203
}
204204

205205
#if BOARD_HAVE_SERIALUSB
206-
#ifdef BOOTLOADER_maple
207-
//USBSerial SerialUSB;
206+
#ifdef SERIAL_USB
208207
USBSerial Serial;
209208
#endif
210209
#endif
@@ -232,7 +231,7 @@ static void ifaceSetupHook(unsigned hook, void *requestvp) {
232231
return;
233232
}
234233

235-
#if defined(BOOTLOADER_maple)
234+
#ifdef SERIAL_USB
236235
// We need to see a negative edge on DTR before we start looking
237236
// for the in-band magic reset byte sequence.
238237
uint8 dtr = usb_cdcacm_get_dtr();
@@ -268,7 +267,7 @@ static void ifaceSetupHook(unsigned hook, void *requestvp) {
268267
}
269268

270269
#define RESET_DELAY 100000
271-
#if defined(BOOTLOADER_maple)
270+
#ifdef SERIAL_USB
272271
static void wait_reset(void) {
273272
delay_us(RESET_DELAY);
274273
nvic_sys_reset();
@@ -286,7 +285,7 @@ static void rxHook(unsigned hook, void *ignored) {
286285

287286
if (usb_cdcacm_data_available() >= 4) {
288287
// The magic reset sequence is "1EAF".
289-
#if defined(BOOTLOADER_maple)
288+
#ifdef SERIAL_USB
290289
static const uint8 magic[4] = {'1', 'E', 'A', 'F'};
291290
#else
292291
#if defined(BOOTLOADER_robotis)
@@ -307,7 +306,7 @@ static void rxHook(unsigned hook, void *ignored) {
307306
}
308307
}
309308

310-
#if defined(BOOTLOADER_maple)
309+
#ifdef SERIAL_USB
311310
// Got the magic sequence -> reset, presumably into the bootloader.
312311
// Return address is wait_reset, but we must set the thumb bit.
313312
uintptr_t target = (uintptr_t)wait_reset | 0x1;

STM32F1/cores/maple/usb_serial.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,7 @@ class USBSerial : public Stream {
7474
};
7575

7676
#if BOARD_HAVE_SERIALUSB
77-
#ifdef BOOTLOADER_maple
78-
//extern USBSerial SerialUSB;
77+
#ifdef SERIAL_USB
7978
extern USBSerial Serial;
8079
#endif
8180
#endif

STM32F1/variants/generic_stm32f103c/wirish/boards.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,10 @@ static void setup_clocks(void) {
157157
extern char __text_start__;
158158

159159
static void setup_nvic(void) {
160+
161+
nvic_init((uint32)VECT_TAB_ADDR, 0);
162+
163+
/* Roger Clark. We now control nvic vector table in boards.txt using the build.vect paramater
160164
#ifdef VECT_TAB_FLASH
161165
nvic_init(USER_ADDR_ROM, 0);
162166
#elif defined VECT_TAB_RAM
@@ -171,6 +175,8 @@ static void setup_nvic(void) {
171175
// should be the start of the vector table.
172176
nvic_init((uint32)&__text_start__, 0);
173177
#endif
178+
179+
*/
174180
}
175181

176182
static void adc_default_config(const adc_dev *dev) {

STM32F1/variants/generic_stm32f103c/wirish/boards_setup.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,7 @@ namespace wirish {
7575

7676
__weak void board_setup_usb(void) {
7777
#if BOARD_HAVE_SERIALUSB
78-
#ifdef BOOTLOADER_maple
79-
// SerialUSB.begin();
78+
#ifdef SERIAL_USB
8079
Serial.begin();// Roger Clark. Changed SerialUSB to Serial for Arduino sketch compatibility
8180
#endif
8281
#endif

STM32F1/variants/generic_stm32f103rxx/wirish/boards.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,10 @@ static void setup_clocks(void) {
157157
extern char __text_start__;
158158

159159
static void setup_nvic(void) {
160+
161+
nvic_init((uint32)VECT_TAB_ADDR, 0);
162+
163+
/* Roger Clark. We now control nvic vector table in boards.txt using the build.vect paramater
160164
#ifdef VECT_TAB_FLASH
161165
nvic_init(USER_ADDR_ROM, 0);
162166
#elif defined VECT_TAB_RAM
@@ -171,6 +175,8 @@ static void setup_nvic(void) {
171175
// should be the start of the vector table.
172176
nvic_init((uint32)&__text_start__, 0);
173177
#endif
178+
179+
*/
174180
}
175181

176182
static void adc_default_config(const adc_dev *dev) {

STM32F1/variants/generic_stm32f103rxx/wirish/boards_setup.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,7 @@ namespace wirish {
7575

7676
__weak void board_setup_usb(void) {
7777
#if BOARD_HAVE_SERIALUSB
78-
#ifdef BOOTLOADER_maple
79-
// SerialUSB.begin();
78+
#ifdef SERIAL_USB
8079
Serial.begin();// Roger Clark. Changed SerialUSB to Serial for Arduino sketch compatibility
8180
#endif
8281
#endif

STM32F1/variants/generic_stm32f103zxx/wirish/boards.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,10 @@ static void setup_clocks(void) {
157157
extern char __text_start__;
158158

159159
static void setup_nvic(void) {
160+
161+
nvic_init((uint32)VECT_TAB_ADDR, 0);
162+
163+
/* Roger Clark. We now control nvic vector table in boards.txt using the build.vect paramater
160164
#ifdef VECT_TAB_FLASH
161165
nvic_init(USER_ADDR_ROM, 0);
162166
#elif defined VECT_TAB_RAM
@@ -171,6 +175,8 @@ static void setup_nvic(void) {
171175
// should be the start of the vector table.
172176
nvic_init((uint32)&__text_start__, 0);
173177
#endif
178+
179+
*/
174180
}
175181

176182
static void adc_default_config(const adc_dev *dev) {

0 commit comments

Comments
 (0)