on 2021-05-18 06:46 AM
USBD_CDC_LineCodingTypeDef LineCoding = { 115200, /* baud rate */ 0x00, /* stop bits-1 */ 0x00, /* parity - none */ 0x08 /* nb. of bits 8 */ };then structure need to be correctly added into CDC_control_xS function:
static int8_t CDC_Control_xS(uint8_t cmd, uint8_t* pbuf, uint16_t length) { /* USER CODE BEGIN 5 */ switch(cmd) { ... case CDC_SET_LINE_CODING: LineCoding.bitrate = (uint32_t) (pbuf[0] | (pbuf[1] << 8) | (pbuf[2] << 16) | (pbuf[3] << 24)); LineCoding.format = pbuf[4]; LineCoding.paritytype = pbuf[5]; LineCoding.datatype = pbuf[6]; break; case CDC_GET_LINE_CODING: pbuf[0] = (uint8_t) (LineCoding.bitrate); pbuf[1] = (uint8_t) (LineCoding.bitrate >> 8); pbuf[2] = (uint8_t) (LineCoding.bitrate >> 16); pbuf[3] = (uint8_t) (LineCoding.bitrate >> 24); pbuf[4] = LineCoding.format; pbuf[5] = LineCoding.paritytype; pbuf[6] = LineCoding.datatype; break; ... return (USBD_OK); /* USER CODE END 5 */ }
But how to use it for USB Host? Any example plz?
Hello,
line coding may be used on USB host side as well to set correctly parameters of UART peripheral behind. Example of line coding handling on host side can be found in USB CDC host examples in our repositories. Multiple such examples on multiple STM32 families available, one of them on following link:
Best regards,
Lubos
I'm debugging the CDC Host interface on our H743 controller and its not working with a remote device which has a CP2102.
Basically, after the ST H74 usbh_cdc.c code calls getlineconfig, before activating the class, following a successful CP2102 enumeration of the dual bridge interfaces, the USB controller returns a stall status, so it seems that the CP2102 is rejecting the format of the request passed over:-
"Silicon Labs:- Typically, the STALL handshake indicates a functional stall. A functional stall occurs when the halt feature of an endpoint is set. In this circumstance, host intervention is required via the default control pipe to clear the halt feature of the halted endpoint."
The ST USB host code does not handle the stall condition, and although there are some posts about this issue, none give a solution.
I also sent a setlineconfig request and it also stalled.
Do you know how this can be fixed?