Skip to content

Commit 78d81de

Browse files
Fix mistake with Maple mini USB DISC pin using LED_PIN, also renamed USB_DISC to USB_DISC_PIN to more accurately reflect its use
1 parent 0073bf6 commit 78d81de

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

STM32F1/config.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104

105105
/* USB Disc Pin Setup. USB DISC is PB9 */
106106
#define USB_DISC_BANK GPIOB
107-
#define USB_DISC 9
107+
#define USB_DISC_PIN 9
108108

109109
#elif defined TARGET_MAPLE_REV3
110110

@@ -123,7 +123,7 @@
123123

124124
/* USB Disc Pin Setup. USB DISC is PB9 */
125125
#define USB_DISC_BANK GPIOB
126-
#define USB_DISC 9
126+
#define USB_DISC_PIN 9
127127

128128
#elif defined TARGET_MAPLE_REV5
129129

@@ -140,7 +140,7 @@
140140

141141
/* USB Disc Pin Setup. USB DISC is PB9 */
142142
#define USB_DISC_BANK GPIOB
143-
#define USB_DISC 9
143+
#define USB_DISC_PIN 9
144144

145145
#elif defined TARGET_GENERIC_F103_PC13
146146

STM32F1/usb.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,31 +41,31 @@ void setupUSB (void) {
4141

4242
#ifdef HAS_MAPLE_HARDWARE
4343
/* Setup USB DISC pin as output open drain */
44-
SET_REG(GPIO_CR(USB_DISC_BANK,USB_DISC),(GET_REG(GPIO_CR(USB_DISC_BANK,USB_DISC)) & crMask(USB_DISC)) | CR_OUTPUT_OD << CR_SHITF(LED_PIN));
45-
gpio_write_bit(USB_DISC_BANK,USB_DISC,1);
44+
SET_REG(GPIO_CR(USB_DISC_BANK,USB_DISC_PIN),(GET_REG(GPIO_CR(USB_DISC_BANK,USB_DISC_PIN)) & crMask(USB_DISC_PIN)) | CR_OUTPUT_OD << CR_SHITF(USB_DISC_PIN));
45+
gpio_write_bit(USB_DISC_BANK,USB_DISC_PIN,1);
4646

4747
/* turn on the USB clock */
4848
//pRCC->APB1ENR |= RCC_APB1ENR_USB_CLK;// done in setupCLK()
4949

50-
gpio_write_bit(USB_DISC_BANK,USB_DISC,0); /* present ourselves to the host */
50+
gpio_write_bit(USB_DISC_BANK,USB_DISC_PIN,0); /* present ourselves to the host */
5151
#else
5252

5353
/* Generic boards don't have disconnect hardware, so we drive PA12 which is connected to the usb D+ line*/
5454
#define USB_DISC_BANK GPIOA
55-
#define USB_DISC 12
55+
#define USB_DISC_PIN 12
5656

57-
SET_REG(GPIO_CR(USB_DISC_BANK,USB_DISC),
58-
(GET_REG(GPIO_CR(USB_DISC_BANK,USB_DISC)) & crMask(USB_DISC)) | CR_OUTPUT_PP << CR_SHITF(USB_DISC));
57+
SET_REG(GPIO_CR(USB_DISC_BANK,USB_DISC_PIN),
58+
(GET_REG(GPIO_CR(USB_DISC_BANK,USB_DISC_PIN)) & crMask(USB_DISC_PIN)) | CR_OUTPUT_PP << CR_SHITF(USB_DISC_PIN));
5959

60-
gpio_write_bit(USB_DISC_BANK,USB_DISC,0); /* present ourselves to the host */
60+
gpio_write_bit(USB_DISC_BANK,USB_DISC_PIN,0); /* present ourselves to the host */
6161

6262
volatile unsigned int delay;
6363
for(delay = 0;delay<256;delay++);
6464

6565
// volatile unsigned x = 1024; do { ; }while(--x);// wait a moment
6666
/* turn on the USB clock */
67-
SET_REG(GPIO_CR(USB_DISC_BANK,USB_DISC),
68-
(GET_REG(GPIO_CR(USB_DISC_BANK,USB_DISC)) & crMask(USB_DISC)) | CR_INPUT << CR_SHITF(USB_DISC)); //Sets the PA12 as floating input
67+
SET_REG(GPIO_CR(USB_DISC_BANK,USB_DISC_PIN),
68+
(GET_REG(GPIO_CR(USB_DISC_BANK,USB_DISC_PIN)) & crMask(USB_DISC_PIN)) | CR_INPUT << CR_SHITF(USB_DISC_PIN)); //Sets the PA12 as floating input
6969
// pRCC->APB1ENR |= RCC_APB1ENR_USB_CLK;
7070
#endif
7171
/* initialize the usb application */
@@ -85,11 +85,11 @@ void setupUSB (void) {
8585

8686

8787
void usbDsbBus(void) {
88-
// setPin(USB_DISC_BANK,USB_DISC);
88+
// setPin(USB_DISC_BANK,USB_DISC_PIN);
8989
usbPowerOff();
9090
// SET_REG(USB_DISC_CR,
9191
// (GET_REG(USB_DISC_CR) & USB_DISC_CR_MASK) | USB_DISC_CR_OUTPUT);
92-
// resetPin(USB_DISC_BANK, USB_DISC); /* Pull DP+ down */
92+
// resetPin(USB_DISC_BANK, USB_DISC_PIN); /* Pull DP+ down */
9393
// volatile unsigned x = 500000; do { ; }while(--x);
9494
// SET_REG(USB_DISC_CR,
9595
// (GET_REG(USB_DISC_CR) & USB_DISC_CR_MASK) | USB_DISC_CR_INPUT); //Sets the PA12 as floating input
@@ -264,7 +264,7 @@ RESULT usbPowerOff(void) {
264264

265265
/* note that all weve done here is powerdown the
266266
usb peripheral. we have no disabled the clocks,
267-
pulled the usb_disc pin back up, or reset the
267+
pulled the USB_DISC_PIN pin back up, or reset the
268268
application state machines */
269269

270270
return USB_SUCCESS;

0 commit comments

Comments
 (0)