#include <array>

#include "delay.h"

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

#include "platform/nrf52/gpio.h"
#include "platform/nrf52/InterruptHandler.h"
#include "platform/nrf52/InterruptGuardian.h"

using namespace pinetime::platform;

enum {
    PIN_NUMBER_LED_1 = 17,
    PIN_NUMBER_LED_2 = 18,
    PIN_NUMBER_LED_3 = 19,
    PIN_NUMBER_LED_4 = 20
};

nrf52::Gpio led_1(PIN_NUMBER_LED_1);
nrf52::Gpio led_2(PIN_NUMBER_LED_2);
nrf52::Gpio led_3(PIN_NUMBER_LED_3);
nrf52::Gpio led_4(PIN_NUMBER_LED_4);

std::array<nrf52::Gpio *, 4> leds = {&led_1, &led_2, &led_3, &led_4};

cm4::InterruptGuardian cm4::InterruptGuardian::instance;
nrf52::InterruptGuardian nrf52::InterruptGuardian::instance;

int main(void)
{
    while(true) {
        for(auto it = std::begin(leds); it != std::end(leds); ++it) {
            nrf52::Gpio * tmp = *it;
            tmp->toggle();
            delay_ms(500);
        }
    }
    return 0;
}
