#if ! defined ( REG_ENTRIES_HPP )
#define REG_ENTRIES_HPP

#include <lepto/regConfig.hpp>
#include <biwak/rfm69cw/registers.hpp>

#define RE constexpr const SRegEntry

RE RESequencerOff   { RegOpMode, 7, 1 };
namespace ESequencerOff {
enum ESequencerOff: int {
   SequencerOn= 0x0,
   SequencerOff= 0x1,
};
}

RE REListenOn       { RegOpMode, 6, 1 };
namespace EListenOn {
enum EListenOn: int {
   ListenOn= 0x1,
   ListenOff= 0x0,
};
}

RE REListenAbort    { RegOpMode, 5, 1 };

RE REMode           { RegOpMode, 2, 3 };
namespace EMode
{
enum EMode: int {
   Sleep           =0x0,
   Standby         =0x1,
   FrequencySynth  =2,
   Transmit        =3,
   Receive         =4
};
}

RE REDataMode       { RegDataModul, 5, 2 };
namespace EDataMode
{
enum EDataMode: int {
   PacketMode     =0,
   Reserved       =1,
   ContinuousWithBitSynchronizer    =2,
   ContinuousWithoutBitSynchronizer =3,
};
}

RE REModulationType { RegDataModul, 3, 2 };
namespace EModulationType
{
enum EModulationType: int {
   FSK=0,
   OOK=1,
};
}

RE REModulationShaping{ RegDataModul, 0, 2 };
namespace EModulationShaping
{
enum EModulationShaping: int {
   None=0,
   Gaussian_BT_1_0=1,
   Gaussian_BT_0_5=2,
   Gaussian_BT_0_3=3,
};
}

RE REBitRateMsb{ RegBitRateMsb, 0, 8 };
namespace EBitRateMsb
{
enum EBitRateMsb: int {
   _4800   =  0x1A,
   _55555  =  0x02,
   _115kbps = 0x01,
   _150kbps = 0x00,
   _200kbps = 0x00,
   _250kbps = 0x00,
   _300kbps = 0x00,
};
}
RE REBitRateLsb{ RegBitRateLsb, 0, 8 };
namespace EBitRateLsb
{
enum EBitRateLsb: int {
   _4800   =  0x0B,
   _55555  =  0x40,
   _115kbps = 0x16,
   _150kbps = 0xD5,
   _200kbps = 0xA0,
   _250kbps = 0x80,
   _300kbps = 0x6B,
};
}

RE REFdevMsb{ RegFdevMsb, 0, 8 };
namespace EFdevMsb
{
enum EFdevMsb: int {
   _5000Hz  =  0x03,
};
}
RE REFdevLsb{ RegFdevLsb, 0, 8 };
namespace EFdevLsb
{
enum EFdevLsb: int {
   _5000Hz  =  0x33,
};
}

RE REFrfMsb{ RegFrfMsb, 0, 8 };
namespace EFrfMsb
{
enum EFrfMsb: int {
   _868Mhz  =  0xD9,
};
}
RE REFrfMid{ RegFrfMid, 0, 8 };
namespace EFrfMid
{
enum EFrfMid: int {
   _868Mhz  =  0,
};
}
RE REFrfLsb{ RegFrfLsb, 0, 8 };
namespace EFrfLsb
{
enum EFrfLsb: int {
   _868Mhz  =  0,
};
}

RE RERcCalStart{ RegOsc1, 7, 1};
RE RERcCalDone{ RegOsc1, 6, 1};
namespace ERcCalDone
{
enum ERcCalDone: int {
   Progress=0,
   Done=1,
};
}

RE REAfcLowBetaOn{ RegAfcCtrl, 5, 1};
namespace EAfcLowBetaOn
{
enum EAfcLowBetaOn: int {
   Standard,
   Improved,
};
}

RE REListenResolIdle{ RegListen1, 6, 2};
RE REListenResolRx{ RegListen1, 4, 2};
RE REListenCriteria{ RegListen1, 3, 1};
RE REListenEnd{ RegListen1, 1, 2};

RE REListenCoefIdle{ RegListen2, 0, 8};
RE REListenCoefRx{ RegListen3, 0, 8};

RE REVersion{ RegVersion, 0, 8};

RE REPa0On{ RegPaLevel, 7, 1};
RE REPa1On{ RegPaLevel, 6, 1};
RE REPa2On{ RegPaLevel, 5, 1};
RE REOutputPower{ RegPaLevel, 0, 5};

RE REPaRamp{ RegPaRamp, 0, 4};

RE REOcpOn{ RegOcp, 4, 1};
RE REOcpTrim{ RegOcp, 0, 4};

RE RELnaZin{ RegLna, 7, 1};
RE RELnaCurrentGain{ RegLna, 3, 3};
RE RELnaGainSelect{ RegLna, 0, 3};

RE REDccFreq{ RegRxBw, 5, 3};
RE RERxBwMant{ RegRxBw, 4, 2};
namespace ERxBwMant
{
enum ERxBwMant: int {
   M16          = 0b00,
   M20          = 0b01,
   M24          = 0b10,
   Reserved     = 0b10,
};
}
RE RERxBwExp{ RegRxBw, 0, 3};

RE REDccFreqAfc{ RegAfcBw, 5, 3};
RE RERxBwMantAfc{ RegAfcBw, 3, 2};
RE RERxBwExpAfc{ RegAfcBw, 0, 3};

RE REOokThreshType{ RegOokPeak, 6, 7};
RE REOokPeakTheshStep{ RegOokPeak, 3, 3};
RE REOokPeakTheshDec{ RegOokPeak, 0, 3};

RE REOokAverageThreshFilt{ RegOokAvg, 6, 2};

RE REOokFixedThresh{ RegOokFix, 0, 8};

RE REFeiDone{ RegAfcFei, 6, 1};
RE REFeiStart{ RegAfcFei, 5, 1};
RE REAfcDone{ RegAfcFei, 4, 1};
RE REAfcAutclearOn{ RegAfcFei, 3, 1};
RE REAfcAutoOn{ RegAfcFei, 2, 1};
RE REAfcClear{ RegAfcFei, 1, 1};
RE REAfcStart{ RegAfcFei, 0, 1};

RE REAfcValueMsb{ RegAfcMsb, 0, 8};
RE REAfcValueLsb{ RegAfcLsb, 0, 8};
RE REFeiValueMsb{ RegFeiMsb, 0, 8};
RE REFeiValueLsb{ RegFeiLsb, 0, 8};

RE RERssiDone{ RegRssiConfig, 1, 1};
RE RERssiStart{ RegRssiConfig, 0, 1};

RE RERssiValue{ RegRssiValue, 0, 8};

RE REDio0Mapping{ RegDioMapping1, 6, 2};
RE REDio1Mapping{ RegDioMapping1, 4, 2};
RE REDio2Mapping{ RegDioMapping1, 2, 2};
RE REDio3Mapping{ RegDioMapping1, 0, 2};

RE REDio5Mapping{ RegDioMapping2, 4, 2};
RE REClkOut{ RegDioMapping2, 0, 3};
namespace EClkOut
{
enum EClkOut: int {
   Off          = 0b111,
   FXOSC        = 0b000,
};
}


RE REModeReady{ RegIrqFlags1, 7, 1};
RE RERxReady{ RegIrqFlags1, 6, 1};
RE RETxReady{ RegIrqFlags1, 5, 1};
RE REPllLock{ RegIrqFlags1, 4, 1};
RE RERssi{ RegIrqFlags1, 3, 1};
RE RETimeout{ RegIrqFlags1, 2, 1};
RE REAutoMode{ RegIrqFlags1, 1, 1};
RE RESyncAddressMatch{ RegIrqFlags1, 0, 1};

RE REFifoFull{ RegIrqFlags2, 7, 1};
RE REFifoNotEmpty{ RegIrqFlags2, 6, 1};
RE REFifoLevel{ RegIrqFlags2, 5, 1};
RE REFifoOverrun{ RegIrqFlags2, 4, 1};
RE REPacketSent{ RegIrqFlags2, 3, 1};
RE REPayloadReady{ RegIrqFlags2, 2, 1};
RE RECrcOk{ RegIrqFlags2, 1, 1};

RE RERssiThreshold{ RegRssiThresh, 0, 8};
RE RETimeoutRxStart{ RegRxTimeout1, 0, 8};
RE RETimeoutRssiThresh{ RegRxTimeout2, 0, 8};
RE REPreambleSizeMsb{ RegPreambleMsb, 0, 8};
RE REPreambleSizeLsb{ RegPreambleLsb, 0, 8};

RE RESyncOn{ RegSyncConfig, 7, 1};
namespace ESyncOn
{
enum ESyncOn: int {
   SyncOff          = 0x0,
   SyncOn           = 0x1,
};
}
RE REFifoFillCondition{ RegSyncConfig, 6, 1};
namespace EFifoFillCondition
{
enum EFifoFillCondition: int {
   Auto              = 0x0,
   Manual            = 0x1,
};
}

RE RESyncSize{ RegSyncConfig, 3, 3};
namespace ESyncSize
{
enum ESyncSize: int {
   _1Bytes           = 0x0,
   _2Bytes           = 0x1,
   _3Bytes           = 0x2,
   _4Bytes           = 0x3,
   _5Bytes           = 0x4,
   _6Bytes           = 0x5,
   _7Bytes           = 0x6,
   _8Bytes           = 0x7,
};
}

RE RESyncTol{ RegSyncConfig, 0, 3};
RE RESyncValue1{ RegSyncValue1, 0, 8};
RE RESyncValue2{ RegSyncValue2, 0, 8};
RE RESyncValue3{ RegSyncValue3, 0, 8};
RE RESyncValue4{ RegSyncValue4, 0, 8};
RE RESyncValue5{ RegSyncValue5, 0, 8};
RE RESyncValue6{ RegSyncValue6, 0, 8};
RE RESyncValue7{ RegSyncValue7, 0, 8};
RE RESyncValue8{ RegSyncValue8, 0, 8};

RE REPacketFormat{ RegPacketConfig1, 7, 1};
namespace EPacketFormat
{
enum EPacketFormat: int {
   Fixed              = 0x0,
   Variable           = 0x1,
};
}
RE REDcFree{ RegPacketConfig1, 5, 2};
namespace EDcFree
{
enum EDcFree: int {
   None              = 0b00,
   Manchaster        = 0b01,
   Whitening         = 0b10,
   Reserved          = 0b11,
};
}
RE RECrcOn{ RegPacketConfig1, 4, 1};
namespace ECrcOn
{
enum ECrcOn: int {
   CrcOff            = 0x0,
   CrcOn             = 0x1,
};
}
RE RECrcAutoClearOff{ RegPacketConfig1, 3, 1};
namespace ECrcAutoClearOff
{
enum ECrcAutoClearOff: int {
   AutoClearOn       = 0x0,
   AutoClearOff      = 0x1,
};
}

RE REAddressFiltering{ RegPacketConfig1, 1, 2};
namespace EAddressFiltering
{
enum EAddressFiltering: int {
   None              = 0x0,
   Address           = 0x1,
   AddressBroadCast  = 0x2,
};
}

RE REPayloadLength{ RegPayloadLength, 0, 8};
RE RENodeAddress{ RegNodeAdrs, 0, 8};
RE REBroadcastAddress{ RegBroadcastAdrs, 0, 8};

RE REEnterCondition{ RegAutoModes, 5, 3};
RE REExitCondition{ RegAutoModes, 2, 3};
RE REIntermediateMode{ RegAutoModes, 0, 2};

RE RETxStartCondition{ RegFifoThresh, 7, 1};
namespace ETxStartCondition
{
enum EInterPacketRxDelay: int {
   FifoLevel              = 0x0,
   FifoNotEmpty           = 0x1,
};
}
RE REFifoThreshold{ RegFifoThresh, 0, 7};
RE REInterPacketRxDelay{ RegPacketConfig2, 4, 4};
namespace EInterPacketRxDelay
{
enum EInterPacketRxDelay: int {
   Delay2Bits             = 0x1,
};
}

RE RERestartRx{ RegPacketConfig2, 2, 1};
RE REAutoRxRestartOn{ RegPacketConfig2, 1, 1};
namespace EAutoRxRestartOn
{
enum EAutoRxRestartOn: int {
   RestartOf              = 0x0,
   RestartOn              = 0x1,
};
}

RE REAesOn{ RegPacketConfig2, 0, 1};
namespace EAesOn
{
enum EAesOn: int {
   AesOff             = 0x0,
   AesOn              = 0x1,
};
}

RE REAesKey1{ RegAesKey1, 0, 8};
RE REAesKey2{ RegAesKey2, 0, 8};
RE REAesKey3{ RegAesKey3, 0, 8};
RE REAesKey4{ RegAesKey4, 0, 8};
RE REAesKey5{ RegAesKey5, 0, 8};
RE REAesKey6{ RegAesKey6, 0, 8};
RE REAesKey7{ RegAesKey7, 0, 8};
RE REAesKey8{ RegAesKey8, 0, 8};
RE REAesKey9{ RegAesKey9, 0, 8};
RE REAesKey10{ RegAesKey10, 0, 8};
RE REAesKey11{ RegAesKey11, 0, 8};
RE REAesKey12{ RegAesKey12, 0, 8};
RE REAesKey13{ RegAesKey13, 0, 8};
RE REAesKey14{ RegAesKey14, 0, 8};
RE REAesKey15{ RegAesKey15, 0, 8};
RE REAesKey16{ RegAesKey16, 0, 8};

RE RETempMeasStart{ RegTemp1, 3, 1};
RE RETempMeasRunning{ RegTemp1, 2, 1};
RE RETempValue{ RegTemp2, 0, 8};

RE RESensitivityBoost{ RegTestLna, 0, 8};
RE REPa13dBm1{ RegTestPa1, 0, 8};
RE REPa13dBm2{ RegTestPa2, 0, 8};
RE REContinuousDagc{ RegTestDagc, 0, 8};
namespace EContinuousDagc
{
enum EContinuousDagc: int {
   Normal                  = 0x0,
   ImprovedMargin_LowBeta1  = 0x20,
   ImprovedMargin_LowBeta0  = 0x30,
};
}

RE RELowBetaAfcOffset{ RegTestAfc, 0, 8};


#endif // ? ! REG_ENTRIES_HPP
