Skip to content

Commit

Permalink
Updates for new libraries.
Browse files Browse the repository at this point in the history
  • Loading branch information
mmosca committed Jan 14, 2025
1 parent c9016a9 commit f1ecb57
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 4 deletions.
37 changes: 36 additions & 1 deletion src/main/vcp_hal/usbd_cdc_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ static int8_t CDC_Itf_Init(void);
static int8_t CDC_Itf_DeInit(void);
static int8_t CDC_Itf_Control(uint8_t cmd, uint8_t* pbuf, uint16_t length);
static int8_t CDC_Itf_Receive(uint8_t* pbuf, uint32_t *Len);
#if defined(STM32H7)
static int8_t CDC_Itf_Transmit(uint8_t *pbuf, uint32_t *Len, uint8_t epnum);
#endif


static void TIM_Config(void);
static void Error_Handler(void);
Expand All @@ -107,7 +111,10 @@ USBD_CDC_ItfTypeDef USBD_CDC_fops =
CDC_Itf_Init,
CDC_Itf_DeInit,
CDC_Itf_Control,
CDC_Itf_Receive
CDC_Itf_Receive,
#if defined(STM32H7)
CDC_Itf_Transmit
#endif
};


Expand Down Expand Up @@ -296,6 +303,29 @@ static int8_t CDC_Itf_Receive(uint8_t* Buf, uint32_t *Len)
return (USBD_OK);
}

#if defined(STM32H7)
/**
* @brief CDC_Itf_Transmit
* Data transmitted callback
*
* @note
* This function is IN transfer complete callback used to inform user that
* the submitted Data is successfully sent over USB.
*
* @param Buf: Buffer of data to be received
* @param Len: Number of data received (in bytes)
* @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL
*/
static int8_t CDC_Itf_Transmit(uint8_t *Buf, uint32_t *Len, uint8_t epnum)
{
UNUSED(Buf);
UNUSED(Len);
UNUSED(epnum);

return (0);
}
#endif

/**
* @brief TIM_Config: Configure TIMusb timer
* @param None.
Expand Down Expand Up @@ -387,7 +417,12 @@ uint32_t CDC_Send_FreeBytes(void)
*/
uint32_t CDC_Send_DATA(const uint8_t *ptrBuffer, uint32_t sendLength)
{
#if defined(STM32H7)
USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef*)USBD_Device.pClassData;
#else
USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef*)USBD_Device.pCDC_ClassData;
#endif

while (hcdc->TxState != 0);

for (uint32_t i = 0; i < sendLength; i++)
Expand Down
6 changes: 3 additions & 3 deletions src/main/vcp_hal/usbd_conf_stm32h7xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ USBD_StatusTypeDef USBD_LL_Init(USBD_HandleTypeDef * pdev)
hpcd.Instance = USB2_OTG_FS;
hpcd.Init.dev_endpoints = 9;
hpcd.Init.use_dedicated_ep1 = DISABLE;
hpcd.Init.ep0_mps = DEP0CTL_MPS_64;
hpcd.Init.ep0_mps = EP_MPS_64;
hpcd.Init.low_power_enable = DISABLE;
hpcd.Init.phy_itface = PCD_PHY_EMBEDDED;
hpcd.Init.Sof_enable = DISABLE;
Expand Down Expand Up @@ -592,7 +592,7 @@ USBD_StatusTypeDef USBD_LL_SetUSBAddress(USBD_HandleTypeDef * pdev,
*/
USBD_StatusTypeDef USBD_LL_Transmit(USBD_HandleTypeDef * pdev,
uint8_t ep_addr,
uint8_t * pbuf, uint16_t size)
uint8_t * pbuf, uint32_t size)
{
/* Get the packet total length */
pdev->ep_in[ep_addr & 0x7F].total_length = size;
Expand All @@ -611,7 +611,7 @@ USBD_StatusTypeDef USBD_LL_Transmit(USBD_HandleTypeDef * pdev,
*/
USBD_StatusTypeDef USBD_LL_PrepareReceive(USBD_HandleTypeDef * pdev,
uint8_t ep_addr,
uint8_t * pbuf, uint16_t size)
uint8_t * pbuf, uint32_t size)
{
HAL_PCD_EP_Receive(pdev->pData, ep_addr, pbuf, size);
return USBD_OK;
Expand Down

0 comments on commit f1ecb57

Please sign in to comment.