]> git.friedersdorff.com Git - max/tmk_keyboard.git/blob - tmk_core/protocol/usb_hid/USB_Host_Shield_2.0/max3421e.h
lufa: usb-usb: Use LUFA startup instead of cusotom
[max/tmk_keyboard.git] / tmk_core / protocol / usb_hid / USB_Host_Shield_2.0 / max3421e.h
1 /* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved.
2
3 This software may be distributed and modified under the terms of the GNU
4 General Public License version 2 (GPL2) as published by the Free Software
5 Foundation and appearing in the file GPL2.TXT included in the packaging of
6 this file. Please note that GPL2 Section 2[b] requires that all works based
7 on this software must also be made publicly available under the terms of
8 the GPL2 ("Copyleft").
9
10 Contact information
11 -------------------
12
13 Circuits At Home, LTD
14 Web      :  http://www.circuitsathome.com
15 e-mail   :  support@circuitsathome.com
16  */
17 #if !defined(_usb_h_) || defined(_max3421e_h_)
18 #error "Never include max3421e.h directly; include Usb.h instead"
19 #else
20
21 #define _max3421e_h_
22
23 /* MAX3421E register/bit names and bitmasks */
24
25 /* Arduino pin definitions */
26 /* pin numbers to port numbers */
27
28 #define SE0     0
29 #define SE1     1
30 #define FSHOST  2
31 #define LSHOST  3
32
33 /* MAX3421E command byte format: rrrrr0wa where 'r' is register number  */
34 //
35 // MAX3421E Registers in HOST mode.
36 //
37 #define rRCVFIFO    0x08    //1<<3
38 #define rSNDFIFO    0x10    //2<<3
39 #define rSUDFIFO    0x20    //4<<3
40 #define rRCVBC      0x30    //6<<3
41 #define rSNDBC      0x38    //7<<3
42
43 #define rUSBIRQ     0x68    //13<<3
44 /* USBIRQ Bits  */
45 #define bmVBUSIRQ   0x40    //b6
46 #define bmNOVBUSIRQ 0x20    //b5
47 #define bmOSCOKIRQ  0x01    //b0
48
49 #define rUSBIEN     0x70    //14<<3
50 /* USBIEN Bits  */
51 #define bmVBUSIE    0x40    //b6
52 #define bmNOVBUSIE  0x20    //b5
53 #define bmOSCOKIE   0x01    //b0
54
55 #define rUSBCTL     0x78    //15<<3
56 /* USBCTL Bits  */
57 #define bmCHIPRES   0x20    //b5
58 #define bmPWRDOWN   0x10    //b4
59
60 #define rCPUCTL     0x80    //16<<3
61 /* CPUCTL Bits  */
62 #define bmPUSLEWID1 0x80    //b7
63 #define bmPULSEWID0 0x40    //b6
64 #define bmIE        0x01    //b0
65
66 #define rPINCTL     0x88    //17<<3
67 /* PINCTL Bits  */
68 #define bmFDUPSPI   0x10    //b4
69 #define bmINTLEVEL  0x08    //b3
70 #define bmPOSINT    0x04    //b2
71 #define bmGPXB      0x02    //b1
72 #define bmGPXA      0x01    //b0
73 // GPX pin selections
74 #define GPX_OPERATE 0x00
75 #define GPX_VBDET   0x01
76 #define GPX_BUSACT  0x02
77 #define GPX_SOF     0x03
78
79 #define rREVISION   0x90    //18<<3
80
81 #define rIOPINS1    0xa0    //20<<3
82
83 /* IOPINS1 Bits */
84 #define bmGPOUT0    0x01
85 #define bmGPOUT1    0x02
86 #define bmGPOUT2    0x04
87 #define bmGPOUT3    0x08
88 #define bmGPIN0     0x10
89 #define bmGPIN1     0x20
90 #define bmGPIN2     0x40
91 #define bmGPIN3     0x80
92
93 #define rIOPINS2    0xa8    //21<<3
94 /* IOPINS2 Bits */
95 #define bmGPOUT4    0x01
96 #define bmGPOUT5    0x02
97 #define bmGPOUT6    0x04
98 #define bmGPOUT7    0x08
99 #define bmGPIN4     0x10
100 #define bmGPIN5     0x20
101 #define bmGPIN6     0x40
102 #define bmGPIN7     0x80
103
104 #define rGPINIRQ    0xb0    //22<<3
105 /* GPINIRQ Bits */
106 #define bmGPINIRQ0 0x01
107 #define bmGPINIRQ1 0x02
108 #define bmGPINIRQ2 0x04
109 #define bmGPINIRQ3 0x08
110 #define bmGPINIRQ4 0x10
111 #define bmGPINIRQ5 0x20
112 #define bmGPINIRQ6 0x40
113 #define bmGPINIRQ7 0x80
114
115 #define rGPINIEN    0xb8    //23<<3
116 /* GPINIEN Bits */
117 #define bmGPINIEN0 0x01
118 #define bmGPINIEN1 0x02
119 #define bmGPINIEN2 0x04
120 #define bmGPINIEN3 0x08
121 #define bmGPINIEN4 0x10
122 #define bmGPINIEN5 0x20
123 #define bmGPINIEN6 0x40
124 #define bmGPINIEN7 0x80
125
126 #define rGPINPOL    0xc0    //24<<3
127 /* GPINPOL Bits */
128 #define bmGPINPOL0 0x01
129 #define bmGPINPOL1 0x02
130 #define bmGPINPOL2 0x04
131 #define bmGPINPOL3 0x08
132 #define bmGPINPOL4 0x10
133 #define bmGPINPOL5 0x20
134 #define bmGPINPOL6 0x40
135 #define bmGPINPOL7 0x80
136
137 #define rHIRQ       0xc8    //25<<3
138 /* HIRQ Bits */
139 #define bmBUSEVENTIRQ   0x01   // indicates BUS Reset Done or BUS Resume
140 #define bmRWUIRQ        0x02
141 #define bmRCVDAVIRQ     0x04
142 #define bmSNDBAVIRQ     0x08
143 #define bmSUSDNIRQ      0x10
144 #define bmCONDETIRQ     0x20
145 #define bmFRAMEIRQ      0x40
146 #define bmHXFRDNIRQ     0x80
147
148 #define rHIEN           0xd0    //26<<3
149
150 /* HIEN Bits */
151 #define bmBUSEVENTIE    0x01
152 #define bmRWUIE         0x02
153 #define bmRCVDAVIE      0x04
154 #define bmSNDBAVIE      0x08
155 #define bmSUSDNIE       0x10
156 #define bmCONDETIE      0x20
157 #define bmFRAMEIE       0x40
158 #define bmHXFRDNIE      0x80
159
160 #define rMODE           0xd8    //27<<3
161
162 /* MODE Bits */
163 #define bmHOST          0x01
164 #define bmLOWSPEED      0x02
165 #define bmHUBPRE        0x04
166 #define bmSOFKAENAB     0x08
167 #define bmSEPIRQ        0x10
168 #define bmDELAYISO      0x20
169 #define bmDMPULLDN      0x40
170 #define bmDPPULLDN      0x80
171
172 #define rPERADDR    0xe0    //28<<3
173
174 #define rHCTL       0xe8    //29<<3
175 /* HCTL Bits */
176 #define bmBUSRST        0x01
177 #define bmFRMRST        0x02
178 #define bmSAMPLEBUS     0x04
179 #define bmSIGRSM        0x08
180 #define bmRCVTOG0       0x10
181 #define bmRCVTOG1       0x20
182 #define bmSNDTOG0       0x40
183 #define bmSNDTOG1       0x80
184
185 #define rHXFR       0xf0    //30<<3
186 /* Host transfer token values for writing the HXFR register (R30)   */
187 /* OR this bit field with the endpoint number in bits 3:0               */
188 #define tokSETUP  0x10  // HS=0, ISO=0, OUTNIN=0, SETUP=1
189 #define tokIN     0x00  // HS=0, ISO=0, OUTNIN=0, SETUP=0
190 #define tokOUT    0x20  // HS=0, ISO=0, OUTNIN=1, SETUP=0
191 #define tokINHS   0x80  // HS=1, ISO=0, OUTNIN=0, SETUP=0
192 #define tokOUTHS  0xA0  // HS=1, ISO=0, OUTNIN=1, SETUP=0
193 #define tokISOIN  0x40  // HS=0, ISO=1, OUTNIN=0, SETUP=0
194 #define tokISOOUT 0x60  // HS=0, ISO=1, OUTNIN=1, SETUP=0
195
196 #define rHRSL       0xf8    //31<<3
197
198 /* HRSL Bits */
199 #define bmRCVTOGRD  0x10
200 #define bmSNDTOGRD  0x20
201 #define bmKSTATUS   0x40
202 #define bmJSTATUS   0x80
203 #define bmSE0       0x00    //SE0 - disconnect state
204 #define bmSE1       0xc0    //SE1 - illegal state
205
206 /* Host error result codes, the 4 LSB's in the HRSL register */
207 #define hrSUCCESS   0x00
208 #define hrBUSY      0x01
209 #define hrBADREQ    0x02
210 #define hrUNDEF     0x03
211 #define hrNAK       0x04
212 #define hrSTALL     0x05
213 #define hrTOGERR    0x06
214 #define hrWRONGPID  0x07
215 #define hrBADBC     0x08
216 #define hrPIDERR    0x09
217 #define hrPKTERR    0x0A
218 #define hrCRCERR    0x0B
219 #define hrKERR      0x0C
220 #define hrJERR      0x0D
221 #define hrTIMEOUT   0x0E
222 #define hrBABBLE    0x0F
223
224 #define MODE_FS_HOST    (bmDPPULLDN|bmDMPULLDN|bmHOST|bmSOFKAENAB)
225 #define MODE_LS_HOST    (bmDPPULLDN|bmDMPULLDN|bmHOST|bmLOWSPEED|bmSOFKAENAB)
226
227
228 #endif //_max3421e_h_