From 635a199a470969f830f2da6dc87694a09cdb196d Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Fri, 3 Aug 2018 21:26:49 -0400 Subject: [PATCH] usb_cdc: Allow USB endpoint ids to be board specific It's common for boards to have restrictions on the type of each endpoint. So, make it possible for the board to select the endpoint ids for each endpoint. Signed-off-by: Kevin O'Connor --- src/generic/usb_cdc.c | 3 ++- src/generic/usb_cdc.h | 8 +------- src/generic/usb_cdc_ep.h | 11 +++++++++++ src/lpc176x/usb_cdc_ep.h | 10 ++++++++++ src/lpc176x/usbserial.c | 3 ++- 5 files changed, 26 insertions(+), 9 deletions(-) create mode 100644 src/generic/usb_cdc_ep.h create mode 100644 src/lpc176x/usb_cdc_ep.h diff --git a/src/generic/usb_cdc.c b/src/generic/usb_cdc.c index 04b02da0..dfc88511 100644 --- a/src/generic/usb_cdc.c +++ b/src/generic/usb_cdc.c @@ -6,12 +6,13 @@ #include // memmove #include "board/pgm.h" // PROGMEM -#include "board/usb_cdc.h" // usb_notify_setup +#include "board/usb_cdc_ep.h" // USB_CDC_EP_BULK_IN #include "byteorder.h" // cpu_to_le16 #include "command.h" // output #include "generic/usbstd.h" // struct usb_device_descriptor #include "generic/usbstd_cdc.h" // struct usb_cdc_header_descriptor #include "sched.h" // sched_wake_task +#include "usb_cdc.h" // usb_notify_setup // XXX - move to Kconfig #define CONFIG_USB_VENDOR_ID 0x2341 diff --git a/src/generic/usb_cdc.h b/src/generic/usb_cdc.h index c5450bfa..2e63b7a3 100644 --- a/src/generic/usb_cdc.h +++ b/src/generic/usb_cdc.h @@ -3,17 +3,11 @@ #include // uint_fast8_t +// endpoint sizes enum { USB_CDC_EP0_SIZE = 16, - - // XXX - endpoint ids may need to changed per-board - USB_CDC_EP_ACM = 1, USB_CDC_EP_ACM_SIZE = 8, - - USB_CDC_EP_BULK_OUT = 2, USB_CDC_EP_BULK_OUT_SIZE = 64, - - USB_CDC_EP_BULK_IN = 5, USB_CDC_EP_BULK_IN_SIZE = 64, }; diff --git a/src/generic/usb_cdc_ep.h b/src/generic/usb_cdc_ep.h new file mode 100644 index 00000000..1ca97a79 --- /dev/null +++ b/src/generic/usb_cdc_ep.h @@ -0,0 +1,11 @@ +#ifndef __GENERIC_USB_CDC_EP_H +#define __GENERIC_USB_CDC_EP_H + +// Default USB endpoint ids +enum { + USB_CDC_EP_ACM = 1, + USB_CDC_EP_BULK_OUT = 2, + USB_CDC_EP_BULK_IN = 3, +}; + +#endif // usb_cdc_ep.h diff --git a/src/lpc176x/usb_cdc_ep.h b/src/lpc176x/usb_cdc_ep.h new file mode 100644 index 00000000..d657f3c2 --- /dev/null +++ b/src/lpc176x/usb_cdc_ep.h @@ -0,0 +1,10 @@ +#ifndef __LPC176X_USB_CDC_EP_H +#define __LPC176X_USB_CDC_EP_H + +enum { + USB_CDC_EP_ACM = 1, + USB_CDC_EP_BULK_OUT = 2, + USB_CDC_EP_BULK_IN = 5, +}; + +#endif // usb_cdc_ep.h diff --git a/src/lpc176x/usbserial.c b/src/lpc176x/usbserial.c index 28c0881f..2b6dca00 100644 --- a/src/lpc176x/usbserial.c +++ b/src/lpc176x/usbserial.c @@ -6,11 +6,12 @@ #include // memcpy #include "LPC17xx.h" // LPC_SC -#include "board/usb_cdc.h" // usb_notify_setup #include "byteorder.h" // cpu_to_le32 #include "command.h" // output +#include "generic/usb_cdc.h" // usb_notify_setup #include "internal.h" // gpio_peripheral #include "sched.h" // DECL_INIT +#include "usb_cdc_ep.h" // USB_CDC_EP_BULK_IN // Internal endpoint addresses #define EP0OUT 0x00