2 * FreeRTOS Kernel V10.1.0
\r
3 * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
\r
5 * Permission is hereby granted, free of charge, to any person obtaining a copy of
\r
6 * this software and associated documentation files (the "Software"), to deal in
\r
7 * the Software without restriction, including without limitation the rights to
\r
8 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
\r
9 * the Software, and to permit persons to whom the Software is furnished to do so,
\r
10 * subject to the following conditions:
\r
12 * The above copyright notice and this permission notice shall be included in all
\r
13 * copies or substantial portions of the Software.
\r
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
\r
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
\r
17 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
\r
18 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
\r
19 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
\r
20 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\r
22 * http://www.FreeRTOS.org
\r
23 * http://aws.amazon.com/freertos
\r
25 * 1 tab == 4 spaces!
\r
28 /* Descriptor type definitions. */
\r
29 #define usbDESCRIPTOR_TYPE_DEVICE ( 0x01 )
\r
30 #define usbDESCRIPTOR_TYPE_CONFIGURATION ( 0x02 )
\r
31 #define usbDESCRIPTOR_TYPE_STRING ( 0x03 )
\r
33 /* USB request type definitions. */
\r
34 #define usbGET_REPORT_REQUEST ( 0x01 )
\r
35 #define usbGET_IDLE_REQUEST ( 0x02 )
\r
36 #define usbGET_PROTOCOL_REQUEST ( 0x03 )
\r
37 #define usbSET_REPORT_REQUEST ( 0x09 )
\r
38 #define usbSET_IDLE_REQUEST ( 0x0A )
\r
39 #define usbSET_PROTOCOL_REQUEST ( 0x0B )
\r
40 #define usbGET_CONFIGURATION_REQUEST ( 0x08 )
\r
41 #define usbGET_STATUS_REQUEST ( 0x00 )
\r
42 #define usbCLEAR_FEATURE_REQUEST ( 0x01 )
\r
43 #define usbSET_FEATURE_REQUEST ( 0x03 )
\r
44 #define usbSET_ADDRESS_REQUEST ( 0x05 )
\r
45 #define usbGET_DESCRIPTOR_REQUEST ( 0x06 )
\r
46 #define usbSET_CONFIGURATION_REQUEST ( 0x09 )
\r
47 #define usbGET_INTERFACE_REQUEST ( 0x0A )
\r
48 #define usbSET_INTERFACE_REQUEST ( 0x0B )
\r
51 #define usbSEND_ENCAPSULATED_COMMAND ( 0x00 )
\r
52 #define usbGET_ENCAPSULATED_RESPONSE ( 0x01 )
\r
53 #define usbSET_LINE_CODING ( 0x20 )
\r
54 #define usbGET_LINE_CODING ( 0x21 )
\r
55 #define usbSET_CONTROL_LINE_STATE ( 0x22 )
\r
57 /* Misc USB definitions. */
\r
58 #define usbDEVICE_CLASS_VENDOR_SPECIFIC ( 0xFF )
\r
59 #define usbBUS_POWERED ( 0x80 )
\r
60 #define usbHID_REPORT_DESCRIPTOR ( 0x22 )
\r
61 #define AT91C_UDP_TRANSCEIVER_ENABLE ( *( ( unsigned long * ) 0xfffb0074 ) )
\r
63 /* Index to the various string. */
\r
64 #define usbLANGUAGE_STRING ( 0 )
\r
65 #define usbMANUFACTURER_STRING ( 1 )
\r
66 #define usbPRODUCT_STRING ( 2 )
\r
67 #define usbCONFIGURATION_STRING ( 3 )
\r
68 #define usbINTERFACE_STRING ( 4 )
\r
70 /* Defines fields of standard SETUP request. Now in normal order. */
\r
71 #define usbREQUEST_TYPE_INDEX ( 0 )
\r
72 #define usbREQUEST_INDEX ( 1 )
\r
73 #define usbVALUE_HIGH_BYTE ( 3 )
\r
74 #define usbVALUE_LOW_BYTE ( 2 )
\r
75 #define usbINDEX_HIGH_BYTE ( 5 )
\r
76 #define usbINDEX_LOW_BYTE ( 4 )
\r
77 #define usbLENGTH_HIGH_BYTE ( 7 )
\r
78 #define usbLENGTH_LOW_BYTE ( 6 )
\r
80 /* Misc application definitions. */
\r
81 #define usbINTERRUPT_PRIORITY ( 3 )
\r
82 #define usbQUEUE_LENGTH ( 0x3 ) /* Must have all bits set! */
\r
83 #define usbFIFO_LENGTH ( ( unsigned long ) 8 )
\r
84 #define usbEND_POINT_0 ( 0 )
\r
85 #define usbEND_POINT_1 ( 1 )
\r
86 #define usbEND_POINT_2 ( 2 )
\r
87 #define usbEND_POINT_3 ( 3 )
\r
88 #define usbMAX_CONTROL_MESSAGE_SIZE ( 128 )
\r
89 #define usbRX_COUNT_MASK ( ( unsigned long ) 0x7ff )
\r
90 #define AT91C_UDP_STALLSENT AT91C_UDP_ISOERROR
\r
91 #define usbSHORTEST_DELAY ( ( TickType_t ) 1 )
\r
92 #define usbINIT_DELAY ( ( TickType_t ) 1000 / portTICK_PERIOD_MS )
\r
93 #define usbSHORT_DELAY ( ( TickType_t ) 50 / portTICK_PERIOD_MS )
\r
94 #define usbEND_POINT_RESET_MASK ( ( unsigned long ) 0x0f )
\r
95 #define usbDATA_INC ( ( char ) 5 )
\r
96 #define usbEXPECTED_NUMBER_OF_BYTES ( ( unsigned long ) 8 )
\r
98 /* Control request types. */
\r
99 #define usbSTANDARD_DEVICE_REQUEST ( 0 )
\r
100 #define usbSTANDARD_INTERFACE_REQUEST ( 1 )
\r
101 #define usbSTANDARD_END_POINT_REQUEST ( 2 )
\r
102 #define usbCLASS_INTERFACE_REQUEST ( 5 )
\r
105 /* Macros to manipulate the control and status registers. These registers
\r
106 cannot be accessed using a direct read modify write operation outside of the
\r
107 ISR as some bits are left unchanged by writing with a 0, and some are left
\r
108 unchanged by writing with a 1. */
\r
111 #define usbCSR_SET_BIT( pulValueNow, ulBit ) \
\r
113 /* Set TXCOMP, RX_DATA_BK0, RXSETUP, */ \
\r
114 /* STALLSENT and RX_DATA_BK1 to 1 so the */ \
\r
115 /* write has no effect. */ \
\r
116 ( * ( ( unsigned long * ) pulValueNow ) ) |= ( unsigned long ) 0x4f; \
\r
118 /* Clear the FORCE_STALL and TXPKTRDY bits */ \
\r
119 /* so the write has no effect. */ \
\r
120 ( * ( ( unsigned long * ) pulValueNow ) ) &= ( unsigned long ) 0xffffffcf; \
\r
122 /* Set whichever bit we want set. */ \
\r
123 ( * ( ( unsigned long * ) pulValueNow ) ) |= ( ulBit ); \
\r
126 #define usbCSR_CLEAR_BIT( pulValueNow, ulBit ) \
\r
128 /* Set TXCOMP, RX_DATA_BK0, RXSETUP, */ \
\r
129 /* STALLSENT and RX_DATA_BK1 to 1 so the */ \
\r
130 /* write has no effect. */ \
\r
131 ( * ( ( unsigned long * ) pulValueNow ) ) |= ( unsigned long ) 0x4f; \
\r
133 /* Clear the FORCE_STALL and TXPKTRDY bits */ \
\r
134 /* so the write has no effect. */ \
\r
135 ( * ( ( unsigned long * ) pulValueNow ) ) &= ( unsigned long ) 0xffffffcf; \
\r
137 /* Clear whichever bit we want clear. */ \
\r
138 ( * ( ( unsigned long * ) pulValueNow ) ) &= ( ~ulBit ); \
\r