cancel
Showing results for 
Search instead for 
Did you mean: 

USB CDC Host SetControlLineState

simon239955_stm1_st
Associate II

Hi

Can anyone please show me an example of a working USB CDC Host sending the SetControlLineState command? This hasn't been implemented in the STM32 HAL drivers/middleware but it should be a simple thing to add.

SetControlLineState is used to signal the Host is ready to receive data from the CDC device. I tried adding and calling my own routine after the USB enumeration completes:

USBH_StatusTypeDef  USBH_CDC_SetControlLineState(USBH_HandleTypeDef *phost)
{
 
  phost->Control.setup.b.bmRequestType = USB_H2D | USB_REQ_TYPE_CLASS | USB_REQ_RECIPIENT_INTERFACE;
	
  phost->Control.setup.b.bRequest = CDC_SET_CONTROL_LINE_STATE;
  phost->Control.setup.b.wValue.w = 3U;
  phost->Control.setup.b.wIndex.w = 2;
  phost->Control.setup.b.wLength.w = 0;
 
  return USBH_CtlReq(phost, 0, 0);
}

The transmitted data appears to be correctly formed but the phost->RequestState appears to get stuck on CMD_WAIT expecting a reply from the device which I understand is not part of the CDC protocol. I then modified USBH_CtlReq to always set phost->RequestState = CMD_SEND when called from the above procedure but I still cannot get the USB CDC device to send data out.

I would be gratedul for a working USB CDC Host SetControlLineState example or suggestions to try.

Thank you in advance.

1 REPLY 1
bernieserver
Associate II

Hi ST,

I am waiting as well for exaktly the same feature or I am looking for a way to set the DTR signal on an USB device.