aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarti Bolivar <mbolivar@leaflabs.com>2012-08-04 18:28:34 -0400
committerMarti Bolivar <mbolivar@leaflabs.com>2012-08-04 18:43:49 -0400
commita87c65d2ef804b2fc632f4f0850c1947c81faafe (patch)
tree58cefb06cd1cca86ae207366c88e903133fb4f9c
parent0d39520529ef9ed8b002137ac0a9a375992a55c8 (diff)
downloadlibrambutan-a87c65d2ef804b2fc632f4f0850c1947c81faafe.tar.gz
librambutan-a87c65d2ef804b2fc632f4f0850c1947c81faafe.zip
usb_cdcacm.h: Add convenience for declaring device descriptor.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
-rw-r--r--libmaple/include/libmaple/usb_cdcacm.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/libmaple/include/libmaple/usb_cdcacm.h b/libmaple/include/libmaple/usb_cdcacm.h
index 1c46b56..8b3c1fe 100644
--- a/libmaple/include/libmaple/usb_cdcacm.h
+++ b/libmaple/include/libmaple/usb_cdcacm.h
@@ -36,6 +36,7 @@
#include <libmaple/libmaple_types.h>
#include <libmaple/gpio.h>
+#include <libmaple/usb.h>
#ifdef __cplusplus
extern "C" {
@@ -71,6 +72,26 @@ extern "C" {
#define USB_INTERFACE_SUBCLASS_CDC_ACM 0x02
#define USB_INTERFACE_CLASS_DIC 0x0A
+#ifndef __cplusplus
+#define USB_CDCACM_DECLARE_DEV_DESC(vid, pid) \
+ { \
+ .bLength = sizeof(usb_descriptor_device), \
+ .bDescriptorType = USB_DESCRIPTOR_TYPE_DEVICE, \
+ .bcdUSB = 0x0200, \
+ .bDeviceClass = USB_DEVICE_CLASS_CDC, \
+ .bDeviceSubClass = USB_DEVICE_SUBCLASS_CDC, \
+ .bDeviceProtocol = 0x00, \
+ .bMaxPacketSize0 = 0x40, \
+ .idVendor = vid, \
+ .idProduct = pid, \
+ .bcdDevice = 0x0200, \
+ .iManufacturer = 0x01, \
+ .iProduct = 0x02, \
+ .iSerialNumber = 0x00, \
+ .bNumConfigurations = 0x01, \
+ }
+#endif
+
/*
* CDC ACM interface
*/