STM32 H573-DK USBX CDC ACM CLASS Stand-Alone
Hello ST Community,
I was trying to use USBX with ThreadX and it worked. So far so good. But in our project, we will use FreeRTOS and after some research and getting in touch with some people, I learned that I can not use USBX with FreeRTOS. So they suggested to me to use USBX StandAlone. I'm now trying using USBX CDC ACM class in standalone mode. I inited USBX, my virtual comport appears in the device manager. I tried to send data from discovery kit to my PC with this function "_ux_device_class_cdc_acm_write_run" and I could send it. After one try, i tried to send again but this time it didnt send and this function "_ux_device_class_cdc_acm_write_run" returned "UX_STATE_WAIT".
I debugged the code, examine the transmit process. After transmit an interrupt occured and these flags are set;
transfer_request -> ux_slave_transfer_request_completion_code = UX_SUCCESS;
/* The transfer is completed. */
transfer_request -> ux_slave_transfer_request_status = UX_TRANSFER_STATUS_COMPLETED;
transfer_request -> ux_slave_transfer_request_actual_length =
transfer_request -> ux_slave_transfer_request_requested_length;
Then I started to examine "_ux_device_class_cdc_acm_write_run" this and I find out my code returns "UX_STATE_NEXT" from here;
if (ed_status & UX_DCD_STM32_ED_STATUS_TRANSFER)
{
if (ed_status & UX_DCD_STM32_ED_STATUS_DONE)
{
/* Keep used, stall and task pending bits. */
ed -> ux_dcd_stm32_ed_status &= (UX_DCD_STM32_ED_STATUS_USED |
UX_DCD_STM32_ED_STATUS_STALLED |
UX_DCD_STM32_ED_STATUS_TASK_PENDING);
UX_RESTORE
return(UX_STATE_NEXT);
}
UX_RESTORE
return(UX_STATE_WAIT);
}
normally, when it sends it should pass this code block and run this part;
/* Start transfer. */
ed -> ux_dcd_stm32_ed_status |= UX_DCD_STM32_ED_STATUS_TRANSFER;
/* Check for transfer direction. Is this a IN endpoint ? */
if (transfer_request -> ux_slave_transfer_request_phase == UX_TRANSFER_PHASE_DATA_OUT)
{
/* Transmit data. */
HAL_PCD_EP_Transmit(dcd_stm32 -> pcd_handle,
endpoint->ux_slave_endpoint_descriptor.bEndpointAddress,
transfer_request->ux_slave_transfer_request_data_pointer,
transfer_request->ux_slave_transfer_request_requested_length);
}
else
{
/* We have a request for a SETUP or OUT Endpoint. */
/* Receive data. */
HAL_PCD_EP_Receive(dcd_stm32 -> pcd_handle,
endpoint->ux_slave_endpoint_descriptor.bEndpointAddress,
transfer_request->ux_slave_transfer_request_data_pointer,
transfer_request->ux_slave_transfer_request_requested_length);
}
I can't find any example or documentation about this. Should I clean this transfer request or do something else? Or am I doing this completely wrong? Can you help me with this?
I attached my init and send files.
Thanks.
Best Regards.
