2025-01-28 05:01 AM
Hello,
I implemented a virtual com port using the usbx stack for the stm32U575 in standalone mode and it basicaly works.
My problem is that I just can't put more than 8 bytes in the TX buffer at the time. If I do the program gets stuck (in the main loop)
I tried both: ux_device_class_cdc_acm_write_with_callback and ux_device_class_cdc_acm_write_run
but they only work when the buffer length is less than 8 bytes.
I have the following code in app_usbx_device.c:
/* USER CODE BEGIN MX_USBX_Device_Init1 */
/* Initialize the USB Peripheral */
MX_USB_OTG_FS_PCD_Init();
HAL_PCDEx_SetRxFiFo(&hpcd_USB_OTG_FS, 0x80);
HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, 0, USBD_MAX_EP0_SIZE / 4);
HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, 1, USBD_CDCACM_EPIN_FS_MPS / 4);
HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, 2, USBD_CDCACM_EPINCMD_FS_MPS / 4);
/* Link the USB drivers with the USBX DCD and check if it return error */
if(ux_dcd_stm32_initialize((ULONG)USB_OTG_FS, (ULONG)&hpcd_USB_OTG_FS) != UX_SUCCESS){
Error_Handler();
}
/* Start the PCD Peripheral */
HAL_PCD_Start(&hpcd_USB_OTG_FS);
/* USER CODE END MX_USBX_Device_Init1 */
And in ux_device_cdc_acm.c (with callback):
VOID USBD_CDC_ACM_Activate(VOID *cdc_acm_instance)
{
/* USER CODE BEGIN USBD_CDC_ACM_Activate */
cdc_acm = (UX_SLAVE_CLASS_CDC_ACM*) cdc_acm_instance;
UX_SLAVE_CLASS_CDC_ACM_CALLBACK_PARAMETER cdc_acm_slave_callback;
cdc_acm_slave_callback.ux_device_class_cdc_acm_parameter_read_callback = USBX_cdc_acm_device_read_callback;
cdc_acm_slave_callback.ux_device_class_cdc_acm_parameter_write_callback = USBX_cdc_acm_device_write_callback;
ux_device_class_cdc_acm_ioctl(cdc_acm, UX_SLAVE_CLASS_CDC_ACM_IOCTL_TRANSMISSION_START, (VOID*)&cdc_acm_slave_callback);
/* USER CODE END USBD_CDC_ACM_Activate */
return;
}
I was wondering if the routine, which empties the buffer doesn't get called in standalone mode or if I missed something in the init of the stack.
Thank you in advance for your input !