I am trying to transmit data using the HAL Serial over USB Driver on an STM32F4. I am watching the value of sdup->config->usbp->state in gdb and have found that the application is returning at line 158 of serial_usb.c as shown below because sdup->config->usbp->state is USB_READY not USB_ACTIVE as it should be (I did check that sdup->state == SDU_READY so that part is fine).
Code: Select all
/* If the USB driver is not in the appropriate state then transactions
must not be started.*/
if ((usbGetDriverStateI(sdup->config->usbp) != USB_ACTIVE) ||
(sdup->state != SDU_READY))
return;
Here is my usb setup function -- is there something I should be doing to make the state USB_ACTIVE rather than USB_READY after these steps? I pulled this and the configuration structures (edited for my board obviously) straight from the testhal example.
Code: Select all
void usb_setup(void) {
/*
* Initializes a serial-over-USB CDC driver.
*/
sduObjectInit(&SDU1);
sduStart(&SDU1, &serusbcfg);
/*
* Activates the USB driver and then the USB bus pull-up on D+.
* Note, a delay is inserted in order to not have to disconnect the cable
* after a reset.
*/
usbDisconnectBus(serusbcfg.usbp);
chThdSleepMilliseconds(1000);
usbStart(serusbcfg.usbp, &usbcfg);
usbConnectBus(serusbcfg.usbp);
}
Thank you in advance!