cancel
Showing results for 
Search instead for 
Did you mean: 

Sending data using CDC host

AJE
Associate II
Posted on July 28, 2015 at 00:47

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;
}
}

2 REPLIES 2
stm32forum
Associate II
Posted on July 28, 2015 at 10:11

Where did you connected it to?

AJE
Associate II
Posted on July 28, 2015 at 11:15

Hi Edje

I have an OTG adapter connected to my board, and then a USB to RS232 converter.

Andrew