From e372aabda9da9309671e058839d668ec38c7e8c1 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Fri, 17 Aug 2012 12:40:48 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4575 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- testhal/STM32F4xx/USB_CDC/main.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) (limited to 'testhal') diff --git a/testhal/STM32F4xx/USB_CDC/main.c b/testhal/STM32F4xx/USB_CDC/main.c index 027f92a81..34bdf55eb 100644 --- a/testhal/STM32F4xx/USB_CDC/main.c +++ b/testhal/STM32F4xx/USB_CDC/main.c @@ -323,17 +323,21 @@ static void usb_event(USBDriver *usbp, usbevent_t event) { return; } +/* + * USB driver configuration. + */ +static const USBConfig usbcfg = { + usb_event, + get_descriptor, + sduRequestsHook, + NULL +}; + /* * Serial over USB driver configuration. */ static const SerialUSBConfig serusbcfg = { - &USBD1, - { - usb_event, - get_descriptor, - sduRequestsHook, - NULL - } + &USBD1 }; /*===========================================================================*/ @@ -479,13 +483,20 @@ int main(void) { halInit(); chSysInit(); + /* + * 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); - sduObjectInit(&SDU1); - sduStart(&SDU1, &serusbcfg); + usbStart(&USBD1, &usbcfg); usbConnectBus(serusbcfg.usbp); /* -- cgit v1.2.3