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

This commit is contained in:
Roger Clark 2017-06-25 13:08:30 +10:00
parent 747634a31a
commit f7a576f2e0
5 changed files with 19 additions and 15 deletions

View File

@ -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) {

View File

@ -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 {

View File

@ -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

View File

@ -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 {

View File

@ -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