mirror of
				https://github.com/digistump/DigistumpArduino.git
				synced 2025-11-03 21:14:46 -08:00 
			
		
		
		
	switch to setup for Arduino Boards Manager
This commit is contained in:
		
							
								
								
									
										113
									
								
								digistump-sam/system/CMSIS/Device/ARM/ARMCM3/Include/ARMCM3.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										113
									
								
								digistump-sam/system/CMSIS/Device/ARM/ARMCM3/Include/ARMCM3.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,113 @@
 | 
			
		||||
/**************************************************************************//**
 | 
			
		||||
 * @file     ARMCM3.h
 | 
			
		||||
 * @brief    CMSIS Cortex-M3 Core Peripheral Access Layer Header File
 | 
			
		||||
 *           for CM3 Device Series
 | 
			
		||||
 * @version  V1.05
 | 
			
		||||
 * @date     26. July 2011
 | 
			
		||||
 *
 | 
			
		||||
 * @note
 | 
			
		||||
 * Copyright (C) 2010-2011 ARM Limited. All rights reserved.
 | 
			
		||||
 *
 | 
			
		||||
 * @par
 | 
			
		||||
 * ARM Limited (ARM) is supplying this software for use with Cortex-M 
 | 
			
		||||
 * processor based microcontrollers.  This file can be freely distributed 
 | 
			
		||||
 * within development tools that are supporting such ARM based processors. 
 | 
			
		||||
 *
 | 
			
		||||
 * @par
 | 
			
		||||
 * THIS SOFTWARE IS PROVIDED "AS IS".  NO WARRANTIES, WHETHER EXPRESS, IMPLIED
 | 
			
		||||
 * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
 | 
			
		||||
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
 | 
			
		||||
 * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
 | 
			
		||||
 * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
 | 
			
		||||
 *
 | 
			
		||||
 ******************************************************************************/
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#ifndef ARMCM3_H
 | 
			
		||||
#define ARMCM3_H
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * ==========================================================================
 | 
			
		||||
 * ---------- Interrupt Number Definition -----------------------------------
 | 
			
		||||
 * ==========================================================================
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
typedef enum IRQn
 | 
			
		||||
{
 | 
			
		||||
/******  Cortex-M3 Processor Exceptions Numbers ***************************************************/
 | 
			
		||||
  NonMaskableInt_IRQn         = -14,    /*!<  2 Cortex-M3 Non Maskable Interrupt                  */
 | 
			
		||||
  HardFault_IRQn              = -13,    /*!<  3 Cortex-M3 Hard Fault Interrupt                    */
 | 
			
		||||
  MemoryManagement_IRQn       = -12,    /*!<  4 Cortex-M3 Memory Management Interrupt             */
 | 
			
		||||
  BusFault_IRQn               = -11,    /*!<  5 Cortex-M3 Bus Fault Interrupt                     */
 | 
			
		||||
  UsageFault_IRQn             = -10,    /*!<  6 Cortex-M3 Usage Fault Interrupt                   */
 | 
			
		||||
  SVCall_IRQn                 = -5,     /*!< 11 Cortex-M3 SV Call Interrupt                       */
 | 
			
		||||
  DebugMonitor_IRQn           = -4,     /*!< 12 Cortex-M3 Debug Monitor Interrupt                 */
 | 
			
		||||
  PendSV_IRQn                 = -2,     /*!< 14 Cortex-M3 Pend SV Interrupt                       */
 | 
			
		||||
  SysTick_IRQn                = -1,     /*!< 15 Cortex-M3 System Tick Interrupt                   */
 | 
			
		||||
 | 
			
		||||
/******  ARMCM3 specific Interrupt Numbers ********************************************************/
 | 
			
		||||
  GPIO_IRQn                   = 0       /*!< GPIO Interrupt                                       */
 | 
			
		||||
} IRQn_Type;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * ==========================================================================
 | 
			
		||||
 * ----------- Processor and Core Peripheral Section ------------------------
 | 
			
		||||
 * ==========================================================================
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
/* Configuration of the Cortex-M3 Processor and Core Peripherals */
 | 
			
		||||
#define __CM3_REV                 0x0201    /*!< Core Revision r2p1                               */
 | 
			
		||||
#define __MPU_PRESENT             1         /*!< MPU present or not                               */
 | 
			
		||||
#define __NVIC_PRIO_BITS          3         /*!< Number of Bits used for Priority Levels          */
 | 
			
		||||
#define __Vendor_SysTickConfig    0         /*!< Set to 1 if different SysTick Config is used     */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#include <core_cm3.h>                       /* Cortex-M3 processor and core peripherals           */
 | 
			
		||||
#include "system_ARMCM3.h"                  /* System Header                                      */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/******************************************************************************/
 | 
			
		||||
/*                Device Specific Peripheral registers structures             */
 | 
			
		||||
/******************************************************************************/
 | 
			
		||||
 | 
			
		||||
/*--------------------- General Purpose Input and Ouptut ---------------------*/
 | 
			
		||||
typedef union
 | 
			
		||||
{
 | 
			
		||||
  __IO uint32_t WORD;  
 | 
			
		||||
  __IO uint8_t  BYTE[4];
 | 
			
		||||
} GPIO_Data_TypeDef;
 | 
			
		||||
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  GPIO_Data_TypeDef DATA [256];
 | 
			
		||||
  __O uint32_t  DIR;
 | 
			
		||||
  uint32_t      RESERVED[3];
 | 
			
		||||
  __O uint32_t  IE;
 | 
			
		||||
} ARM_GPIO_TypeDef;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/******************************************************************************/
 | 
			
		||||
/*                         Peripheral memory map                              */
 | 
			
		||||
/******************************************************************************/
 | 
			
		||||
/* Peripheral and SRAM base address */
 | 
			
		||||
#define ARM_SRAM_BASE             ((     uint32_t)0x20000000UL)
 | 
			
		||||
#define ARM_PERIPH_BASE           ((     uint32_t)0x40000000UL)
 | 
			
		||||
 | 
			
		||||
/* Peripheral memory map */
 | 
			
		||||
#define ARM_GPIO_BASE              ARM_PERIPH_BASE
 | 
			
		||||
 | 
			
		||||
#define ARM_GPIO0_BASE            (ARM_GPIO_BASE)
 | 
			
		||||
#define ARM_GPIO1_BASE            (ARM_GPIO_BASE       + 0x0800UL)
 | 
			
		||||
#define ARM_GPIO2_BASE            (ARM_GPIO_BASE       + 0x1000UL)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/******************************************************************************/
 | 
			
		||||
/*                         Peripheral declaration                             */
 | 
			
		||||
/******************************************************************************/
 | 
			
		||||
#define ARM_GPIO0                ((ARM_GPIO_TypeDef *) ARM_GPIO0_BASE)
 | 
			
		||||
#define ARM_GPIO1                ((ARM_GPIO_TypeDef *) ARM_GPIO1_BASE)
 | 
			
		||||
#define ARM_GPIO2                ((ARM_GPIO_TypeDef *) ARM_GPIO2_BASE)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#endif  /* ARMCM3_H */
 | 
			
		||||
@@ -0,0 +1,62 @@
 | 
			
		||||
/**************************************************************************//**
 | 
			
		||||
 * @file     system_ARMCM3.h
 | 
			
		||||
 * @brief    CMSIS Cortex-M3 Device System Header File
 | 
			
		||||
 *           for CM3 Device Series
 | 
			
		||||
 * @version  V1.05
 | 
			
		||||
 * @date     19. July 2011
 | 
			
		||||
 *
 | 
			
		||||
 * @note
 | 
			
		||||
 * Copyright (C) 2010-2011 ARM Limited. All rights reserved.
 | 
			
		||||
 *
 | 
			
		||||
 * @par
 | 
			
		||||
 * ARM Limited (ARM) is supplying this software for use with Cortex-M 
 | 
			
		||||
 * processor based microcontrollers.  This file can be freely distributed 
 | 
			
		||||
 * within development tools that are supporting such ARM based processors. 
 | 
			
		||||
 *
 | 
			
		||||
 * @par
 | 
			
		||||
 * THIS SOFTWARE IS PROVIDED "AS IS".  NO WARRANTIES, WHETHER EXPRESS, IMPLIED
 | 
			
		||||
 * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
 | 
			
		||||
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
 | 
			
		||||
 * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
 | 
			
		||||
 * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
 | 
			
		||||
 *
 | 
			
		||||
 ******************************************************************************/
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#ifndef SYSTEM_ARMCM3_H
 | 
			
		||||
#define SYSTEM_ARMCM3_H
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
extern uint32_t SystemCoreClock;     /*!< System Clock Frequency (Core Clock)  */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Initialize the system
 | 
			
		||||
 *
 | 
			
		||||
 * @param  none
 | 
			
		||||
 * @return none
 | 
			
		||||
 *
 | 
			
		||||
 * @brief  Setup the microcontroller system.
 | 
			
		||||
 *         Initialize the System and update the SystemCoreClock variable.
 | 
			
		||||
 */
 | 
			
		||||
extern void SystemInit (void);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Update SystemCoreClock variable
 | 
			
		||||
 *
 | 
			
		||||
 * @param  none
 | 
			
		||||
 * @return none
 | 
			
		||||
 *
 | 
			
		||||
 * @brief  Updates the SystemCoreClock with current core Clock 
 | 
			
		||||
 *         retrieved from cpu registers.
 | 
			
		||||
 */
 | 
			
		||||
extern void SystemCoreClockUpdate (void);
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif /* SYSTEM_ARMCM3_H */
 | 
			
		||||
@@ -0,0 +1,181 @@
 | 
			
		||||
;/**************************************************************************//**
 | 
			
		||||
; * @file     startup_ARMCM3.s
 | 
			
		||||
; * @brief    CMSIS Cortex-M4 Core Device Startup File
 | 
			
		||||
; *           for CM3 Device Series
 | 
			
		||||
; * @version  V1.05
 | 
			
		||||
; * @date     25. July 2011
 | 
			
		||||
; *
 | 
			
		||||
; * @note
 | 
			
		||||
; * Copyright (C) 2010-2011 ARM Limited. All rights reserved.
 | 
			
		||||
; *
 | 
			
		||||
; * @par
 | 
			
		||||
; * ARM Limited (ARM) is supplying this software for use with Cortex-M 
 | 
			
		||||
; * processor based microcontrollers.  This file can be freely distributed 
 | 
			
		||||
; * within development tools that are supporting such ARM based processors. 
 | 
			
		||||
; *
 | 
			
		||||
; * @par
 | 
			
		||||
; * THIS SOFTWARE IS PROVIDED "AS IS".  NO WARRANTIES, WHETHER EXPRESS, IMPLIED
 | 
			
		||||
; * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
 | 
			
		||||
; * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
 | 
			
		||||
; * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
 | 
			
		||||
; * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
 | 
			
		||||
; *
 | 
			
		||||
; ******************************************************************************/
 | 
			
		||||
;/*
 | 
			
		||||
;//-------- <<< Use Configuration Wizard in Context Menu >>> ------------------
 | 
			
		||||
;*/
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
; <h> Stack Configuration
 | 
			
		||||
;   <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
 | 
			
		||||
; </h>
 | 
			
		||||
 | 
			
		||||
Stack_Size      EQU     0x00000400
 | 
			
		||||
 | 
			
		||||
                AREA    STACK, NOINIT, READWRITE, ALIGN=3
 | 
			
		||||
Stack_Mem       SPACE   Stack_Size
 | 
			
		||||
__initial_sp
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
; <h> Heap Configuration
 | 
			
		||||
;   <o>  Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
 | 
			
		||||
; </h>
 | 
			
		||||
 | 
			
		||||
Heap_Size       EQU     0x00000000
 | 
			
		||||
 | 
			
		||||
                AREA    HEAP, NOINIT, READWRITE, ALIGN=3
 | 
			
		||||
__heap_base
 | 
			
		||||
Heap_Mem        SPACE   Heap_Size
 | 
			
		||||
__heap_limit
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                PRESERVE8
 | 
			
		||||
                THUMB
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
; Vector Table Mapped to Address 0 at Reset
 | 
			
		||||
 | 
			
		||||
                AREA    RESET, DATA, READONLY
 | 
			
		||||
                EXPORT  __Vectors
 | 
			
		||||
                EXPORT  __Vectors_End
 | 
			
		||||
                EXPORT  __Vectors_Size
 | 
			
		||||
 | 
			
		||||
__Vectors       DCD     __initial_sp              ; Top of Stack
 | 
			
		||||
                DCD     Reset_Handler             ; Reset Handler
 | 
			
		||||
                DCD     NMI_Handler               ; NMI Handler
 | 
			
		||||
                DCD     HardFault_Handler         ; Hard Fault Handler
 | 
			
		||||
                DCD     MemManage_Handler         ; MPU Fault Handler
 | 
			
		||||
                DCD     BusFault_Handler          ; Bus Fault Handler
 | 
			
		||||
                DCD     UsageFault_Handler        ; Usage Fault Handler
 | 
			
		||||
                DCD     0                         ; Reserved
 | 
			
		||||
                DCD     0                         ; Reserved
 | 
			
		||||
                DCD     0                         ; Reserved
 | 
			
		||||
                DCD     0                         ; Reserved
 | 
			
		||||
                DCD     SVC_Handler               ; SVCall Handler
 | 
			
		||||
                DCD     DebugMon_Handler          ; Debug Monitor Handler
 | 
			
		||||
                DCD     0                         ; Reserved
 | 
			
		||||
                DCD     PendSV_Handler            ; PendSV Handler
 | 
			
		||||
                DCD     SysTick_Handler           ; SysTick Handler
 | 
			
		||||
 | 
			
		||||
                ; External Interrupts
 | 
			
		||||
                DCD     DEF_IRQHandler            ;  0: Default
 | 
			
		||||
__Vectors_End
 | 
			
		||||
 | 
			
		||||
__Vectors_Size 	EQU 	__Vectors_End - __Vectors
 | 
			
		||||
 | 
			
		||||
                AREA    |.text|, CODE, READONLY
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
; Reset Handler
 | 
			
		||||
 | 
			
		||||
Reset_Handler   PROC
 | 
			
		||||
                EXPORT  Reset_Handler             [WEAK]
 | 
			
		||||
                IMPORT  SystemInit
 | 
			
		||||
                IMPORT  __main
 | 
			
		||||
                LDR     R0, =SystemInit
 | 
			
		||||
                BLX     R0
 | 
			
		||||
                LDR     R0, =__main
 | 
			
		||||
                BX      R0
 | 
			
		||||
                ENDP
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
; Dummy Exception Handlers (infinite loops which can be modified)
 | 
			
		||||
 | 
			
		||||
NMI_Handler     PROC
 | 
			
		||||
                EXPORT  NMI_Handler               [WEAK]
 | 
			
		||||
                B       .
 | 
			
		||||
                ENDP
 | 
			
		||||
HardFault_Handler\
 | 
			
		||||
                PROC
 | 
			
		||||
                EXPORT  HardFault_Handler         [WEAK]
 | 
			
		||||
                B       .
 | 
			
		||||
                ENDP
 | 
			
		||||
MemManage_Handler\
 | 
			
		||||
                PROC
 | 
			
		||||
                EXPORT  MemManage_Handler         [WEAK]
 | 
			
		||||
                B       .
 | 
			
		||||
                ENDP
 | 
			
		||||
BusFault_Handler\
 | 
			
		||||
                PROC
 | 
			
		||||
                EXPORT  BusFault_Handler          [WEAK]
 | 
			
		||||
                B       .
 | 
			
		||||
                ENDP
 | 
			
		||||
UsageFault_Handler\
 | 
			
		||||
                PROC
 | 
			
		||||
                EXPORT  UsageFault_Handler        [WEAK]
 | 
			
		||||
                B       .
 | 
			
		||||
                ENDP
 | 
			
		||||
SVC_Handler     PROC
 | 
			
		||||
                EXPORT  SVC_Handler               [WEAK]
 | 
			
		||||
                B       .
 | 
			
		||||
                ENDP
 | 
			
		||||
DebugMon_Handler\
 | 
			
		||||
                PROC
 | 
			
		||||
                EXPORT  DebugMon_Handler          [WEAK]
 | 
			
		||||
                B       .
 | 
			
		||||
                ENDP
 | 
			
		||||
PendSV_Handler  PROC
 | 
			
		||||
                EXPORT  PendSV_Handler            [WEAK]
 | 
			
		||||
                B       .
 | 
			
		||||
                ENDP
 | 
			
		||||
SysTick_Handler PROC
 | 
			
		||||
                EXPORT  SysTick_Handler           [WEAK]
 | 
			
		||||
                B       .
 | 
			
		||||
                ENDP
 | 
			
		||||
 | 
			
		||||
Default_Handler PROC
 | 
			
		||||
                EXPORT  DEF_IRQHandler            [WEAK]
 | 
			
		||||
DEF_IRQHandler
 | 
			
		||||
                B       .
 | 
			
		||||
                ENDP
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                ALIGN
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
; User Initial Stack & Heap
 | 
			
		||||
 | 
			
		||||
                IF      :DEF:__MICROLIB
 | 
			
		||||
                
 | 
			
		||||
                EXPORT  __initial_sp
 | 
			
		||||
                EXPORT  __heap_base
 | 
			
		||||
                EXPORT  __heap_limit
 | 
			
		||||
                
 | 
			
		||||
                ELSE
 | 
			
		||||
                
 | 
			
		||||
                IMPORT  __use_two_region_memory
 | 
			
		||||
                EXPORT  __user_initial_stackheap
 | 
			
		||||
__user_initial_stackheap
 | 
			
		||||
 | 
			
		||||
                LDR     R0, =  Heap_Mem
 | 
			
		||||
                LDR     R1, =(Stack_Mem + Stack_Size)
 | 
			
		||||
                LDR     R2, = (Heap_Mem +  Heap_Size)
 | 
			
		||||
                LDR     R3, = Stack_Mem
 | 
			
		||||
                BX      LR
 | 
			
		||||
 | 
			
		||||
                ALIGN
 | 
			
		||||
 | 
			
		||||
                ENDIF
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                END
 | 
			
		||||
@@ -0,0 +1,192 @@
 | 
			
		||||
/**************************************************************************//**
 | 
			
		||||
 * @file     startup_ARMCM3.s
 | 
			
		||||
 * @brief    CMSIS Cortex-M4 Core Device Startup File
 | 
			
		||||
 *           for CM3 Device Series
 | 
			
		||||
 * @version  V1.05
 | 
			
		||||
 * @date     25. July 2011
 | 
			
		||||
 *
 | 
			
		||||
 * @note     Version CodeSourcery Sourcery G++ Lite (with CS3)
 | 
			
		||||
 * Copyright (C) 2010-2011 ARM Limited. All rights reserved.
 | 
			
		||||
 *
 | 
			
		||||
 * @par
 | 
			
		||||
 * ARM Limited (ARM) is supplying this software for use with Cortex-M 
 | 
			
		||||
 * processor based microcontrollers.  This file can be freely distributed 
 | 
			
		||||
 * within development tools that are supporting such ARM based processors. 
 | 
			
		||||
 *
 | 
			
		||||
 * @par
 | 
			
		||||
 * THIS SOFTWARE IS PROVIDED "AS IS".  NO WARRANTIES, WHETHER EXPRESS, IMPLIED
 | 
			
		||||
 * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
 | 
			
		||||
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
 | 
			
		||||
 * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
 | 
			
		||||
 * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
 | 
			
		||||
 *
 | 
			
		||||
 ******************************************************************************/
 | 
			
		||||
/*
 | 
			
		||||
//-------- <<< Use Configuration Wizard in Context Menu >>> ------------------
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
// <h> Stack Configuration
 | 
			
		||||
//   <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
 | 
			
		||||
// </h>
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
    .equ    Stack_Size, 0x00000400
 | 
			
		||||
    .section ".stack", "w"
 | 
			
		||||
    .align  3
 | 
			
		||||
    .globl  __cs3_stack_mem
 | 
			
		||||
    .globl  __cs3_stack_size
 | 
			
		||||
__cs3_stack_mem:
 | 
			
		||||
    .if     Stack_Size
 | 
			
		||||
    .space  Stack_Size
 | 
			
		||||
    .endif
 | 
			
		||||
    .size   __cs3_stack_mem,  . - __cs3_stack_mem
 | 
			
		||||
    .set    __cs3_stack_size, . - __cs3_stack_mem
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
// <h> Heap Configuration
 | 
			
		||||
//   <o>  Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
 | 
			
		||||
// </h>
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
    .equ    Heap_Size,  0x00000000
 | 
			
		||||
    
 | 
			
		||||
    .section ".heap", "w"
 | 
			
		||||
    .align  3
 | 
			
		||||
    .globl  __cs3_heap_start
 | 
			
		||||
    .globl  __cs3_heap_end
 | 
			
		||||
__cs3_heap_start:
 | 
			
		||||
    .if     Heap_Size
 | 
			
		||||
    .space  Heap_Size
 | 
			
		||||
    .endif
 | 
			
		||||
__cs3_heap_end:
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* Vector Table */
 | 
			
		||||
 | 
			
		||||
    .section ".cs3.interrupt_vector"
 | 
			
		||||
    .globl  __cs3_interrupt_vector_cortex_m
 | 
			
		||||
    .type   __cs3_interrupt_vector_cortex_m, %object
 | 
			
		||||
 | 
			
		||||
__cs3_interrupt_vector_cortex_m:
 | 
			
		||||
    .long   __cs3_stack                 /* Top of Stack                 */
 | 
			
		||||
    .long   __cs3_reset                 /* Reset Handler                */
 | 
			
		||||
    .long   NMI_Handler                 /* NMI Handler                  */
 | 
			
		||||
    .long   HardFault_Handler           /* Hard Fault Handler           */
 | 
			
		||||
    .long   MemManage_Handler           /* MPU Fault Handler            */
 | 
			
		||||
    .long   BusFault_Handler            /* Bus Fault Handler            */
 | 
			
		||||
    .long   UsageFault_Handler          /* Usage Fault Handler          */
 | 
			
		||||
    .long   0                           /* Reserved                     */
 | 
			
		||||
    .long   0                           /* Reserved                     */
 | 
			
		||||
    .long   0                           /* Reserved                     */
 | 
			
		||||
    .long   0                           /* Reserved                     */
 | 
			
		||||
    .long   SVC_Handler                 /* SVCall Handler               */
 | 
			
		||||
    .long   DebugMon_Handler            /* Debug Monitor Handler        */
 | 
			
		||||
    .long   0                           /* Reserved                     */
 | 
			
		||||
    .long   PendSV_Handler              /* PendSV Handler               */
 | 
			
		||||
    .long   SysTick_Handler             /* SysTick Handler              */
 | 
			
		||||
 | 
			
		||||
    /* External Interrupts */
 | 
			
		||||
    .long   DEF_IRQHandler              /*  0: Default                  */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    .size   __cs3_interrupt_vector_cortex_m, . - __cs3_interrupt_vector_cortex_m
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    .thumb
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* Reset Handler */
 | 
			
		||||
 | 
			
		||||
    .section .cs3.reset,"x",%progbits
 | 
			
		||||
    .thumb_func
 | 
			
		||||
    .globl  __cs3_reset_cortex_m
 | 
			
		||||
    .type   __cs3_reset_cortex_m, %function
 | 
			
		||||
__cs3_reset_cortex_m:
 | 
			
		||||
    .fnstart
 | 
			
		||||
    LDR     R0, =SystemInit
 | 
			
		||||
    BLX     R0
 | 
			
		||||
    LDR     R0,=_start
 | 
			
		||||
    BX      R0
 | 
			
		||||
    .pool
 | 
			
		||||
    .cantunwind
 | 
			
		||||
    .fnend
 | 
			
		||||
    .size   __cs3_reset_cortex_m,.-__cs3_reset_cortex_m
 | 
			
		||||
 | 
			
		||||
    .section ".text"
 | 
			
		||||
 | 
			
		||||
/* Exception Handlers */
 | 
			
		||||
 | 
			
		||||
    .weak   NMI_Handler
 | 
			
		||||
    .type   NMI_Handler, %function
 | 
			
		||||
NMI_Handler:
 | 
			
		||||
    B       .
 | 
			
		||||
    .size   NMI_Handler, . - NMI_Handler
 | 
			
		||||
 | 
			
		||||
    .weak   HardFault_Handler
 | 
			
		||||
    .type   HardFault_Handler, %function
 | 
			
		||||
HardFault_Handler:
 | 
			
		||||
    B       .
 | 
			
		||||
    .size   HardFault_Handler, . - HardFault_Handler
 | 
			
		||||
 | 
			
		||||
    .weak   MemManage_Handler
 | 
			
		||||
    .type   MemManage_Handler, %function
 | 
			
		||||
MemManage_Handler:
 | 
			
		||||
    B       .
 | 
			
		||||
    .size   MemManage_Handler, . - MemManage_Handler
 | 
			
		||||
 | 
			
		||||
    .weak   BusFault_Handler
 | 
			
		||||
    .type   BusFault_Handler, %function
 | 
			
		||||
BusFault_Handler:
 | 
			
		||||
    B       .
 | 
			
		||||
    .size   BusFault_Handler, . - BusFault_Handler
 | 
			
		||||
 | 
			
		||||
    .weak   UsageFault_Handler
 | 
			
		||||
    .type   UsageFault_Handler, %function
 | 
			
		||||
UsageFault_Handler:
 | 
			
		||||
    B       .
 | 
			
		||||
    .size   UsageFault_Handler, . - UsageFault_Handler
 | 
			
		||||
 | 
			
		||||
    .weak   SVC_Handler
 | 
			
		||||
    .type   SVC_Handler, %function
 | 
			
		||||
SVC_Handler:
 | 
			
		||||
    B       .
 | 
			
		||||
    .size   SVC_Handler, . - SVC_Handler
 | 
			
		||||
 | 
			
		||||
    .weak   DebugMon_Handler
 | 
			
		||||
    .type   DebugMon_Handler, %function
 | 
			
		||||
DebugMon_Handler:
 | 
			
		||||
    B       .
 | 
			
		||||
    .size   DebugMon_Handler, . - DebugMon_Handler
 | 
			
		||||
 | 
			
		||||
    .weak   PendSV_Handler
 | 
			
		||||
    .type   PendSV_Handler, %function
 | 
			
		||||
PendSV_Handler:
 | 
			
		||||
    B       .
 | 
			
		||||
    .size   PendSV_Handler, . - PendSV_Handler
 | 
			
		||||
 | 
			
		||||
    .weak   SysTick_Handler
 | 
			
		||||
    .type   SysTick_Handler, %function
 | 
			
		||||
SysTick_Handler:
 | 
			
		||||
    B       .
 | 
			
		||||
    .size   SysTick_Handler, . - SysTick_Handler
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* IRQ Handlers */
 | 
			
		||||
 | 
			
		||||
    .globl  Default_Handler
 | 
			
		||||
    .type   Default_Handler, %function
 | 
			
		||||
Default_Handler:
 | 
			
		||||
    B       .
 | 
			
		||||
    .size   Default_Handler, . - Default_Handler
 | 
			
		||||
 | 
			
		||||
    .macro  IRQ handler
 | 
			
		||||
    .weak   \handler
 | 
			
		||||
    .set    \handler, Default_Handler
 | 
			
		||||
    .endm
 | 
			
		||||
 | 
			
		||||
    IRQ     DEF_IRQHandler
 | 
			
		||||
 | 
			
		||||
    .end
 | 
			
		||||
@@ -0,0 +1,147 @@
 | 
			
		||||
/* Linker script to configure memory regions. */
 | 
			
		||||
MEMORY
 | 
			
		||||
{
 | 
			
		||||
  FLASH (rx) : ORIGIN = 0x0, LENGTH = 0x20000 /* 128k */
 | 
			
		||||
  RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x8000 /* 32k */
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* Library configurations */
 | 
			
		||||
GROUP(libgcc.a libc.a libm.a libnosys.a)
 | 
			
		||||
 | 
			
		||||
/* Linker script to place sections and symbol values. Should be used together
 | 
			
		||||
 * with other linker script that defines memory regions FLASH and RAM.
 | 
			
		||||
 * It references following symbols, which must be defined in code:
 | 
			
		||||
 *   Reset_Handler : Entry of reset handler
 | 
			
		||||
 * 
 | 
			
		||||
 * It defines following symbols, which code can use without definition:
 | 
			
		||||
 *   __exidx_start
 | 
			
		||||
 *   __exidx_end
 | 
			
		||||
 *   __etext
 | 
			
		||||
 *   __data_start__
 | 
			
		||||
 *   __preinit_array_start
 | 
			
		||||
 *   __preinit_array_end
 | 
			
		||||
 *   __init_array_start
 | 
			
		||||
 *   __init_array_end
 | 
			
		||||
 *   __fini_array_start
 | 
			
		||||
 *   __fini_array_end
 | 
			
		||||
 *   __data_end__
 | 
			
		||||
 *   __bss_start__
 | 
			
		||||
 *   __bss_end__
 | 
			
		||||
 *   __end__
 | 
			
		||||
 *   end
 | 
			
		||||
 *   __HeapLimit
 | 
			
		||||
 *   __StackLimit
 | 
			
		||||
 *   __StackTop
 | 
			
		||||
 *   __stack
 | 
			
		||||
 */
 | 
			
		||||
ENTRY(Reset_Handler)
 | 
			
		||||
 | 
			
		||||
SECTIONS
 | 
			
		||||
{
 | 
			
		||||
	.text :
 | 
			
		||||
	{
 | 
			
		||||
		KEEP(*(.isr_vector))
 | 
			
		||||
		*(.text*)
 | 
			
		||||
 | 
			
		||||
		KEEP(*(.init))
 | 
			
		||||
		KEEP(*(.fini))
 | 
			
		||||
 | 
			
		||||
		/* .ctors */
 | 
			
		||||
		*crtbegin.o(.ctors)
 | 
			
		||||
		*crtbegin?.o(.ctors)
 | 
			
		||||
		*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
 | 
			
		||||
		*(SORT(.ctors.*))
 | 
			
		||||
		*(.ctors)
 | 
			
		||||
 | 
			
		||||
		/* .dtors */
 | 
			
		||||
 		*crtbegin.o(.dtors)
 | 
			
		||||
 		*crtbegin?.o(.dtors)
 | 
			
		||||
 		*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
 | 
			
		||||
 		*(SORT(.dtors.*))
 | 
			
		||||
 		*(.dtors)
 | 
			
		||||
 | 
			
		||||
		*(.rodata*)
 | 
			
		||||
 | 
			
		||||
		KEEP(*(.eh_frame*))
 | 
			
		||||
	} > FLASH
 | 
			
		||||
 | 
			
		||||
	.ARM.extab : 
 | 
			
		||||
	{
 | 
			
		||||
		*(.ARM.extab* .gnu.linkonce.armextab.*)
 | 
			
		||||
	} > FLASH
 | 
			
		||||
 | 
			
		||||
	__exidx_start = .;
 | 
			
		||||
	.ARM.exidx :
 | 
			
		||||
	{
 | 
			
		||||
		*(.ARM.exidx* .gnu.linkonce.armexidx.*)
 | 
			
		||||
	} > FLASH
 | 
			
		||||
	__exidx_end = .;
 | 
			
		||||
 | 
			
		||||
	__etext = .;
 | 
			
		||||
		
 | 
			
		||||
	.data : AT (__etext)
 | 
			
		||||
	{
 | 
			
		||||
		__data_start__ = .;
 | 
			
		||||
		*(vtable)
 | 
			
		||||
		*(.data*)
 | 
			
		||||
 | 
			
		||||
		. = ALIGN(4);
 | 
			
		||||
		/* preinit data */
 | 
			
		||||
		PROVIDE (__preinit_array_start = .);
 | 
			
		||||
		*(.preinit_array)
 | 
			
		||||
		PROVIDE (__preinit_array_end = .);
 | 
			
		||||
 | 
			
		||||
		. = ALIGN(4);
 | 
			
		||||
		/* init data */
 | 
			
		||||
		PROVIDE (__init_array_start = .);
 | 
			
		||||
		*(SORT(.init_array.*))
 | 
			
		||||
		*(.init_array)
 | 
			
		||||
		PROVIDE (__init_array_end = .);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		. = ALIGN(4);
 | 
			
		||||
		/* finit data */
 | 
			
		||||
		PROVIDE (__fini_array_start = .);
 | 
			
		||||
		*(SORT(.fini_array.*))
 | 
			
		||||
		*(.fini_array)
 | 
			
		||||
		PROVIDE (__fini_array_end = .);
 | 
			
		||||
 | 
			
		||||
		. = ALIGN(4);
 | 
			
		||||
		/* All data end */
 | 
			
		||||
		__data_end__ = .;
 | 
			
		||||
 | 
			
		||||
	} > RAM
 | 
			
		||||
 | 
			
		||||
	.bss :
 | 
			
		||||
	{
 | 
			
		||||
		__bss_start__ = .;
 | 
			
		||||
		*(.bss*)
 | 
			
		||||
		*(COMMON)
 | 
			
		||||
		__bss_end__ = .;
 | 
			
		||||
	} > RAM
 | 
			
		||||
	
 | 
			
		||||
	.heap :
 | 
			
		||||
	{
 | 
			
		||||
		__end__ = .;
 | 
			
		||||
		end = __end__;
 | 
			
		||||
		*(.heap*)
 | 
			
		||||
		__HeapLimit = .;
 | 
			
		||||
	} > RAM
 | 
			
		||||
 | 
			
		||||
	/* .stack_dummy section doesn't contains any symbols. It is only
 | 
			
		||||
	 * used for linker to calculate size of stack sections, and assign
 | 
			
		||||
	 * values to stack symbols later */
 | 
			
		||||
	.stack_dummy :
 | 
			
		||||
	{
 | 
			
		||||
		*(.stack)
 | 
			
		||||
	} > RAM
 | 
			
		||||
 | 
			
		||||
	/* Set stack top to end of RAM, and stack limit move down by
 | 
			
		||||
	 * size of stack_dummy section */
 | 
			
		||||
	__StackTop = ORIGIN(RAM) + LENGTH(RAM);
 | 
			
		||||
	__StackLimit = __StackTop - SIZEOF(.stack_dummy);
 | 
			
		||||
	PROVIDE(__stack = __StackTop);
 | 
			
		||||
	
 | 
			
		||||
	/* Check if data + heap + stack exceeds RAM limit */
 | 
			
		||||
	ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,165 @@
 | 
			
		||||
/* File: startup_ARMCM3.S
 | 
			
		||||
 * Purpose: startup file for Cortex-M3 devices. Should use with 
 | 
			
		||||
 *   GCC for ARM Embedded Processors
 | 
			
		||||
 * Version: V1.2
 | 
			
		||||
 * Date: 15 Nov 2011
 | 
			
		||||
 * 
 | 
			
		||||
 * Copyright (c) 2011, ARM Limited
 | 
			
		||||
 * All rights reserved.
 | 
			
		||||
 * 
 | 
			
		||||
 * Redistribution and use in source and binary forms, with or without
 | 
			
		||||
 * modification, are permitted provided that the following conditions are met:
 | 
			
		||||
    * Redistributions of source code must retain the above copyright
 | 
			
		||||
      notice, this list of conditions and the following disclaimer.
 | 
			
		||||
    * Redistributions in binary form must reproduce the above copyright
 | 
			
		||||
      notice, this list of conditions and the following disclaimer in the
 | 
			
		||||
      documentation and/or other materials provided with the distribution.
 | 
			
		||||
    * Neither the name of the ARM Limited nor the
 | 
			
		||||
      names of its contributors may be used to endorse or promote products
 | 
			
		||||
      derived from this software without specific prior written permission.
 | 
			
		||||
 * 
 | 
			
		||||
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 | 
			
		||||
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 | 
			
		||||
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 | 
			
		||||
 * DISCLAIMED. IN NO EVENT SHALL ARM LIMITED BE LIABLE FOR ANY
 | 
			
		||||
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 | 
			
		||||
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 | 
			
		||||
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 | 
			
		||||
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 | 
			
		||||
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 | 
			
		||||
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 | 
			
		||||
 */
 | 
			
		||||
    .syntax unified
 | 
			
		||||
    .arch armv7-m
 | 
			
		||||
 | 
			
		||||
    .section .stack
 | 
			
		||||
    .align 3
 | 
			
		||||
#ifdef __STACK_SIZE
 | 
			
		||||
    .equ    Stack_Size, __STACK_SIZE
 | 
			
		||||
#else
 | 
			
		||||
    .equ    Stack_Size, 0xc00
 | 
			
		||||
#endif
 | 
			
		||||
    .globl    __StackTop
 | 
			
		||||
    .globl    __StackLimit
 | 
			
		||||
__StackLimit:
 | 
			
		||||
    .space    Stack_Size
 | 
			
		||||
    .size __StackLimit, . - __StackLimit
 | 
			
		||||
__StackTop:
 | 
			
		||||
    .size __StackTop, . - __StackTop
 | 
			
		||||
 | 
			
		||||
    .section .heap
 | 
			
		||||
    .align 3
 | 
			
		||||
#ifdef __HEAP_SIZE
 | 
			
		||||
    .equ    Heap_Size, __HEAP_SIZE
 | 
			
		||||
#else
 | 
			
		||||
    .equ    Heap_Size, 0x800
 | 
			
		||||
#endif
 | 
			
		||||
    .globl    __HeapBase
 | 
			
		||||
    .globl    __HeapLimit
 | 
			
		||||
__HeapBase:
 | 
			
		||||
    .space    Heap_Size
 | 
			
		||||
    .size __HeapBase, . - __HeapBase
 | 
			
		||||
__HeapLimit:
 | 
			
		||||
    .size __HeapLimit, . - __HeapLimit
 | 
			
		||||
    
 | 
			
		||||
    .section .isr_vector
 | 
			
		||||
    .align 2
 | 
			
		||||
    .globl __isr_vector
 | 
			
		||||
__isr_vector:
 | 
			
		||||
    .long    __StackTop            /* Top of Stack */
 | 
			
		||||
    .long    Reset_Handler         /* Reset Handler */
 | 
			
		||||
    .long    NMI_Handler           /* NMI Handler */
 | 
			
		||||
    .long    HardFault_Handler     /* Hard Fault Handler */
 | 
			
		||||
    .long    MemManage_Handler     /* MPU Fault Handler */
 | 
			
		||||
    .long    BusFault_Handler      /* Bus Fault Handler */
 | 
			
		||||
    .long    UsageFault_Handler    /* Usage Fault Handler */
 | 
			
		||||
    .long    0                     /* Reserved */
 | 
			
		||||
    .long    0                     /* Reserved */
 | 
			
		||||
    .long    0                     /* Reserved */
 | 
			
		||||
    .long    0                     /* Reserved */
 | 
			
		||||
    .long    SVC_Handler           /* SVCall Handler */
 | 
			
		||||
    .long    DebugMon_Handler      /* Debug Monitor Handler */
 | 
			
		||||
    .long    0                     /* Reserved */
 | 
			
		||||
    .long    PendSV_Handler        /* PendSV Handler */
 | 
			
		||||
    .long    SysTick_Handler       /* SysTick Handler */
 | 
			
		||||
 | 
			
		||||
    /* External interrupts */
 | 
			
		||||
    .long    Default_Handler
 | 
			
		||||
    
 | 
			
		||||
    .size    __isr_vector, . - __isr_vector
 | 
			
		||||
 | 
			
		||||
    .text
 | 
			
		||||
    .thumb
 | 
			
		||||
    .thumb_func
 | 
			
		||||
    .align 2
 | 
			
		||||
    .globl    Reset_Handler
 | 
			
		||||
    .type    Reset_Handler, %function
 | 
			
		||||
Reset_Handler:
 | 
			
		||||
/*     Loop to copy data from read only memory to RAM. The ranges
 | 
			
		||||
 *      of copy from/to are specified by following symbols evaluated in 
 | 
			
		||||
 *      linker script.
 | 
			
		||||
 *      __etext: End of code section, i.e., begin of data sections to copy from.
 | 
			
		||||
 *      __data_start__/__data_end__: RAM address range that data should be
 | 
			
		||||
 *      copied to. Both must be aligned to 4 bytes boundary.  */
 | 
			
		||||
 | 
			
		||||
    ldr    r1, =__etext
 | 
			
		||||
    ldr    r2, =__data_start__
 | 
			
		||||
    ldr    r3, =__data_end__
 | 
			
		||||
 | 
			
		||||
#if 1
 | 
			
		||||
/* Here are two copies of loop implemenations. First one favors code size
 | 
			
		||||
 * and the second one favors performance. Default uses the first one. 
 | 
			
		||||
 * Change to "#if 0" to use the second one */
 | 
			
		||||
.flash_to_ram_loop:
 | 
			
		||||
    cmp     r2, r3
 | 
			
		||||
    ittt    lt
 | 
			
		||||
    ldrlt   r0, [r1], #4
 | 
			
		||||
    strlt   r0, [r2], #4
 | 
			
		||||
    blt    .flash_to_ram_loop
 | 
			
		||||
#else
 | 
			
		||||
    subs    r3, r2
 | 
			
		||||
    ble    .flash_to_ram_loop_end    
 | 
			
		||||
.flash_to_ram_loop:
 | 
			
		||||
    subs    r3, #4
 | 
			
		||||
    ldr    r0, [r1, r3]
 | 
			
		||||
    str    r0, [r2, r3]
 | 
			
		||||
    bgt    .flash_to_ram_loop
 | 
			
		||||
.flash_to_ram_loop_end:
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    ldr    r0, =SystemInit
 | 
			
		||||
    blx    r0
 | 
			
		||||
    ldr    r0, =_start
 | 
			
		||||
    bx    r0
 | 
			
		||||
    .pool
 | 
			
		||||
    .size Reset_Handler, . - Reset_Handler
 | 
			
		||||
    
 | 
			
		||||
/*    Macro to define default handlers. Default handler
 | 
			
		||||
 *    will be weak symbol and just dead loops. They can be
 | 
			
		||||
 *    overwritten by other handlers */
 | 
			
		||||
    .macro    def_default_handler    handler_name
 | 
			
		||||
    .align 1
 | 
			
		||||
    .thumb_func
 | 
			
		||||
    .weak    \handler_name
 | 
			
		||||
    .type    \handler_name, %function
 | 
			
		||||
\handler_name :
 | 
			
		||||
    b    .
 | 
			
		||||
    .size    \handler_name, . - \handler_name
 | 
			
		||||
    .endm
 | 
			
		||||
    
 | 
			
		||||
    def_default_handler    NMI_Handler
 | 
			
		||||
    def_default_handler    HardFault_Handler
 | 
			
		||||
    def_default_handler    MemManage_Handler
 | 
			
		||||
    def_default_handler    BusFault_Handler
 | 
			
		||||
    def_default_handler    UsageFault_Handler
 | 
			
		||||
    def_default_handler    SVC_Handler
 | 
			
		||||
    def_default_handler    DebugMon_Handler
 | 
			
		||||
    def_default_handler    PendSV_Handler
 | 
			
		||||
    def_default_handler    SysTick_Handler
 | 
			
		||||
    def_default_handler    Default_Handler
 | 
			
		||||
 | 
			
		||||
    .weak    DEF_IRQHandler
 | 
			
		||||
    .set    DEF_IRQHandler, Default_Handler
 | 
			
		||||
 | 
			
		||||
    .end
 | 
			
		||||
@@ -0,0 +1,151 @@
 | 
			
		||||
;/**************************************************************************//**
 | 
			
		||||
; * @file     startup_ARMCM3.s
 | 
			
		||||
; * @brief    CMSIS Cortex-M4 Core Device Startup File
 | 
			
		||||
; *           for CM3 Device Series
 | 
			
		||||
; * @version  V1.05
 | 
			
		||||
; * @date     25. July 2011
 | 
			
		||||
; *
 | 
			
		||||
; * @note
 | 
			
		||||
; * Copyright (C) 2010-2011 ARM Limited. All rights reserved.
 | 
			
		||||
; *
 | 
			
		||||
; * @par
 | 
			
		||||
; * ARM Limited (ARM) is supplying this software for use with Cortex-M 
 | 
			
		||||
; * processor based microcontrollers.  This file can be freely distributed 
 | 
			
		||||
; * within development tools that are supporting such ARM based processors. 
 | 
			
		||||
; *
 | 
			
		||||
; * @par
 | 
			
		||||
; * THIS SOFTWARE IS PROVIDED "AS IS".  NO WARRANTIES, WHETHER EXPRESS, IMPLIED
 | 
			
		||||
; * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
 | 
			
		||||
; * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
 | 
			
		||||
; * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
 | 
			
		||||
; * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
 | 
			
		||||
; *
 | 
			
		||||
; ******************************************************************************/
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
;
 | 
			
		||||
; The modules in this file are included in the libraries, and may be replaced
 | 
			
		||||
; by any user-defined modules that define the PUBLIC symbol _program_start or
 | 
			
		||||
; a user defined start symbol.
 | 
			
		||||
; To override the cstartup defined in the library, simply add your modified
 | 
			
		||||
; version to the workbench project.
 | 
			
		||||
;
 | 
			
		||||
; The vector table is normally located at address 0.
 | 
			
		||||
; When debugging in RAM, it can be located in RAM, aligned to at least 2^6.
 | 
			
		||||
; The name "__vector_table" has special meaning for C-SPY:
 | 
			
		||||
; it is where the SP start value is found, and the NVIC vector
 | 
			
		||||
; table register (VTOR) is initialized to this address if != 0.
 | 
			
		||||
;
 | 
			
		||||
; Cortex-M version
 | 
			
		||||
;
 | 
			
		||||
 | 
			
		||||
        MODULE  ?cstartup
 | 
			
		||||
 | 
			
		||||
        ;; Forward declaration of sections.
 | 
			
		||||
        SECTION CSTACK:DATA:NOROOT(3)
 | 
			
		||||
 | 
			
		||||
        SECTION .intvec:CODE:NOROOT(2)
 | 
			
		||||
	
 | 
			
		||||
        EXTERN  __iar_program_start
 | 
			
		||||
        EXTERN  SystemInit
 | 
			
		||||
        PUBLIC  __vector_table
 | 
			
		||||
        PUBLIC  __vector_table_0x1c
 | 
			
		||||
        PUBLIC  __Vectors
 | 
			
		||||
        PUBLIC  __Vectors_End
 | 
			
		||||
        PUBLIC  __Vectors_Size
 | 
			
		||||
 | 
			
		||||
        DATA
 | 
			
		||||
 | 
			
		||||
__vector_table
 | 
			
		||||
        DCD     sfe(CSTACK)
 | 
			
		||||
        DCD     Reset_Handler
 | 
			
		||||
 | 
			
		||||
        DCD     NMI_Handler
 | 
			
		||||
        DCD     HardFault_Handler
 | 
			
		||||
        DCD     MemManage_Handler
 | 
			
		||||
        DCD     BusFault_Handler
 | 
			
		||||
        DCD     UsageFault_Handler
 | 
			
		||||
__vector_table_0x1c
 | 
			
		||||
        DCD     0
 | 
			
		||||
        DCD     0
 | 
			
		||||
        DCD     0
 | 
			
		||||
        DCD     0
 | 
			
		||||
        DCD     SVC_Handler
 | 
			
		||||
        DCD     DebugMon_Handler
 | 
			
		||||
        DCD     0
 | 
			
		||||
        DCD     PendSV_Handler
 | 
			
		||||
        DCD     SysTick_Handler
 | 
			
		||||
 | 
			
		||||
        ; External Interrupts
 | 
			
		||||
        DCD     DEF_IRQHandler            ;  0: Default
 | 
			
		||||
__Vectors_End
 | 
			
		||||
 | 
			
		||||
__Vectors       EQU   __vector_table
 | 
			
		||||
__Vectors_Size 	EQU   __Vectors_End - __Vectors
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 | 
			
		||||
;;
 | 
			
		||||
;; Default interrupt handlers.
 | 
			
		||||
;;
 | 
			
		||||
        THUMB
 | 
			
		||||
 | 
			
		||||
        PUBWEAK Reset_Handler
 | 
			
		||||
        SECTION .text:CODE:REORDER(2)
 | 
			
		||||
Reset_Handler
 | 
			
		||||
        LDR     R0, =SystemInit
 | 
			
		||||
        BLX     R0
 | 
			
		||||
        LDR     R0, =__iar_program_start
 | 
			
		||||
        BX      R0
 | 
			
		||||
 | 
			
		||||
        PUBWEAK NMI_Handler
 | 
			
		||||
        SECTION .text:CODE:REORDER(1)
 | 
			
		||||
NMI_Handler
 | 
			
		||||
        B NMI_Handler
 | 
			
		||||
 | 
			
		||||
        PUBWEAK HardFault_Handler
 | 
			
		||||
        SECTION .text:CODE:REORDER(1)
 | 
			
		||||
HardFault_Handler
 | 
			
		||||
        B HardFault_Handler
 | 
			
		||||
 | 
			
		||||
        PUBWEAK MemManage_Handler
 | 
			
		||||
        SECTION .text:CODE:REORDER(1)
 | 
			
		||||
MemManage_Handler
 | 
			
		||||
        B MemManage_Handler
 | 
			
		||||
 | 
			
		||||
        PUBWEAK BusFault_Handler
 | 
			
		||||
        SECTION .text:CODE:REORDER(1)
 | 
			
		||||
BusFault_Handler
 | 
			
		||||
        B BusFault_Handler
 | 
			
		||||
 | 
			
		||||
        PUBWEAK UsageFault_Handler
 | 
			
		||||
        SECTION .text:CODE:REORDER(1)
 | 
			
		||||
UsageFault_Handler
 | 
			
		||||
        B UsageFault_Handler
 | 
			
		||||
 | 
			
		||||
        PUBWEAK SVC_Handler
 | 
			
		||||
        SECTION .text:CODE:REORDER(1)
 | 
			
		||||
SVC_Handler
 | 
			
		||||
        B SVC_Handler
 | 
			
		||||
 | 
			
		||||
        PUBWEAK DebugMon_Handler
 | 
			
		||||
        SECTION .text:CODE:REORDER(1)
 | 
			
		||||
DebugMon_Handler
 | 
			
		||||
        B DebugMon_Handler
 | 
			
		||||
 | 
			
		||||
        PUBWEAK PendSV_Handler
 | 
			
		||||
        SECTION .text:CODE:REORDER(1)
 | 
			
		||||
PendSV_Handler
 | 
			
		||||
        B PendSV_Handler
 | 
			
		||||
 | 
			
		||||
        PUBWEAK SysTick_Handler
 | 
			
		||||
        SECTION .text:CODE:REORDER(1)
 | 
			
		||||
SysTick_Handler
 | 
			
		||||
        B SysTick_Handler
 | 
			
		||||
 | 
			
		||||
        PUBWEAK DEF_IRQHandler
 | 
			
		||||
        SECTION .text:CODE:REORDER(1)
 | 
			
		||||
DEF_IRQHandler
 | 
			
		||||
        B DEF_IRQHandler
 | 
			
		||||
 | 
			
		||||
        END
 | 
			
		||||
@@ -0,0 +1,76 @@
 | 
			
		||||
/**************************************************************************//**
 | 
			
		||||
 * @file     system_ARMCM3.c
 | 
			
		||||
 * @brief    CMSIS Cortex-M3 Device System Source File
 | 
			
		||||
 *           for CM3 Device Series
 | 
			
		||||
 * @version  V1.05
 | 
			
		||||
 * @date     26. July 2011
 | 
			
		||||
 *
 | 
			
		||||
 * @note
 | 
			
		||||
 * Copyright (C) 2010-2011 ARM Limited. All rights reserved.
 | 
			
		||||
 *
 | 
			
		||||
 * @par
 | 
			
		||||
 * ARM Limited (ARM) is supplying this software for use with Cortex-M 
 | 
			
		||||
 * processor based microcontrollers.  This file can be freely distributed 
 | 
			
		||||
 * within development tools that are supporting such ARM based processors. 
 | 
			
		||||
 *
 | 
			
		||||
 * @par
 | 
			
		||||
 * THIS SOFTWARE IS PROVIDED "AS IS".  NO WARRANTIES, WHETHER EXPRESS, IMPLIED
 | 
			
		||||
 * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
 | 
			
		||||
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
 | 
			
		||||
 * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
 | 
			
		||||
 * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
 | 
			
		||||
 *
 | 
			
		||||
 ******************************************************************************/
 | 
			
		||||
 | 
			
		||||
#include "ARMCM3.h"
 | 
			
		||||
 | 
			
		||||
/*----------------------------------------------------------------------------
 | 
			
		||||
  Define clocks
 | 
			
		||||
 *----------------------------------------------------------------------------*/
 | 
			
		||||
#define __HSI             ( 8000000UL)
 | 
			
		||||
#define __XTAL            (12000000UL)    /* Oscillator frequency             */
 | 
			
		||||
 | 
			
		||||
#define __SYSTEM_CLOCK    (4*__XTAL)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/*----------------------------------------------------------------------------
 | 
			
		||||
  Clock Variable definitions
 | 
			
		||||
 *----------------------------------------------------------------------------*/
 | 
			
		||||
uint32_t SystemCoreClock = __SYSTEM_CLOCK;/*!< System Clock Frequency (Core Clock)*/
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/*----------------------------------------------------------------------------
 | 
			
		||||
  Clock functions
 | 
			
		||||
 *----------------------------------------------------------------------------*/
 | 
			
		||||
void SystemCoreClockUpdate (void)            /* Get Core Clock Frequency      */
 | 
			
		||||
{
 | 
			
		||||
  SystemCoreClock = __SYSTEM_CLOCK;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Initialize the system
 | 
			
		||||
 *
 | 
			
		||||
 * @param  none
 | 
			
		||||
 * @return none
 | 
			
		||||
 *
 | 
			
		||||
 * @brief  Setup the microcontroller system.
 | 
			
		||||
 *         Initialize the System.
 | 
			
		||||
 */
 | 
			
		||||
void SystemInit (void)
 | 
			
		||||
{
 | 
			
		||||
  SystemCoreClock = __SYSTEM_CLOCK;
 | 
			
		||||
 | 
			
		||||
#ifdef __USE_GPIO
 | 
			
		||||
  ARM_GPIO0->DATA[0].WORD = 0;
 | 
			
		||||
  ARM_GPIO0->IE = 0;
 | 
			
		||||
  ARM_GPIO0->DIR = 0xff83;
 | 
			
		||||
  
 | 
			
		||||
  ARM_GPIO1->DATA[0].WORD = 0;
 | 
			
		||||
  ARM_GPIO1->IE = 0;
 | 
			
		||||
  ARM_GPIO1->DIR = 0;
 | 
			
		||||
  
 | 
			
		||||
  ARM_GPIO2->DATA[0].WORD = 0;
 | 
			
		||||
  ARM_GPIO2->IE = 0;
 | 
			
		||||
  ARM_GPIO2->DIR = 0;
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user