Max3421e_constants.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2009-2011 Oleg Mazurov, Circuits At Home, http://www.circuitsathome.com
00003  * MAX3421E USB host controller support
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions
00007  * are met:
00008  * 1. Redistributions of source code must retain the above copyright
00009  *    notice, this list of conditions and the following disclaimer.
00010  * 2. Redistributions in binary form must reproduce the above copyright
00011  *    notice, this list of conditions and the following disclaimer in the
00012  *    documentation and/or other materials provided with the distribution.
00013  * 3. Neither the name of the authors nor the names of its contributors
00014  *    may be used to endorse or promote products derived from this software
00015  *    without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
00018  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00019  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00020  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
00021  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00022  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00023  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00024  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00025  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00026  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00027  * SUCH DAMAGE.
00028  */
00029 
00030 /* MAX3421E register/bit names and bitmasks */
00031 
00032 #ifndef _MAX3421Econstants_h_
00033 #define _MAX3421Econstants_h_
00034 
00035 /* SPI pins for diffrent Arduinos */
00036 
00037 #if defined(__AVR_ATmega1280__) || (__AVR_ATmega2560__)
00038   #define SCK_PIN   52
00039   #define MISO_PIN  50
00040   #define MOSI_PIN  51
00041   #define SS_PIN    53
00042 #endif
00043 #if  defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__)
00044   #define SCK_PIN   13
00045   #define MISO_PIN  12
00046   #define MOSI_PIN  11
00047   #define SS_PIN    10
00048 #endif
00049 
00050 #define MAX_SS    53
00051 #define MAX_INT   9
00052 #define MAX_GPX   8
00053 #define MAX_RESET 7
00054 
00055 /* "Breakpoint" pins for debugging */
00056 //#define BPNT_0      3
00057 //#define BPNT_1      2
00058      
00059 //#define Select_MAX3421E     digitalWrite(MAX_SS,LOW)
00060 //#define Deselect_MAX3421E   digitalWrite(MAX_SS,HIGH)
00061 
00062 /* */
00063 
00064 #define ON  true
00065 #define OFF false
00066 
00067 /* VBUS states */
00068 #define SE0     0
00069 #define SE1     1
00070 #define FSHOST  2
00071 #define LSHOST  3
00072 
00073 /* MAX3421E command byte format: rrrrr0wa where 'r' is register number  */
00074 //
00075 // MAX3421E Registers in HOST mode. 
00076 //
00077 #define rRCVFIFO    0x08    //1<<3
00078 #define rSNDFIFO    0x10    //2<<3
00079 #define rSUDFIFO    0x20    //4<<3
00080 #define rRCVBC      0x30    //6<<3
00081 #define rSNDBC      0x38    //7<<3
00082 
00083 #define rUSBIRQ     0x68    //13<<3
00084 /* USBIRQ Bits  */
00085 #define bmVBUSIRQ   0x40    //b6
00086 #define bmNOVBUSIRQ 0x20    //b5
00087 #define bmOSCOKIRQ  0x01    //b0
00088 
00089 #define rUSBIEN     0x70    //14<<3
00090 /* USBIEN Bits  */
00091 #define bmVBUSIE    0x40    //b6
00092 #define bmNOVBUSIE  0x20    //b5
00093 #define bmOSCOKIE   0x01    //b0
00094 
00095 #define rUSBCTL     0x78    //15<<3
00096 /* USBCTL Bits  */
00097 #define bmCHIPRES   0x20    //b5
00098 #define bmPWRDOWN   0x10    //b4
00099 
00100 #define rCPUCTL     0x80    //16<<3
00101 /* CPUCTL Bits  */
00102 #define bmPUSLEWID1 0x80    //b7
00103 #define bmPULSEWID0 0x40    //b6
00104 #define bmIE        0x01    //b0
00105 
00106 #define rPINCTL     0x88    //17<<3
00107 /* PINCTL Bits  */
00108 #define bmFDUPSPI   0x10    //b4
00109 #define bmINTLEVEL  0x08    //b3
00110 #define bmPOSINT    0x04    //b2
00111 #define bmGPXB      0x02    //b1
00112 #define bmGPXA      0x01    //b0
00113 // GPX pin selections
00114 #define GPX_OPERATE 0x00
00115 #define GPX_VBDET   0x01
00116 #define GPX_BUSACT  0x02
00117 #define GPX_SOF     0x03
00118 
00119 #define rREVISION   0x90    //18<<3
00120 
00121 #define rIOPINS1    0xa0    //20<<3
00122 
00123 /* IOPINS1 Bits */
00124 #define bmGPOUT0    0x01
00125 #define bmGPOUT1    0x02
00126 #define bmGPOUT2    0x04
00127 #define bmGPOUT3    0x08
00128 #define bmGPIN0     0x10
00129 #define bmGPIN1     0x20
00130 #define bmGPIN2     0x40
00131 #define bmGPIN3     0x80
00132 
00133 #define rIOPINS2    0xa8    //21<<3
00134 /* IOPINS2 Bits */
00135 #define bmGPOUT4    0x01
00136 #define bmGPOUT5    0x02
00137 #define bmGPOUT6    0x04
00138 #define bmGPOUT7    0x08
00139 #define bmGPIN4     0x10
00140 #define bmGPIN5     0x20
00141 #define bmGPIN6     0x40
00142 #define bmGPIN7     0x80
00143 
00144 #define rGPINIRQ    0xb0    //22<<3
00145 /* GPINIRQ Bits */
00146 #define bmGPINIRQ0 0x01
00147 #define bmGPINIRQ1 0x02
00148 #define bmGPINIRQ2 0x04
00149 #define bmGPINIRQ3 0x08
00150 #define bmGPINIRQ4 0x10
00151 #define bmGPINIRQ5 0x20
00152 #define bmGPINIRQ6 0x40
00153 #define bmGPINIRQ7 0x80
00154 
00155 #define rGPINIEN    0xb8    //23<<3
00156 /* GPINIEN Bits */
00157 #define bmGPINIEN0 0x01
00158 #define bmGPINIEN1 0x02
00159 #define bmGPINIEN2 0x04
00160 #define bmGPINIEN3 0x08
00161 #define bmGPINIEN4 0x10
00162 #define bmGPINIEN5 0x20
00163 #define bmGPINIEN6 0x40
00164 #define bmGPINIEN7 0x80
00165 
00166 #define rGPINPOL    0xc0    //24<<3
00167 /* GPINPOL Bits */
00168 #define bmGPINPOL0 0x01
00169 #define bmGPINPOL1 0x02
00170 #define bmGPINPOL2 0x04
00171 #define bmGPINPOL3 0x08
00172 #define bmGPINPOL4 0x10
00173 #define bmGPINPOL5 0x20
00174 #define bmGPINPOL6 0x40
00175 #define bmGPINPOL7 0x80
00176 
00177 #define rHIRQ       0xc8    //25<<3
00178 /* HIRQ Bits */
00179 #define bmBUSEVENTIRQ   0x01   // indicates BUS Reset Done or BUS Resume     
00180 #define bmRWUIRQ        0x02
00181 #define bmRCVDAVIRQ     0x04
00182 #define bmSNDBAVIRQ     0x08
00183 #define bmSUSDNIRQ      0x10
00184 #define bmCONDETIRQ     0x20
00185 #define bmFRAMEIRQ      0x40
00186 #define bmHXFRDNIRQ     0x80
00187 
00188 #define rHIEN       0xd0    //26<<3
00189 /* HIEN Bits */
00190 #define bmBUSEVENTIE    0x01
00191 #define bmRWUIE         0x02
00192 #define bmRCVDAVIE      0x04
00193 #define bmSNDBAVIE      0x08
00194 #define bmSUSDNIE       0x10
00195 #define bmCONDETIE      0x20
00196 #define bmFRAMEIE       0x40
00197 #define bmHXFRDNIE      0x80
00198 
00199 #define rMODE       0xd8    //27<<3
00200 /* MODE Bits */
00201 #define bmHOST          0x01
00202 #define bmLOWSPEED      0x02
00203 #define bmHUBPRE        0x04
00204 #define bmSOFKAENAB     0x08
00205 #define bmSEPIRQ        0x10
00206 #define bmDELAYISO      0x20
00207 #define bmDMPULLDN      0x40
00208 #define bmDPPULLDN      0x80
00209 
00210 #define rPERADDR    0xe0    //28<<3
00211 
00212 #define rHCTL       0xe8    //29<<3
00213 /* HCTL Bits */
00214 #define bmBUSRST        0x01
00215 #define bmFRMRST        0x02
00216 #define bmSAMPLEBUS     0x04
00217 #define bmSIGRSM        0x08
00218 #define bmRCVTOG0       0x10
00219 #define bmRCVTOG1       0x20
00220 #define bmSNDTOG0       0x40
00221 #define bmSNDTOG1       0x80
00222 
00223 #define rHXFR       0xf0    //30<<3
00224 /* Host transfer token values for writing the HXFR register (R30)   */
00225 /* OR this bit field with the endpoint number in bits 3:0               */
00226 #define tokSETUP  0x10  // HS=0, ISO=0, OUTNIN=0, SETUP=1
00227 #define tokIN     0x00  // HS=0, ISO=0, OUTNIN=0, SETUP=0
00228 #define tokOUT    0x20  // HS=0, ISO=0, OUTNIN=1, SETUP=0
00229 #define tokINHS   0x80  // HS=1, ISO=0, OUTNIN=0, SETUP=0
00230 #define tokOUTHS  0xA0  // HS=1, ISO=0, OUTNIN=1, SETUP=0 
00231 #define tokISOIN  0x40  // HS=0, ISO=1, OUTNIN=0, SETUP=0
00232 #define tokISOOUT 0x60  // HS=0, ISO=1, OUTNIN=1, SETUP=0
00233 
00234 #define rHRSL       0xf8    //31<<3
00235 /* HRSL Bits */
00236 #define bmRCVTOGRD  0x10
00237 #define bmSNDTOGRD  0x20
00238 #define bmKSTATUS   0x40
00239 #define bmJSTATUS   0x80
00240 #define bmSE0       0x00    //SE0 - disconnect state
00241 #define bmSE1       0xc0    //SE1 - illegal state       
00242 /* Host error result codes, the 4 LSB's in the HRSL register */
00243 #define hrSUCCESS   0x00
00244 #define hrBUSY      0x01
00245 #define hrBADREQ    0x02
00246 #define hrUNDEF     0x03
00247 #define hrNAK       0x04
00248 #define hrSTALL     0x05
00249 #define hrTOGERR    0x06
00250 #define hrWRONGPID  0x07
00251 #define hrBADBC     0x08
00252 #define hrPIDERR    0x09
00253 #define hrPKTERR    0x0A
00254 #define hrCRCERR    0x0B
00255 #define hrKERR      0x0C
00256 #define hrJERR      0x0D
00257 #define hrTIMEOUT   0x0E
00258 #define hrBABBLE    0x0F
00259 
00260 #define MODE_FS_HOST    (bmDPPULLDN|bmDMPULLDN|bmHOST|bmSOFKAENAB)
00261 #define MODE_LS_HOST    (bmDPPULLDN|bmDMPULLDN|bmHOST|bmLOWSPEED|bmSOFKAENAB)
00262 
00263 
00264 #endif //_MAX3421Econstants_h_


rosserial_adk_demo
Author(s): Adam Stambler
autogenerated on Mon Dec 2 2013 12:02:02