00001
00039 #ifndef CHIP_REGS_H_INCLUDED
00040 #define CHIP_REGS_H_INCLUDED
00041
00042 #include <arch/io.h>
00043
00044
00045 #define AVR_REG_PINA 0x20
00046 #define AVR_REG_DDRA 0x21
00047 #define AVR_REG_PORTA 0x22
00048 #define AVR_REG_PINB 0x23
00049 #define AVR_REG_DDRB 0x24
00050 #define AVR_REG_PORTB 0x25
00051 #define AVR_REG_PINC 0x26
00052 #define AVR_REG_DDRC 0x27
00053 #define AVR_REG_PORTC 0x28
00054 #define AVR_REG_PIND 0x29
00055 #define AVR_REG_DDRD 0x2A
00056 #define AVR_REG_PORTD 0x2B
00057 #define AVR_REG_PINE 0x2C
00058 #define AVR_REG_DDRE 0x2D
00059 #define AVR_REG_PORTE 0x2E
00060 #define AVR_REG_PINF 0x2F
00061 #define AVR_REG_DDRF 0x30
00062 #define AVR_REG_PORTF 0x31
00063
00064 #define AVR_REG_TIFR0 0x35
00065 #define AVR_REG_TIFR1 0x36
00066 #define AVR_REG_TIFR2 0x37
00067 #define AVR_REG_TIFR3 0x38
00068
00069 #define AVR_REG_PCIFR 0x3B
00070 #define AVR_REG_EIFR 0x3C
00071 #define AVR_REG_EIMSK 0x3D
00072
00073 #define AVR_REG_GPIOR0 0x3E
00074
00075 #define AVR_REG_EECR 0x3F
00076 #define AVR_REG_EEDR 0x40
00077 #define AVR_REG_EEARL 0x41
00078 #define AVR_REG_EEARH 0x42
00079
00080 #define AVR_REG_GTCCR 0x43
00081
00082 #define AVR_REG_TCCR0A 0x44
00083 #define AVR_REG_TCCR0B 0x45
00084 #define AVR_REG_TCNT0 0x46
00085 #define AVR_REG_OCR0A 0x47
00086 #define AVR_REG_OCR0B 0x48
00087
00088 #define AVR_REG_PLLCSR 0x49
00089
00090 #define AVR_REG_GPIOR1 0x4A
00091 #define AVR_REG_GPIOR2 0x4B
00092
00093 #define AVR_REG_SPCR 0x4C
00094 # define AVR_BF_SPCR_SPR_OFFSET 0
00095 # define AVR_BF_SPCR_SPR_SIZE 2
00096 # define AVR_BF_SPCR_CPHA_OFFSET 2
00097 # define AVR_BF_SPCR_CPOL_OFFSET 3
00098 # define AVR_BF_SPCR_MODE_OFFSET 2 //!< Mode covering CPHA and CPOL
00099 # define AVR_BF_SPCR_MODE_SIZE 2
00100 # define AVR_BF_SPCR_MSTR_OFFSET 4
00101 # define AVR_BF_SPCR_DORD_OFFSET 5
00102 # define AVR_BF_SPCR_SPE_OFFSET 6
00103 # define AVR_BF_SPCR_SPIE_OFFSET 7
00104 #define AVR_REG_SPSR 0x4D
00105 # define AVR_BF_SPSR_SPI2X_OFFSET 0
00106 # define AVR_BF_SPSR_WCOL_OFFSET 6
00107 # define AVR_BF_SPSR_SPIF_OFFSET 7
00108 #define AVR_REG_SPDR 0x4E
00109
00110 #define AVR_REG_ACSR 0x50
00111
00112 #define AVR_REG_OCDR 0x51
00113 #define AVR_REG_MONDR 0x51
00114
00115 #define AVR_REG_SMCR 0x53
00116
00117 #define AVR_REG_MCUSR 0x54 //!< MCU reset cause register
00118 # define AVR_BF_MCUSR_PORF_OFFSET 0 //!< Power-on reset flag
00119 # define AVR_BF_MCUSR_EXTRF_OFFSET 1 //!< External reset flag
00120 # define AVR_BF_MCUSR_BORF_OFFSET 2 //!< Brown-out reset flag
00121 # define AVR_BF_MCUSR_WDRF_OFFSET 3 //!< Watchdog reset flag
00122 # define AVR_BF_MCUSR_JTRF_OFFSET 4 //!< JTAG reset flag
00123 #define AVR_REG_MCUCR 0x55 //!< MCU control register
00124 # define AVR_BF_MCUCR_IVCE_OFFSET 0 //!< Interrupt vector change enable
00125 # define AVR_BF_MCUCR_IVSL_OFFSET 1 //!< Interrupt vector select
00126 # define AVR_BF_MCUCR_PUD_OFFSET 4 //!< Pull-up disable on all I/O pins
00127 # define AVR_BF_MCUCR_JTD_OFFSET 7 //!< JTAG interface disable
00128
00129 #define AVR_REG_SPMCSR 0x57
00130 #define AVR_REG_RAMPZ 0x5B
00131 #define AVR_REG_SPL 0x5D
00132 #define AVR_REG_SPH 0x5E
00133 #define AVR_REG_SREG 0x5F
00134
00135 #define AVR_REG_WDTCSR 0x60
00136
00137 #define AVR_REG_CLKPR 0x61
00138 #define AVR_REG_PRR0 0x64
00139 #define AVR_REG_PRR1 0x65
00140 #define AVR_REG_OSCCAL 0x66
00141 #define AVR_REG_PCICR 0x68
00142 #define AVR_REG_EICRA 0X69
00143 #define AVR_REG_EICRB 0x6A
00144
00145 #define AVR_REG_PCMSK0 0x6B
00146 #define AVR_REG_TIMSK0 0x6E
00147 #define AVR_REG_TIMSK1 0x6F
00148 #define AVR_REG_TIMSK2 0x70
00149 #define AVR_REG_TIMSK3 0x71
00150
00151 #define AVR_REG_XMCRA 0x74
00152 #define AVR_REG_XMCRB 0x75
00153
00154 #define AVR_REG_ADCL 0x78
00155 #define AVR_REG_ADCH 0x79
00156 #define AVR_REG_ADCSRA 0x7A
00157 #define AVR_REG_ADCSRB 0x7B
00158 #define AVR_REG_ADMUX 0x7C
00159
00160 #define AVR_REG_DIDR0 0x7E
00161 #define AVR_REG_DIDR1 0x7F
00162
00163 #define AVR_REG_TCCR1A 0x80
00164 #define AVR_REG_TCCR1B 0x81
00165 #define AVR_REG_TCCR1C 0x82
00166 #define AVR_REG_TCNT1L 0x84
00167 #define AVR_REG_TCNT1H 0x85
00168 #define AVR_REG_ICR1L 0x86
00169 #define AVR_REG_ICR1H 0x87
00170 #define AVR_REG_OCR1AL 0x88
00171 #define AVR_REG_OCR1AH 0x89
00172 #define AVR_REG_OCR1BL 0x8A
00173 #define AVR_REG_OCR1BH 0x8B
00174 #define AVR_REG_OCR1CL 0x8C
00175 #define AVR_REG_OCR1CH 0x8D
00176
00177 #define AVR_REG_TCCR3A 0x90
00178 #define AVR_REG_TCCR3B 0x91
00179 #define AVR_REG_TCCR3C 0x92
00180 #define AVR_REG_TCNT3L 0x94
00181 #define AVR_REG_TCNT3H 0x95
00182 #define AVR_REG_ICR3L 0x96
00183 #define AVR_REG_ICR3H 0x97
00184 #define AVR_REG_OCR3AL 0x98
00185 #define AVR_REG_OCR3AH 0x99
00186 #define AVR_REG_OCR3BL 0x9A
00187 #define AVR_REG_OCR3BH 0x9B
00188 #define AVR_REG_OCR3CL 0x9C
00189 #define AVR_REG_OCR3CH 0x9D
00190
00191 #define AVR_REG_UHCON 0x9E
00192 #define AVR_REG_UHINT 0x9F
00193 #define AVR_REG_UHIEN 0xA0
00194 #define AVR_REG_UHADDR 0xA1
00195 #define AVR_REG_UHFNUML 0xA2
00196 #define AVR_REG_UHFNUMH 0xA3
00197 #define AVR_REG_UHFLEN 0xA4
00198 #define AVR_REG_UPINRQX 0xA5
00199 #define AVR_REG_UPINTX 0xA6
00200 #define AVR_REG_UPNUM 0xA7
00201 #define AVR_REG_UPRST 0xA8
00202 #define AVR_REG_UPCONX 0xA9
00203 #define AVR_REG_UPCFG0X 0xAA
00204 #define AVR_REG_UPCFG1X 0xAB
00205 #define AVR_REG_UPSTAX 0xAC
00206 #define AVR_REG_UPCFG2X 0xAD
00207 #define AVR_REG_UPIENX 0xAE
00208 #define AVR_REG_UPDATX 0xAF
00209
00210 #define AVR_REG_TCCR2A 0xB0
00211 #define AVR_REG_TCCR2B 0xB1
00212 #define AVR_REG_TCNT2 0xB2
00213 #define AVR_REG_OCR2A 0xB3
00214 #define AVR_REG_OCR2B 0xB4
00215
00216 #define AVR_REG_ASSR 0xB6
00217
00218 #define AVR_REG_TWBR 0xB8
00219 #define AVR_REG_TWSR 0xB9
00220 #define AVR_REG_TWAR 0xBA
00221 #define AVR_REG_TWDR 0xBB
00222 #define AVR_REG_TWCR 0xBC
00223 #define AVR_REG_TWAMR 0xBD
00224
00225 #define AVR_REG_UCSR1A 0xC8
00226 #define AVR_REG_UCSR1B 0xC9
00227 #define AVR_REG_UCSR1C 0xCA
00228 #define AVR_REG_UBRR1L 0xCC
00229 #define AVR_REG_UBRR1H 0xCD
00230 #define AVR_REG_UDR1 0xCE
00231
00232
00233 #define AVR_REG_UCSR0A AVR_REG_UCSR1A
00234 #define AVR_REG_UCSR0B AVR_REG_UCSR1B
00235 #define AVR_REG_UCSR0C AVR_REG_UCSR1C
00236 #define AVR_REG_UBRR0L AVR_REG_UBRR1L
00237 #define AVR_REG_UBRR0H AVR_REG_UBRR1H
00238 #define AVR_REG_UDR0 AVR_REG_UDR1
00239
00240 #define AVR_REG_UHWCON 0xD7
00241 #define AVR_REG_USBCON 0xD8
00242 #define AVR_REG_USBSTA 0xD9
00243 #define AVR_REG_USBINT 0xDA
00244 #define AVR_REG_OTGCON 0xDD
00245 #define AVR_REG_OTGIEN 0xDE
00246 #define AVR_REG_OTGINT 0xDF
00247 #define AVR_REG_UDCON 0xE0
00248 #define AVR_REG_UDINT 0xE1
00249 #define AVR_REG_UDIEN 0xE2
00250 #define AVR_REG_UDADDR 0xE3
00251 #define AVR_REG_UDFNUML 0xE4
00252 #define AVR_REG_UDFNUMH 0xE5
00253 #define AVR_REG_UDMFN 0xE6
00254 #define AVR_REG_UEINTX 0xE8
00255 #define AVR_REG_UENUM 0xE9
00256 #define AVR_REG_UERST 0xEA
00257 #define AVR_REG_UECONX 0xEB
00258 #define AVR_REG_UECFG0X 0xEC
00259 #define AVR_REG_UECFG1X 0xED
00260 #define AVR_REG_UESTA0X 0xEE
00261 #define AVR_REG_UESTA1X 0xEF
00262 #define AVR_REG_UEIENX 0xF0
00263 #define AVR_REG_UEDATX 0xF1
00264 #define AVR_REG_UEBCLX 0xF2
00265 #define AVR_REG_UEBCHX 0xF3
00266 #define AVR_REG_UEINT 0xF4
00267 #define AVR_REG_UPERRX 0xF5
00268 #define AVR_REG_UPBCLX 0xF6
00269 #define AVR_REG_UPBCHX 0xF7
00270 #define AVR_REG_UPINT 0xF8
00271 #define AVR_REG_OTGTCON 0xF9
00272
00273
00274 #define AVR_BF_PLLCSR_PLOCK_SIZE 1
00275 #define AVR_BF_PLLCSR_PLOCK_OFFSET 0
00276 #define AVR_BF_PLLCSR_PLLE_SIZE 1
00277 #define AVR_BF_PLLCSR_PLLE_OFFSET 1
00278 #define AVR_BF_PLLCSR_PLLP0_SIZE 1
00279 #define AVR_BF_PLLCSR_PLLP0_OFFSET 2
00280 #define AVR_BF_PLLCSR_PLLP1_SIZE 1
00281 #define AVR_BF_PLLCSR_PLLP1_OFFSET 3
00282 #define AVR_BF_PLLCSR_PLLP2_SIZE 1
00283 #define AVR_BF_PLLCSR_PLLP2_OFFSET 4
00284
00285
00286 #define AVR_BF_MPCM_SIZE 1
00287 #define AVR_BF_MPCM_OFFSET 0
00288 #define AVR_BF_U2X_SIZE 1
00289 #define AVR_BF_U2X_OFFSET 1
00290 #define AVR_BF_UPE_SIZE 1
00291 #define AVR_BF_UPE_OFFSET 2
00292 #define AVR_BF_DOR_SIZE 1
00293 #define AVR_BF_DOR_OFFSET 3
00294 #define AVR_BF_FE_SIZE 1
00295 #define AVR_BF_FE_OFFSET 4
00296 #define AVR_BF_UDRE_SIZE 1
00297 #define AVR_BF_UDRE_OFFSET 5
00298 #define AVR_BF_TXC_SIZE 1
00299 #define AVR_BF_TXC_OFFSET 6
00300 #define AVR_BF_RXC_SIZE 1
00301 #define AVR_BF_RXC_OFFSET 7
00302
00303
00304 #define AVR_BF_TXEN_SIZE 1
00305 #define AVR_BF_TXEN_OFFSET 3
00306 #define AVR_BF_RXEN_SIZE 1
00307 #define AVR_BF_RXEN_OFFSET 4
00308 #define AVR_BF_UDRIE_SIZE 1
00309 #define AVR_BF_UDRIE_OFFSET 5
00310 #define AVR_BF_TXCIE_SIZE 1
00311 #define AVR_BF_TXCIE_OFFSET 6
00312 #define AVR_BF_RXCIE_SIZE 1
00313 #define AVR_BF_RXCIE_OFFSET 7
00314
00315
00316 #define AVR_BF_UCSZ_SIZE 2
00317 #define AVR_BF_UCSZ_OFFSET 1
00318 #define AVR_BF_USBS_SIZE 1
00319 #define AVR_BF_USBS_OFFSET 3
00320 #define AVR_BF_UPM_SIZE 2
00321 #define AVR_BF_UPM_OFFSET 4
00322
00323
00324 #define AVR_BIT(name) \
00325 (1 << AVR_BF_##name##_OFFSET)
00326 #define AVR_BF(name,value) \
00327 (((value) & ((1 << AVR_BF_##name##_SIZE) - 1)) \
00328 << AVR_BF_##name##_OFFSET)
00329 #define AVR_BFEXT(name,value) \
00330 (((value) >> AVR_BF_##name##_OFFSET) \
00331 & ((1 << AVR_BF_##name##_SIZE) - 1))
00332 #define AVR_BFINS(name,value,old) \
00333 (((old) & ~(((1 << AVR_BF_##name##_SIZE) - 1) \
00334 << AVR_BF_##name##_OFFSET)) \
00335 | AVR_BF(name,value))
00336
00337 #define avr_read_reg8(reg) \
00338 mmio_read8((void *)(AVR_REG_##reg))
00339 #define avr_write_reg8(reg, value) \
00340 mmio_write8((void *)(AVR_REG_##reg), value)
00341
00342 #endif