#ifndef __PLATFORM_NRF52_GPIOTE_H__
#define __PLATFORM_NRF52_GPIOTE_H__

#include <array>

#include "gpio_interface.h"
#include "platform/nrf52/InterruptHandler.h"

namespace pinetime::platform::nrf52
{
class Gpiote;
}
extern pinetime::platform::nrf52::Gpiote gpiote;

namespace pinetime::platform::nrf52
{

class Gpiote
    : public pinetime::platform::nrf52::InterruptHandler
{
public:
    Gpiote();

    static inline Gpiote & instance() { return gpiote; }

    void enable() override;
    void disable() override;

    void register_handler(pinetime::interfaces::GpioInterface *);

private:
    void handle() override;

    enum {
        GPIOTE_CHANNELS = 8,
    };

    std::array<pinetime::interfaces::GpioInterface *, GPIOTE_CHANNELS> gpiote_channels;
    uint32_t num_registered;
};

}

#endif
