#pragma once
#include "ioport.hpp"

namespace JabyEngine {
    namespace Timer_IO_Values {
        __declare_io_struct(CounterMode, uint32_t) {
            static constexpr auto SyncEnable       = Bit(0);
            static constexpr auto FreeRun          = !SyncEnable;
            static constexpr auto SyncMode         = BitRange::from_to(1, 2);
            static constexpr auto ResetAfterTarget = Bit(3);
            static constexpr auto IRQAtTarget      = Bit(4);
            static constexpr auto IRQAtMax         = Bit(5);
            static constexpr auto IRQEveryTime     = Bit(6);
            static constexpr auto IRQOneShot       = !IRQEveryTime;
            static constexpr auto IRQToggle        = Bit(7);
            static constexpr auto IRQPulse         = !IRQToggle;            
            static constexpr auto ClockSource      = BitRange::from_to(8, 9);
            static constexpr auto HasIRQRequest    = Bit(10);
            static constexpr auto IsTargetReached  = Bit(11);
            static constexpr auto IsMaxReached     = Bit(12);
        };

        __declare_io_struct(CounterTarget, uint32_t) {
            static constexpr auto CounterTargetValue = BitRange::from_to(0, 15);
        };

        __declare_io_struct(CounterValue, uint32_t) {
            static constexpr auto Value = BitRange::from_to(0, 15);
        };
    }
}