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 + 7 * AO_USB_HAS_IN3)
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 #ifndef AO_USBCONFIG_SYMBOL
64 #define AO_USBCONFIG_SYMBOL AO_ROMCONFIG_SYMBOL
67 /* USB descriptors in one giant block of bytes */
68 AO_USBCONFIG_SYMBOL uint8_t ao_usb_descriptors [] =
70 /* Device descriptor */
73 LE_WORD(0x0110), /* bcdUSB */
74 AO_USB_DEVICE_CLASS, /* bDeviceClass */
75 0x00, /* bDeviceSubClass */
76 0x00, /* bDeviceProtocol */
77 AO_USB_CONTROL_SIZE, /* bMaxPacketSize */
78 LE_WORD(AO_idVendor_NUMBER), /* idVendor */
79 LE_WORD(AO_idProduct_NUMBER), /* idProduct */
80 LE_WORD(0x0100), /* bcdDevice */
81 0x01, /* iManufacturer */
83 0x03, /* iSerialNumber */
84 0x01, /* bNumConfigurations */
86 /* Configuration descriptor */
88 AO_USB_DESC_CONFIGURATION,
89 LE_WORD(TOTAL_LENGTH), /* wTotalLength */
90 NUM_INTERFACES, /* bNumInterfaces */
91 0x01, /* bConfigurationValue */
92 0x00, /* iConfiguration */
93 0x80 | (AO_USB_SELF_POWER << 6), /* bmAttributes */
94 AO_USB_MAX_POWER >> 1, /* bMaxPower, 2mA units */
97 /* Control class interface */
99 AO_USB_DESC_INTERFACE,
100 0x00, /* bInterfaceNumber */
101 0x00, /* bAlternateSetting */
102 0x01, /* bNumEndPoints */
103 AO_USB_INTERFACE_CLASS_CONTROL, /* bInterfaceClass */
104 0x02, /* bInterfaceSubClass */
105 0x01, /* bInterfaceProtocol, linux requires value of 1 for the cdc_acm module */
106 0x00, /* iInterface */
108 /* Header functional descriptor */
111 0x00, /* bDescriptor SubType Header */
112 LE_WORD(0x0110), /* CDC version 1.1 */
114 /* Call management functional descriptor */
117 0x01, /* bDescriptor SubType Call Management */
118 0x01, /* bmCapabilities = device handles call management */
119 0x01, /* bDataInterface call management interface number */
121 /* ACM functional descriptor */
124 0x02, /* bDescriptor SubType Abstract Control Management */
125 0x02, /* bmCapabilities = D1 (Set_line_Coding, Set_Control_Line_State, Get_Line_Coding and Serial_State) */
127 /* Union functional descriptor */
130 0x06, /* bDescriptor SubType Union Functional descriptor */
131 0x00, /* bMasterInterface */
132 0x01, /* bSlaveInterface0 */
134 /* Notification EP */
136 AO_USB_DESC_ENDPOINT,
137 AO_USB_INT_EP|0x80, /* bEndpointAddress */
138 0x03, /* bmAttributes = intr */
139 LE_WORD(8), /* wMaxPacketSize */
140 0xff, /* bInterval */
143 /* Data class interface descriptor */
145 AO_USB_DESC_INTERFACE,
146 AO_USB_HAS_INT, /* bInterfaceNumber */
147 0x00, /* bAlternateSetting */
148 AO_USB_HAS_OUT + AO_USB_HAS_IN + AO_USB_HAS_IN2 + AO_USB_HAS_IN3, /* bNumEndPoints */
149 AO_USB_INTERFACE_CLASS_DATA, /* bInterfaceClass = data */
150 0x00, /* bInterfaceSubClass */
151 0x00, /* bInterfaceProtocol */
152 0x00, /* iInterface */
157 AO_USB_DESC_ENDPOINT,
158 AO_USB_OUT_EP, /* bEndpointAddress */
159 0x02, /* bmAttributes = bulk */
160 LE_WORD(AO_USB_OUT_SIZE),/* wMaxPacketSize */
161 0x00, /* bInterval */
167 AO_USB_DESC_ENDPOINT,
168 AO_USB_IN_EP|0x80, /* bEndpointAddress */
169 0x02, /* bmAttributes = bulk */
170 LE_WORD(AO_USB_IN_SIZE),/* wMaxPacketSize */
171 0x00, /* bInterval */
177 AO_USB_DESC_ENDPOINT,
178 AO_USB_IN2_EP|0x80, /* bEndpointAddress */
179 0x02, /* bmAttributes = bulk */
180 LE_WORD(AO_USB_IN_SIZE),/* wMaxPacketSize */
181 0x00, /* bInterval */
187 AO_USB_DESC_ENDPOINT,
188 AO_USB_IN3_EP|0x80, /* bEndpointAddress */
189 0x02, /* bmAttributes = bulk */
190 LE_WORD(AO_USB_IN_SIZE),/* wMaxPacketSize */
191 0x00, /* bInterval */
194 /* String descriptors */
200 AO_iManufacturer_LEN,
202 AO_iManufacturer_UCS2,
214 /* Terminating zero */