Robobo
sam3u2c.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 _SAM3U2C_
31 #define _SAM3U2C_
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 SAM3U2C */
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 /****** SAM3U2C 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  EFC0_IRQn = 6,
84  EFC1_IRQn = 7,
85  UART_IRQn = 8,
86  SMC_IRQn = 9,
87  PIOA_IRQn = 10,
88  PIOB_IRQn = 11,
89  USART0_IRQn = 13,
90  USART1_IRQn = 14,
91  USART2_IRQn = 15,
92  HSMCI_IRQn = 17,
93  TWI0_IRQn = 18,
94  TWI1_IRQn = 19,
95  SPI_IRQn = 20,
96  SSC_IRQn = 21,
97  TC0_IRQn = 22,
98  TC1_IRQn = 23,
99  TC2_IRQn = 24,
100  PWM_IRQn = 25,
101  ADC12B_IRQn = 26,
102  ADC_IRQn = 27,
103  DMAC_IRQn = 28,
104  UDPHS_IRQn = 29,
107 } IRQn_Type;
108 
109 typedef struct _DeviceVectors
110 {
111  /* Stack pointer */
112  void* pvStack;
113 
114  /* Cortex-M handlers */
115  void* pfnReset_Handler;
116  void* pfnNMI_Handler;
117  void* pfnHardFault_Handler;
118  void* pfnMemManage_Handler;
119  void* pfnBusFault_Handler;
120  void* pfnUsageFault_Handler;
121  void* pfnReserved1_Handler;
122  void* pfnReserved2_Handler;
123  void* pfnReserved3_Handler;
124  void* pfnReserved4_Handler;
125  void* pfnSVC_Handler;
126  void* pfnDebugMon_Handler;
127  void* pfnReserved5_Handler;
128  void* pfnPendSV_Handler;
129  void* pfnSysTick_Handler;
130 
131  /* Peripheral handlers */
132  void* pfnSUPC_Handler; /* 0 Supply Controller */
133  void* pfnRSTC_Handler; /* 1 Reset Controller */
134  void* pfnRTC_Handler; /* 2 Real Time Clock */
135  void* pfnRTT_Handler; /* 3 Real Time Timer */
136  void* pfnWDT_Handler; /* 4 Watchdog Timer */
137  void* pfnPMC_Handler; /* 5 Power Management Controller */
138  void* pfnEFC0_Handler; /* 6 Enhanced Embedded Flash Controller 0 */
139  void* pfnEFC1_Handler; /* 7 Enhanced Embedded Flash Controller 1 */
140  void* pfnUART_Handler; /* 8 Universal Asynchronous Receiver Transmitter */
141  void* pfnSMC_Handler; /* 9 Static Memory Controller */
142  void* pfnPIOA_Handler; /* 10 Parallel I/O Controller A, */
143  void* pfnPIOB_Handler; /* 11 Parallel I/O Controller B */
144  void* pvReserved12;
145  void* pfnUSART0_Handler; /* 13 USART 0 */
146  void* pfnUSART1_Handler; /* 14 USART 1 */
147  void* pfnUSART2_Handler; /* 15 USART 2 */
148  void* pvReserved16;
149  void* pfnHSMCI_Handler; /* 17 High Speed Multimedia Card Interface */
150  void* pfnTWI0_Handler; /* 18 Two-Wire Interface 0 */
151  void* pfnTWI1_Handler; /* 19 Two-Wire Interface 1 */
152  void* pfnSPI_Handler; /* 20 Serial Peripheral Interface */
153  void* pfnSSC_Handler; /* 21 Synchronous Serial Controller */
154  void* pfnTC0_Handler; /* 22 Timer Counter 0 */
155  void* pfnTC1_Handler; /* 23 Timer Counter 1 */
156  void* pfnTC2_Handler; /* 24 Timer Counter 2 */
157  void* pfnPWM_Handler; /* 25 Pulse Width Modulation Controller */
158  void* pfnADC12B_Handler; /* 26 12-bit ADC Controller */
159  void* pfnADC_Handler; /* 27 10-bit ADC Controller */
160  void* pfnDMAC_Handler; /* 28 DMA Controller */
161  void* pfnUDPHS_Handler; /* 29 USB Device High Speed */
162 } DeviceVectors;
163 
164 /* Cortex-M3 core handlers */
165 void Reset_Handler ( void );
166 void NMI_Handler ( void );
167 void HardFault_Handler ( void );
168 void MemManage_Handler ( void );
169 void BusFault_Handler ( void );
170 void UsageFault_Handler ( void );
171 void SVC_Handler ( void );
172 void DebugMon_Handler ( void );
173 void PendSV_Handler ( void );
174 void SysTick_Handler ( void );
175 
176 /* Peripherals handlers */
177 void ADC_Handler ( void );
178 void ADC12B_Handler ( void );
179 void DMAC_Handler ( void );
180 void EFC0_Handler ( void );
181 void EFC1_Handler ( void );
182 void HSMCI_Handler ( void );
183 void PIOA_Handler ( void );
184 void PIOB_Handler ( void );
185 void PMC_Handler ( void );
186 void PWM_Handler ( void );
187 void RSTC_Handler ( void );
188 void RTC_Handler ( void );
189 void RTT_Handler ( void );
190 void SMC_Handler ( void );
191 void SPI_Handler ( void );
192 void SSC_Handler ( void );
193 void SUPC_Handler ( void );
194 void TC0_Handler ( void );
195 void TC1_Handler ( void );
196 void TC2_Handler ( void );
197 void TWI0_Handler ( void );
198 void TWI1_Handler ( void );
199 void UART_Handler ( void );
200 void UDPHS_Handler ( void );
201 void USART0_Handler ( void );
202 void USART1_Handler ( void );
203 void USART2_Handler ( void );
204 void WDT_Handler ( void );
205 
210 #define __CM3_REV 0x0200
211 #define __MPU_PRESENT 1
212 #define __NVIC_PRIO_BITS 4
213 #define __Vendor_SysTickConfig 0
215 /*
216  * \brief CMSIS includes
217  */
218 
219 #include <core_cm3.h>
220 #if !defined DONT_USE_CMSIS_INIT
221 #include "system_sam3u.h"
222 #endif /* DONT_USE_CMSIS_INIT */
223 
226 /* ************************************************************************** */
228 /* ************************************************************************** */
231 
232 #include "component/component_adc.h"
233 #include "component/component_adc12b.h"
234 #include "component/component_chipid.h"
235 #include "component/component_dmac.h"
236 #include "component/component_efc.h"
237 #include "component/component_gpbr.h"
238 #include "component/component_hsmci.h"
239 #include "component/component_matrix.h"
240 #include "component/component_pdc.h"
241 #include "component/component_pio.h"
242 #include "component/component_pmc.h"
243 #include "component/component_pwm.h"
244 #include "component/component_rstc.h"
245 #include "component/component_rtc.h"
246 #include "component/component_rtt.h"
247 #include "component/component_smc.h"
248 #include "component/component_spi.h"
249 #include "component/component_ssc.h"
250 #include "component/component_supc.h"
251 #include "component/component_tc.h"
252 #include "component/component_twi.h"
253 #include "component/component_uart.h"
254 #include "component/component_udphs.h"
255 #include "component/component_usart.h"
256 #include "component/component_wdt.h"
259 /* ************************************************************************** */
260 /* REGISTER ACCESS DEFINITIONS FOR SAM3U2C */
261 /* ************************************************************************** */
264 
265 #include "instance/instance_hsmci.h"
266 #include "instance/instance_ssc.h"
267 #include "instance/instance_spi.h"
268 #include "instance/instance_tc0.h"
269 #include "instance/instance_twi0.h"
270 #include "instance/instance_twi1.h"
271 #include "instance/instance_pwm.h"
272 #include "instance/instance_usart0.h"
273 #include "instance/instance_usart1.h"
274 #include "instance/instance_usart2.h"
275 #include "instance/instance_udphs.h"
276 #include "instance/instance_adc12b.h"
277 #include "instance/instance_adc.h"
278 #include "instance/instance_dmac.h"
279 #include "instance/instance_smc.h"
280 #include "instance/instance_matrix.h"
281 #include "instance/instance_pmc.h"
282 #include "instance/instance_uart.h"
283 #include "instance/instance_chipid.h"
284 #include "instance/instance_efc0.h"
285 #include "instance/instance_efc1.h"
286 #include "instance/instance_pioa.h"
287 #include "instance/instance_piob.h"
288 #include "instance/instance_rstc.h"
289 #include "instance/instance_supc.h"
290 #include "instance/instance_rtt.h"
291 #include "instance/instance_wdt.h"
292 #include "instance/instance_rtc.h"
293 #include "instance/instance_gpbr.h"
296 /* ************************************************************************** */
297 /* PERIPHERAL ID DEFINITIONS FOR SAM3U2C */
298 /* ************************************************************************** */
301 
302 #define ID_SUPC ( 0)
303 #define ID_RSTC ( 1)
304 #define ID_RTC ( 2)
305 #define ID_RTT ( 3)
306 #define ID_WDT ( 4)
307 #define ID_PMC ( 5)
308 #define ID_EFC0 ( 6)
309 #define ID_EFC1 ( 7)
310 #define ID_UART ( 8)
311 #define ID_SMC ( 9)
312 #define ID_PIOA (10)
313 #define ID_PIOB (11)
314 #define ID_USART0 (13)
315 #define ID_USART1 (14)
316 #define ID_USART2 (15)
317 #define ID_HSMCI (17)
318 #define ID_TWI0 (18)
319 #define ID_TWI1 (19)
320 #define ID_SPI (20)
321 #define ID_SSC (21)
322 #define ID_TC0 (22)
323 #define ID_TC1 (23)
324 #define ID_TC2 (24)
325 #define ID_PWM (25)
326 #define ID_ADC12B (26)
327 #define ID_ADC (27)
328 #define ID_DMAC (28)
329 #define ID_UDPHS (29)
331 #define ID_PERIPH_COUNT (30)
333 
334 /* ************************************************************************** */
335 /* BASE ADDRESS DEFINITIONS FOR SAM3U2C */
336 /* ************************************************************************** */
339 
340 #if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
341 #define HSMCI (0x40000000U)
342 #define SSC (0x40004000U)
343 #define SPI (0x40008000U)
344 #define TC0 (0x40080000U)
345 #define TWI0 (0x40084000U)
346 #define PDC_TWI0 (0x40084100U)
347 #define TWI1 (0x40088000U)
348 #define PDC_TWI1 (0x40088100U)
349 #define PWM (0x4008C000U)
350 #define PDC_PWM (0x4008C100U)
351 #define USART0 (0x40090000U)
352 #define PDC_USART0 (0x40090100U)
353 #define USART1 (0x40094000U)
354 #define PDC_USART1 (0x40094100U)
355 #define USART2 (0x40098000U)
356 #define PDC_USART2 (0x40098100U)
357 #define UDPHS (0x400A4000U)
358 #define ADC12B (0x400A8000U)
359 #define PDC_ADC12B (0x400A8100U)
360 #define ADC (0x400AC000U)
361 #define PDC_ADC (0x400AC100U)
362 #define DMAC (0x400B0000U)
363 #define SMC (0x400E0000U)
364 #define MATRIX (0x400E0200U)
365 #define PMC (0x400E0400U)
366 #define UART (0x400E0600U)
367 #define PDC_UART (0x400E0700U)
368 #define CHIPID (0x400E0740U)
369 #define EFC0 (0x400E0800U)
370 #define EFC1 (0x400E0A00U)
371 #define PIOA (0x400E0C00U)
372 #define PIOB (0x400E0E00U)
373 #define RSTC (0x400E1200U)
374 #define SUPC (0x400E1210U)
375 #define RTT (0x400E1230U)
376 #define WDT (0x400E1250U)
377 #define RTC (0x400E1260U)
378 #define GPBR (0x400E1290U)
379 #else
380 #define HSMCI ((Hsmci *)0x40000000U)
381 #define SSC ((Ssc *)0x40004000U)
382 #define SPI ((Spi *)0x40008000U)
383 #define TC0 ((Tc *)0x40080000U)
384 #define TWI0 ((Twi *)0x40084000U)
385 #define PDC_TWI0 ((Pdc *)0x40084100U)
386 #define TWI1 ((Twi *)0x40088000U)
387 #define PDC_TWI1 ((Pdc *)0x40088100U)
388 #define PWM ((Pwm *)0x4008C000U)
389 #define PDC_PWM ((Pdc *)0x4008C100U)
390 #define USART0 ((Usart *)0x40090000U)
391 #define PDC_USART0 ((Pdc *)0x40090100U)
392 #define USART1 ((Usart *)0x40094000U)
393 #define PDC_USART1 ((Pdc *)0x40094100U)
394 #define USART2 ((Usart *)0x40098000U)
395 #define PDC_USART2 ((Pdc *)0x40098100U)
396 #define UDPHS ((Udphs *)0x400A4000U)
397 #define ADC12B ((Adc12b *)0x400A8000U)
398 #define PDC_ADC12B ((Pdc *)0x400A8100U)
399 #define ADC ((Adc *)0x400AC000U)
400 #define PDC_ADC ((Pdc *)0x400AC100U)
401 #define DMAC ((Dmac *)0x400B0000U)
402 #define SMC ((Smc *)0x400E0000U)
403 #define MATRIX ((Matrix *)0x400E0200U)
404 #define PMC ((Pmc *)0x400E0400U)
405 #define UART ((Uart *)0x400E0600U)
406 #define PDC_UART ((Pdc *)0x400E0700U)
407 #define CHIPID ((Chipid *)0x400E0740U)
408 #define EFC0 ((Efc *)0x400E0800U)
409 #define EFC1 ((Efc *)0x400E0A00U)
410 #define PIOA ((Pio *)0x400E0C00U)
411 #define PIOB ((Pio *)0x400E0E00U)
412 #define RSTC ((Rstc *)0x400E1200U)
413 #define SUPC ((Supc *)0x400E1210U)
414 #define RTT ((Rtt *)0x400E1230U)
415 #define WDT ((Wdt *)0x400E1250U)
416 #define RTC ((Rtc *)0x400E1260U)
417 #define GPBR ((Gpbr *)0x400E1290U)
418 #endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
419 
421 /* ************************************************************************** */
422 /* PIO DEFINITIONS FOR SAM3U2C */
423 /* ************************************************************************** */
426 
427 #include "pio/pio_sam3u2c.h"
430 /* ************************************************************************** */
431 /* MEMORY MAPPING DEFINITIONS FOR SAM3U2C */
432 /* ************************************************************************** */
433 
434 #define IFLASH0_SIZE (0x20000u)
435 #define IFLASH0_PAGE_SIZE (256u)
436 #define IFLASH0_LOCK_REGION_SIZE (8192u)
437 #define IFLASH0_NB_OF_PAGES (512u)
438 #define IRAM0_SIZE (0x4000u)
439 #define IRAM1_SIZE (0x4000u)
440 #define NFCRAM_SIZE (0x1000u)
441 #define IFLASH_SIZE (IFLASH0_SIZE)
442 #define IRAM_SIZE (IRAM0_SIZE+IRAM1_SIZE)
443 
444 #define IFLASH0_ADDR (0x00080000u)
445 #define IROM_ADDR (0x00180000u)
446 #define IRAM0_ADDR (0x20000000u)
447 #define IRAM1_ADDR (0x20080000u)
448 #define NFC_RAM_ADDR (0x20100000u)
449 #define UDPHS_RAM_ADDR (0x20180000u)
451 /* ************************************************************************** */
452 /* ELECTRICAL DEFINITIONS FOR SAM3U2C */
453 /* ************************************************************************** */
454 
455 /* Device characteristics */
456 #define CHIP_FREQ_SLCK_RC_MIN (20000UL)
457 #define CHIP_FREQ_SLCK_RC (32000UL)
458 #define CHIP_FREQ_SLCK_RC_MAX (44000UL)
459 #define CHIP_FREQ_MAINCK_RC_4MHZ (4000000UL)
460 #define CHIP_FREQ_MAINCK_RC_8MHZ (8000000UL)
461 #define CHIP_FREQ_MAINCK_RC_12MHZ (12000000UL)
462 #define CHIP_FREQ_CPU_MAX (96000000UL)
463 #define CHIP_FREQ_XTAL_32K (32768UL)
464 #define CHIP_FREQ_XTAL_12M (12000000UL)
465 
466 /* Embedded Flash Write Wait State */
467 #define CHIP_FLASH_WRITE_WAIT_STATE (6U)
468 
469 /* Embedded Flash Read Wait State (VDDCORE set at 1.65V) */
470 #define CHIP_FREQ_FWS_0 (24000000UL)
471 #define CHIP_FREQ_FWS_1 (40000000UL)
472 #define CHIP_FREQ_FWS_2 (72000000UL)
473 #define CHIP_FREQ_FWS_3 (84000000UL)
476 #ifdef __cplusplus
477 }
478 #endif
479 
482 #endif /* _SAM3U2C_ */
Definition: sam3u2c.h:71
Definition: sam3u2c.h:91
volatile uint32_t WoReg
Definition: sam3u2c.h:53
Definition: sam3u2c.h:72
Definition: sam3u2c.h:101
Definition: sam3n00a.h:102
Definition: sam3u2c.h:97
Definition: sam3u2c.h:88
Definition: sam3u2c.h:94
Definition: sam3u2c.h:77
Definition: sam3u2c.h:104
Definition: sam3u2c.h:84
Definition: sam3u2c.h:87
volatile const uint32_t RoReg
Definition: sam3u2c.h:49
IRQn
Definition: ARMCM0.h:35
Definition: sam3u2c.h:74
Definition: sam3u2c.h:70
Definition: sam3u2c.h:82
CMSIS Cortex-M3 Core Peripheral Access Layer Header File.
void HardFault_Handler(void)
Definition: FreeRTOS_ARM.c:99
enum IRQn IRQn_Type
Definition: sam3u2c.h:90
Definition: sam3u2c.h:92
Definition: sam3u2c.h:93
Definition: sam3u2c.h:102
Definition: sam3u2c.h:69
Definition: sam3u2c.h:99
Definition: sam3u2c.h:98
volatile uint32_t RwReg
Definition: sam3u2c.h:54
Definition: sam3u2c.h:79
Definition: sam3u2c.h:78
void BusFault_Handler(void)
Definition: FreeRTOS_ARM.c:104
void UsageFault_Handler(void)
Definition: FreeRTOS_ARM.c:109
Definition: sam3u2c.h:67
Definition: sam3u2c.h:80
Definition: sam3u2c.h:83
Definition: sam3u2c.h:89
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: sam3u2c.h:95
Definition: sam3u2c.h:73
Definition: sam3u2c.h:100
Definition: sam3u2c.h:86
Definition: sam3u2c.h:96
Definition: sam3u2c.h:85
Definition: sam3u2c.h:68
Definition: sam3u2c.h:81
void SysTick_Handler(void)
SysTick_Handler.
Definition: main.c:78
CMSIS Cortex-M# Device Peripheral Access Layer Header File for SAM3 devices.
Definition: sam3u2c.h:103
Definition: sam3u2c.h:106