at91sam7.h

Go to the documentation of this file.
00001 
00042 /*
00043  * Copyright (C) 2006-2007 by egnite Software GmbH. All rights reserved.
00044  *
00045  * Redistribution and use in source and binary forms, with or without
00046  * modification, are permitted provided that the following conditions
00047  * are met:
00048  *
00049  * 1. Redistributions of source code must retain the above copyright
00050  *    notice, this list of conditions and the following disclaimer.
00051  * 2. Redistributions in binary form must reproduce the above copyright
00052  *    notice, this list of conditions and the following disclaimer in the
00053  *    documentation and/or other materials provided with the distribution.
00054  * 3. Neither the name of the copyright holders nor the names of
00055  *    contributors may be used to endorse or promote products derived
00056  *    from this software without specific prior written permission.
00057  *
00058  * THIS SOFTWARE IS PROVIDED BY EGNITE SOFTWARE GMBH AND CONTRIBUTORS
00059  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00060  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00061  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL EGNITE
00062  * SOFTWARE GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00063  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00064  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
00065  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
00066  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00067  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
00068  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00069  * SUCH DAMAGE.
00070  *
00071  * For additional information see http://www.ethernut.de/
00072  */
00073 
00074 #ifndef AT91SAM7_H
00075 #define AT91SAM7_H
00076 
00077 #include <cfg/compiler.h>
00078 
00079 #if CPU_ARM_SAM7X || CPU_ARM_SAM7S_LARGE
00080     #define FLASH_BASE      0x100000UL
00081     #define RAM_BASE        0x200000UL
00082 
00083     #define TC_BASE         0xFFFA0000      
00084     #define UDP_BASE        0xFFFB0000      
00085     #define TWI_BASE        0xFFFB8000      
00086     #define USART0_BASE     0xFFFC0000      
00087     #define USART1_BASE     0xFFFC4000      
00088     #define PWMC_BASE       0xFFFCC000      
00089     #define SSC_BASE        0xFFFD4000      
00090     #define ADC_BASE        0xFFFD8000      
00091 
00092     #define AIC_BASE        0xFFFFF000      
00093     #define DBGU_BASE       0xFFFFF200      
00094     #define PIOA_BASE       0xFFFFF400      
00095     #define PMC_BASE        0xFFFFFC00      
00096     #define RSTC_BASE       0xFFFFFD00      
00097     #define RTT_BASE        0xFFFFFD20      
00098     #define PIT_BASE        0xFFFFFD30      
00099     #define WDT_BASE        0xFFFFFD40      
00100     #define VREG_BASE       0xFFFFFD60      
00101     #define MC_BASE         0xFFFFFF00      
00102 
00103     #if CPU_ARM_SAM7X
00104         #define CAN_BASE        0xFFFD0000      
00105         #define EMAC_BASE       0xFFFDC000      
00106         #define SPI0_BASE       0xFFFE0000      
00107         #define SPI1_BASE       0xFFFE4000      
00108         #define PIOB_BASE       0xFFFFF600      
00109     #endif
00110 
00111     #if CPU_ARM_SAM7S_LARGE
00112         #define SPI_BASE        0xFFFE0000      
00113     #endif
00114 
00115     #define PIO_HAS_MULTIDRIVER        1
00116     #define PIO_HAS_PULLUP             1
00117     #define PIO_HAS_PERIPHERALSELECT   1
00118     #define PIO_HAS_OUTPUTWRITEENABLE  1
00119 
00120     #define DBGU_HAS_PDC               1
00121     #define SPI_HAS_PDC                1
00122     #define SSC_HAS_PDC                1
00123     #define USART_HAS_PDC              1
00124 
00125     /* PDC registers */
00126     #define PERIPH_RPR_OFF  0x100  
00127     #define PERIPH_RCR_OFF  0x104  
00128     #define PERIPH_TPR_OFF  0x108  
00129     #define PERIPH_TCR_OFF  0x10C  
00130     #define PERIPH_RNPR_OFF 0x110  
00131     #define PERIPH_RNCR_OFF 0x114  
00132     #define PERIPH_TNPR_OFF 0x118  
00133     #define PERIPH_TNCR_OFF 0x11C  
00134     #define PERIPH_PTCR_OFF 0x120  
00135     #define PERIPH_PTSR_OFF 0x124  
00136 
00137     #define PDC_RXTEN  0
00138     #define PDC_RXTDIS 1
00139     #define PDC_TXTEN  8
00140     #define PDC_TXTDIS 9
00141 
00142 #else
00143     #error No base address register definition for selected ARM CPU
00144 
00145 #endif
00146 
00147 #include "at91_aic.h"
00148 #include "at91_pit.h"
00149 #include "at91_pmc.h"
00150 #include "at91_mc.h"
00151 #include "at91_wdt.h"
00152 #include "at91_rstc.h"
00153 #include "at91_pio.h"
00154 #include "at91_us.h"
00155 #include "at91_dbgu.h"
00156 #include "at91_tc.h"
00157 #include "at91_adc.h"
00158 #include "at91_pwm.h"
00159 #include "at91_spi.h"
00160 #include "at91_twi.h"
00161 #include "at91_ssc.h"
00162 //TODO: add other peripherals
00163 
00168 #if CPU_ARM_SAM7X || CPU_ARM_SAM7S_LARGE
00169     #define FIQ_ID      0       
00170     #define SYSC_ID     1       
00171     #define US0_ID      6       
00172     #define US1_ID      7       
00173     #define SSC_ID      8       
00174     #define TWI_ID      9       
00175     #define PWMC_ID     10      
00176     #define UDP_ID      11      
00177     #define TC0_ID      12      
00178     #define TC1_ID      13      
00179     #define TC2_ID      14      
00180 
00181     #define IRQ0_ID     30      
00182     #define IRQ1_ID     31      
00183 
00184     #if CPU_ARM_SAM7X
00185         #define PIOA_ID     2       
00186         #define PIOB_ID     3       
00187         #define SPI0_ID     4       
00188         #define SPI1_ID     5       
00189         #define CAN_ID      15      
00190         #define EMAC_ID     16      
00191         #define ADC_ID      17      
00192         /* 18-29 Reserved */
00193 
00194     #endif
00195 
00196     #if CPU_ARM_SAM7S_LARGE
00197         #define PIOA_ID     2       
00198         /* ID 3 is reserved */
00199         #define ADC_ID      4       
00200         #define SPI_ID      5       
00201         #define SPI0_ID     SPI_ID  
00202     #endif
00203 
00204 #else
00205     #error No peripheral ID and interrupts definition for selected ARM CPU
00206 
00207 #endif
00208 /*\}*/
00209 
00214 #if CPU_ARM_SAM7S_LARGE
00215     #define RXD0        5
00216     #define TXD0        6
00217     #define RXD1       21
00218     #define TXD1       22
00219     #define DTXD       10
00220     #define DRXD        9
00221 #elif CPU_ARM_SAM7X
00222     #define RXD0        0 // PA0
00223     #define TXD0        1 // PA1
00224     #define RXD1        5 // PA5
00225     #define TXD1        6 // PA6
00226     #define DTXD       28 // PA28
00227     #define DRXD       27 // PA27
00228 #else
00229     #error No USART & debug pin names definition for selected ARM CPU
00230 #endif
00231 /*\}*/
00232 
00237 #if CPU_ARM_SAM7S_LARGE
00238     #define SPI0_NPCS0      11  // Same as NSS pin.
00239     #define SPI0_MISO       12
00240     #define SPI0_MOSI       13
00241     #define SPI0_SPCK       14
00242 
00243 #elif CPU_ARM_SAM7X
00244     #define SPI0_NPCS0  12 // Same as NSS pin. PA12
00245     #define SPI0_NPCS1  13 // PA13
00246     #define SPI0_NPCS2  14 // PA14
00247     #define SPI0_NPCS3  15 // PA15
00248     #define SPI0_MISO   16 // PA16
00249     #define SPI0_MOSI   17 // PA17
00250     #define SPI0_SPCK   18 // PA18
00251 
00252     #define SPI1_NPCS0  21 // Same as NSS pin. PA21
00253     #define SPI1_NPCS1  25 // PA25
00254     #define SPI1_NPCS2  26 // PA26
00255     #define SPI1_NPCS3  29 // PA29
00256     #define SPI1_MISO   24 // PA24
00257     #define SPI1_MOSI   23 // PA23
00258     #define SPI1_SPCK   22 // PA22
00259 
00260 #else
00261     #error No SPI pins name definition for selected ARM CPU
00262 
00263 #endif
00264 /*\}*/
00265 
00270 #if CPU_ARM_SAM7S_LARGE
00271 
00272     #define SSC_TF     15 // PA15
00273     #define SSC_TK     16 // PA16
00274     #define SSC_TD     17 // PA17
00275     #define SSC_RD     18 // PA18
00276     #define SSC_RK     19 // PA19
00277     #define SSC_RF     20 // PA20
00278 
00279 #elif CPU_ARM_SAM7X
00280 
00281     #define SSC_TF     21 // PA21
00282     #define SSC_TK     22 // PA22
00283     #define SSC_TD     23 // PA23
00284     #define SSC_RD     24 // PA24
00285     #define SSC_RK     25 // PA25
00286     #define SSC_RF     26 // PA26
00287 
00288 #else
00289     #error No SSC pins name definition for selected ARM CPU
00290 
00291 #endif
00292 /*\}*/
00293 
00298 #if CPU_ARM_SAM7X
00299     #define TIOA0  23 // PB23
00300     #define TIOB0  24 // PB24
00301     #define TIOA1  25 // PB25
00302     #define TIOB1  26 // PB26
00303     #define TIOA2  27 // PB27
00304     #define TIOB2  28 // PB28
00305 
00306     #define TIO_PIO_PDR     PIOB_PDR
00307     #define TIO_PIO_ABSR    PIOB_ASR
00308 
00309 #elif CPU_ARM_SAM7S_LARGE
00310     #define TIOA0  0 // PA0
00311     #define TIOB0  1 // PA1
00312     #define TIOA1  15 // PA15
00313     #define TIOB1  16 // PA16
00314     #define TIOA2  26 // PA26
00315     #define TIOB2  27 // PA27
00316 
00317     #define TIO_PIO_PDR     PIOA_PDR
00318     #define TIO_PIO_ABSR    PIOA_BSR
00319 
00320 #else
00321     #error No Timer Counter names of pins definition for selected ARM CPU
00322 
00323 #endif
00324 /*\}*/
00325 
00326 
00331 #if CPU_ARM_SAM7X
00332     #define PWM0  19 // PB19
00333     #define PWM1  20 // PB20
00334     #define PWM2  21 // PB21
00335     #define PWM3  22 // PB22
00336 
00337     #define PWM_PIO_PDR     PIOB_PDR
00338     #define PWM_PIO_PER     PIOB_PER
00339     #define PWM_PIO_CODR    PIOB_CODR
00340     #define PWM_PIO_OER     PIOB_OER
00341     #define PWM_PIO_ABSR    PIOB_ASR
00342 
00343 #elif CPU_ARM_SAM7S_LARGE
00344     #define PWM0  11 // PA11
00345     #define PWM1  12 // PA12
00346     #define PWM2  13 // PA13
00347     #define PWM3  14 // PA14
00348 
00349     #define PWM_PIO_PDR     PIOA_PDR
00350     #define PWM_PIO_PER     PIOA_PER
00351     #define PWM_PIO_CODR    PIOA_CODR
00352     #define PWM_PIO_OER     PIOA_OER
00353     #define PWM_PIO_ABSR    PIOA_BSR
00354 
00355 #else
00356     #error No PWM names of pins definition for selected ARM CPU
00357 
00358 #endif
00359 /*\}*/
00360 
00365 #if CPU_ARM_SAM7X
00366     #define TWD  10
00367     #define TWCK 11
00368 
00369 #elif CPU_ARM_SAM7S_LARGE
00370     #define TWD  3    //PA3
00371     #define TWCK 4    //PA4
00372 
00373 #else
00374     #error No TWI names of pins definition for selected ARM CPU
00375 #endif
00376 
00381 #if CPU_ARM_SAM7X
00382     #define ADTRG   18 // PB18
00383     #define AD0     23 // PB27
00384     #define AD1     24 // PB28
00385     #define AD2     25 // PB29
00386     #define AD3     26 // PB30
00387 
00388 #elif CPU_ARM_SAM7S_LARGE
00389     #define ADTRG   18 // PA8
00390     #define AD0      0 // PA17
00391     #define AD1      1 // PA18
00392     #define AD2     15 // PA19
00393     #define AD3     16 // PA20
00394 
00395 #else
00396     #error No ADC names of pins definition for selected ARM CPU
00397 
00398 #endif
00399 /*\}*/
00400 
00401 #endif /* AT91SAM7_H */