// Copyright (c) 2022 Cesanta Software Limited // All rights reserved // Startup code __attribute__((naked, noreturn)) void _reset(void) { // Initialise memory extern long _sbss, _ebss, _sdata, _edata, _sidata; for (long *src = &_sbss; src < &_ebss; src++) *src = 0; for (long *src = &_sdata, *dst = &_sidata; src < &_edata;) *src++ = *dst++; // Call main() extern void main(void); main(); for (;;) (void) 0; } void __attribute__((weak)) DefaultIRQHandler(void) { for (;;) (void) 0; } #define WEAK_ALIAS __attribute__((weak, alias("DefaultIRQHandler"))) WEAK_ALIAS void NMI_Handler(void); WEAK_ALIAS void HardFault_Handler(void); WEAK_ALIAS void MemManage_Handler(void); WEAK_ALIAS void BusFault_Handler(void); WEAK_ALIAS void UsageFault_Handler(void); WEAK_ALIAS void SVC_Handler(void); WEAK_ALIAS void DebugMon_Handler(void); WEAK_ALIAS void PendSV_Handler(void); WEAK_ALIAS void SysTick_Handler(void); // IRQ table extern void _estack(); __attribute__((section(".vectors"))) void (*tab[16 + 150])(void) = { // Cortex interrupts _estack, _reset, NMI_Handler, HardFault_Handler, MemManage_Handler, BusFault_Handler, UsageFault_Handler, 0, 0, 0, 0, SVC_Handler, DebugMon_Handler, 0, PendSV_Handler, SysTick_Handler, // Interrupts from peripherals DefaultIRQHandler};