Mouse code for the MacroRat

Dependencies:   ITG3200 QEI

Committer:
sahilmgandhi
Date:
Sat Jun 03 00:22:44 2017 +0000
Revision:
46:b156ef445742
Parent:
18:6a4db94011d3
Final code for internal battlebot competition.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sahilmgandhi 18:6a4db94011d3 1 /**
sahilmgandhi 18:6a4db94011d3 2 * \file
sahilmgandhi 18:6a4db94011d3 3 *
sahilmgandhi 18:6a4db94011d3 4 * \brief Startup file for SAMG55.
sahilmgandhi 18:6a4db94011d3 5 *
sahilmgandhi 18:6a4db94011d3 6 * Copyright (c) 2014-2015 Atmel Corporation. All rights reserved.
sahilmgandhi 18:6a4db94011d3 7 *
sahilmgandhi 18:6a4db94011d3 8 * \asf_license_start
sahilmgandhi 18:6a4db94011d3 9 *
sahilmgandhi 18:6a4db94011d3 10 * \page License
sahilmgandhi 18:6a4db94011d3 11 *
sahilmgandhi 18:6a4db94011d3 12 * Redistribution and use in source and binary forms, with or without
sahilmgandhi 18:6a4db94011d3 13 * modification, are permitted provided that the following conditions are met:
sahilmgandhi 18:6a4db94011d3 14 *
sahilmgandhi 18:6a4db94011d3 15 * 1. Redistributions of source code must retain the above copyright notice,
sahilmgandhi 18:6a4db94011d3 16 * this list of conditions and the following disclaimer.
sahilmgandhi 18:6a4db94011d3 17 *
sahilmgandhi 18:6a4db94011d3 18 * 2. Redistributions in binary form must reproduce the above copyright notice,
sahilmgandhi 18:6a4db94011d3 19 * this list of conditions and the following disclaimer in the documentation
sahilmgandhi 18:6a4db94011d3 20 * and/or other materials provided with the distribution.
sahilmgandhi 18:6a4db94011d3 21 *
sahilmgandhi 18:6a4db94011d3 22 * 3. The name of Atmel may not be used to endorse or promote products derived
sahilmgandhi 18:6a4db94011d3 23 * from this software without specific prior written permission.
sahilmgandhi 18:6a4db94011d3 24 *
sahilmgandhi 18:6a4db94011d3 25 * 4. This software may only be redistributed and used in connection with an
sahilmgandhi 18:6a4db94011d3 26 * Atmel microcontroller product.
sahilmgandhi 18:6a4db94011d3 27 *
sahilmgandhi 18:6a4db94011d3 28 * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
sahilmgandhi 18:6a4db94011d3 29 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
sahilmgandhi 18:6a4db94011d3 30 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
sahilmgandhi 18:6a4db94011d3 31 * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
sahilmgandhi 18:6a4db94011d3 32 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
sahilmgandhi 18:6a4db94011d3 33 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
sahilmgandhi 18:6a4db94011d3 34 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
sahilmgandhi 18:6a4db94011d3 35 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
sahilmgandhi 18:6a4db94011d3 36 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
sahilmgandhi 18:6a4db94011d3 37 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
sahilmgandhi 18:6a4db94011d3 38 * POSSIBILITY OF SUCH DAMAGE.
sahilmgandhi 18:6a4db94011d3 39 *
sahilmgandhi 18:6a4db94011d3 40 * \asf_license_stop
sahilmgandhi 18:6a4db94011d3 41 *
sahilmgandhi 18:6a4db94011d3 42 */
sahilmgandhi 18:6a4db94011d3 43 /*
sahilmgandhi 18:6a4db94011d3 44 * Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a>
sahilmgandhi 18:6a4db94011d3 45 */
sahilmgandhi 18:6a4db94011d3 46
sahilmgandhi 18:6a4db94011d3 47 #include "samg55.h"
sahilmgandhi 18:6a4db94011d3 48
sahilmgandhi 18:6a4db94011d3 49 #if __FPU_USED /* CMSIS defined value to indicate usage of FPU */
sahilmgandhi 18:6a4db94011d3 50 #include "fpu.h"
sahilmgandhi 18:6a4db94011d3 51 #endif
sahilmgandhi 18:6a4db94011d3 52
sahilmgandhi 18:6a4db94011d3 53 /* Initialize segments */
sahilmgandhi 18:6a4db94011d3 54 extern uint32_t _sfixed;
sahilmgandhi 18:6a4db94011d3 55 extern uint32_t _efixed;
sahilmgandhi 18:6a4db94011d3 56 extern uint32_t _etext;
sahilmgandhi 18:6a4db94011d3 57 extern uint32_t _srelocate;
sahilmgandhi 18:6a4db94011d3 58 extern uint32_t _erelocate;
sahilmgandhi 18:6a4db94011d3 59 extern uint32_t _szero;
sahilmgandhi 18:6a4db94011d3 60 extern uint32_t _ezero;
sahilmgandhi 18:6a4db94011d3 61 extern uint32_t _sstack;
sahilmgandhi 18:6a4db94011d3 62 extern uint32_t _estack;
sahilmgandhi 18:6a4db94011d3 63
sahilmgandhi 18:6a4db94011d3 64 /** \cond DOXYGEN_SHOULD_SKIP_THIS */
sahilmgandhi 18:6a4db94011d3 65 int main(void);
sahilmgandhi 18:6a4db94011d3 66 /** \endcond */
sahilmgandhi 18:6a4db94011d3 67
sahilmgandhi 18:6a4db94011d3 68 void __libc_init_array(void);
sahilmgandhi 18:6a4db94011d3 69
sahilmgandhi 18:6a4db94011d3 70 /* Default empty handler */
sahilmgandhi 18:6a4db94011d3 71 void Dummy_Handler(void);
sahilmgandhi 18:6a4db94011d3 72
sahilmgandhi 18:6a4db94011d3 73 /* Cortex-M4 core handlers */
sahilmgandhi 18:6a4db94011d3 74 void NMI_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
sahilmgandhi 18:6a4db94011d3 75 void HardFault_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
sahilmgandhi 18:6a4db94011d3 76 void MemManage_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
sahilmgandhi 18:6a4db94011d3 77 void BusFault_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
sahilmgandhi 18:6a4db94011d3 78 void UsageFault_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
sahilmgandhi 18:6a4db94011d3 79 void SVC_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
sahilmgandhi 18:6a4db94011d3 80 void DebugMon_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
sahilmgandhi 18:6a4db94011d3 81 void PendSV_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
sahilmgandhi 18:6a4db94011d3 82 void SysTick_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
sahilmgandhi 18:6a4db94011d3 83
sahilmgandhi 18:6a4db94011d3 84 /* Peripherals handlers */
sahilmgandhi 18:6a4db94011d3 85 void SUPC_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
sahilmgandhi 18:6a4db94011d3 86 void RSTC_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
sahilmgandhi 18:6a4db94011d3 87 void RTC_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
sahilmgandhi 18:6a4db94011d3 88 void RTT_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
sahilmgandhi 18:6a4db94011d3 89 void WDT_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
sahilmgandhi 18:6a4db94011d3 90 void PMC_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
sahilmgandhi 18:6a4db94011d3 91 void EFC_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
sahilmgandhi 18:6a4db94011d3 92 #ifdef _SAMG55_FLEXCOM7_INSTANCE_
sahilmgandhi 18:6a4db94011d3 93 void FLEXCOM7_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
sahilmgandhi 18:6a4db94011d3 94 #endif /* _SAMG55_FLEXCOM7_INSTANCE_*/
sahilmgandhi 18:6a4db94011d3 95 void FLEXCOM0_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
sahilmgandhi 18:6a4db94011d3 96 void FLEXCOM1_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
sahilmgandhi 18:6a4db94011d3 97 void PIOA_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
sahilmgandhi 18:6a4db94011d3 98 void PIOB_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
sahilmgandhi 18:6a4db94011d3 99 void PDMIC0_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
sahilmgandhi 18:6a4db94011d3 100 void FLEXCOM2_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
sahilmgandhi 18:6a4db94011d3 101 void MEM2MEM_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
sahilmgandhi 18:6a4db94011d3 102 void I2SC0_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
sahilmgandhi 18:6a4db94011d3 103 void I2SC1_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
sahilmgandhi 18:6a4db94011d3 104 void PDMIC1_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
sahilmgandhi 18:6a4db94011d3 105 void FLEXCOM3_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
sahilmgandhi 18:6a4db94011d3 106 void FLEXCOM4_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
sahilmgandhi 18:6a4db94011d3 107 void FLEXCOM5_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
sahilmgandhi 18:6a4db94011d3 108 void FLEXCOM6_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
sahilmgandhi 18:6a4db94011d3 109 void TC0_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
sahilmgandhi 18:6a4db94011d3 110 void TC1_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
sahilmgandhi 18:6a4db94011d3 111 void TC2_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
sahilmgandhi 18:6a4db94011d3 112 void TC3_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
sahilmgandhi 18:6a4db94011d3 113 void TC4_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
sahilmgandhi 18:6a4db94011d3 114 void TC5_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
sahilmgandhi 18:6a4db94011d3 115 void ADC_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
sahilmgandhi 18:6a4db94011d3 116 void ARM_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
sahilmgandhi 18:6a4db94011d3 117 void UHP_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
sahilmgandhi 18:6a4db94011d3 118 void UDP_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
sahilmgandhi 18:6a4db94011d3 119 void CRCCU_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
sahilmgandhi 18:6a4db94011d3 120
sahilmgandhi 18:6a4db94011d3 121 /* Exception Table */
sahilmgandhi 18:6a4db94011d3 122 __attribute__ ((section(".vectors")))
sahilmgandhi 18:6a4db94011d3 123 const DeviceVectors exception_table = {
sahilmgandhi 18:6a4db94011d3 124
sahilmgandhi 18:6a4db94011d3 125 /* Configure Initial Stack Pointer, using linker-generated symbols */
sahilmgandhi 18:6a4db94011d3 126 .pvStack = (void*) (&_estack),
sahilmgandhi 18:6a4db94011d3 127
sahilmgandhi 18:6a4db94011d3 128 .pfnReset_Handler = (void*) Reset_Handler,
sahilmgandhi 18:6a4db94011d3 129 .pfnNMI_Handler = (void*) NMI_Handler,
sahilmgandhi 18:6a4db94011d3 130 .pfnHardFault_Handler = (void*) HardFault_Handler,
sahilmgandhi 18:6a4db94011d3 131 .pfnMemManage_Handler = (void*) MemManage_Handler,
sahilmgandhi 18:6a4db94011d3 132 .pfnBusFault_Handler = (void*) BusFault_Handler,
sahilmgandhi 18:6a4db94011d3 133 .pfnUsageFault_Handler = (void*) UsageFault_Handler,
sahilmgandhi 18:6a4db94011d3 134 .pfnReserved1_Handler = (void*) (0UL), /* Reserved */
sahilmgandhi 18:6a4db94011d3 135 .pfnReserved2_Handler = (void*) (0UL), /* Reserved */
sahilmgandhi 18:6a4db94011d3 136 .pfnReserved3_Handler = (void*) (0UL), /* Reserved */
sahilmgandhi 18:6a4db94011d3 137 .pfnReserved4_Handler = (void*) (0UL), /* Reserved */
sahilmgandhi 18:6a4db94011d3 138 .pfnSVC_Handler = (void*) SVC_Handler,
sahilmgandhi 18:6a4db94011d3 139 .pfnDebugMon_Handler = (void*) DebugMon_Handler,
sahilmgandhi 18:6a4db94011d3 140 .pfnReserved5_Handler = (void*) (0UL), /* Reserved */
sahilmgandhi 18:6a4db94011d3 141 .pfnPendSV_Handler = (void*) PendSV_Handler,
sahilmgandhi 18:6a4db94011d3 142 .pfnSysTick_Handler = (void*) SysTick_Handler,
sahilmgandhi 18:6a4db94011d3 143
sahilmgandhi 18:6a4db94011d3 144 /* Configurable interrupts */
sahilmgandhi 18:6a4db94011d3 145 .pfnSUPC_Handler = (void*) SUPC_Handler, /* 0 Supply Controller */
sahilmgandhi 18:6a4db94011d3 146 .pfnRSTC_Handler = (void*) RSTC_Handler, /* 1 Reset Controller */
sahilmgandhi 18:6a4db94011d3 147 .pfnRTC_Handler = (void*) RTC_Handler, /* 2 Real Time Clock */
sahilmgandhi 18:6a4db94011d3 148 .pfnRTT_Handler = (void*) RTT_Handler, /* 3 Real Time Timer */
sahilmgandhi 18:6a4db94011d3 149 .pfnWDT_Handler = (void*) WDT_Handler, /* 4 Watchdog Timer */
sahilmgandhi 18:6a4db94011d3 150 .pfnPMC_Handler = (void*) PMC_Handler, /* 5 Power Management Controller */
sahilmgandhi 18:6a4db94011d3 151 .pfnEFC_Handler = (void*) EFC_Handler, /* 6 Enhanced Flash Controller */
sahilmgandhi 18:6a4db94011d3 152 #ifdef _SAMG55_FLEXCOM7_INSTANCE_
sahilmgandhi 18:6a4db94011d3 153 .pfnFLEXCOM7_Handler = (void*) FLEXCOM7_Handler, /* 7 FLEXCOM 7 */
sahilmgandhi 18:6a4db94011d3 154 #else
sahilmgandhi 18:6a4db94011d3 155 .pvReserved7 = (void*) (0UL), /* 7 Reserved */
sahilmgandhi 18:6a4db94011d3 156 #endif /* _SAMG55_FLEXCOM7_INSTANCE_ */
sahilmgandhi 18:6a4db94011d3 157 .pfnFLEXCOM0_Handler = (void*) FLEXCOM0_Handler, /* 8 FLEXCOM 0 */
sahilmgandhi 18:6a4db94011d3 158 .pfnFLEXCOM1_Handler = (void*) FLEXCOM1_Handler, /* 9 FLEXCOM 1 */
sahilmgandhi 18:6a4db94011d3 159 .pvReserved10 = (void*) (0UL), /* 10 Reserved */
sahilmgandhi 18:6a4db94011d3 160 .pfnPIOA_Handler = (void*) PIOA_Handler, /* 11 Parallel I/O Controller A */
sahilmgandhi 18:6a4db94011d3 161 .pfnPIOB_Handler = (void*) PIOB_Handler, /* 12 Parallel I/O Controller B */
sahilmgandhi 18:6a4db94011d3 162 .pfnPDMIC0_Handler = (void*) PDMIC0_Handler, /* 13 PDM 0 */
sahilmgandhi 18:6a4db94011d3 163 .pfnFLEXCOM2_Handler = (void*) FLEXCOM2_Handler, /* 14 FLEXCOM2 */
sahilmgandhi 18:6a4db94011d3 164 .pfnMEM2MEM_Handler = (void*) MEM2MEM_Handler, /* 15 MEM2MEM */
sahilmgandhi 18:6a4db94011d3 165 .pfnI2SC0_Handler = (void*) I2SC0_Handler, /* 16 I2SC0 */
sahilmgandhi 18:6a4db94011d3 166 .pfnI2SC1_Handler = (void*) I2SC1_Handler, /* 17 I2SC1 */
sahilmgandhi 18:6a4db94011d3 167 .pfnPDMIC1_Handler = (void*) PDMIC1_Handler, /* 18 PDM 1 */
sahilmgandhi 18:6a4db94011d3 168 .pfnFLEXCOM3_Handler = (void*) FLEXCOM3_Handler, /* 19 FLEXCOM3 */
sahilmgandhi 18:6a4db94011d3 169 .pfnFLEXCOM4_Handler = (void*) FLEXCOM4_Handler, /* 20 FLEXCOM4 */
sahilmgandhi 18:6a4db94011d3 170 .pfnFLEXCOM5_Handler = (void*) FLEXCOM5_Handler, /* 21 FLEXCOM5 */
sahilmgandhi 18:6a4db94011d3 171 .pfnFLEXCOM6_Handler = (void*) FLEXCOM6_Handler, /* 22 FLEXCOM6 */
sahilmgandhi 18:6a4db94011d3 172 .pfnTC0_Handler = (void*) TC0_Handler, /* 23 Timer/Counter 0 */
sahilmgandhi 18:6a4db94011d3 173 .pfnTC1_Handler = (void*) TC1_Handler, /* 24 Timer/Counter 1 */
sahilmgandhi 18:6a4db94011d3 174 .pfnTC2_Handler = (void*) TC2_Handler, /* 25 Timer/Counter 2 */
sahilmgandhi 18:6a4db94011d3 175 .pfnTC3_Handler = (void*) TC3_Handler, /* 26 Timer/Counter 3 */
sahilmgandhi 18:6a4db94011d3 176 .pfnTC4_Handler = (void*) TC4_Handler, /* 27 Timer/Counter 4 */
sahilmgandhi 18:6a4db94011d3 177 .pfnTC5_Handler = (void*) TC5_Handler, /* 28 Timer/Counter 5 */
sahilmgandhi 18:6a4db94011d3 178 .pfnADC_Handler = (void*) ADC_Handler, /* 29 Analog To Digital Converter */
sahilmgandhi 18:6a4db94011d3 179 .pfnARM_Handler = (void*) ARM_Handler, /* 30 FPU */
sahilmgandhi 18:6a4db94011d3 180 .pvReserved31 = (void*) (0UL), /* 31 Reserved */
sahilmgandhi 18:6a4db94011d3 181 .pvReserved32 = (void*) (0UL), /* 32 Reserved */
sahilmgandhi 18:6a4db94011d3 182 .pvReserved33 = (void*) (0UL), /* 33 Reserved */
sahilmgandhi 18:6a4db94011d3 183 .pvReserved34 = (void*) (0UL), /* 34 Reserved */
sahilmgandhi 18:6a4db94011d3 184 .pvReserved35 = (void*) (0UL), /* 35 Reserved */
sahilmgandhi 18:6a4db94011d3 185 .pvReserved36 = (void*) (0UL), /* 36 Reserved */
sahilmgandhi 18:6a4db94011d3 186 .pvReserved37 = (void*) (0UL), /* 37 Reserved */
sahilmgandhi 18:6a4db94011d3 187 .pvReserved38 = (void*) (0UL), /* 38 Reserved */
sahilmgandhi 18:6a4db94011d3 188 .pvReserved39 = (void*) (0UL), /* 39 Reserved */
sahilmgandhi 18:6a4db94011d3 189 .pvReserved40 = (void*) (0UL), /* 40 Reserved */
sahilmgandhi 18:6a4db94011d3 190 .pvReserved41 = (void*) (0UL), /* 41 Reserved */
sahilmgandhi 18:6a4db94011d3 191 .pvReserved42 = (void*) (0UL), /* 42 Reserved */
sahilmgandhi 18:6a4db94011d3 192 .pvReserved43 = (void*) (0UL), /* 43 Reserved */
sahilmgandhi 18:6a4db94011d3 193 .pvReserved44 = (void*) (0UL), /* 44 Reserved */
sahilmgandhi 18:6a4db94011d3 194 .pvReserved45 = (void*) (0UL), /* 45 Reserved */
sahilmgandhi 18:6a4db94011d3 195 .pvReserved46 = (void*) (0UL), /* 46 Reserved */
sahilmgandhi 18:6a4db94011d3 196 .pfnUHP_Handler = (void*) UHP_Handler, /* 47 USB OHCI */
sahilmgandhi 18:6a4db94011d3 197 .pfnUDP_Handler = (void*) UDP_Handler, /* 48 USB Device FS */
sahilmgandhi 18:6a4db94011d3 198 .pfnCRCCU_Handler = (void*) CRCCU_Handler /* 49 CRCCU */
sahilmgandhi 18:6a4db94011d3 199 };
sahilmgandhi 18:6a4db94011d3 200
sahilmgandhi 18:6a4db94011d3 201 /* TEMPORARY PATCH FOR SCB */
sahilmgandhi 18:6a4db94011d3 202 #define SCB_VTOR_TBLBASE_Pos 29 /*!< SCB VTOR: TBLBASE Position */
sahilmgandhi 18:6a4db94011d3 203 #define SCB_VTOR_TBLBASE_Msk (1UL << SCB_VTOR_TBLBASE_Pos) /*!< SCB VTOR: TBLBASE Mask */
sahilmgandhi 18:6a4db94011d3 204
sahilmgandhi 18:6a4db94011d3 205 /**
sahilmgandhi 18:6a4db94011d3 206 * \brief This is the code that gets called on processor reset.
sahilmgandhi 18:6a4db94011d3 207 * To initialize the device, and call the main() routine.
sahilmgandhi 18:6a4db94011d3 208 */
sahilmgandhi 18:6a4db94011d3 209 void Reset_Handler(void)
sahilmgandhi 18:6a4db94011d3 210 {
sahilmgandhi 18:6a4db94011d3 211 uint32_t *pSrc, *pDest;
sahilmgandhi 18:6a4db94011d3 212
sahilmgandhi 18:6a4db94011d3 213 /* Initialize the relocate segment */
sahilmgandhi 18:6a4db94011d3 214 pSrc = &_etext;
sahilmgandhi 18:6a4db94011d3 215 pDest = &_srelocate;
sahilmgandhi 18:6a4db94011d3 216
sahilmgandhi 18:6a4db94011d3 217 if (pSrc != pDest) {
sahilmgandhi 18:6a4db94011d3 218 for (; pDest < &_erelocate;) {
sahilmgandhi 18:6a4db94011d3 219 *pDest++ = *pSrc++;
sahilmgandhi 18:6a4db94011d3 220 }
sahilmgandhi 18:6a4db94011d3 221 }
sahilmgandhi 18:6a4db94011d3 222
sahilmgandhi 18:6a4db94011d3 223 /* Clear the zero segment */
sahilmgandhi 18:6a4db94011d3 224 for (pDest = &_szero; pDest < &_ezero;) {
sahilmgandhi 18:6a4db94011d3 225 *pDest++ = 0;
sahilmgandhi 18:6a4db94011d3 226 }
sahilmgandhi 18:6a4db94011d3 227
sahilmgandhi 18:6a4db94011d3 228 /* Set the vector table base address */
sahilmgandhi 18:6a4db94011d3 229 pSrc = (uint32_t *) & _sfixed;
sahilmgandhi 18:6a4db94011d3 230 SCB->VTOR = ((uint32_t) pSrc & SCB_VTOR_TBLOFF_Msk);
sahilmgandhi 18:6a4db94011d3 231
sahilmgandhi 18:6a4db94011d3 232 #if __FPU_USED
sahilmgandhi 18:6a4db94011d3 233 fpu_enable();
sahilmgandhi 18:6a4db94011d3 234 #endif
sahilmgandhi 18:6a4db94011d3 235
sahilmgandhi 18:6a4db94011d3 236 if (((uint32_t) pSrc >= IRAM_ADDR) && ((uint32_t) pSrc < IRAM_ADDR + IRAM_SIZE)) {
sahilmgandhi 18:6a4db94011d3 237 SCB->VTOR |= 1 << SCB_VTOR_TBLBASE_Pos;
sahilmgandhi 18:6a4db94011d3 238 }
sahilmgandhi 18:6a4db94011d3 239
sahilmgandhi 18:6a4db94011d3 240 /* Initialize the C library */
sahilmgandhi 18:6a4db94011d3 241 __libc_init_array();
sahilmgandhi 18:6a4db94011d3 242
sahilmgandhi 18:6a4db94011d3 243 /* Branch to main function */
sahilmgandhi 18:6a4db94011d3 244 main();
sahilmgandhi 18:6a4db94011d3 245
sahilmgandhi 18:6a4db94011d3 246 /* Infinite loop */
sahilmgandhi 18:6a4db94011d3 247 while (1);
sahilmgandhi 18:6a4db94011d3 248 }
sahilmgandhi 18:6a4db94011d3 249
sahilmgandhi 18:6a4db94011d3 250 /**
sahilmgandhi 18:6a4db94011d3 251 * \brief Default interrupt handler for unused IRQs.
sahilmgandhi 18:6a4db94011d3 252 */
sahilmgandhi 18:6a4db94011d3 253 void Dummy_Handler(void)
sahilmgandhi 18:6a4db94011d3 254 {
sahilmgandhi 18:6a4db94011d3 255 while (1) {
sahilmgandhi 18:6a4db94011d3 256 }
sahilmgandhi 18:6a4db94011d3 257 }