Skip to content

Commit cb9f3b5

Browse files
author
AJM
committed
Maple Native Changes
added the usb disc pin at GPIOB-8, added some macro definitions to reduce magic-number-plaque
1 parent d86b0ec commit cb9f3b5

File tree

3 files changed

+20
-11
lines changed

3 files changed

+20
-11
lines changed

hardware.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#define RCC ((u32)0x40021000)
3434
#define FLASH ((u32)0x40022000)
3535
#define GPIOA ((u32)0x40010800)
36+
#define GPIOB ((u32)0x40010C00)
3637
#define GPIOC ((u32)0x40011000)
3738

3839
#define RCC_CR RCC

usb.c

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,24 +35,23 @@
3535

3636
void setupUSB (void) {
3737
u32 rwmVal; /* read-write-modify place holder var */
38-
38+
3939
/* Setup the USB DISC Pin */
4040
rwmVal = GET_REG(RCC_APB2ENR);
41-
rwmVal |= 0x00000010;
41+
rwmVal |= RCC_BANKB_ENB;
4242
SET_REG(RCC_APB2ENR,rwmVal);
4343

44-
// todo, macroize usb_disc pin
45-
/* Setup GPIOC Pin 12 as OD out */
46-
rwmVal = GET_REG(GPIO_CRH(GPIOC));
47-
rwmVal &= 0xFFF0FFFF;
48-
rwmVal |= 0x00050000;
49-
setPin (GPIOC,12);
50-
SET_REG(GPIO_CRH(GPIOC),rwmVal);
44+
/* Setup GPIOB Pin 8 as OD out */
45+
rwmVal = GET_REG(GPIO_CRH(USB_DISC_BANK));
46+
rwmVal &= PIN_8_MASK;
47+
rwmVal |= PIN_8_OUTPUT_PP;
48+
setPin (USB_DISC_BANK,USB_DISC);
49+
SET_REG(GPIO_CRH(USB_DISC_BANK),rwmVal);
5150

52-
pRCC->APB1ENR |= 0x00800000;
51+
pRCC->APB1ENR |= RCC_USB_ENB;
5352

5453
/* initialize the usb application */
55-
resetPin (GPIOC,12); /* present ourselves to the host */
54+
resetPin (USB_DISC_BANK,USB_DISC); /* present ourselves to the host */
5655
usbAppInit();
5756

5857
}

usb.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,15 @@
2828
#include "usb_lib.h"
2929
#include "usb_descriptor.h"
3030

31+
/* USB Disc Pin Setup */
32+
#define USB_DISC 8
33+
#define USB_DISC_BANK GPIOB
34+
35+
#define RCC_BANKB_ENB 0x00000008
36+
#define PIN_8_MASK 0xFFFFFFF0
37+
#define PIN_8_OUTPUT_PP 0x00000005
38+
#define RCC_USB_ENB 0x00800000
39+
3140
/* USB configuration params */
3241
#define BTABLE_ADDRESS 0x00
3342
#define ENDP0_RXADDR 0x40

0 commit comments

Comments
 (0)