#include <cassert>

#include "platform/cm4/InterruptHandler.h"
#include "platform/cm4/InterruptGuardian.h"

extern "C" {
    void NMI_Handler(void);
    void HardFault_Handler(void);
    void MemoryManagement_Handler(void);
    void BusFault_Handler(void);
    void UsageFault_Handler(void);
    void SVC_Handler(void);
    void DebugMon_Handler(void);
    void PendSV_Handler(void);
    void SysTick_Handler(void);
}

using namespace pinetime::platform::cm4;

void SysTick_Handler(void)
{
    uint32_t irq_nr = InterruptGuardian::SYS_TICK_IRQ;
    InterruptHandler *h = InterruptGuardian::instance.cm4_vector[irq_nr];

    assert(h != nullptr);

    h->handle();
}
