1 |
583 |
jeremybenn |
/*
|
2 |
|
|
FreeRTOS V6.1.1 - Copyright (C) 2011 Real Time Engineers Ltd.
|
3 |
|
|
|
4 |
|
|
***************************************************************************
|
5 |
|
|
* *
|
6 |
|
|
* If you are: *
|
7 |
|
|
* *
|
8 |
|
|
* + New to FreeRTOS, *
|
9 |
|
|
* + Wanting to learn FreeRTOS or multitasking in general quickly *
|
10 |
|
|
* + Looking for basic training, *
|
11 |
|
|
* + Wanting to improve your FreeRTOS skills and productivity *
|
12 |
|
|
* *
|
13 |
|
|
* then take a look at the FreeRTOS books - available as PDF or paperback *
|
14 |
|
|
* *
|
15 |
|
|
* "Using the FreeRTOS Real Time Kernel - a Practical Guide" *
|
16 |
|
|
* http://www.FreeRTOS.org/Documentation *
|
17 |
|
|
* *
|
18 |
|
|
* A pdf reference manual is also available. Both are usually delivered *
|
19 |
|
|
* to your inbox within 20 minutes to two hours when purchased between 8am *
|
20 |
|
|
* and 8pm GMT (although please allow up to 24 hours in case of *
|
21 |
|
|
* exceptional circumstances). Thank you for your support! *
|
22 |
|
|
* *
|
23 |
|
|
***************************************************************************
|
24 |
|
|
|
25 |
|
|
This file is part of the FreeRTOS distribution.
|
26 |
|
|
|
27 |
|
|
FreeRTOS is free software; you can redistribute it and/or modify it under
|
28 |
|
|
the terms of the GNU General Public License (version 2) as published by the
|
29 |
|
|
Free Software Foundation AND MODIFIED BY the FreeRTOS exception.
|
30 |
|
|
***NOTE*** The exception to the GPL is included to allow you to distribute
|
31 |
|
|
a combined work that includes FreeRTOS without being obliged to provide the
|
32 |
|
|
source code for proprietary components outside of the FreeRTOS kernel.
|
33 |
|
|
FreeRTOS is distributed in the hope that it will be useful, but WITHOUT
|
34 |
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
35 |
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
36 |
|
|
more details. You should have received a copy of the GNU General Public
|
37 |
|
|
License and the FreeRTOS license exception along with FreeRTOS; if not it
|
38 |
|
|
can be viewed here: http://www.freertos.org/a00114.html and also obtained
|
39 |
|
|
by writing to Richard Barry, contact details for whom are available on the
|
40 |
|
|
FreeRTOS WEB site.
|
41 |
|
|
|
42 |
|
|
1 tab == 4 spaces!
|
43 |
|
|
|
44 |
|
|
http://www.FreeRTOS.org - Documentation, latest information, license and
|
45 |
|
|
contact details.
|
46 |
|
|
|
47 |
|
|
http://www.SafeRTOS.com - A version that is certified for use in safety
|
48 |
|
|
critical systems.
|
49 |
|
|
|
50 |
|
|
http://www.OpenRTOS.com - Commercial support, development, porting,
|
51 |
|
|
licensing and training services.
|
52 |
|
|
*/
|
53 |
|
|
|
54 |
|
|
/* Descriptor type definitions. */
|
55 |
|
|
#define usbDESCRIPTOR_TYPE_DEVICE ( 0x01 )
|
56 |
|
|
#define usbDESCRIPTOR_TYPE_CONFIGURATION ( 0x02 )
|
57 |
|
|
#define usbDESCRIPTOR_TYPE_STRING ( 0x03 )
|
58 |
|
|
|
59 |
|
|
/* USB request type definitions. */
|
60 |
|
|
#define usbGET_REPORT_REQUEST ( 0x01 )
|
61 |
|
|
#define usbGET_IDLE_REQUEST ( 0x02 )
|
62 |
|
|
#define usbGET_PROTOCOL_REQUEST ( 0x03 )
|
63 |
|
|
#define usbSET_REPORT_REQUEST ( 0x09 )
|
64 |
|
|
#define usbSET_IDLE_REQUEST ( 0x0A )
|
65 |
|
|
#define usbSET_PROTOCOL_REQUEST ( 0x0B )
|
66 |
|
|
#define usbGET_CONFIGURATION_REQUEST ( 0x08 )
|
67 |
|
|
#define usbGET_STATUS_REQUEST ( 0x00 )
|
68 |
|
|
#define usbCLEAR_FEATURE_REQUEST ( 0x01 )
|
69 |
|
|
#define usbSET_FEATURE_REQUEST ( 0x03 )
|
70 |
|
|
#define usbSET_ADDRESS_REQUEST ( 0x05 )
|
71 |
|
|
#define usbGET_DESCRIPTOR_REQUEST ( 0x06 )
|
72 |
|
|
#define usbSET_CONFIGURATION_REQUEST ( 0x09 )
|
73 |
|
|
#define usbGET_INTERFACE_REQUEST ( 0x0A )
|
74 |
|
|
#define usbSET_INTERFACE_REQUEST ( 0x0B )
|
75 |
|
|
|
76 |
|
|
/* ACM Requests */
|
77 |
|
|
#define usbSEND_ENCAPSULATED_COMMAND ( 0x00 )
|
78 |
|
|
#define usbGET_ENCAPSULATED_RESPONSE ( 0x01 )
|
79 |
|
|
#define usbSET_LINE_CODING ( 0x20 )
|
80 |
|
|
#define usbGET_LINE_CODING ( 0x21 )
|
81 |
|
|
#define usbSET_CONTROL_LINE_STATE ( 0x22 )
|
82 |
|
|
|
83 |
|
|
/* Misc USB definitions. */
|
84 |
|
|
#define usbDEVICE_CLASS_VENDOR_SPECIFIC ( 0xFF )
|
85 |
|
|
#define usbBUS_POWERED ( 0x80 )
|
86 |
|
|
#define usbHID_REPORT_DESCRIPTOR ( 0x22 )
|
87 |
|
|
#define AT91C_UDP_TRANSCEIVER_ENABLE ( *( ( unsigned long * ) 0xfffb0074 ) )
|
88 |
|
|
|
89 |
|
|
/* Index to the various string. */
|
90 |
|
|
#define usbLANGUAGE_STRING ( 0 )
|
91 |
|
|
#define usbMANUFACTURER_STRING ( 1 )
|
92 |
|
|
#define usbPRODUCT_STRING ( 2 )
|
93 |
|
|
#define usbCONFIGURATION_STRING ( 3 )
|
94 |
|
|
#define usbINTERFACE_STRING ( 4 )
|
95 |
|
|
|
96 |
|
|
/* Defines fields of standard SETUP request. Now in normal order. */
|
97 |
|
|
#define usbREQUEST_TYPE_INDEX ( 0 )
|
98 |
|
|
#define usbREQUEST_INDEX ( 1 )
|
99 |
|
|
#define usbVALUE_HIGH_BYTE ( 3 )
|
100 |
|
|
#define usbVALUE_LOW_BYTE ( 2 )
|
101 |
|
|
#define usbINDEX_HIGH_BYTE ( 5 )
|
102 |
|
|
#define usbINDEX_LOW_BYTE ( 4 )
|
103 |
|
|
#define usbLENGTH_HIGH_BYTE ( 7 )
|
104 |
|
|
#define usbLENGTH_LOW_BYTE ( 6 )
|
105 |
|
|
|
106 |
|
|
/* Misc application definitions. */
|
107 |
|
|
#define usbINTERRUPT_PRIORITY ( 3 )
|
108 |
|
|
#define usbQUEUE_LENGTH ( 0x3 ) /* Must have all bits set! */
|
109 |
|
|
#define usbFIFO_LENGTH ( ( unsigned long ) 8 )
|
110 |
|
|
#define usbEND_POINT_0 ( 0 )
|
111 |
|
|
#define usbEND_POINT_1 ( 1 )
|
112 |
|
|
#define usbEND_POINT_2 ( 2 )
|
113 |
|
|
#define usbEND_POINT_3 ( 3 )
|
114 |
|
|
#define usbMAX_CONTROL_MESSAGE_SIZE ( 128 )
|
115 |
|
|
#define usbRX_COUNT_MASK ( ( unsigned long ) 0x7ff )
|
116 |
|
|
#define AT91C_UDP_STALLSENT AT91C_UDP_ISOERROR
|
117 |
|
|
#define usbSHORTEST_DELAY ( ( portTickType ) 1 )
|
118 |
|
|
#define usbINIT_DELAY ( ( portTickType ) 1000 / portTICK_RATE_MS )
|
119 |
|
|
#define usbSHORT_DELAY ( ( portTickType ) 50 / portTICK_RATE_MS )
|
120 |
|
|
#define usbEND_POINT_RESET_MASK ( ( unsigned long ) 0x0f )
|
121 |
|
|
#define usbDATA_INC ( ( char ) 5 )
|
122 |
|
|
#define usbEXPECTED_NUMBER_OF_BYTES ( ( unsigned long ) 8 )
|
123 |
|
|
|
124 |
|
|
/* Control request types. */
|
125 |
|
|
#define usbSTANDARD_DEVICE_REQUEST ( 0 )
|
126 |
|
|
#define usbSTANDARD_INTERFACE_REQUEST ( 1 )
|
127 |
|
|
#define usbSTANDARD_END_POINT_REQUEST ( 2 )
|
128 |
|
|
#define usbCLASS_INTERFACE_REQUEST ( 5 )
|
129 |
|
|
|
130 |
|
|
|
131 |
|
|
/* Macros to manipulate the control and status registers. These registers
|
132 |
|
|
cannot be accessed using a direct read modify write operation outside of the
|
133 |
|
|
ISR as some bits are left unchanged by writing with a 0, and some are left
|
134 |
|
|
unchanged by writing with a 1. */
|
135 |
|
|
|
136 |
|
|
|
137 |
|
|
#define usbCSR_SET_BIT( pulValueNow, ulBit ) \
|
138 |
|
|
{ \
|
139 |
|
|
/* Set TXCOMP, RX_DATA_BK0, RXSETUP, */ \
|
140 |
|
|
/* STALLSENT and RX_DATA_BK1 to 1 so the */ \
|
141 |
|
|
/* write has no effect. */ \
|
142 |
|
|
( * ( ( unsigned long * ) pulValueNow ) ) |= ( unsigned long ) 0x4f; \
|
143 |
|
|
\
|
144 |
|
|
/* Clear the FORCE_STALL and TXPKTRDY bits */ \
|
145 |
|
|
/* so the write has no effect. */ \
|
146 |
|
|
( * ( ( unsigned long * ) pulValueNow ) ) &= ( unsigned long ) 0xffffffcf; \
|
147 |
|
|
\
|
148 |
|
|
/* Set whichever bit we want set. */ \
|
149 |
|
|
( * ( ( unsigned long * ) pulValueNow ) ) |= ( ulBit ); \
|
150 |
|
|
}
|
151 |
|
|
|
152 |
|
|
#define usbCSR_CLEAR_BIT( pulValueNow, ulBit ) \
|
153 |
|
|
{ \
|
154 |
|
|
/* Set TXCOMP, RX_DATA_BK0, RXSETUP, */ \
|
155 |
|
|
/* STALLSENT and RX_DATA_BK1 to 1 so the */ \
|
156 |
|
|
/* write has no effect. */ \
|
157 |
|
|
( * ( ( unsigned long * ) pulValueNow ) ) |= ( unsigned long ) 0x4f; \
|
158 |
|
|
\
|
159 |
|
|
/* Clear the FORCE_STALL and TXPKTRDY bits */ \
|
160 |
|
|
/* so the write has no effect. */ \
|
161 |
|
|
( * ( ( unsigned long * ) pulValueNow ) ) &= ( unsigned long ) 0xffffffcf; \
|
162 |
|
|
\
|
163 |
|
|
/* Clear whichever bit we want clear. */ \
|
164 |
|
|
( * ( ( unsigned long * ) pulValueNow ) ) &= ( ~ulBit ); \
|
165 |
|
|
}
|