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 #if CPU_ARM_AT91SAM7S256 || CPU_ARM_AT91SAM7X256
00148     #define FLASH_MEM_SIZE          0x40000UL 
00149     #define FLASH_PAGE_SIZE_BYTES         256 
00150     #define FLASH_BANKS_NUM                 1 
00151     #define FLASH_SECTORS_NUM              16 
00152     #define FLASH_PAGE_PER_SECTOR          64 
00153 
00154 #else
00155     #error Memory size definition for selected ARM CPU
00156 #endif
00157 
00158 #include "at91_aic.h"
00159 #include "at91_pit.h"
00160 #include "at91_pmc.h"
00161 #include "at91_mc.h"
00162 #include "at91_wdt.h"
00163 #include "at91_rstc.h"
00164 #include "at91_pio.h"
00165 #include "at91_us.h"
00166 #include "at91_dbgu.h"
00167 #include "at91_tc.h"
00168 #include "at91_adc.h"
00169 #include "at91_pwm.h"
00170 #include "at91_spi.h"
00171 #include "at91_twi.h"
00172 #include "at91_ssc.h"
00173 //TODO: add other peripherals
00174 
00179 #if CPU_ARM_SAM7X || CPU_ARM_SAM7S_LARGE
00180     #define FIQ_ID      0       
00181     #define SYSC_ID     1       
00182     #define US0_ID      6       
00183     #define US1_ID      7       
00184     #define SSC_ID      8       
00185     #define TWI_ID      9       
00186     #define PWMC_ID     10      
00187     #define UDP_ID      11      
00188     #define TC0_ID      12      
00189     #define TC1_ID      13      
00190     #define TC2_ID      14      
00191 
00192     #define IRQ0_ID     30      
00193     #define IRQ1_ID     31      
00194 
00195     #if CPU_ARM_SAM7X
00196         #define PIOA_ID     2       
00197         #define PIOB_ID     3       
00198         #define SPI0_ID     4       
00199         #define SPI1_ID     5       
00200         #define CAN_ID      15      
00201         #define EMAC_ID     16      
00202         #define ADC_ID      17      
00203         /* 18-29 Reserved */
00204 
00205     #endif
00206 
00207     #if CPU_ARM_SAM7S_LARGE
00208         #define PIOA_ID     2       
00209         /* ID 3 is reserved */
00210         #define ADC_ID      4       
00211         #define SPI_ID      5       
00212         #define SPI0_ID     SPI_ID  
00213     #endif
00214 
00215 #else
00216     #error No peripheral ID and interrupts definition for selected ARM CPU
00217 
00218 #endif
00219 /*\}*/
00220 
00225 #if CPU_ARM_SAM7S_LARGE
00226     #define RXD0        5
00227     #define TXD0        6
00228     #define RXD1       21
00229     #define TXD1       22
00230     #define DTXD       10
00231     #define DRXD        9
00232 #elif CPU_ARM_SAM7X
00233     #define RXD0        0 // PA0
00234     #define TXD0        1 // PA1
00235     #define RXD1        5 // PA5
00236     #define TXD1        6 // PA6
00237     #define DTXD       28 // PA28
00238     #define DRXD       27 // PA27
00239 #else
00240     #error No USART & debug pin names definition for selected ARM CPU
00241 #endif
00242 /*\}*/
00243 
00248 #if CPU_ARM_SAM7S_LARGE
00249     #define SPI0_NPCS0      11  // Same as NSS pin.
00250     #define SPI0_MISO       12
00251     #define SPI0_MOSI       13
00252     #define SPI0_SPCK       14
00253 
00254 #elif CPU_ARM_SAM7X
00255     #define SPI0_NPCS0  12 // Same as NSS pin. PA12
00256     #define SPI0_NPCS1  13 // PA13
00257     #define SPI0_NPCS2  14 // PA14
00258     #define SPI0_NPCS3  15 // PA15
00259     #define SPI0_MISO   16 // PA16
00260     #define SPI0_MOSI   17 // PA17
00261     #define SPI0_SPCK   18 // PA18
00262 
00263     #define SPI1_NPCS0  21 // Same as NSS pin. PA21
00264     #define SPI1_NPCS1  25 // PA25
00265     #define SPI1_NPCS2  26 // PA26
00266     #define SPI1_NPCS3  29 // PA29
00267     #define SPI1_MISO   24 // PA24
00268     #define SPI1_MOSI   23 // PA23
00269     #define SPI1_SPCK   22 // PA22
00270 
00271 #else
00272     #error No SPI pins name definition for selected ARM CPU
00273 
00274 #endif
00275 /*\}*/
00276 
00281 #if CPU_ARM_SAM7S_LARGE
00282 
00283     #define SSC_TF     15 // PA15
00284     #define SSC_TK     16 // PA16
00285     #define SSC_TD     17 // PA17
00286     #define SSC_RD     18 // PA18
00287     #define SSC_RK     19 // PA19
00288     #define SSC_RF     20 // PA20
00289 
00290 #elif CPU_ARM_SAM7X
00291 
00292     #define SSC_TF     21 // PA21
00293     #define SSC_TK     22 // PA22
00294     #define SSC_TD     23 // PA23
00295     #define SSC_RD     24 // PA24
00296     #define SSC_RK     25 // PA25
00297     #define SSC_RF     26 // PA26
00298 
00299 #else
00300     #error No SSC pins name definition for selected ARM CPU
00301 
00302 #endif
00303 /*\}*/
00304 
00309 #if CPU_ARM_SAM7X
00310     #define TIOA0  23 // PB23
00311     #define TIOB0  24 // PB24
00312     #define TIOA1  25 // PB25
00313     #define TIOB1  26 // PB26
00314     #define TIOA2  27 // PB27
00315     #define TIOB2  28 // PB28
00316 
00317     #define TIO_PIO_PDR     PIOB_PDR
00318     #define TIO_PIO_ABSR    PIOB_ASR
00319 
00320 #elif CPU_ARM_SAM7S_LARGE
00321     #define TIOA0  0 // PA0
00322     #define TIOB0  1 // PA1
00323     #define TIOA1  15 // PA15
00324     #define TIOB1  16 // PA16
00325     #define TIOA2  26 // PA26
00326     #define TIOB2  27 // PA27
00327 
00328     #define TIO_PIO_PDR     PIOA_PDR
00329     #define TIO_PIO_ABSR    PIOA_BSR
00330 
00331 #else
00332     #error No Timer Counter names of pins definition for selected ARM CPU
00333 
00334 #endif
00335 /*\}*/
00336 
00337 
00342 #if CPU_ARM_SAM7X
00343     #define PWM0  19 // PB19
00344     #define PWM1  20 // PB20
00345     #define PWM2  21 // PB21
00346     #define PWM3  22 // PB22
00347 
00348     #define PWM_PIO_PDR     PIOB_PDR
00349     #define PWM_PIO_PER     PIOB_PER
00350     #define PWM_PIO_CODR    PIOB_CODR
00351     #define PWM_PIO_OER     PIOB_OER
00352     #define PWM_PIO_ABSR    PIOB_ASR
00353 
00354 #elif CPU_ARM_SAM7S_LARGE
00355     #define PWM0  11 // PA11
00356     #define PWM1  12 // PA12
00357     #define PWM2  13 // PA13
00358     #define PWM3  14 // PA14
00359 
00360     #define PWM_PIO_PDR     PIOA_PDR
00361     #define PWM_PIO_PER     PIOA_PER
00362     #define PWM_PIO_CODR    PIOA_CODR
00363     #define PWM_PIO_OER     PIOA_OER
00364     #define PWM_PIO_ABSR    PIOA_BSR
00365 
00366 #else
00367     #error No PWM names of pins definition for selected ARM CPU
00368 
00369 #endif
00370 /*\}*/
00371 
00376 #if CPU_ARM_SAM7X
00377     #define TWD  10
00378     #define TWCK 11
00379 
00380 #elif CPU_ARM_SAM7S_LARGE
00381     #define TWD  3    //PA3
00382     #define TWCK 4    //PA4
00383 
00384 #else
00385     #error No TWI names of pins definition for selected ARM CPU
00386 #endif
00387 
00392 #if CPU_ARM_SAM7X
00393     #define ADTRG   18 // PB18
00394     #define AD0     23 // PB27
00395     #define AD1     24 // PB28
00396     #define AD2     25 // PB29
00397     #define AD3     26 // PB30
00398 
00399 #elif CPU_ARM_SAM7S_LARGE
00400     #define ADTRG   18 // PA8
00401     #define AD0      0 // PA17
00402     #define AD1      1 // PA18
00403     #define AD2     15 // PA19
00404     #define AD3     16 // PA20
00405 
00406 #else
00407     #error No ADC names of pins definition for selected ARM CPU
00408 
00409 #endif
00410 /*\}*/
00411 
00412 #endif /* AT91SAM7_H */