Robobo
sam3s8b.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 _SAM3S8B_
31 #define _SAM3S8B_
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 SAM3S8B */
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 /****** SAM3S8B 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  HSMCI_IRQn = 18,
91  TWI0_IRQn = 19,
92  TWI1_IRQn = 20,
93  SPI_IRQn = 21,
94  SSC_IRQn = 22,
95  TC0_IRQn = 23,
96  TC1_IRQn = 24,
97  TC2_IRQn = 25,
98  ADC_IRQn = 29,
99  DACC_IRQn = 30,
100  PWM_IRQn = 31,
101  CRCCU_IRQn = 32,
102  ACC_IRQn = 33,
103  UDP_IRQn = 34,
106 } IRQn_Type;
107 
108 typedef struct _DeviceVectors
109 {
110  /* Stack pointer */
111  void* pvStack;
112 
113  /* Cortex-M handlers */
114  void* pfnReset_Handler;
115  void* pfnNMI_Handler;
116  void* pfnHardFault_Handler;
117  void* pfnMemManage_Handler;
118  void* pfnBusFault_Handler;
119  void* pfnUsageFault_Handler;
120  void* pfnReserved1_Handler;
121  void* pfnReserved2_Handler;
122  void* pfnReserved3_Handler;
123  void* pfnReserved4_Handler;
124  void* pfnSVC_Handler;
125  void* pfnDebugMon_Handler;
126  void* pfnReserved5_Handler;
127  void* pfnPendSV_Handler;
128  void* pfnSysTick_Handler;
129 
130  /* Peripheral handlers */
131  void* pfnSUPC_Handler; /* 0 Supply Controller */
132  void* pfnRSTC_Handler; /* 1 Reset Controller */
133  void* pfnRTC_Handler; /* 2 Real Time Clock */
134  void* pfnRTT_Handler; /* 3 Real Time Timer */
135  void* pfnWDT_Handler; /* 4 Watchdog Timer */
136  void* pfnPMC_Handler; /* 5 Power Management Controller */
137  void* pfnEFC_Handler; /* 6 Enhanced Embedded Flash Controller */
138  void* pvReserved7;
139  void* pfnUART0_Handler; /* 8 UART 0 */
140  void* pfnUART1_Handler; /* 9 UART 1 */
141  void* pvReserved10;
142  void* pfnPIOA_Handler; /* 11 Parallel I/O Controller A */
143  void* pfnPIOB_Handler; /* 12 Parallel I/O Controller B */
144  void* pvReserved13;
145  void* pfnUSART0_Handler; /* 14 USART 0 */
146  void* pfnUSART1_Handler; /* 15 USART 1 */
147  void* pvReserved16;
148  void* pvReserved17;
149  void* pfnHSMCI_Handler; /* 18 Multimedia Card Interface */
150  void* pfnTWI0_Handler; /* 19 Two Wire Interface 0 */
151  void* pfnTWI1_Handler; /* 20 Two Wire Interface 1 */
152  void* pfnSPI_Handler; /* 21 Serial Peripheral Interface */
153  void* pfnSSC_Handler; /* 22 Synchronous Serial Controler */
154  void* pfnTC0_Handler; /* 23 Timer/Counter 0 */
155  void* pfnTC1_Handler; /* 24 Timer/Counter 1 */
156  void* pfnTC2_Handler; /* 25 Timer/Counter 2 */
157  void* pvReserved26;
158  void* pvReserved27;
159  void* pvReserved28;
160  void* pfnADC_Handler; /* 29 Analog To Digital Converter */
161  void* pfnDACC_Handler; /* 30 Digital To Analog Converter */
162  void* pfnPWM_Handler; /* 31 Pulse Width Modulation */
163  void* pfnCRCCU_Handler; /* 32 CRC Calculation Unit */
164  void* pfnACC_Handler; /* 33 Analog Comparator */
165  void* pfnUDP_Handler; /* 34 USB Device Port */
166 } DeviceVectors;
167 
168 /* Cortex-M3 core handlers */
169 void Reset_Handler ( void );
170 void NMI_Handler ( void );
171 void HardFault_Handler ( void );
172 void MemManage_Handler ( void );
173 void BusFault_Handler ( void );
174 void UsageFault_Handler ( void );
175 void SVC_Handler ( void );
176 void DebugMon_Handler ( void );
177 void PendSV_Handler ( void );
178 void SysTick_Handler ( void );
179 
180 /* Peripherals handlers */
181 void ACC_Handler ( void );
182 void ADC_Handler ( void );
183 void CRCCU_Handler ( void );
184 void DACC_Handler ( void );
185 void EFC_Handler ( void );
186 void HSMCI_Handler ( void );
187 void PIOA_Handler ( void );
188 void PIOB_Handler ( void );
189 void PMC_Handler ( void );
190 void PWM_Handler ( void );
191 void RSTC_Handler ( void );
192 void RTC_Handler ( void );
193 void RTT_Handler ( void );
194 void SPI_Handler ( void );
195 void SSC_Handler ( void );
196 void SUPC_Handler ( void );
197 void TC0_Handler ( void );
198 void TC1_Handler ( void );
199 void TC2_Handler ( void );
200 void TWI0_Handler ( void );
201 void TWI1_Handler ( void );
202 void UART0_Handler ( void );
203 void UART1_Handler ( void );
204 void UDP_Handler ( void );
205 void USART0_Handler ( void );
206 void USART1_Handler ( void );
207 void WDT_Handler ( void );
208 
213 #define __CM3_REV 0x0200
214 #define __MPU_PRESENT 1
215 #define __NVIC_PRIO_BITS 4
216 #define __Vendor_SysTickConfig 0
218 /*
219  * \brief CMSIS includes
220  */
221 
222 #include <core_cm3.h>
223 #if !defined DONT_USE_CMSIS_INIT
224 #include "system_sam3sd8.h"
225 #endif /* DONT_USE_CMSIS_INIT */
226 
229 /* ************************************************************************** */
231 /* ************************************************************************** */
234 
235 #include "component/component_acc.h"
236 #include "component/component_adc.h"
237 #include "component/component_chipid.h"
238 #include "component/component_crccu.h"
239 #include "component/component_dacc.h"
240 #include "component/component_efc.h"
241 #include "component/component_gpbr.h"
242 #include "component/component_hsmci.h"
243 #include "component/component_matrix.h"
244 #include "component/component_pdc.h"
245 #include "component/component_pio.h"
246 #include "component/component_pmc.h"
247 #include "component/component_pwm.h"
248 #include "component/component_rstc.h"
249 #include "component/component_rtc.h"
250 #include "component/component_rtt.h"
251 #include "component/component_spi.h"
252 #include "component/component_ssc.h"
253 #include "component/component_supc.h"
254 #include "component/component_tc.h"
255 #include "component/component_twi.h"
256 #include "component/component_uart.h"
257 #include "component/component_udp.h"
258 #include "component/component_usart.h"
259 #include "component/component_wdt.h"
262 /* ************************************************************************** */
263 /* REGISTER ACCESS DEFINITIONS FOR SAM3S8B */
264 /* ************************************************************************** */
267 
268 #include "instance/instance_hsmci.h"
269 #include "instance/instance_ssc.h"
270 #include "instance/instance_spi.h"
271 #include "instance/instance_tc0.h"
272 #include "instance/instance_twi0.h"
273 #include "instance/instance_twi1.h"
274 #include "instance/instance_pwm.h"
275 #include "instance/instance_usart0.h"
276 #include "instance/instance_usart1.h"
277 #include "instance/instance_udp.h"
278 #include "instance/instance_adc.h"
279 #include "instance/instance_dacc.h"
280 #include "instance/instance_acc.h"
281 #include "instance/instance_crccu.h"
282 #include "instance/instance_matrix.h"
283 #include "instance/instance_pmc.h"
284 #include "instance/instance_uart0.h"
285 #include "instance/instance_chipid.h"
286 #include "instance/instance_uart1.h"
287 #include "instance/instance_efc.h"
288 #include "instance/instance_pioa.h"
289 #include "instance/instance_piob.h"
290 #include "instance/instance_rstc.h"
291 #include "instance/instance_supc.h"
292 #include "instance/instance_rtt.h"
293 #include "instance/instance_wdt.h"
294 #include "instance/instance_rtc.h"
295 #include "instance/instance_gpbr.h"
298 /* ************************************************************************** */
299 /* PERIPHERAL ID DEFINITIONS FOR SAM3S8B */
300 /* ************************************************************************** */
303 
304 #define ID_SUPC ( 0)
305 #define ID_RSTC ( 1)
306 #define ID_RTC ( 2)
307 #define ID_RTT ( 3)
308 #define ID_WDT ( 4)
309 #define ID_PMC ( 5)
310 #define ID_EFC ( 6)
311 #define ID_UART0 ( 8)
312 #define ID_UART1 ( 9)
313 #define ID_PIOA (11)
314 #define ID_PIOB (12)
315 #define ID_USART0 (14)
316 #define ID_USART1 (15)
317 #define ID_HSMCI (18)
318 #define ID_TWI0 (19)
319 #define ID_TWI1 (20)
320 #define ID_SPI (21)
321 #define ID_SSC (22)
322 #define ID_TC0 (23)
323 #define ID_TC1 (24)
324 #define ID_TC2 (25)
325 #define ID_ADC (29)
326 #define ID_DACC (30)
327 #define ID_PWM (31)
328 #define ID_CRCCU (32)
329 #define ID_ACC (33)
330 #define ID_UDP (34)
332 #define ID_PERIPH_COUNT (35)
334 
335 /* ************************************************************************** */
336 /* BASE ADDRESS DEFINITIONS FOR SAM3S8B */
337 /* ************************************************************************** */
340 
341 #if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
342 #define HSMCI (0x40000000U)
343 #define PDC_HSMCI (0x40000100U)
344 #define SSC (0x40004000U)
345 #define PDC_SSC (0x40004100U)
346 #define SPI (0x40008000U)
347 #define PDC_SPI (0x40008100U)
348 #define TC0 (0x40010000U)
349 #define TWI0 (0x40018000U)
350 #define PDC_TWI0 (0x40018100U)
351 #define TWI1 (0x4001C000U)
352 #define PDC_TWI1 (0x4001C100U)
353 #define PWM (0x40020000U)
354 #define PDC_PWM (0x40020100U)
355 #define USART0 (0x40024000U)
356 #define PDC_USART0 (0x40024100U)
357 #define USART1 (0x40028000U)
358 #define PDC_USART1 (0x40028100U)
359 #define UDP (0x40034000U)
360 #define ADC (0x40038000U)
361 #define PDC_ADC (0x40038100U)
362 #define DACC (0x4003C000U)
363 #define PDC_DACC (0x4003C100U)
364 #define ACC (0x40040000U)
365 #define CRCCU (0x40044000U)
366 #define MATRIX (0x400E0200U)
367 #define PMC (0x400E0400U)
368 #define UART0 (0x400E0600U)
369 #define PDC_UART0 (0x400E0700U)
370 #define CHIPID (0x400E0740U)
371 #define UART1 (0x400E0800U)
372 #define PDC_UART1 (0x400E0900U)
373 #define EFC (0x400E0A00U)
374 #define PIOA (0x400E0E00U)
375 #define PDC_PIOA (0x400E0F68U)
376 #define PIOB (0x400E1000U)
377 #define RSTC (0x400E1400U)
378 #define SUPC (0x400E1410U)
379 #define RTT (0x400E1430U)
380 #define WDT (0x400E1450U)
381 #define RTC (0x400E1460U)
382 #define GPBR (0x400E1490U)
383 #else
384 #define HSMCI ((Hsmci *)0x40000000U)
385 #define PDC_HSMCI ((Pdc *)0x40000100U)
386 #define SSC ((Ssc *)0x40004000U)
387 #define PDC_SSC ((Pdc *)0x40004100U)
388 #define SPI ((Spi *)0x40008000U)
389 #define PDC_SPI ((Pdc *)0x40008100U)
390 #define TC0 ((Tc *)0x40010000U)
391 #define TWI0 ((Twi *)0x40018000U)
392 #define PDC_TWI0 ((Pdc *)0x40018100U)
393 #define TWI1 ((Twi *)0x4001C000U)
394 #define PDC_TWI1 ((Pdc *)0x4001C100U)
395 #define PWM ((Pwm *)0x40020000U)
396 #define PDC_PWM ((Pdc *)0x40020100U)
397 #define USART0 ((Usart *)0x40024000U)
398 #define PDC_USART0 ((Pdc *)0x40024100U)
399 #define USART1 ((Usart *)0x40028000U)
400 #define PDC_USART1 ((Pdc *)0x40028100U)
401 #define UDP ((Udp *)0x40034000U)
402 #define ADC ((Adc *)0x40038000U)
403 #define PDC_ADC ((Pdc *)0x40038100U)
404 #define DACC ((Dacc *)0x4003C000U)
405 #define PDC_DACC ((Pdc *)0x4003C100U)
406 #define ACC ((Acc *)0x40040000U)
407 #define CRCCU ((Crccu *)0x40044000U)
408 #define MATRIX ((Matrix *)0x400E0200U)
409 #define PMC ((Pmc *)0x400E0400U)
410 #define UART0 ((Uart *)0x400E0600U)
411 #define PDC_UART0 ((Pdc *)0x400E0700U)
412 #define CHIPID ((Chipid *)0x400E0740U)
413 #define UART1 ((Uart *)0x400E0800U)
414 #define PDC_UART1 ((Pdc *)0x400E0900U)
415 #define EFC ((Efc *)0x400E0A00U)
416 #define PIOA ((Pio *)0x400E0E00U)
417 #define PDC_PIOA ((Pdc *)0x400E0F68U)
418 #define PIOB ((Pio *)0x400E1000U)
419 #define RSTC ((Rstc *)0x400E1400U)
420 #define SUPC ((Supc *)0x400E1410U)
421 #define RTT ((Rtt *)0x400E1430U)
422 #define WDT ((Wdt *)0x400E1450U)
423 #define RTC ((Rtc *)0x400E1460U)
424 #define GPBR ((Gpbr *)0x400E1490U)
425 #endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
426 
428 /* ************************************************************************** */
429 /* PIO DEFINITIONS FOR SAM3S8B */
430 /* ************************************************************************** */
433 
434 #include "pio/pio_sam3s8b.h"
437 /* ************************************************************************** */
438 /* MEMORY MAPPING DEFINITIONS FOR SAM3S8B */
439 /* ************************************************************************** */
440 
441 #define IFLASH0_SIZE (0x80000u)
442 #define IFLASH0_PAGE_SIZE (256u)
443 #define IFLASH0_LOCK_REGION_SIZE (16384u)
444 #define IFLASH0_NB_OF_PAGES (2048u)
445 #define IFLASH0_NB_OF_LOCK_BITS (16u)
446 #define IRAM_SIZE (0x10000u)
447 #define IFLASH_SIZE (IFLASH0_SIZE)
448 
449 #define IFLASH_ADDR (0x00400000u)
450 #define IFLASH0_ADDR (0x00400000u)
451 #define IROM_ADDR (0x00800000u)
452 #define IRAM_ADDR (0x20000000u)
453 #define EBI_CS0_ADDR (0x60000000u)
454 #define EBI_CS1_ADDR (0x61000000u)
455 #define EBI_CS2_ADDR (0x62000000u)
456 #define EBI_CS3_ADDR (0x63000000u)
458 /* ************************************************************************** */
459 /* ELECTRICAL DEFINITIONS FOR SAM3S8B */
460 /* ************************************************************************** */
461 
462 /* Device characteristics */
463 #define CHIP_FREQ_SLCK_RC_MIN (20000UL)
464 #define CHIP_FREQ_SLCK_RC (32000UL)
465 #define CHIP_FREQ_SLCK_RC_MAX (44000UL)
466 #define CHIP_FREQ_MAINCK_RC_4MHZ (4000000UL)
467 #define CHIP_FREQ_MAINCK_RC_8MHZ (8000000UL)
468 #define CHIP_FREQ_MAINCK_RC_12MHZ (12000000UL)
469 #define CHIP_FREQ_CPU_MAX (64000000UL)
470 #define CHIP_FREQ_XTAL_32K (32768UL)
471 #define CHIP_FREQ_XTAL_12M (12000000UL)
472 
473 /* Embedded Flash Write Wait State */
474 #define CHIP_FLASH_WRITE_WAIT_STATE (6U)
475 
476 /* Embedded Flash Read Wait State (VDDCORE set at 1.65V) */
477 #define CHIP_FREQ_FWS_0 (21000000UL)
478 #define CHIP_FREQ_FWS_1 (35000000UL)
479 #define CHIP_FREQ_FWS_2 (60000000UL)
480 #define CHIP_FREQ_FWS_3 (64000000UL)
483 #ifdef __cplusplus
484 }
485 #endif
486 
489 #endif /* _SAM3S8B_ */
void UsageFault_Handler(void)
Definition: FreeRTOS_ARM.c:109
Definition: sam3s8b.h:71
Definition: sam3s8b.h:83
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: sam3s8b.h:72
enum IRQn IRQn_Type
Definition: sam3s8b.h:99
Definition: sam3n00a.h:102
Definition: sam3s8b.h:95
volatile uint32_t RwReg
Definition: sam3s8b.h:54
Definition: sam3s8b.h:87
Definition: sam3s8b.h:92
Definition: sam3s8b.h:77
Definition: sam3s8b.h:86
IRQn
Definition: ARMCM0.h:35
Definition: sam3s8b.h:74
Definition: sam3s8b.h:84
Definition: sam3s8b.h:70
Definition: sam3s8b.h:82
void SysTick_Handler(void)
SysTick_Handler.
Definition: main.c:78
CMSIS Cortex-M3 Core Peripheral Access Layer Header File.
Definition: sam3s8b.h:89
volatile uint32_t WoReg
Definition: sam3s8b.h:53
Definition: sam3s8b.h:90
Definition: sam3s8b.h:91
Definition: sam3s8b.h:98
Definition: sam3s8b.h:69
Definition: sam3s8b.h:97
Definition: sam3s8b.h:96
Definition: sam3s8b.h:102
Definition: sam3s8b.h:85
Definition: sam3s8b.h:79
Definition: sam3s8b.h:78
Definition: sam3s8b.h:67
Definition: sam3s8b.h:80
volatile const uint32_t RoReg
Definition: sam3s8b.h:49
Definition: sam3s8b.h:88
void HardFault_Handler(void)
Definition: FreeRTOS_ARM.c:99
Definition: sam3s8b.h:93
Definition: sam3s8b.h:73
Definition: sam3s8b.h:100
Definition: sam3s8b.h:94
Definition: sam3s8b.h:68
void BusFault_Handler(void)
Definition: FreeRTOS_ARM.c:104
CMSIS Cortex-M# Device Peripheral Access Layer Header File for SAM3 devices.
Definition: sam3s8b.h:103
Definition: sam3s8b.h:101
Definition: sam3s8b.h:81
Definition: sam3s8b.h:105