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