2 * Copyright © 2009 Keith Packard <keithp@keithp.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
20 #include "ao_product.h"
22 /* Defines which mark this particular AltOS product */
24 const char ao_version[AO_MAX_VERSION] = AO_iVersion_STRING;
25 const char ao_manufacturer[] = AO_iManufacturer_STRING;
26 const char ao_product[] = AO_iProduct_STRING;
28 #define LE_WORD(x) ((x)&0xFF),((uint8_t) (((uint16_t) (x))>>8))
32 /* Maximum power in mA */
33 #ifndef AO_USB_MAX_POWER
34 #define AO_USB_MAX_POWER 100
37 #ifndef AO_USB_SELF_POWER
38 #define AO_USB_SELF_POWER 1
41 #define AO_USB_DEVICE_CLASS_COMMUNICATION 0x02
42 #define AO_USB_INTERFACE_CLASS_CONTROL_CDC 0x02
43 #define AO_USB_INTERFACE_CLASS_DATA_CDC 0x0A
45 #ifndef AO_USB_DEVICE_CLASS
46 #define AO_USB_DEVICE_CLASS AO_USB_DEVICE_CLASS_COMMUNICATION
49 #ifndef AO_USB_INTERFACE_CLASS_DATA
50 #define AO_USB_INTERFACE_CLASS_CONTROL AO_USB_INTERFACE_CLASS_CONTROL_CDC
51 #define AO_USB_INTERFACE_CLASS_DATA AO_USB_INTERFACE_CLASS_DATA_CDC
57 #define CONTROL_CLASS_LEN 35
58 #define DATA_LEN (9 + 7 * AO_USB_HAS_OUT + 7 * AO_USB_HAS_IN + 7 * AO_USB_HAS_IN2)
60 #define TOTAL_LENGTH (HEADER_LEN + AO_USB_HAS_INT * CONTROL_CLASS_LEN + DATA_LEN)
61 #define NUM_INTERFACES (AO_USB_HAS_INT + 1)
63 /* USB descriptors in one giant block of bytes */
64 AO_ROMCONFIG_SYMBOL(0x00aa) uint8_t ao_usb_descriptors [] =
66 /* Device descriptor */
69 LE_WORD(0x0110), /* bcdUSB */
70 AO_USB_DEVICE_CLASS, /* bDeviceClass */
71 0x00, /* bDeviceSubClass */
72 0x00, /* bDeviceProtocol */
73 AO_USB_CONTROL_SIZE, /* bMaxPacketSize */
74 LE_WORD(AO_idVendor_NUMBER), /* idVendor */
75 LE_WORD(AO_idProduct_NUMBER), /* idProduct */
76 LE_WORD(0x0100), /* bcdDevice */
77 0x01, /* iManufacturer */
79 0x03, /* iSerialNumber */
80 0x01, /* bNumConfigurations */
82 /* Configuration descriptor */
84 AO_USB_DESC_CONFIGURATION,
85 LE_WORD(TOTAL_LENGTH), /* wTotalLength */
86 NUM_INTERFACES, /* bNumInterfaces */
87 0x01, /* bConfigurationValue */
88 0x00, /* iConfiguration */
89 0x80 | (AO_USB_SELF_POWER << 6), /* bmAttributes */
90 AO_USB_MAX_POWER >> 1, /* bMaxPower, 2mA units */
93 /* Control class interface */
95 AO_USB_DESC_INTERFACE,
96 0x00, /* bInterfaceNumber */
97 0x00, /* bAlternateSetting */
98 0x01, /* bNumEndPoints */
99 AO_USB_INTERFACE_CLASS_CONTROL, /* bInterfaceClass */
100 0x02, /* bInterfaceSubClass */
101 0x01, /* bInterfaceProtocol, linux requires value of 1 for the cdc_acm module */
102 0x00, /* iInterface */
104 /* Header functional descriptor */
107 0x00, /* bDescriptor SubType Header */
108 LE_WORD(0x0110), /* CDC version 1.1 */
110 /* Call management functional descriptor */
113 0x01, /* bDescriptor SubType Call Management */
114 0x01, /* bmCapabilities = device handles call management */
115 0x01, /* bDataInterface call management interface number */
117 /* ACM functional descriptor */
120 0x02, /* bDescriptor SubType Abstract Control Management */
121 0x02, /* bmCapabilities = D1 (Set_line_Coding, Set_Control_Line_State, Get_Line_Coding and Serial_State) */
123 /* Union functional descriptor */
126 0x06, /* bDescriptor SubType Union Functional descriptor */
127 0x00, /* bMasterInterface */
128 0x01, /* bSlaveInterface0 */
130 /* Notification EP */
132 AO_USB_DESC_ENDPOINT,
133 AO_USB_INT_EP|0x80, /* bEndpointAddress */
134 0x03, /* bmAttributes = intr */
135 LE_WORD(8), /* wMaxPacketSize */
136 0xff, /* bInterval */
139 /* Data class interface descriptor */
141 AO_USB_DESC_INTERFACE,
142 AO_USB_HAS_INT, /* bInterfaceNumber */
143 0x00, /* bAlternateSetting */
144 AO_USB_HAS_OUT + AO_USB_HAS_IN + AO_USB_HAS_IN2, /* bNumEndPoints */
145 AO_USB_INTERFACE_CLASS_DATA, /* bInterfaceClass = data */
146 0x00, /* bInterfaceSubClass */
147 0x00, /* bInterfaceProtocol */
148 0x00, /* iInterface */
153 AO_USB_DESC_ENDPOINT,
154 AO_USB_OUT_EP, /* bEndpointAddress */
155 0x02, /* bmAttributes = bulk */
156 LE_WORD(AO_USB_OUT_SIZE),/* wMaxPacketSize */
157 0x00, /* bInterval */
163 AO_USB_DESC_ENDPOINT,
164 AO_USB_IN_EP|0x80, /* bEndpointAddress */
165 0x02, /* bmAttributes = bulk */
166 LE_WORD(AO_USB_IN_SIZE),/* wMaxPacketSize */
167 0x00, /* bInterval */
173 AO_USB_DESC_ENDPOINT,
174 AO_USB_IN2_EP|0x80, /* bEndpointAddress */
175 0x02, /* bmAttributes = bulk */
176 LE_WORD(AO_USB_IN_SIZE),/* wMaxPacketSize */
177 0x00, /* bInterval */
180 /* String descriptors */
186 AO_iManufacturer_LEN,
188 AO_iManufacturer_UCS2,
200 /* Terminating zero */