@@ -46,10 +46,11 @@ typedef struct
46
46
/* memorize dummy buffer used for reception */
47
47
uint32_t pBufRx [MAXTRANSFER_SIZE >>2 ];
48
48
uint32_t pBufRx0 [MAX_PACKET_SIZE_EP0 >>2 ];
49
- gpio_t usb_switch ;
49
+ gpio_t usb_switch ;
50
50
}USBHAL_Private_t ;
51
51
52
- void HAL_PCDEx_SetConnectionState (PCD_HandleTypeDef * hpcd , uint8_t state ){
52
+ void HAL_PCDEx_SetConnectionState (PCD_HandleTypeDef * hpcd , uint8_t state )
53
+ {
53
54
USBHAL_Private_t * priv = ((USBHAL_Private_t * )(hpcd -> pData ));
54
55
gpio_write (& (priv -> usb_switch ),!state );
55
56
}
@@ -58,18 +59,19 @@ uint32_t HAL_PCDEx_GetTxFiFo(PCD_HandleTypeDef *hpcd, uint8_t fifo)
58
59
{
59
60
return 1024 ;
60
61
}
61
- void HAL_PCD_SOFCallback (PCD_HandleTypeDef * hpcd ) {
62
+ void HAL_PCD_SOFCallback (PCD_HandleTypeDef * hpcd )
63
+ {
62
64
USBHAL_Private_t * priv = ((USBHAL_Private_t * )(hpcd -> pData ));
63
65
USBHAL * obj = priv -> inst ;
64
66
uint32_t sofnum = (hpcd -> Instance -> FNR ) & USB_FNR_FN ;
65
67
void (USBHAL ::* func )(int frame ) = priv -> sof ;
66
- /* fix me call with same frame number */
67
68
(obj -> * func )(sofnum );
68
69
}
69
70
70
71
USBHAL * USBHAL ::instance ;
71
72
72
- USBHAL ::USBHAL (void ) {
73
+ USBHAL ::USBHAL (void )
74
+ {
73
75
/* init parameter */
74
76
USBHAL_Private_t * HALPriv = new (USBHAL_Private_t );
75
77
/* initialized all field of init including 0 field */
@@ -106,26 +108,28 @@ USBHAL::USBHAL(void) {
106
108
107
109
/* Configure USB VBUS GPIO */
108
110
gpio_init_out (& HALPriv -> usb_switch ,PB_14 );
109
- gpio_mode (& HALPriv -> usb_switch ,OpenDrain );
111
+ gpio_mode (& HALPriv -> usb_switch ,OpenDrain );
110
112
/* Configure USB FS GPIOs */
111
113
112
- /* Configure DM DP Pins */
113
- /* - USB-DP (D+ of the USB connector) <======> PA12 (Nucleo board)
114
- Make sure to connect a 1.5KOhm pull up to USB-DP PA12 pin (permanent pull-up)
115
- - USB-DM (D- of the USB connector) <======> PA11 (Nucleo board) */
116
-
114
+ /* Configure DM DP Pins
115
+ * - USB-DP (D+ of the USB connector) <======> PA12 (Nucleo board)
116
+ * Make sure to connect a 1.5KOhm pull up to USB-DP PA12 pin
117
+ * (permanent pull-up)
118
+ - USB-DM (D- of the USB connector) <======> PA11 (Nucleo board)
119
+ */
120
+
117
121
pin_function (PA_11 , STM_PIN_DATA (STM_MODE_AF_PP , GPIO_PULLUP , GPIO_MODE_AF_INPUT ));
118
122
pin_function (PA_12 , STM_PIN_DATA (STM_MODE_AF_PP , GPIO_PULLUP , GPIO_MODE_AF_INPUT ));
119
123
120
- __HAL_RCC_USB_CLK_ENABLE ();
124
+ __HAL_RCC_USB_CLK_ENABLE ();
121
125
122
126
hpcd .State = HAL_PCD_STATE_RESET ;
123
127
124
128
HAL_PCD_Init (& hpcd );
125
129
/* hardcoded size of FIFO according definition*/
126
130
HAL_PCDEx_PMAConfig (& hpcd , 0x00 , PCD_SNG_BUF , 0x30 );
127
131
HAL_PCDEx_PMAConfig (& hpcd , 0x80 , PCD_SNG_BUF , 0x70 );
128
- HAL_PCDEx_PMAConfig (& hpcd , 0x01 , PCD_SNG_BUF , 0x90 );
132
+ HAL_PCDEx_PMAConfig (& hpcd , 0x01 , PCD_SNG_BUF , 0x90 );
129
133
HAL_PCDEx_PMAConfig (& hpcd , 0x81 , PCD_SNG_BUF , 0xb0 );
130
134
#if 0
131
135
HAL_PCDEx_PMAConfig (& hpcd , 0x2 , PCD_DBL_BUF , 0x018000b0 );
0 commit comments