From 25cecf6e7ef75e0ac60d13177dfc7fbfbfcf55b2 Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Tue, 10 Oct 2017 14:05:08 +0000 Subject: Added unified lwIP-FATFS-USB demo. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@10808 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- demos/STM32/RT-STM32-LWIP-FATFS-USB/src/usbcfg.c | 43 ++++++++++++------------ 1 file changed, 22 insertions(+), 21 deletions(-) (limited to 'demos/STM32/RT-STM32-LWIP-FATFS-USB/src/usbcfg.c') diff --git a/demos/STM32/RT-STM32-LWIP-FATFS-USB/src/usbcfg.c b/demos/STM32/RT-STM32-LWIP-FATFS-USB/src/usbcfg.c index bb05f43c8..ff290eebb 100644 --- a/demos/STM32/RT-STM32-LWIP-FATFS-USB/src/usbcfg.c +++ b/demos/STM32/RT-STM32-LWIP-FATFS-USB/src/usbcfg.c @@ -15,22 +15,23 @@ */ #include "hal.h" +#include "portab.h" /* Virtual serial port over USB.*/ -SerialUSBDriver SDU2; +SerialUSBDriver PORTAB_SDU1; /* - * Endpoints to be used for USBD2. + * Endpoints to be used for USBD1. */ -#define USBD2_DATA_REQUEST_EP 1 -#define USBD2_DATA_AVAILABLE_EP 1 -#define USBD2_INTERRUPT_REQUEST_EP 2 +#define USB1_DATA_REQUEST_EP 1 +#define USB1_DATA_AVAILABLE_EP 1 +#define USB1_INTERRUPT_REQUEST_EP 2 /* * USB Device Descriptor. */ static const uint8_t vcom_device_descriptor_data[18] = { - USB_DESC_DEVICE (0x0200, /* bcdUSB (2.0). */ + USB_DESC_DEVICE (0x0110, /* bcdUSB (1.1). */ 0x02, /* bDeviceClass (CDC). */ 0x00, /* bDeviceSubClass. */ 0x00, /* bDeviceProtocol. */ @@ -102,7 +103,7 @@ static const uint8_t vcom_configuration_descriptor_data[67] = { USB_DESC_BYTE (0x01), /* bSlaveInterface0 (Data Class Interface). */ /* Endpoint 2 Descriptor.*/ - USB_DESC_ENDPOINT (USBD2_INTERRUPT_REQUEST_EP|0x80, + USB_DESC_ENDPOINT (USB1_INTERRUPT_REQUEST_EP|0x80, 0x03, /* bmAttributes (Interrupt). */ 0x0008, /* wMaxPacketSize. */ 0xFF), /* bInterval. */ @@ -118,12 +119,12 @@ static const uint8_t vcom_configuration_descriptor_data[67] = { 4.7). */ 0x00), /* iInterface. */ /* Endpoint 3 Descriptor.*/ - USB_DESC_ENDPOINT (USBD2_DATA_AVAILABLE_EP, /* bEndpointAddress.*/ + USB_DESC_ENDPOINT (USB1_DATA_AVAILABLE_EP, /* bEndpointAddress.*/ 0x02, /* bmAttributes (Bulk). */ 0x0040, /* wMaxPacketSize. */ 0x00), /* bInterval. */ /* Endpoint 1 Descriptor.*/ - USB_DESC_ENDPOINT (USBD2_DATA_REQUEST_EP|0x80, /* bEndpointAddress.*/ + USB_DESC_ENDPOINT (USB1_DATA_REQUEST_EP|0x80, /* bEndpointAddress.*/ 0x02, /* bmAttributes (Bulk). */ 0x0040, /* wMaxPacketSize. */ 0x00) /* bInterval. */ @@ -235,7 +236,7 @@ static const USBEndpointConfig ep1config = { 0x0040, &ep1instate, &ep1outstate, - 4, + 2, NULL }; @@ -264,7 +265,7 @@ static const USBEndpointConfig ep2config = { * Handles the USB driver global events. */ static void usb_event(USBDriver *usbp, usbevent_t event) { - extern SerialUSBDriver SDU2; + extern SerialUSBDriver PORTAB_SDU1; switch (event) { case USB_EVENT_ADDRESS: @@ -275,11 +276,11 @@ static void usb_event(USBDriver *usbp, usbevent_t event) { /* Enables the endpoints specified into the configuration. Note, this callback is invoked from an ISR so I-Class functions must be used.*/ - usbInitEndpointI(usbp, USBD2_DATA_REQUEST_EP, &ep1config); - usbInitEndpointI(usbp, USBD2_INTERRUPT_REQUEST_EP, &ep2config); + usbInitEndpointI(usbp, USB1_DATA_REQUEST_EP, &ep1config); + usbInitEndpointI(usbp, USB1_INTERRUPT_REQUEST_EP, &ep2config); /* Resetting the state of the CDC subsystem.*/ - sduConfigureHookI(&SDU2); + sduConfigureHookI(&PORTAB_SDU1); chSysUnlockFromISR(); return; @@ -291,7 +292,7 @@ static void usb_event(USBDriver *usbp, usbevent_t event) { chSysLockFromISR(); /* Disconnection event on suspend.*/ - sduSuspendHookI(&SDU2); + sduSuspendHookI(&PORTAB_SDU1); chSysUnlockFromISR(); return; @@ -299,7 +300,7 @@ static void usb_event(USBDriver *usbp, usbevent_t event) { chSysLockFromISR(); /* Disconnection event on suspend.*/ - sduWakeupHookI(&SDU2); + sduWakeupHookI(&PORTAB_SDU1); chSysUnlockFromISR(); return; @@ -317,7 +318,7 @@ static void sof_handler(USBDriver *usbp) { (void)usbp; osalSysLockFromISR(); - sduSOFHookI(&SDU2); + sduSOFHookI(&PORTAB_SDU1); osalSysUnlockFromISR(); } @@ -335,8 +336,8 @@ const USBConfig usbcfg = { * Serial over USB driver configuration. */ const SerialUSBConfig serusbcfg = { - &USBD2, - USBD2_DATA_REQUEST_EP, - USBD2_DATA_AVAILABLE_EP, - USBD2_INTERRUPT_REQUEST_EP + &PORTAB_USB1, + USB1_DATA_REQUEST_EP, + USB1_DATA_AVAILABLE_EP, + USB1_INTERRUPT_REQUEST_EP }; -- cgit v1.2.3