2023-12-15 01:37 AM
HELLO
I am working with Xmodem file transferring vai usb I want to know how i get know about USB status like Ready or not how we get in UART
while (!(HAL_UART_GetState(&huart4) == HAL_UART_STATE_READY) && wTimeout) {
wTimeout--;
}
if (HAL_UART_GetState(&huart4) == HAL_UART_STATE_READY)
break;
}
like this we have any things in USB i may not aware let me know
Solved! Go to Solution.
2023-12-15 08:17 AM
There isn't a built-in function to do this, but you can make your own.
It depends on the USB class you're using. Here is the check for CDC:
uint8_t CDC_Transmit_HS(uint8_t* Buf, uint16_t Len)
{
uint8_t result = USBD_OK;
/* USER CODE BEGIN 12 */
USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef*)hUsbDeviceHS.pClassData;
if (hcdc->TxState != 0) {
return USBD_BUSY;
}
USBD_CDC_SetTxBuffer(&hUsbDeviceHS, Buf, Len);
result = USBD_CDC_TransmitPacket(&hUsbDeviceHS);
/* USER CODE END 12 */
return result;
}
Be careful not to dereference null pointers.
2023-12-15 08:17 AM
There isn't a built-in function to do this, but you can make your own.
It depends on the USB class you're using. Here is the check for CDC:
uint8_t CDC_Transmit_HS(uint8_t* Buf, uint16_t Len)
{
uint8_t result = USBD_OK;
/* USER CODE BEGIN 12 */
USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef*)hUsbDeviceHS.pClassData;
if (hcdc->TxState != 0) {
return USBD_BUSY;
}
USBD_CDC_SetTxBuffer(&hUsbDeviceHS, Buf, Len);
result = USBD_CDC_TransmitPacket(&hUsbDeviceHS);
/* USER CODE END 12 */
return result;
}
Be careful not to dereference null pointers.
2023-12-15 03:02 PM
Hello @PESHWA ,
There has been a case created to resolve this question and we will be reaching out to you directly.
Regards,
Roger