Skip to content

Commit cbc78ed

Browse files
author
rogerclarkmelbourne
committed
Include VictorPV's usb reset code to all generic board when SERIAL_USB is enabled ( by the defined in boards.txt)
1 parent f69d71b commit cbc78ed

3 files changed

Lines changed: 22 additions & 2 deletions

File tree

STM32F1/variants/generic_stm32f103c/wirish/boards_setup.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,17 @@ namespace wirish {
7575

7676
__weak void board_setup_usb(void) {
7777
#ifdef SERIAL_USB
78+
//Attempt to reset the USB interface - developed by Victor PV
79+
80+
gpio_set_mode(PIN_MAP[PA12].gpio_device, PIN_MAP[PA12].gpio_bit, GPIO_OUTPUT_PP);
81+
gpio_write_bit(PIN_MAP[PA12].gpio_device, PIN_MAP[PA12].gpio_bit,0);
82+
83+
84+
for(volatile unsigned int i=0;i<5000000;i++)
85+
{
86+
asm("nop");
87+
}
88+
gpio_set_mode(PIN_MAP[PA12].gpio_device, PIN_MAP[PA12].gpio_bit, GPIO_INPUT_FLOATING);
7889
Serial.begin();// Roger Clark. Changed SerialUSB to Serial for Arduino sketch compatibility
7990
#endif
8091
}

STM32F1/variants/generic_stm32f103r/wirish/boards_setup.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,17 @@ namespace wirish {
7575

7676
__weak void board_setup_usb(void) {
7777
#ifdef SERIAL_USB
78+
//Attempt to reset the USB interface - developed by Victor PV
79+
80+
gpio_set_mode(PIN_MAP[PA12].gpio_device, PIN_MAP[PA12].gpio_bit, GPIO_OUTPUT_PP);
81+
gpio_write_bit(PIN_MAP[PA12].gpio_device, PIN_MAP[PA12].gpio_bit,0);
82+
83+
84+
for(volatile unsigned int i=0;i<5000000;i++)
85+
{
86+
asm("nop");
87+
}
88+
gpio_set_mode(PIN_MAP[PA12].gpio_device, PIN_MAP[PA12].gpio_bit, GPIO_INPUT_FLOATING);
7889
Serial.begin();// Roger Clark. Changed SerialUSB to Serial for Arduino sketch compatibility
7990
#endif
8091
}

STM32F1/variants/generic_stm32f103z/wirish/boards_setup.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ namespace wirish {
7878

7979

8080
#ifdef SERIAL_USB
81-
/*
8281
//Attempt to reset the USB interface - developed by Victor PV
8382

8483
gpio_set_mode(PIN_MAP[PA12].gpio_device, PIN_MAP[PA12].gpio_bit, GPIO_OUTPUT_PP);
@@ -90,7 +89,6 @@ namespace wirish {
9089
asm("nop");
9190
}
9291
gpio_set_mode(PIN_MAP[PA12].gpio_device, PIN_MAP[PA12].gpio_bit, GPIO_INPUT_FLOATING);
93-
*/
9492
Serial.begin();// Roger Clark. Changed SerialUSB to Serial for Arduino sketch compatibility
9593
#endif
9694
}

0 commit comments

Comments
 (0)