AnsweredAssumed Answered

Sending data using CDC host

Question asked by ellis.andrew.001 on Jul 28, 2015
Latest reply on Jul 28, 2015 by ellis.andrew.001
Hi,

I'm trying to get the CDC host to working in my application. I have been following the example provided in \STM32Cube_FW_F4_V1.7.0\Projects\STM324xG_EVAL\Applications\USB_Host\CDC_Standalone. I am using the CooCox IDE. I have posted my code below. The code should be outputting the string, "Hello world", over the CDC port. Whenever USBH_CDC_Transmit() is called it returns USBH_BUSY. All the other functions I call to set up the USB interface return USBH_OK. I have posted my code at the bottom of the  message. Could someone please suggest what I've missed.

Kind regards

Andrew

int main(void)
{
    CDC_LineCodingTypeDef FrameFormat;
    int nRet = 0;
 
    uint8_t buf[] = "Hello  world\n";
 
    SystemInit();
 
    nRet = USBH_RegisterClass(&USB_Host, USBH_CDC_CLASS);
 
    FrameFormat.b.dwDTERate = 9600;
    FrameFormat.b.bCharFormat = 0;
    FrameFormat.b.bDataBits = 8;
    FrameFormat.b.bParityType = 0;
 
    USBH_CDC_SetLineCoding(&USB_Host, &FrameFormat);
 
    nRet = USBH_Start(&USB_Host);
 
    while (1)
    {
        /* Host Task handler */
        nRet =  USBH_Process(&USB_Host);
        nRet =  USBH_CDC_Transmit(&USB_Host, buf, 13);
    }
}
 
static void USBH_UserProcess(USBH_HandleTypeDef *phost, uint8_t id)
{
 
    switch(id)
      {
      case HOST_USER_SELECT_CONFIGURATION:
        break;
 
      case HOST_USER_DISCONNECTION:
        Appli_state = APPLICATION_DISCONNECT;
 
        break;
 
      case HOST_USER_CLASS_ACTIVE:
      //  GetDefaultConfiguration();
        Appli_state = APPLICATION_READY;
        break;
 
      case HOST_USER_CONNECTION:
        Appli_state = APPLICATION_START;
        break;
 
      default:
        break;
      }
}








Outcomes