Skip to content

Commit 345bea8

Browse files
committed
[BSP]fix F4-HAL bsp usbdriver
1 parent 896c5a1 commit 345bea8

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

bsp/stm32f4xx-HAL/drivers/drv_usb.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@ static struct ep_id _ep_pool[] =
2525
{0x0, USB_EP_ATTR_CONTROL, USB_DIR_INOUT, 64, ID_ASSIGNED },
2626
{0x1, USB_EP_ATTR_BULK, USB_DIR_IN, 64, ID_UNASSIGNED},
2727
{0x1, USB_EP_ATTR_BULK, USB_DIR_OUT, 64, ID_UNASSIGNED},
28-
{0x2, USB_EP_ATTR_INT, USB_DIR_OUT, 64, ID_UNASSIGNED},
2928
{0x2, USB_EP_ATTR_INT, USB_DIR_IN, 64, ID_UNASSIGNED},
29+
{0x2, USB_EP_ATTR_INT, USB_DIR_OUT, 64, ID_UNASSIGNED},
30+
{0x3, USB_EP_ATTR_BULK, USB_DIR_IN, 64, ID_UNASSIGNED},
31+
{0x3, USB_EP_ATTR_BULK, USB_DIR_OUT, 64, ID_UNASSIGNED},
3032
{0xFF, USB_EP_ATTR_TYPE_MASK, USB_DIR_MASK, 0, ID_ASSIGNED },
3133
};
3234

@@ -74,7 +76,7 @@ void HAL_PCD_ConnectCallback(PCD_HandleTypeDef *hpcd)
7476

7577
void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd)
7678
{
77-
// rt_usbd_sof_handler(&_stm_udc);
79+
rt_usbd_sof_handler(&_stm_udc);
7880
}
7981

8082
void HAL_PCD_DisconnectCallback(PCD_HandleTypeDef *hpcd)
@@ -233,7 +235,7 @@ static rt_err_t _init(rt_device_t device)
233235
pcd = (PCD_HandleTypeDef*)device->user_data;
234236

235237
pcd->Instance = USB_OTG_FS;
236-
pcd->Init.dev_endpoints = 8;
238+
pcd->Init.dev_endpoints = 4;
237239
pcd->Init.speed = PCD_SPEED_FULL;
238240
pcd->Init.dma_enable = DISABLE;
239241
pcd->Init.ep0_mps = DEP0CTL_MPS_64;
@@ -249,7 +251,9 @@ static rt_err_t _init(rt_device_t device)
249251

250252
HAL_PCDEx_SetRxFiFo(pcd, 0x80);
251253
HAL_PCDEx_SetTxFiFo(pcd, 0, 0x40);
252-
HAL_PCDEx_SetTxFiFo(pcd, 1, 0x80);
254+
HAL_PCDEx_SetTxFiFo(pcd, 1, 0x40);
255+
HAL_PCDEx_SetTxFiFo(pcd, 2, 0x40);
256+
HAL_PCDEx_SetTxFiFo(pcd, 3, 0x40);
253257
HAL_PCD_Start(pcd);
254258

255259
return RT_EOK;

0 commit comments

Comments
 (0)