diff --git a/STM32F1/cores/maple/libmaple/usb/stm32f1/usb_cdcacm.c b/STM32F1/cores/maple/libmaple/usb/stm32f1/usb_cdcacm.c index 7a5a772..774be42 100644 --- a/STM32F1/cores/maple/libmaple/usb/stm32f1/usb_cdcacm.c +++ b/STM32F1/cores/maple/libmaple/usb/stm32f1/usb_cdcacm.c @@ -384,9 +384,13 @@ void usb_cdcacm_enable(gpio_dev *disc_dev, uint8 disc_bit) { /* Present ourselves to the host. Writing 0 to "disc" pin must * pull USB_DP pin up while leaving USB_DM pulled down by the * transceiver. See USB 2.0 spec, section 7.1.7.3. */ - gpio_set_mode(disc_dev, disc_bit, GPIO_OUTPUT_PP); - gpio_write_bit(disc_dev, disc_bit, 0); - + + if (disc_dev!=NULL) + { + gpio_set_mode(disc_dev, disc_bit, GPIO_OUTPUT_PP); + gpio_write_bit(disc_dev, disc_bit, 0); + } + /* Initialize the USB peripheral. */ usb_init_usblib(USBLIB, ep_int_in, ep_int_out); } @@ -395,7 +399,10 @@ void usb_cdcacm_disable(gpio_dev *disc_dev, uint8 disc_bit) { /* Turn off the interrupt and signal disconnect (see e.g. USB 2.0 * spec, section 7.1.7.3). */ nvic_irq_disable(NVIC_USB_LP_CAN_RX0); - gpio_write_bit(disc_dev, disc_bit, 1); + if (disc_dev!=NULL) + { + gpio_write_bit(disc_dev, disc_bit, 1); + } } void usb_cdcacm_putc(char ch) { diff --git a/STM32F1/variants/generic_gd32f103c/board/board.h b/STM32F1/variants/generic_gd32f103c/board/board.h index 50dd989..16295a1 100644 --- a/STM32F1/variants/generic_gd32f103c/board/board.h +++ b/STM32F1/variants/generic_gd32f103c/board/board.h @@ -70,8 +70,8 @@ #define BOARD_JTDO_PIN 19 #define BOARD_NJTRST_PIN 18 -#define BOARD_USB_DISC_DEV GPIOB -#define BOARD_USB_DISC_BIT 10 +#define BOARD_USB_DISC_DEV NULL +#define BOARD_USB_DISC_BIT NULL // Note this needs to match with the PIN_MAP array in board.cpp enum { diff --git a/STM32F1/variants/generic_stm32f103c/board/board.h b/STM32F1/variants/generic_stm32f103c/board/board.h index 09351a6..4736dc9 100644 --- a/STM32F1/variants/generic_stm32f103c/board/board.h +++ b/STM32F1/variants/generic_stm32f103c/board/board.h @@ -70,8 +70,8 @@ #define BOARD_JTDO_PIN 19 #define BOARD_NJTRST_PIN 18 -#define BOARD_USB_DISC_DEV GPIOB -#define BOARD_USB_DISC_BIT 10 +#define BOARD_USB_DISC_DEV NULL +#define BOARD_USB_DISC_BIT NULL #define LED_BUILTIN PC13 diff --git a/STM32F1/variants/generic_stm32f103r8/board/board.h b/STM32F1/variants/generic_stm32f103r8/board/board.h index c274d64..36c2241 100644 --- a/STM32F1/variants/generic_stm32f103r8/board/board.h +++ b/STM32F1/variants/generic_stm32f103r8/board/board.h @@ -70,8 +70,8 @@ #define BOARD_JTDO_PIN 19 #define BOARD_NJTRST_PIN 18 -#define BOARD_USB_DISC_DEV GPIOB -#define BOARD_USB_DISC_BIT 10 +#define BOARD_USB_DISC_DEV NULL +#define BOARD_USB_DISC_BIT NULL // Note this needs to match with the PIN_MAP array in board.cpp enum { diff --git a/STM32F1/variants/nucleo_f103rb/board/board.h b/STM32F1/variants/nucleo_f103rb/board/board.h index b27862d..5c7ece7 100644 --- a/STM32F1/variants/nucleo_f103rb/board/board.h +++ b/STM32F1/variants/nucleo_f103rb/board/board.h @@ -102,11 +102,8 @@ /** * Note: there is no USB in this board. */ - // Roger Clark. These USB disconnect pin definitions have been added as a temporary fix in order that the this board compiles - // following changes to add usb serial to other boards - // I will remove them when the code in the core usb_serial.cpp has been tidied up so that they are no longer needed. -#define BOARD_USB_DISC_DEV GPIOB -#define BOARD_USB_DISC_BIT 10 +#define BOARD_USB_DISC_DEV NULL +#define BOARD_USB_DISC_BIT NULL /* Pin aliases: these give the GPIO port/bit for each pin as an * enum. These are optional, but recommended. They make it easier to