diff --git a/src/main/vcp_hal/usbd_cdc_interface.c b/src/main/vcp_hal/usbd_cdc_interface.c index 2489d74fb26..dbc093fb641 100644 --- a/src/main/vcp_hal/usbd_cdc_interface.c +++ b/src/main/vcp_hal/usbd_cdc_interface.c @@ -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); @@ -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 }; @@ -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. @@ -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++) diff --git a/src/main/vcp_hal/usbd_conf_stm32h7xx.c b/src/main/vcp_hal/usbd_conf_stm32h7xx.c index 40713f7a397..b80fa521f36 100644 --- a/src/main/vcp_hal/usbd_conf_stm32h7xx.c +++ b/src/main/vcp_hal/usbd_conf_stm32h7xx.c @@ -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; @@ -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; @@ -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;