e7da3eadf09b0ac87fd03bb9e53a26364655bb93
[bertos.git] / cpu / arm / io / at91sam7s.h
1 /**
2  * \file
3  * <!--
4  * This file is part of BeRTOS.
5  *
6  * Bertos is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19  *
20  * As a special exception, you may use this file as part of a free software
21  * library without restriction.  Specifically, if other files instantiate
22  * templates or use macros or inline functions from this file, or you compile
23  * this file and link it with other files to produce an executable, this
24  * file does not by itself cause the resulting executable to be covered by
25  * the GNU General Public License.  This exception does not however
26  * invalidate any other reasons why the executable file might be covered by
27  * the GNU General Public License.
28  *
29  * Copyright 2007 Develer S.r.l. (http://www.develer.com/)
30  *
31  * -->
32  *
33  * \version $Id$
34  *
35  * \author Francesco Sacchi <batt@develer.com>
36  *
37  * AT91SAM7S register definitions.
38  * This file is based on NUT/OS implementation. See license below.
39  */
40
41 /*
42  * Copyright (C) 2006-2007 by egnite Software GmbH. All rights reserved.
43  *
44  * Redistribution and use in source and binary forms, with or without
45  * modification, are permitted provided that the following conditions
46  * are met:
47  *
48  * 1. Redistributions of source code must retain the above copyright
49  *    notice, this list of conditions and the following disclaimer.
50  * 2. Redistributions in binary form must reproduce the above copyright
51  *    notice, this list of conditions and the following disclaimer in the
52  *    documentation and/or other materials provided with the distribution.
53  * 3. Neither the name of the copyright holders nor the names of
54  *    contributors may be used to endorse or promote products derived
55  *    from this software without specific prior written permission.
56  *
57  * THIS SOFTWARE IS PROVIDED BY EGNITE SOFTWARE GMBH AND CONTRIBUTORS
58  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
59  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
60  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL EGNITE
61  * SOFTWARE GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
62  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
63  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
64  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
65  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
66  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
67  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
68  * SUCH DAMAGE.
69  *
70  * For additional information see http://www.ethernut.de/
71  */
72
73 #ifndef AT91SAM7S_H
74 #define AT91SAM7S_H
75
76 #define FLASH_BASE      0x100000UL
77 #define RAM_BASE        0x200000UL
78
79 #define TC_BASE         0xFFFA0000      ///< Timer/counter base address.
80 #define UDP_BASE        0xFFFB0000      ///< USB device port base address.
81 #define TWI_BASE        0xFFFB8000      ///< Two-wire interface base address.
82 #define USART0_BASE     0xFFFC0000      ///< USART 0 base address.
83 #define USART1_BASE     0xFFFC4000      ///< USART 1 base address.
84 #define PWMC_BASE       0xFFFCC000      ///< PWM controller base address.
85 #define SSC_BASE        0xFFFD4000      ///< Serial synchronous controller base address.
86 #define ADC_BASE        0xFFFD8000      ///< ADC base address.
87 #define SPI_BASE        0xFFFE0000      ///< SPI0 base address.
88
89 #define AIC_BASE        0xFFFFF000      ///< AIC base address.
90 #define DBGU_BASE       0xFFFFF200      ///< DBGU base address.
91 #define PIOA_BASE       0xFFFFF400      ///< PIO A base address.
92 #define PMC_BASE        0xFFFFFC00      ///< PMC base address.
93 #define RSTC_BASE       0xFFFFFD00      ///< Resect controller register base address.
94 #define RTT_BASE        0xFFFFFD20      ///< Realtime timer base address.
95 #define PIT_BASE        0xFFFFFD30      ///< Periodic interval timer base address.
96 #define WDT_BASE        0xFFFFFD40      ///< Watch Dog register base address.
97 #define VREG_BASE       0xFFFFFD60      ///< Voltage regulator mode controller base address.
98 #define MC_BASE         0xFFFFFF00      ///< Memory controller base.
99
100 #include "at91_aic.h"
101 #include "at91_pit.h"
102 //TODO: add other peripherals
103
104 /** Peripheral Identifiers and Interrupts */
105 /*\{*/
106 #define FIQ_ID      0       ///< Fast interrupt ID.
107 #define SYSC_ID     1       ///< System controller interrupt.
108 #define PIOA_ID     2       ///< Parallel I/O controller ID.
109 /* ID 3 is reserved */
110 #define ADC_ID      4       ///< Analog to digital converter ID.
111 #define SPI_ID      5       ///< Serial peripheral interface ID.
112 #define US0_ID      6       ///< USART 0 ID.
113 #define US1_ID      7       ///< USART 1 ID.
114 #define SSC_ID      8       ///< Synchronous serial controller ID.
115 #define TWI_ID      9       ///< Two-wire interface ID.
116 #define PWMC_ID     10      ///< PWM controller ID.
117 #define UDP_ID      11      ///< USB device port ID.
118 #define TC0_ID      12      ///< Timer 0 ID.
119 #define TC1_ID      13      ///< Timer 1 ID.
120 #define TC2_ID      14      ///< Timer 2 ID.
121
122 #define IRQ0_ID     30      ///< External interrupt 0 ID.
123 #define IRQ1_ID     31      ///< External interrupt 1 ID.
124 /*\}*/
125
126 #warning Revise me after this line!
127
128 #define PERIPH_RPR_OFF  0x00000100      ///< Receive pointer register offset.
129 #define PERIPH_RCR_OFF  0x00000104      ///< Receive counter register offset.
130 #define PERIPH_TPR_OFF  0x00000108      ///< Transmit pointer register offset.
131 #define PERIPH_TCR_OFF  0x0000010C      ///< Transmit counter register offset.
132 #define PERIPH_RNPR_OFF 0x00000110      ///< Receive next pointer register offset.
133 #define PERIPH_RNCR_OFF 0x00000114      ///< Receive next counter register offset.
134 #define PERIPH_TNPR_OFF 0x00000118      ///< Transmit next pointer register offset.
135 #define PERIPH_TNCR_OFF 0x0000011C      ///< Transmit next counter register offset.
136 #define PERIPH_PTCR_OFF 0x00000120      ///< PDC transfer control register offset.
137 #define PERIPH_PTSR_OFF 0x00000124      ///< PDC transfer status register offset.
138
139 #define PDC_RXTEN       0x00000001      ///< Receiver transfer enable.
140 #define PDC_RXTDIS      0x00000002      ///< Receiver transfer disable.
141 #define PDC_TXTEN       0x00000100      ///< Transmitter transfer enable.
142 #define PDC_TXTDIS      0x00000200      ///< Transmitter transfer disable.
143
144 #define DBGU_HAS_PDC
145 #define SPI_HAS_PDC
146 #define SSC_HAS_PDC
147 #define USART_HAS_PDC
148
149 #define PIO_HAS_MULTIDRIVER
150 #define PIO_HAS_PULLUP
151 #define PIO_HAS_PERIPHERALSELECT
152 #define PIO_HAS_OUTPUTWRITEENABLE
153
154
155 /** Historical SPI0 Peripheral Multiplexing Names */
156 /*\{*/
157 #define SPI0_NPCS0_PA12A        12      ///< Port bit number on PIO-A Perpheral A.
158 #define SPI0_NPCS1_PA13A        13      ///< Port bit number on PIO-A Perpheral A.
159 #define SPI0_NPCS1_PA07B        7       ///< Port bit number on PIO-A Perpheral B.
160 #define SPI0_NPCS1_PB13B        13      ///< Port bit number on PIO-B Perpheral B.
161 #define SPI0_NPCS2_PA14A        14      ///< Port bit number on PIO-A Perpheral A.
162 #define SPI0_NPCS2_PA08B        8       ///< Port bit number on PIO-A Perpheral B.
163 #define SPI0_NPCS2_PB14B        14      ///< Port bit number on PIO-B Perpheral B.
164 #define SPI0_NPCS3_PA15A        15      ///< Port bit number on PIO-A Perpheral A.
165 #define SPI0_NPCS3_PA09B        9       ///< Port bit number on PIO-A Perpheral B.
166 #define SPI0_NPCS3_PB17B        17      ///< Port bit number on PIO-B Perpheral B.
167 #define SPI0_MISO_PA16A         16      ///< Port bit number on PIO-A Perpheral A.
168 #define SPI0_MOSI_PA17A         17      ///< Port bit number on PIO-A Perpheral A.
169 #define SPI0_SPCK_PA18A         18      ///< Port bit number on PIO-A Perpheral A.
170 /*\}*/
171
172 /** USART Peripheral Multiplexing */
173 /*\{*/
174 #define PA0_RXD0_A          0
175 #define PA1_TXD0_A          1
176 #define PA2_SCK0_A          2
177 #define PA3_RTS0_A          3
178 #define PA4_CTS0_A          4
179
180 #define PA5_RXD1_A          5
181 #define PA6_TXD1_A          6
182 #define PA7_SCK1_A          7
183 #define PA8_RTS1_A          8
184 #define PA9_CTS1_A          9
185 #define PB23_DCD1_B         23
186 #define PB24_DSR1_B         24
187 #define PB25_DTR1_B         25
188 #define PB26_RI1_B          26
189 /*\}*/
190
191 /** SPI Peripheral Multiplexing */
192 /*\{*/
193 #define PA16_SPI0_MISO_A    16
194 #define PA17_SPI0_MOSI_A    17
195 #define PA18_SPI0_SPCK_A    18
196 #define PA12_SPI0_NPCS0_A   12
197 #define PA13_SPI0_NPCS1_A   13
198 #define PA7_SPI0_NPCS1_B    7
199 #define PA14_SPI0_NPCS2_A   14
200 #define PB14_SPI0_NPCS2_B   14
201 #define PA8_SPI0_NPCS2_B    8
202 #define PA15_SPI0_NPCS3_A   15
203 #define PA9_SPI0_NPCS3_B    9
204
205 #define SPI0_PINS           _BV(PA16_SPI0_MISO_A) | _BV(PA17_SPI0_MOSI_A) | _BV(PA18_SPI0_SPCK_A)
206 #define SPI0_PIO_BASE       PIOA_BASE
207 #define SPI0_PSR_OFF        PIO_ASR_OFF
208
209 #define SPI0_CS0_PIN        _BV(PA12_SPI0_NPCS0_A)
210 #define SPI0_CS0_PIO_BASE   PIOA_BASE
211 #define SPI0_CS0_PSR_OFF    PIO_ASR_OFF
212
213 #ifndef SPI0_CS1_PIN
214 #define SPI0_CS1_PIN        _BV(PA13_SPI0_NPCS1_A)
215 #define SPI0_CS1_PIO_BASE   PIOA_BASE
216 #define SPI0_CS1_PSR_OFF    PIO_ASR_OFF
217 #endif
218
219 #ifndef SPI0_CS2_PIN
220 #define SPI0_CS2_PIN        _BV(PA14_SPI0_NPCS2_A)
221 #define SPI0_CS2_PIO_BASE   PIOA_BASE
222 #define SPI0_CS2_PSR_OFF    PIO_ASR_OFF
223 #endif
224
225 #ifndef SPI0_CS3_PIN
226 #define SPI0_CS3_PIN        _BV(PA15_SPI0_NPCS3_A)
227 #define SPI0_CS3_PIO_BASE   PIOA_BASE
228 #define SPI0_CS3_PSR_OFF    PIO_ASR_OFF
229 #endif
230
231 #define PA24_SPI1_MISO_B    24
232 #define PA23_SPI1_MOSI_B    23
233 #define PA22_SPI1_SPCK_B    22
234 #define PA21_SPI1_NPCS0_B   21
235 #define PA25_SPI1_NPCS1_B   25
236 #define PB13_SPI0_NPCS1_B   13
237 #define PA2_SPI1_NPCS1_B    2
238 #define PB10_SPI1_NPCS1_B   10
239 #define PA26_SPI1_NPCS2_B   26
240 #define PA3_SPI1_NPCS2_B    3
241 #define PB11_SPI1_NPCS2_B   11
242 #define PB17_SPI0_NPCS3_B   17
243 #define PA4_SPI1_NPCS3_B    4
244 #define PA29_SPI1_NPCS3_B   29
245 #define PB16_SPI1_NPCS3_B   16
246
247 #define SPI1_PINS           _BV(PA24_SPI1_MISO_B) | _BV(PA23_SPI1_MOSI_B) | _BV(PA22_SPI1_SPCK_B)
248 #define SPI1_PIO_BASE       PIOA_BASE
249 #define SPI1_PSR_OFF        PIO_BSR_OFF
250
251 #define SPI1_CS0_PIN        _BV(PA21_SPI1_NPCS0_B)
252 #define SPI1_CS0_PIO_BASE   PIOA_BASE
253 #define SPI1_CS0_PSR_OFF    PIO_BSR_OFF
254
255 #ifndef SPI1_CS1_PIN
256 #define SPI1_CS1_PIN        _BV(PA25_SPI1_NPCS1_B)
257 #define SPI1_CS1_PIO_BASE   PIOA_BASE
258 #define SPI1_CS1_PSR_OFF    PIO_BSR_OFF
259 #endif
260
261 #ifndef SPI1_CS2_PIN
262 #define SPI1_CS2_PIN        _BV(PA26_SPI1_NPCS2_B)
263 #define SPI1_CS2_PIO_BASE   PIOA_BASE
264 #define SPI1_CS2_PSR_OFF    PIO_BSR_OFF
265 #endif
266
267 #ifndef SPI1_CS3_PIN
268 #define SPI1_CS3_PIN        _BV(PA29_SPI1_NPCS3_B)
269 #define SPI1_CS3_PIO_BASE   PIOA_BASE
270 #define SPI1_CS3_PSR_OFF    PIO_BSR_OFF
271 #endif
272
273 /*\}*/
274
275 /** EMAC Interface Peripheral Multiplexing */
276 /*\{*/
277 #define PB0_ETXCK_EREFCK_A  0
278 #define PB1_ETXEN_A         1
279 #define PB2_ETX0_A          2
280 #define PB3_ETX1_A          3
281 #define PB4_ECRS_A          4
282 #define PB5_ERX0_A          5
283 #define PB6_ERX1_A          6
284 #define PB7_ERXER_A         7
285 #define PB8_EMDC_A          8
286 #define PB9_EMDIO_A         9
287 #define PB10_ETX2_A         10
288 #define PB11_ETX3_A         11
289 #define PB12_ETXER_A        12
290 #define PB13_ERX2_A         13
291 #define PB14_ERX3_A         14
292 #define PB15_ERXDV_ECRSDV_A 15
293 #define PB16_ECOL_A         16
294 #define PB17_ERXCK_A        17
295 #define PB18_EF100_A        18
296 /*\}*/
297
298 /** Debug Unit Peripheral Multiplexing */
299 /*\{*/
300 #define PA27_DRXD_A         27
301 #define PA28_DTXD_A         28
302 /*\}*/
303
304 /** Synchronous Serial Controller Peripheral Multiplexing */
305 /*\{*/
306 #define PA23_TD_A           23  ///< Transmit data pin.
307 #define PA24_RD_A           24  ///< Receive data pin.
308 #define PA22_TK_A           22  ///< Transmit clock pin.
309 #define PA25_RK_A           25  ///< Receive clock pin.
310 #define PA21_TF_A           21  ///< Transmit frame sync. pin.
311 #define PA26_RF_A           26  ///< Receive frame sync. pin.
312 /*\}*/
313
314 /** Two Wire Interface Peripheral Multiplexing */
315 /*\{*/
316 #define PA10_TWD_A          10  ///< Two wire serial data pin.
317 #define PA11_TWCK_A         11  ///< Two wire serial clock pin.
318 /*\}*/
319
320 /** Timer/Counter Peripheral Multiplexing */
321 /*\{*/
322 #define PB23_TIOA0_A        23
323 #define PB24_TIOB0_A        24
324 #define PB12_TCLK0_B        12
325
326 #define PB25_TIOA1_A        25
327 #define PB26_TIOB1_A        26
328 #define PB19_TCLK1_B        19
329
330 #define PB27_TIOA2_A        27
331 #define PB28_TIOB2_A        28
332 #define PA15_TCLK2_B        15
333 /*\}*/
334
335 /** Clocks, Oscillators and PLLs Peripheral Multiplexing */
336 /*\{*/
337 #define PB0_PCK0_B          0
338 #define PB20_PCK0_B         20
339 #define PA13_PCK1_B         13
340 #define PB29_PCK1_A         29
341 #define PB21_PCK1_B         21
342 #define PA30_PCK2_B         30
343 #define PB30_PCK2_A         30
344 #define PB22_PCK2_B         22
345 #define PA27_PCK3_B         27
346 /*\}*/
347
348 /** Advanced Interrupt Controller Peripheral Multiplexing */
349 /*\{*/
350 #define PA29_FIQ_A          29
351 #define PA30_IRQ0_A         30
352 #define PA14_IRQ1_B         14
353 /*\}*/
354
355 /** ADC Interface Peripheral Multiplexing */
356 /*\{*/
357 #define PB18_ADTRG_B        18  ///< ADC trigger pin.
358 /*\}*/
359
360 /** CAN Interface Peripheral Multiplexing */
361 /*\{*/
362 #define PA19_CANRX_A        19
363 #define PA20_CANTX_A        20
364 /*\}*/
365
366 /** PWM Peripheral Multiplexing */
367 /*\{*/
368 #define PB19_PWM0_A         19
369 #define PB27_PWM0_B         27
370 #define PB20_PWM1_A         20
371 #define PB28_PWM1_B         28
372 #define PB21_PWM2_A         21
373 #define PB29_PWM2_B         29
374 #define PB22_PWM3_A         22
375 #define PB30_PWM3_B         30
376 /*\}*/
377
378 #endif /* AT91SAM7S_H */