kopia lustrzana https://github.com/bristol-seds/pico-tracker
207 wiersze
8.7 KiB
C
207 wiersze
8.7 KiB
C
/**
|
|
* \file
|
|
*
|
|
* \brief gcc starttup file for SAMD20
|
|
*
|
|
* Copyright (c) 2013 Atmel Corporation. All rights reserved.
|
|
*
|
|
* \asf_license_start
|
|
*
|
|
* \page License
|
|
*
|
|
* Redistribution and use in source and binary forms, with or without
|
|
* modification, are permitted provided that the following conditions are met:
|
|
*
|
|
* 1. Redistributions of source code must retain the above copyright notice,
|
|
* this list of conditions and the following disclaimer.
|
|
*
|
|
* 2. 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.
|
|
*
|
|
* 3. The name of Atmel may not be used to endorse or promote products derived
|
|
* from this software without specific prior written permission.
|
|
*
|
|
* 4. This software may only be redistributed and used in connection with an
|
|
* Atmel microcontroller product.
|
|
*
|
|
* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
|
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
|
* EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL 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.
|
|
*
|
|
* \asf_license_stop
|
|
*
|
|
*/
|
|
|
|
#include "samd20.h"
|
|
#include "semihosting.h"
|
|
|
|
/* Initialize segments */
|
|
extern uint32_t __fixed_start;
|
|
extern uint32_t __fixed_end;
|
|
extern uint32_t __etext;
|
|
extern uint32_t __data_start;
|
|
extern uint32_t __data_end;
|
|
extern uint32_t __bss_start;
|
|
extern uint32_t __bss_end;
|
|
extern uint32_t __stack_start;
|
|
extern uint32_t __stack_end;
|
|
|
|
/** \cond DOXYGEN_SHOULD_SKIP_THIS */
|
|
int main(void);
|
|
/** \endcond */
|
|
|
|
void __libc_init_array(void);
|
|
extern void initialise_monitor_handles(void);
|
|
|
|
/* Default empty handler */
|
|
void Dummy_Handler(void);
|
|
|
|
/* Cortex-M0+ core handlers */
|
|
void NMI_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
|
|
void HardFault_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
|
|
void SVC_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
|
|
void PendSV_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
|
|
void SysTick_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
|
|
|
|
/* Peripherals handlers */
|
|
void PM_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
|
|
void SYSCTRL_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
|
|
void WDT_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
|
|
void RTC_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
|
|
void EIC_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
|
|
void NVMCTRL_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
|
|
void EVSYS_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
|
|
void SERCOM0_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
|
|
void SERCOM1_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
|
|
void SERCOM2_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
|
|
void SERCOM3_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
|
|
void SERCOM4_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
|
|
void SERCOM5_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
|
|
void TC0_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
|
|
void TC1_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
|
|
void TC2_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
|
|
void TC3_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
|
|
void TC4_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
|
|
void TC5_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
|
|
void TC6_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
|
|
void TC7_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
|
|
void ADC_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
|
|
void AC_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
|
|
void DAC_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
|
|
void PTC_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
|
|
|
|
/* Exception Table */
|
|
__attribute__ ((section(".vectors")))
|
|
const DeviceVectors exception_table = {
|
|
|
|
/* Configure Initial Stack Pointer, using linker-generated symbols */
|
|
(void*) (&__stack_end),
|
|
|
|
(void*) Reset_Handler,
|
|
(void*) NMI_Handler,
|
|
(void*) HardFault_Handler,
|
|
(void*) (0UL), /* Reserved */
|
|
(void*) (0UL), /* Reserved */
|
|
(void*) (0UL), /* Reserved */
|
|
(void*) (0UL), /* Reserved */
|
|
(void*) (0UL), /* Reserved */
|
|
(void*) (0UL), /* Reserved */
|
|
(void*) (0UL), /* Reserved */
|
|
(void*) SVC_Handler,
|
|
(void*) (0UL), /* Reserved */
|
|
(void*) (0UL), /* Reserved */
|
|
(void*) PendSV_Handler,
|
|
(void*) SysTick_Handler,
|
|
|
|
/* Configurable interrupts */
|
|
(void*) PM_Handler, /* 0 Power Manager */
|
|
(void*) SYSCTRL_Handler, /* 1 System Control */
|
|
(void*) WDT_Handler, /* 2 Watchdog Timer */
|
|
(void*) RTC_Handler, /* 3 Real-Time Counter */
|
|
(void*) EIC_Handler, /* 4 External Interrupt Controller */
|
|
(void*) NVMCTRL_Handler, /* 5 Non-Volatile Memory Controller */
|
|
(void*) EVSYS_Handler, /* 6 Event System Interface */
|
|
(void*) SERCOM0_Handler, /* 7 Serial Communication Interface 0 */
|
|
(void*) SERCOM1_Handler, /* 8 Serial Communication Interface 1 */
|
|
(void*) SERCOM2_Handler, /* 9 Serial Communication Interface 2 */
|
|
(void*) SERCOM3_Handler, /* 10 Serial Communication Interface 3 */
|
|
(void*) SERCOM4_Handler, /* 11 Serial Communication Interface 4 */
|
|
(void*) SERCOM5_Handler, /* 12 Serial Communication Interface 5 */
|
|
(void*) TC0_Handler, /* 13 Basic Timer Counter 0 */
|
|
(void*) TC1_Handler, /* 14 Basic Timer Counter 1 */
|
|
(void*) TC2_Handler, /* 15 Basic Timer Counter 2 */
|
|
(void*) TC3_Handler, /* 16 Basic Timer Counter 3 */
|
|
(void*) TC4_Handler, /* 17 Basic Timer Counter 4 */
|
|
(void*) TC5_Handler, /* 18 Basic Timer Counter 5 */
|
|
(void*) TC6_Handler, /* 19 Basic Timer Counter 6 */
|
|
(void*) TC7_Handler, /* 20 Basic Timer Counter 7 */
|
|
(void*) ADC_Handler, /* 21 Analog Digital Converter */
|
|
(void*) AC_Handler, /* 22 Analog Comparators */
|
|
(void*) DAC_Handler, /* 23 Digital Analog Converter */
|
|
(void*) PTC_Handler /* 24 Peripheral Touch Controller */
|
|
};
|
|
|
|
/**
|
|
* \brief This is the code that gets called on processor reset.
|
|
* To initialize the device, and call the main() routine.
|
|
*/
|
|
__attribute__((noreturn))
|
|
void Reset_Handler(void)
|
|
{
|
|
uint32_t *pSrc, *pDest;
|
|
|
|
/* Initialize the relocate segment */
|
|
pSrc = &__etext;
|
|
pDest = &__data_start;
|
|
|
|
if (pSrc != pDest) {
|
|
for (; pDest < &__data_end;) {
|
|
*pDest++ = *pSrc++;
|
|
}
|
|
}
|
|
|
|
/* Clear the zero segment */
|
|
for (pDest = &__bss_start; pDest < &__bss_end;) {
|
|
*pDest++ = 0;
|
|
}
|
|
|
|
/* Initialize the C library */
|
|
__libc_init_array();
|
|
|
|
#ifdef __SEMIHOSTING__
|
|
/* If there's a debugger attached */
|
|
if (DSU->STATUSB.reg & DSU_STATUSB_DBGPRES) {
|
|
|
|
/* Initialise handles for semihosting */
|
|
initialise_monitor_handles();
|
|
|
|
/* Set semihosting functions */
|
|
set_semihosting();
|
|
}
|
|
#endif /* __SEMIHOSTING__ */
|
|
|
|
/* Branch to main function */
|
|
main();
|
|
|
|
/* Infinite loop */
|
|
while (1);
|
|
}
|
|
|
|
/**
|
|
* \brief Default interrupt handler for unused IRQs.
|
|
*/
|
|
void Dummy_Handler(void)
|
|
{
|
|
|
|
while (1);
|
|
}
|