b78ac1aa56d72e4780532bf9635b7e1a68353d18
[fw/altos] / src-avr / 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_product.h"
20
21 /* Defines which mark this particular AltOS product */
22
23 const char ao_version[] = AO_iVersion_STRING;
24 const char ao_manufacturer[] = AO_iManufacturer_STRING;
25 const char ao_product[] = AO_iProduct_STRING;
26 const int ao_serial_number = 1;
27
28 #define LE_WORD(x)    ((x)&0xFF),((uint8_t) (((uint16_t) (x))>>8))
29
30 #if HAS_USB
31 #include "ao_usb.h"
32 /* USB descriptors in one giant block of bytes */
33 #ifdef AVR
34 const uint8_t ao_usb_descriptors [] =
35 #else
36 __code __at(0x00aa) uint8_t ao_usb_descriptors [] =
37 #endif
38 {
39         /* Device descriptor */
40         0x12,
41         AO_USB_DESC_DEVICE,
42         LE_WORD(0x0110),        /*  bcdUSB */
43         0x02,                   /*  bDeviceClass */
44         0x00,                   /*  bDeviceSubClass */
45         0x00,                   /*  bDeviceProtocol */
46         AO_USB_CONTROL_SIZE,    /*  bMaxPacketSize */
47         LE_WORD(0xFFFE),        /*  idVendor */
48         LE_WORD(AO_idProduct_NUMBER),   /*  idProduct */
49         LE_WORD(0x0100),        /*  bcdDevice */
50         0x01,                   /*  iManufacturer */
51         0x02,                   /*  iProduct */
52         0x03,                   /*  iSerialNumber */
53         0x01,                   /*  bNumConfigurations */
54
55         /* Configuration descriptor */
56         0x09,
57         AO_USB_DESC_CONFIGURATION,
58         LE_WORD(67),            /*  wTotalLength */
59         0x02,                   /*  bNumInterfaces */
60         0x01,                   /*  bConfigurationValue */
61         0x00,                   /*  iConfiguration */
62         0xC0,                   /*  bmAttributes */
63         0x32,                   /*  bMaxPower */
64
65         /* Control class interface */
66         0x09,
67         AO_USB_DESC_INTERFACE,
68         0x00,                   /*  bInterfaceNumber */
69         0x00,                   /*  bAlternateSetting */
70         0x01,                   /*  bNumEndPoints */
71         0x02,                   /*  bInterfaceClass */
72         0x02,                   /*  bInterfaceSubClass */
73         0x01,                   /*  bInterfaceProtocol, linux requires value of 1 for the cdc_acm module */
74         0x00,                   /*  iInterface */
75
76         /* Header functional descriptor */
77         0x05,
78         CS_INTERFACE,
79         0x00,                   /*  bDescriptor SubType Header */
80         LE_WORD(0x0110),        /*  CDC version 1.1 */
81
82         /* Call management functional descriptor */
83         0x05,
84         CS_INTERFACE,
85         0x01,                   /* bDescriptor SubType Call Management */
86         0x01,                   /* bmCapabilities = device handles call management */
87         0x01,                   /* bDataInterface call management interface number */
88
89         /* ACM functional descriptor */
90         0x04,
91         CS_INTERFACE,
92         0x02,                   /* bDescriptor SubType Abstract Control Management */
93         0x02,                   /* bmCapabilities = D1 (Set_line_Coding, Set_Control_Line_State, Get_Line_Coding and Serial_State) */
94
95         /* Union functional descriptor */
96         0x05,
97         CS_INTERFACE,
98         0x06,                   /* bDescriptor SubType Union Functional descriptor */
99         0x00,                   /* bMasterInterface */
100         0x01,                   /* bSlaveInterface0 */
101
102         /* Notification EP */
103         0x07,
104         AO_USB_DESC_ENDPOINT,
105         AO_USB_INT_EP|0x80,     /* bEndpointAddress */
106         0x03,                   /* bmAttributes = intr */
107         LE_WORD(8),             /* wMaxPacketSize */
108         0x0A,                   /* bInterval */
109
110         /* Data class interface descriptor */
111         0x09,
112         AO_USB_DESC_INTERFACE,
113         0x01,                   /* bInterfaceNumber */
114         0x00,                   /* bAlternateSetting */
115         0x02,                   /* bNumEndPoints */
116         0x0A,                   /* bInterfaceClass = data */
117         0x00,                   /* bInterfaceSubClass */
118         0x00,                   /* bInterfaceProtocol */
119         0x00,                   /* iInterface */
120
121         /* Data EP OUT */
122         0x07,
123         AO_USB_DESC_ENDPOINT,
124         AO_USB_OUT_EP,          /* bEndpointAddress */
125         0x02,                   /* bmAttributes = bulk */
126         LE_WORD(AO_USB_OUT_SIZE),/* wMaxPacketSize */
127         0x00,                   /* bInterval */
128
129         /* Data EP in */
130         0x07,
131         AO_USB_DESC_ENDPOINT,
132         AO_USB_IN_EP|0x80,      /* bEndpointAddress */
133         0x02,                   /* bmAttributes = bulk */
134         LE_WORD(AO_USB_IN_SIZE),/* wMaxPacketSize */
135         0x00,                   /* bInterval */
136
137         /* String descriptors */
138         0x04,
139         AO_USB_DESC_STRING,
140         LE_WORD(0x0409),
141
142         /* iManufacturer */
143         AO_iManufacturer_LEN,
144         AO_USB_DESC_STRING,
145         AO_iManufacturer_UCS2,
146
147         /* iProduct */
148         AO_iProduct_LEN,
149         AO_USB_DESC_STRING,
150         AO_iProduct_UCS2,
151
152         /* iSerial */
153         AO_iSerial_LEN,
154         AO_USB_DESC_STRING,
155         AO_iSerial_UCS2,
156
157         /* Terminating zero */
158         0
159 };
160 #endif