Skip to content

Commit f7a576f

Browse files
Fixed issue with PB10 being set to OUTPUT for use as a USB Disconnect control on boards which do not have the additional USB disconnect hardware e.g. the Blue Pill. Note. Some variants seem to have the disconnect control on another pin, so I did not change those in case they were actually used
1 parent 747634a commit f7a576f

5 files changed

Lines changed: 19 additions & 15 deletions

File tree

STM32F1/cores/maple/libmaple/usb/stm32f1/usb_cdcacm.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -384,9 +384,13 @@ void usb_cdcacm_enable(gpio_dev *disc_dev, uint8 disc_bit) {
384384
/* Present ourselves to the host. Writing 0 to "disc" pin must
385385
* pull USB_DP pin up while leaving USB_DM pulled down by the
386386
* transceiver. See USB 2.0 spec, section 7.1.7.3. */
387-
gpio_set_mode(disc_dev, disc_bit, GPIO_OUTPUT_PP);
388-
gpio_write_bit(disc_dev, disc_bit, 0);
389-
387+
388+
if (disc_dev!=NULL)
389+
{
390+
gpio_set_mode(disc_dev, disc_bit, GPIO_OUTPUT_PP);
391+
gpio_write_bit(disc_dev, disc_bit, 0);
392+
}
393+
390394
/* Initialize the USB peripheral. */
391395
usb_init_usblib(USBLIB, ep_int_in, ep_int_out);
392396
}
@@ -395,7 +399,10 @@ void usb_cdcacm_disable(gpio_dev *disc_dev, uint8 disc_bit) {
395399
/* Turn off the interrupt and signal disconnect (see e.g. USB 2.0
396400
* spec, section 7.1.7.3). */
397401
nvic_irq_disable(NVIC_USB_LP_CAN_RX0);
398-
gpio_write_bit(disc_dev, disc_bit, 1);
402+
if (disc_dev!=NULL)
403+
{
404+
gpio_write_bit(disc_dev, disc_bit, 1);
405+
}
399406
}
400407

401408
void usb_cdcacm_putc(char ch) {

STM32F1/variants/generic_gd32f103c/board/board.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@
7070
#define BOARD_JTDO_PIN 19
7171
#define BOARD_NJTRST_PIN 18
7272

73-
#define BOARD_USB_DISC_DEV GPIOB
74-
#define BOARD_USB_DISC_BIT 10
73+
#define BOARD_USB_DISC_DEV NULL
74+
#define BOARD_USB_DISC_BIT NULL
7575

7676
// Note this needs to match with the PIN_MAP array in board.cpp
7777
enum {

STM32F1/variants/generic_stm32f103c/board/board.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@
7070
#define BOARD_JTDO_PIN 19
7171
#define BOARD_NJTRST_PIN 18
7272

73-
#define BOARD_USB_DISC_DEV GPIOB
74-
#define BOARD_USB_DISC_BIT 10
73+
#define BOARD_USB_DISC_DEV NULL
74+
#define BOARD_USB_DISC_BIT NULL
7575

7676
#define LED_BUILTIN PC13
7777

STM32F1/variants/generic_stm32f103r8/board/board.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@
7070
#define BOARD_JTDO_PIN 19
7171
#define BOARD_NJTRST_PIN 18
7272

73-
#define BOARD_USB_DISC_DEV GPIOB
74-
#define BOARD_USB_DISC_BIT 10
73+
#define BOARD_USB_DISC_DEV NULL
74+
#define BOARD_USB_DISC_BIT NULL
7575

7676
// Note this needs to match with the PIN_MAP array in board.cpp
7777
enum {

STM32F1/variants/nucleo_f103rb/board/board.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,8 @@
102102
/**
103103
* Note: there is no USB in this board.
104104
*/
105-
// Roger Clark. These USB disconnect pin definitions have been added as a temporary fix in order that the this board compiles
106-
// following changes to add usb serial to other boards
107-
// I will remove them when the code in the core usb_serial.cpp has been tidied up so that they are no longer needed.
108-
#define BOARD_USB_DISC_DEV GPIOB
109-
#define BOARD_USB_DISC_BIT 10
105+
#define BOARD_USB_DISC_DEV NULL
106+
#define BOARD_USB_DISC_BIT NULL
110107

111108
/* Pin aliases: these give the GPIO port/bit for each pin as an
112109
* enum. These are optional, but recommended. They make it easier to

0 commit comments

Comments
 (0)