Skip to content

Commit

Permalink
bug fix: place EP buffers after BTABLE
Browse files Browse the repository at this point in the history
  • Loading branch information
majbthrd committed Feb 8, 2017
1 parent 1089f3c commit 994be65
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/usbd_conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,12 @@ USBD_StatusTypeDef USBD_LL_Init(USBD_HandleTypeDef *pdev)
/* Initialize LL Driver */
HAL_PCD_Init(pdev->pData);

/* start address for PMA allocation */
pma_address = 0;
/*
start address for PMA allocation:
ST's USB stack forces a BTABLE_ADDRESS at the start of PMA memory. The BTABLE occupied 8 bytes per endpoint.
we position the EP buffers starting immediately after this
*/
pma_address = 8 * MAX((sizeof(hpcd.IN_ep) / sizeof(*hpcd.IN_ep)), (sizeof(hpcd.OUT_ep) / sizeof(*hpcd.OUT_ep)));

/* PMA allocation for EP0 */
HAL_PCDEx_PMAConfig(pdev->pData, 0x00, PCD_SNG_BUF, pma_address =+ USB_MAX_EP0_SIZE);
Expand Down

0 comments on commit 994be65

Please sign in to comment.