Question
STM32Cube CDC - problems and a possible bug
Posted on March 22, 2014 at 01:39
Hello.
I am currently trying to build a project using the STM32F429 iDisco. The toolchain I am using is the arm embedded gcc, under Eclipse IDE. I am trying to use STM32Cube to write the initialization part for me. Initially I want to use CDC to loopback data sent from a pc (host) to the board (device). Later I want to implement communication between pc and board to control sensors. I'm fiddling with the various callbacks that Cube puts in usbd_conf.c. Since my first problem is the fact that the host pc cannot recognize the connected board (Windows has stopped this device because it has reported problems. (Code 43)A request for the USB device descriptor failed.) I am playing with HAL_PCD_ConnectCallback, but I am not sure what I should be doing there. I tried opening a bunch of endpoints (with HAL_PCD_EP_Open()), but to no avail. Using the board's LEDs to give me output depending on the device state, tells me that after initialization the device is in USBD_STATE_DEFAULT, but after a while (as soon as Windows enumerates it and cannot find its descriptor) it goes in USB_STATE_SUSPENDED. While playing around with my code I also found something that looked kinda odd. In stm32f4xx_hal_pcd.c, in the functionHAL_StatusTypeDef HAL_PCD_Init(PCD_HandleTypeDef *hpcd), from line 163:for (i = 0; i <
15
; i++)
{
hpcd->OUT_ep[i].is_in = 0;
hpcd->OUT_ep[i].num = i;
hpcd->IN_ep[i].tx_fifo_num = i; //<<<
THIS
LOOKS ODD
/* Control until ep is activated */
hpcd->OUT_ep[i].type = EP_TYPE_CTRL;
hpcd->OUT_ep[i].maxpacket = 0;
hpcd->OUT_ep[i].xfer_buff = 0;
hpcd->OUT_ep[i].xfer_len = 0;
hpcd->Instance->DIEPTXF[i] = 0;
} Line 167 (the third instruction in the for loop) looks out of place to me.
Can anyone tell me what should I write, and where, to implement this loopback?
Ideally, the result of this step in my project would be that the board can receive data from a terminal and loop it back, like I did with a VCP code I downloaded recently.
Also, can anyone confirm that that line is correct as it is?
Thanks,
Matteo
#stm32cubemx #stm32f429 #discovery