Robobo
sam3n4b.h
1 /* ----------------------------------------------------------------------------
2  * SAM Software Package License
3  * ----------------------------------------------------------------------------
4  * Copyright (c) 2012, Atmel Corporation
5  *
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following condition is met:
10  *
11  * - Redistributions of source code must retain the above copyright notice,
12  * this list of conditions and the disclaimer below.
13  *
14  * Atmel's name may not be used to endorse or promote products derived from
15  * this software without specific prior written permission.
16  *
17  * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
18  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
20  * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
21  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
23  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
26  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  * ----------------------------------------------------------------------------
28  */
29 
30 #ifndef _SAM3N4B_
31 #define _SAM3N4B_
32 
41 
42 #ifdef __cplusplus
43  extern "C" {
44 #endif
45 
46 #if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
47 #include <stdint.h>
48 #ifndef __cplusplus
49 typedef volatile const uint32_t RoReg;
50 #else
51 typedef volatile uint32_t RoReg;
52 #endif
53 typedef volatile uint32_t WoReg;
54 typedef volatile uint32_t RwReg;
55 #endif
56 
57 /* ************************************************************************** */
58 /* CMSIS DEFINITIONS FOR SAM3N4B */
59 /* ************************************************************************** */
62 
64 typedef enum IRQn
65 {
66 /****** Cortex-M3 Processor Exceptions Numbers ******************************/
69  BusFault_IRQn = -11,
71  SVCall_IRQn = -5,
73  PendSV_IRQn = -2,
74  SysTick_IRQn = -1,
75 /****** SAM3N4B specific Interrupt Numbers *********************************/
76 
77  SUPC_IRQn = 0,
78  RSTC_IRQn = 1,
79  RTC_IRQn = 2,
80  RTT_IRQn = 3,
81  WDT_IRQn = 4,
82  PMC_IRQn = 5,
83  EFC_IRQn = 6,
84  UART0_IRQn = 8,
85  UART1_IRQn = 9,
86  PIOA_IRQn = 11,
87  PIOB_IRQn = 12,
88  USART0_IRQn = 14,
89  USART1_IRQn = 15,
90  TWI0_IRQn = 19,
91  TWI1_IRQn = 20,
92  SPI_IRQn = 21,
93  TC0_IRQn = 23,
94  TC1_IRQn = 24,
95  TC2_IRQn = 25,
96  ADC_IRQn = 29,
97  DACC_IRQn = 30,
98  PWM_IRQn = 31,
101 } IRQn_Type;
102 
103 typedef struct _DeviceVectors
104 {
105  /* Stack pointer */
106  void* pvStack;
107 
108  /* Cortex-M handlers */
109  void* pfnReset_Handler;
110  void* pfnNMI_Handler;
111  void* pfnHardFault_Handler;
112  void* pfnMemManage_Handler;
113  void* pfnBusFault_Handler;
114  void* pfnUsageFault_Handler;
115  void* pfnReserved1_Handler;
116  void* pfnReserved2_Handler;
117  void* pfnReserved3_Handler;
118  void* pfnReserved4_Handler;
119  void* pfnSVC_Handler;
120  void* pfnDebugMon_Handler;
121  void* pfnReserved5_Handler;
122  void* pfnPendSV_Handler;
123  void* pfnSysTick_Handler;
124 
125  /* Peripheral handlers */
126  void* pfnSUPC_Handler; /* 0 Supply Controller */
127  void* pfnRSTC_Handler; /* 1 Reset Controller */
128  void* pfnRTC_Handler; /* 2 Real Time Clock */
129  void* pfnRTT_Handler; /* 3 Real Time Timer */
130  void* pfnWDT_Handler; /* 4 Watchdog Timer */
131  void* pfnPMC_Handler; /* 5 Power Management Controller */
132  void* pfnEFC_Handler; /* 6 Enhanced Flash Controller */
133  void* pvReserved7;
134  void* pfnUART0_Handler; /* 8 UART 0 */
135  void* pfnUART1_Handler; /* 9 UART 1 */
136  void* pvReserved10;
137  void* pfnPIOA_Handler; /* 11 Parallel I/O Controller A */
138  void* pfnPIOB_Handler; /* 12 Parallel I/O Controller B */
139  void* pvReserved13;
140  void* pfnUSART0_Handler; /* 14 USART 0 */
141  void* pfnUSART1_Handler; /* 15 USART 1 */
142  void* pvReserved16;
143  void* pvReserved17;
144  void* pvReserved18;
145  void* pfnTWI0_Handler; /* 19 Two Wire Interface 0 */
146  void* pfnTWI1_Handler; /* 20 Two Wire Interface 1 */
147  void* pfnSPI_Handler; /* 21 Serial Peripheral Interface */
148  void* pvReserved22;
149  void* pfnTC0_Handler; /* 23 Timer/Counter 0 */
150  void* pfnTC1_Handler; /* 24 Timer/Counter 1 */
151  void* pfnTC2_Handler; /* 25 Timer/Counter 2 */
152  void* pvReserved26;
153  void* pvReserved27;
154  void* pvReserved28;
155  void* pfnADC_Handler; /* 29 Analog To Digital Converter */
156  void* pfnDACC_Handler; /* 30 Digital To Analog Converter */
157  void* pfnPWM_Handler; /* 31 Pulse Width Modulation */
158 } DeviceVectors;
159 
160 /* Cortex-M3 core handlers */
161 void Reset_Handler ( void );
162 void NMI_Handler ( void );
163 void HardFault_Handler ( void );
164 void MemManage_Handler ( void );
165 void BusFault_Handler ( void );
166 void UsageFault_Handler ( void );
167 void SVC_Handler ( void );
168 void DebugMon_Handler ( void );
169 void PendSV_Handler ( void );
170 void SysTick_Handler ( void );
171 
172 /* Peripherals handlers */
173 void ADC_Handler ( void );
174 void DACC_Handler ( void );
175 void EFC_Handler ( void );
176 void PIOA_Handler ( void );
177 void PIOB_Handler ( void );
178 void PMC_Handler ( void );
179 void PWM_Handler ( void );
180 void RSTC_Handler ( void );
181 void RTC_Handler ( void );
182 void RTT_Handler ( void );
183 void SPI_Handler ( void );
184 void SUPC_Handler ( void );
185 void TC0_Handler ( void );
186 void TC1_Handler ( void );
187 void TC2_Handler ( void );
188 void TWI0_Handler ( void );
189 void TWI1_Handler ( void );
190 void UART0_Handler ( void );
191 void UART1_Handler ( void );
192 void USART0_Handler ( void );
193 void USART1_Handler ( void );
194 void WDT_Handler ( void );
195 
200 #define __CM3_REV 0x0200
201 #define __MPU_PRESENT 0
202 #define __NVIC_PRIO_BITS 4
203 #define __Vendor_SysTickConfig 0
205 /*
206  * \brief CMSIS includes
207  */
208 
209 #include <core_cm3.h>
210 #if !defined DONT_USE_CMSIS_INIT
211 #include "system_sam3n.h"
212 #endif /* DONT_USE_CMSIS_INIT */
213 
216 /* ************************************************************************** */
218 /* ************************************************************************** */
221 
222 #include "component/component_adc.h"
223 #include "component/component_chipid.h"
224 #include "component/component_dacc.h"
225 #include "component/component_efc.h"
226 #include "component/component_gpbr.h"
227 #include "component/component_matrix.h"
228 #include "component/component_pdc.h"
229 #include "component/component_pio.h"
230 #include "component/component_pmc.h"
231 #include "component/component_pwm.h"
232 #include "component/component_rstc.h"
233 #include "component/component_rtc.h"
234 #include "component/component_rtt.h"
235 #include "component/component_spi.h"
236 #include "component/component_supc.h"
237 #include "component/component_tc.h"
238 #include "component/component_twi.h"
239 #include "component/component_uart.h"
240 #include "component/component_usart.h"
241 #include "component/component_wdt.h"
244 /* ************************************************************************** */
245 /* REGISTER ACCESS DEFINITIONS FOR SAM3N4B */
246 /* ************************************************************************** */
249 
250 #include "instance/instance_spi.h"
251 #include "instance/instance_tc0.h"
252 #include "instance/instance_twi0.h"
253 #include "instance/instance_twi1.h"
254 #include "instance/instance_pwm.h"
255 #include "instance/instance_usart0.h"
256 #include "instance/instance_usart1.h"
257 #include "instance/instance_adc.h"
258 #include "instance/instance_dacc.h"
259 #include "instance/instance_matrix.h"
260 #include "instance/instance_pmc.h"
261 #include "instance/instance_uart0.h"
262 #include "instance/instance_chipid.h"
263 #include "instance/instance_uart1.h"
264 #include "instance/instance_efc.h"
265 #include "instance/instance_pioa.h"
266 #include "instance/instance_piob.h"
267 #include "instance/instance_rstc.h"
268 #include "instance/instance_supc.h"
269 #include "instance/instance_rtt.h"
270 #include "instance/instance_wdt.h"
271 #include "instance/instance_rtc.h"
272 #include "instance/instance_gpbr.h"
275 /* ************************************************************************** */
276 /* PERIPHERAL ID DEFINITIONS FOR SAM3N4B */
277 /* ************************************************************************** */
280 
281 #define ID_SUPC ( 0)
282 #define ID_RSTC ( 1)
283 #define ID_RTC ( 2)
284 #define ID_RTT ( 3)
285 #define ID_WDT ( 4)
286 #define ID_PMC ( 5)
287 #define ID_EFC ( 6)
288 #define ID_UART0 ( 8)
289 #define ID_UART1 ( 9)
290 #define ID_PIOA (11)
291 #define ID_PIOB (12)
292 #define ID_USART0 (14)
293 #define ID_USART1 (15)
294 #define ID_TWI0 (19)
295 #define ID_TWI1 (20)
296 #define ID_SPI (21)
297 #define ID_TC0 (23)
298 #define ID_TC1 (24)
299 #define ID_TC2 (25)
300 #define ID_ADC (29)
301 #define ID_DACC (30)
302 #define ID_PWM (31)
304 #define ID_PERIPH_COUNT (32)
306 
307 /* ************************************************************************** */
308 /* BASE ADDRESS DEFINITIONS FOR SAM3N4B */
309 /* ************************************************************************** */
312 
313 #if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
314 #define SPI (0x40008000U)
315 #define PDC_SPI (0x40008100U)
316 #define TC0 (0x40010000U)
317 #define TWI0 (0x40018000U)
318 #define PDC_TWI0 (0x40018100U)
319 #define TWI1 (0x4001C000U)
320 #define PWM (0x40020000U)
321 #define USART0 (0x40024000U)
322 #define PDC_USART0 (0x40024100U)
323 #define USART1 (0x40028000U)
324 #define ADC (0x40038000U)
325 #define PDC_ADC (0x40038100U)
326 #define DACC (0x4003C000U)
327 #define PDC_DACC (0x4003C100U)
328 #define MATRIX (0x400E0200U)
329 #define PMC (0x400E0400U)
330 #define UART0 (0x400E0600U)
331 #define PDC_UART0 (0x400E0700U)
332 #define CHIPID (0x400E0740U)
333 #define UART1 (0x400E0800U)
334 #define EFC (0x400E0A00U)
335 #define PIOA (0x400E0E00U)
336 #define PIOB (0x400E1000U)
337 #define RSTC (0x400E1400U)
338 #define SUPC (0x400E1410U)
339 #define RTT (0x400E1430U)
340 #define WDT (0x400E1450U)
341 #define RTC (0x400E1460U)
342 #define GPBR (0x400E1490U)
343 #else
344 #define SPI ((Spi *)0x40008000U)
345 #define PDC_SPI ((Pdc *)0x40008100U)
346 #define TC0 ((Tc *)0x40010000U)
347 #define TWI0 ((Twi *)0x40018000U)
348 #define PDC_TWI0 ((Pdc *)0x40018100U)
349 #define TWI1 ((Twi *)0x4001C000U)
350 #define PWM ((Pwm *)0x40020000U)
351 #define USART0 ((Usart *)0x40024000U)
352 #define PDC_USART0 ((Pdc *)0x40024100U)
353 #define USART1 ((Usart *)0x40028000U)
354 #define ADC ((Adc *)0x40038000U)
355 #define PDC_ADC ((Pdc *)0x40038100U)
356 #define DACC ((Dacc *)0x4003C000U)
357 #define PDC_DACC ((Pdc *)0x4003C100U)
358 #define MATRIX ((Matrix *)0x400E0200U)
359 #define PMC ((Pmc *)0x400E0400U)
360 #define UART0 ((Uart *)0x400E0600U)
361 #define PDC_UART0 ((Pdc *)0x400E0700U)
362 #define CHIPID ((Chipid *)0x400E0740U)
363 #define UART1 ((Uart *)0x400E0800U)
364 #define EFC ((Efc *)0x400E0A00U)
365 #define PIOA ((Pio *)0x400E0E00U)
366 #define PIOB ((Pio *)0x400E1000U)
367 #define RSTC ((Rstc *)0x400E1400U)
368 #define SUPC ((Supc *)0x400E1410U)
369 #define RTT ((Rtt *)0x400E1430U)
370 #define WDT ((Wdt *)0x400E1450U)
371 #define RTC ((Rtc *)0x400E1460U)
372 #define GPBR ((Gpbr *)0x400E1490U)
373 #endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
374 
376 /* ************************************************************************** */
377 /* PIO DEFINITIONS FOR SAM3N4B */
378 /* ************************************************************************** */
381 
382 #include "pio/pio_sam3n4b.h"
385 /* ************************************************************************** */
386 /* MEMORY MAPPING DEFINITIONS FOR SAM3N4B */
387 /* ************************************************************************** */
388 
389 #define IFLASH_SIZE (0x40000u)
390 #define IFLASH_PAGE_SIZE (256u)
391 #define IFLASH_LOCK_REGION_SIZE (16384u)
392 #define IFLASH_NB_OF_PAGES (1024u)
393 #define IFLASH_NB_OF_LOCK_BITS (16u)
394 #define IRAM_SIZE (0x6000u)
395 
396 #define IFLASH_ADDR (0x00400000u)
397 #define IROM_ADDR (0x00800000u)
398 #define IRAM_ADDR (0x20000000u)
400 /* ************************************************************************** */
401 /* ELECTRICAL DEFINITIONS FOR SAM3N4B */
402 /* ************************************************************************** */
403 
404 /* Device characteristics */
405 #define CHIP_FREQ_SLCK_RC_MIN (20000UL)
406 #define CHIP_FREQ_SLCK_RC (32000UL)
407 #define CHIP_FREQ_SLCK_RC_MAX (44000UL)
408 #define CHIP_FREQ_MAINCK_RC_4MHZ (4000000UL)
409 #define CHIP_FREQ_MAINCK_RC_8MHZ (8000000UL)
410 #define CHIP_FREQ_MAINCK_RC_12MHZ (12000000UL)
411 #define CHIP_FREQ_CPU_MAX (48000000UL)
412 #define CHIP_FREQ_XTAL_32K (32768UL)
413 #define CHIP_FREQ_XTAL_12M (12000000UL)
414 
415 /* Embedded Flash Write Wait State */
416 #define CHIP_FLASH_WRITE_WAIT_STATE (6U)
417 
418 /* Embedded Flash Read Wait State (VDDCORE set at 1.65V) */
419 #define CHIP_FREQ_FWS_0 (21000000UL)
420 #define CHIP_FREQ_FWS_1 (32000000UL)
421 #define CHIP_FREQ_FWS_2 (48000000UL)
424 #ifdef __cplusplus
425 }
426 #endif
427 
430 #endif /* _SAM3N4B_ */
Definition: sam3n4b.h:71
void UsageFault_Handler(void)
Definition: FreeRTOS_ARM.c:109
Definition: sam3n4b.h:83
Definition: sam3n4b.h:72
Definition: sam3n4b.h:97
Definition: sam3n00a.h:102
Definition: sam3n4b.h:93
Definition: sam3n4b.h:87
Definition: sam3n4b.h:91
Definition: sam3n4b.h:77
Definition: sam3n4b.h:86
IRQn
Definition: ARMCM0.h:35
Definition: sam3n4b.h:74
void SysTick_Handler(void)
SysTick_Handler.
Definition: main.c:78
void HardFault_Handler(void)
Definition: FreeRTOS_ARM.c:99
Definition: sam3n4b.h:84
Definition: sam3n4b.h:70
enum IRQn IRQn_Type
Definition: sam3n4b.h:82
volatile uint32_t WoReg
Definition: sam3n4b.h:53
CMSIS Cortex-M3 Core Peripheral Access Layer Header File.
volatile const uint32_t RoReg
Definition: sam3n4b.h:49
Definition: sam3n4b.h:89
void BusFault_Handler(void)
Definition: FreeRTOS_ARM.c:104
Definition: sam3n4b.h:90
Definition: sam3n4b.h:96
Definition: sam3n4b.h:69
Definition: sam3n4b.h:95
Definition: sam3n4b.h:94
Definition: sam3n4b.h:85
Definition: sam3n4b.h:79
Definition: sam3n4b.h:78
Definition: sam3n4b.h:67
Definition: sam3n4b.h:80
Definition: sam3n4b.h:88
Definition: sam3n4b.h:92
Definition: sam3n4b.h:73
Definition: sam3n4b.h:98
volatile uint32_t RwReg
Definition: sam3n4b.h:54
Definition: sam3n4b.h:68
void Reset_Handler(void)
This is the code that gets called on processor reset. To initialize the device, and call the main() r...
Definition: startup_sam3n.c:172
Definition: sam3n4b.h:81
Definition: sam3n4b.h:100