Skip to content

Commit 1a20b4f

Browse files
committed
Fix after code review
1 parent fc972f0 commit 1a20b4f

File tree

3 files changed

+17
-15
lines changed

3 files changed

+17
-15
lines changed

targets/TARGET_STM/TARGET_STM32F1/TARGET_NUCLEO_F103RB/USBHAL_STM32F103RB.h

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,11 @@ typedef struct
4646
/* memorize dummy buffer used for reception */
4747
uint32_t pBufRx[MAXTRANSFER_SIZE>>2];
4848
uint32_t pBufRx0[MAX_PACKET_SIZE_EP0>>2];
49-
gpio_t usb_switch;
49+
gpio_t usb_switch;
5050
}USBHAL_Private_t;
5151

52-
void HAL_PCDEx_SetConnectionState(PCD_HandleTypeDef *hpcd, uint8_t state){
52+
void HAL_PCDEx_SetConnectionState(PCD_HandleTypeDef *hpcd, uint8_t state)
53+
{
5354
USBHAL_Private_t *priv=((USBHAL_Private_t *)(hpcd->pData));
5455
gpio_write(&(priv->usb_switch),!state);
5556
}
@@ -58,18 +59,19 @@ uint32_t HAL_PCDEx_GetTxFiFo(PCD_HandleTypeDef *hpcd, uint8_t fifo)
5859
{
5960
return 1024;
6061
}
61-
void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd) {
62+
void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd)
63+
{
6264
USBHAL_Private_t *priv=((USBHAL_Private_t *)(hpcd->pData));
6365
USBHAL *obj= priv->inst;
6466
uint32_t sofnum = (hpcd->Instance->FNR) & USB_FNR_FN;
6567
void (USBHAL::*func)(int frame) = priv->sof;
66-
/* fix me call with same frame number */
6768
(obj->*func)(sofnum);
6869
}
6970

7071
USBHAL * USBHAL::instance;
7172

72-
USBHAL::USBHAL(void) {
73+
USBHAL::USBHAL(void)
74+
{
7375
/* init parameter */
7476
USBHAL_Private_t *HALPriv = new(USBHAL_Private_t);
7577
/* initialized all field of init including 0 field */
@@ -106,26 +108,28 @@ USBHAL::USBHAL(void) {
106108

107109
/* Configure USB VBUS GPIO */
108110
gpio_init_out(&HALPriv->usb_switch,PB_14);
109-
gpio_mode(&HALPriv->usb_switch,OpenDrain);
111+
gpio_mode(&HALPriv->usb_switch,OpenDrain);
110112
/* Configure USB FS GPIOs */
111113

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+
117121
pin_function(PA_11, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_MODE_AF_INPUT));
118122
pin_function(PA_12, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_MODE_AF_INPUT));
119123

120-
__HAL_RCC_USB_CLK_ENABLE();
124+
__HAL_RCC_USB_CLK_ENABLE();
121125

122126
hpcd.State = HAL_PCD_STATE_RESET;
123127

124128
HAL_PCD_Init(&hpcd);
125129
/* hardcoded size of FIFO according definition*/
126130
HAL_PCDEx_PMAConfig(&hpcd , 0x00 , PCD_SNG_BUF, 0x30);
127131
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);
129133
HAL_PCDEx_PMAConfig(&hpcd , 0x81 , PCD_SNG_BUF, 0xb0);
130134
#if 0
131135
HAL_PCDEx_PMAConfig(&hpcd , 0x2, PCD_DBL_BUF, 0x018000b0);

targets/TARGET_STM/TARGET_STM32F3/TARGET_NUCLEO_F303ZE/USBHAL_STM32F303ZE.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd) {
6161
USBHAL *obj= priv->inst;
6262
uint32_t sofnum = (hpcd->Instance->FNR) & USB_FNR_FN;
6363
void (USBHAL::*func)(int frame) = priv->sof;
64-
/* fix me call with same frame number */
6564
(obj->*func)(sofnum);
6665
}
6766

targets/TARGET_STM/USBHAL_STM_144_64pins.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd)
6161
USB_OTG_GlobalTypeDef *USBx = hpcd->Instance;
6262
uint32_t sofnum = (USBx_DEVICE->DSTS & USB_OTG_DSTS_FNSOF) >> 8;
6363
void (USBHAL::*func)(int frame) = priv->sof;
64-
/* fix me call with same frame number */
6564
(obj->*func)(sofnum);
6665
}
6766

0 commit comments

Comments
 (0)