File tree Expand file tree Collapse file tree 3 files changed +20
-11
lines changed Expand file tree Collapse file tree 3 files changed +20
-11
lines changed Original file line number Diff line number Diff line change 33
33
#define RCC ((u32)0x40021000)
34
34
#define FLASH ((u32)0x40022000)
35
35
#define GPIOA ((u32)0x40010800)
36
+ #define GPIOB ((u32)0x40010C00)
36
37
#define GPIOC ((u32)0x40011000)
37
38
38
39
#define RCC_CR RCC
Original file line number Diff line number Diff line change 35
35
36
36
void setupUSB (void ) {
37
37
u32 rwmVal ; /* read-write-modify place holder var */
38
-
38
+
39
39
/* Setup the USB DISC Pin */
40
40
rwmVal = GET_REG (RCC_APB2ENR );
41
- rwmVal |= 0x00000010 ;
41
+ rwmVal |= RCC_BANKB_ENB ;
42
42
SET_REG (RCC_APB2ENR ,rwmVal );
43
43
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 );
51
50
52
- pRCC -> APB1ENR |= 0x00800000 ;
51
+ pRCC -> APB1ENR |= RCC_USB_ENB ;
53
52
54
53
/* 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 */
56
55
usbAppInit ();
57
56
58
57
}
Original file line number Diff line number Diff line change 28
28
#include "usb_lib.h"
29
29
#include "usb_descriptor.h"
30
30
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
+
31
40
/* USB configuration params */
32
41
#define BTABLE_ADDRESS 0x00
33
42
#define ENDP0_RXADDR 0x40
You can’t perform that action at this time.
0 commit comments