Use 'char' instead of 'uint8_t' for character data
[fw/altos] / ao_product.c
1 /*
2  * Copyright © 2009 Keith Packard <keithp@keithp.com>
3  *
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; version 2 of the License.
7  *
8  * This program is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11  * General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License along
14  * with this program; if not, write to the Free Software Foundation, Inc.,
15  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
16  */
17
18 #include "ao.h"
19 #include "ao_usb.h"
20 #include PRODUCT_DEFS
21
22 /* Defines which mark this particular AltOS product */
23
24 const uint16_t ao_serial_number = AO_iSerial_NUMBER;
25
26 #define LE_WORD(x)    ((x)&0xFF),((uint8_t) (((uint16_t) (x))>>8))
27
28 /* USB descriptors in one giant block of bytes */
29 const uint8_t ao_usb_descriptors [] =
30 {
31         /* Device descriptor */
32         0x12,
33         AO_USB_DESC_DEVICE,
34         LE_WORD(0x0110),        /*  bcdUSB */
35         0x02,                   /*  bDeviceClass */
36         0x00,                   /*  bDeviceSubClass */
37         0x00,                   /*  bDeviceProtocol */
38         AO_USB_CONTROL_SIZE,    /*  bMaxPacketSize */
39         LE_WORD(0xFFFE),        /*  idVendor */
40         LE_WORD(0x000A),        /*  idProduct */
41         LE_WORD(0x0100),        /*  bcdDevice */
42         0x01,                   /*  iManufacturer */
43         0x02,                   /*  iProduct */
44         0x03,                   /*  iSerialNumber */
45         0x01,                   /*  bNumConfigurations */
46
47         /* Configuration descriptor */
48         0x09,
49         AO_USB_DESC_CONFIGURATION,
50         LE_WORD(67),            /*  wTotalLength */
51         0x02,                   /*  bNumInterfaces */
52         0x01,                   /*  bConfigurationValue */
53         0x00,                   /*  iConfiguration */
54         0xC0,                   /*  bmAttributes */
55         0x32,                   /*  bMaxPower */
56
57         /* Control class interface */
58         0x09,
59         AO_USB_DESC_INTERFACE,
60         0x00,                   /*  bInterfaceNumber */
61         0x00,                   /*  bAlternateSetting */
62         0x01,                   /*  bNumEndPoints */
63         0x02,                   /*  bInterfaceClass */
64         0x02,                   /*  bInterfaceSubClass */
65         0x01,                   /*  bInterfaceProtocol, linux requires value of 1 for the cdc_acm module */
66         0x00,                   /*  iInterface */
67
68         /* Header functional descriptor */
69         0x05,
70         CS_INTERFACE,
71         0x00,                   /*  bDescriptor SubType Header */
72         LE_WORD(0x0110),        /*  CDC version 1.1 */
73
74         /* Call management functional descriptor */
75         0x05,
76         CS_INTERFACE,
77         0x01,                   /* bDescriptor SubType Call Management */
78         0x01,                   /* bmCapabilities = device handles call management */
79         0x01,                   /* bDataInterface call management interface number */
80
81         /* ACM functional descriptor */
82         0x04,
83         CS_INTERFACE,
84         0x02,                   /* bDescriptor SubType Abstract Control Management */
85         0x02,                   /* bmCapabilities = D1 (Set_line_Coding, Set_Control_Line_State, Get_Line_Coding and Serial_State) */
86
87         /* Union functional descriptor */
88         0x05,
89         CS_INTERFACE,
90         0x06,                   /* bDescriptor SubType Union Functional descriptor */
91         0x00,                   /* bMasterInterface */
92         0x01,                   /* bSlaveInterface0 */
93
94         /* Notification EP */
95         0x07,
96         AO_USB_DESC_ENDPOINT,
97         AO_USB_INT_EP|0x80,     /* bEndpointAddress */
98         0x03,                   /* bmAttributes = intr */
99         LE_WORD(8),             /* wMaxPacketSize */
100         0x0A,                   /* bInterval */
101
102         /* Data class interface descriptor */
103         0x09,
104         AO_USB_DESC_INTERFACE,
105         0x01,                   /* bInterfaceNumber */
106         0x00,                   /* bAlternateSetting */
107         0x02,                   /* bNumEndPoints */
108         0x0A,                   /* bInterfaceClass = data */
109         0x00,                   /* bInterfaceSubClass */
110         0x00,                   /* bInterfaceProtocol */
111         0x00,                   /* iInterface */
112
113         /* Data EP OUT */
114         0x07,
115         AO_USB_DESC_ENDPOINT,
116         AO_USB_OUT_EP,          /* bEndpointAddress */
117         0x02,                   /* bmAttributes = bulk */
118         LE_WORD(AO_USB_OUT_SIZE),/* wMaxPacketSize */
119         0x00,                   /* bInterval */
120
121         /* Data EP in */
122         0x07,
123         AO_USB_DESC_ENDPOINT,
124         AO_USB_IN_EP|0x80,      /* bEndpointAddress */
125         0x02,                   /* bmAttributes = bulk */
126         LE_WORD(AO_USB_IN_SIZE),/* wMaxPacketSize */
127         0x00,                   /* bInterval */
128
129         /* String descriptors */
130         0x04,
131         AO_USB_DESC_STRING,
132         LE_WORD(0x0409),
133
134         /* iManufacturer */
135         AO_iManufacturer_LEN,
136         AO_USB_DESC_STRING,
137         AO_iManufacturer_STRING,
138
139         /* iProduct */
140         AO_iProduct_LEN,
141         AO_USB_DESC_STRING,
142         AO_iProduct_STRING,
143
144         /* iSerial */
145         AO_iSerial_LEN,
146         AO_USB_DESC_STRING,
147         AO_iSerial_STRING,
148
149         /* Terminating zero */
150         0
151 };