#![deny(missing_docs, unsafe_code, warnings)]
#![allow(unused_braces, clippy::upper_case_acronyms)]
use modular_bitfield_msb::prelude::*;
use static_assertions::assert_eq_size;
#[repr(u8)]
#[derive(Debug, BitfieldSpecifier)]
#[bits = 6]
pub enum GDOCfg {
RxFifoThreshold = 0,
RxFifoThresholdEmpty = 1,
TxFifoThreshold = 2,
TxFifoThresholdEmpty = 3,
RxFifoOverflow = 4,
TxFifoUnderflow = 5,
SyncWord = 6,
PacketReceived = 7,
PreambleQualityReached = 8,
ClearChannel = 9,
LockDetected = 10,
SerialClock = 11,
SerialSynchronousData = 12,
SerialAsynchronousData = 13,
CarrierSense = 14,
CrcOk = 15,
RxHardData1 = 22,
RxHardData0 = 23,
PaPd = 27,
LnaPd = 28,
RxSymbolTick = 29,
WorEvnt0 = 36,
WorEvnt1 = 37,
Clk256 = 38,
Clk32k = 39,
ChipRdyN = 41,
XOscStable = 43,
HighZ = 46,
HwTo0 = 47,
ClkXOsc1 = 48,
ClkXOsc1_5 = 49,
ClkXOsc2 = 50,
ClkXOsc3 = 51,
ClkXOsc4 = 52,
ClkXOsc6 = 53,
ClkXOsc8 = 54,
ClkXOsc12 = 55,
ClkXOsc16 = 56,
ClkXOsc24 = 57,
ClkXOsc32 = 58,
ClkXOsc48 = 59,
ClkXOsc64 = 60,
ClkXOsc96 = 61,
ClkXOsc128 = 62,
ClkXOsc192 = 63,
}
#[repr(u8)]
#[derive(Debug, BitfieldSpecifier)]
#[bits = 2]
pub enum RXAttenuation {
Db0,
Db6,
Db12,
Db18,
}
#[repr(u8)]
#[derive(Debug, BitfieldSpecifier)]
#[bits = 4]
pub enum FifoThreshold {
Tx61Rx4,
Tx57Rx8,
Tx53Rx12,
Tx49Rx16,
Tx45Rx20,
Tx41Rx24,
Tx37Rx28,
Tx33Rx32,
Tx29Rx36,
Tx25Rx40,
Tx21Rx44,
Tx17Rx48,
Tx13Rx52,
Tx9Rx56,
Tx5Rx60,
Tx1Rx64,
}
#[repr(u8)]
#[derive(Debug, BitfieldSpecifier)]
#[bits = 2]
pub enum AdrChk {
NoAddressCheck,
AddressCheckNoBroadcast,
AddressCheck0Broadcast,
AddressCheck0_255Broadcast,
}
#[repr(u8)]
#[derive(Debug, BitfieldSpecifier)]
#[bits = 2]
pub enum PktFormat {
Normal,
SynchronousSerial,
RandomTx,
AsynchronousSerial,
}
#[repr(u8)]
#[derive(Debug, BitfieldSpecifier)]
#[bits = 2]
pub enum LengthConfig {
Fixed,
Variable,
Infinite,
}
#[repr(u8)]
#[derive(Debug, BitfieldSpecifier)]
#[bits = 3]
pub enum ModFormat {
Fsk2 = 0,
Gfsk = 1,
AskOok = 3,
Fsk4 = 4,
Msk = 7,
}
#[repr(u8)]
#[derive(Debug, BitfieldSpecifier)]
#[bits = 3]
pub enum SyncMode {
None,
Sync15_16,
Sync16_16,
Sync30_32,
CSAboveThres,
#[allow(non_camel_case_types)]
Sync15_16_CSAboveThres,
#[allow(non_camel_case_types)]
Sync16_16_CSAboveThres,
#[allow(non_camel_case_types)]
Sync30_32_CSAboveThres,
}
#[repr(u8)]
#[derive(Debug, BitfieldSpecifier)]
#[bits = 3]
pub enum NumPreamble {
Bytes2,
Bytes3,
Bytes4,
Bytes6,
Bytes8,
Bytes12,
Bytes16,
Bytes24,
}
#[repr(u8)]
#[derive(Debug, BitfieldSpecifier)]
#[bits = 3]
pub enum RxTime {
Time0,
Time1,
Time2,
Time3,
Time4,
Time5,
Time6,
UntilEndOfPacket,
}
#[repr(u8)]
#[derive(Debug, BitfieldSpecifier)]
#[bits = 2]
pub enum CcaMode {
Always,
RssiBelowThres,
ReceivingPacket,
RssiBelowThresUnlessReceivingPacket,
}
#[repr(u8)]
#[derive(Debug, BitfieldSpecifier)]
#[bits = 2]
pub enum RxoffMode {
Idle,
FstxOn,
Tx,
StayInRx,
}
#[repr(u8)]
#[derive(Debug, BitfieldSpecifier)]
#[bits = 2]
pub enum TxoffMode {
Idle,
FstxOn,
StayInTx,
Rx,
}
#[repr(u8)]
#[derive(Debug, BitfieldSpecifier)]
#[bits = 2]
pub enum FsAutocal {
Never,
FromIdleToRxOrTxOrFstxOn,
FromRxOrTxToIdle,
Every4thFromRxOrTxToIdle,
}
#[repr(u8)]
#[derive(Debug, BitfieldSpecifier)]
#[bits = 2]
pub enum PoTimeout {
Count1,
Count16,
Count64,
Count256,
}
#[repr(u8)]
#[derive(Debug, BitfieldSpecifier)]
#[bits = 2]
pub enum FocPreK {
K,
K2,
K3,
K4,
}
#[repr(u8)]
#[derive(Debug, BitfieldSpecifier)]
#[bits = 1]
pub enum FocPostK {
SameAsPreK,
KOver2,
}
#[repr(u8)]
#[derive(Debug, BitfieldSpecifier)]
#[bits = 2]
pub enum FocLimit {
PM0,
PMBWOver8,
PMBWOver4,
PMBWOver2,
}
#[repr(u8)]
#[derive(Debug, BitfieldSpecifier)]
#[bits = 2]
pub enum BsPreKi {
KI,
KI2,
KI3,
KI4,
}
#[repr(u8)]
#[derive(Debug, BitfieldSpecifier)]
#[bits = 2]
pub enum BsPreKp {
KP,
KP2,
KP3,
KP4,
}
#[repr(u8)]
#[derive(Debug, BitfieldSpecifier)]
#[bits = 1]
pub enum BsPostKi {
SameAsBsPreKi,
KIOver2,
}
#[repr(u8)]
#[derive(Debug, BitfieldSpecifier)]
#[bits = 1]
pub enum BsPostKp {
SameAsBsPreKp,
KP,
}
#[repr(u8)]
#[derive(Debug, BitfieldSpecifier)]
#[bits = 2]
pub enum BsLimit {
PM0,
PM3_125,
PM6_25,
PM12_5,
}
#[repr(u8)]
#[derive(Debug, BitfieldSpecifier)]
#[bits = 2]
pub enum MaxDvgaGain {
AllGainCanBeUsed,
HighestGainCannotBeUsed,
TwoHighestGainCannotBeUsed,
ThreeHighestGainCannotBeUsed,
}
#[repr(u8)]
#[derive(Debug, BitfieldSpecifier)]
#[bits = 3]
pub enum MaxLnaGain {
MaxPossibleLNAPlusLNA2,
Approx2_6BelowMax,
Approx6_1BelowMax,
Approx7_4BelowMax,
Approx9_2BelowMax,
Approx11_5BelowMax,
Approx14_6BelowMax,
Approx17_1BelowMax,
}
#[repr(u8)]
#[derive(Debug, BitfieldSpecifier)]
#[bits = 3]
pub enum MagnTarget {
Db24,
Db27,
Db30,
Db33,
Db36,
Db38,
Db40,
Db42,
}
#[repr(u8)]
#[derive(Debug, BitfieldSpecifier)]
#[bits = 2]
pub enum CarrierSenseRelThr {
RelThrDisabled,
Db6IncreaseRssi,
Db10IncreaseRssi,
Db14IncreaseRssi,
}
#[repr(u8)]
#[derive(Debug, BitfieldSpecifier)]
#[bits = 4]
pub enum CarrierSenseAbsThr {
AbsThrDisabled = 0b1000,
Db7BelowTarget = 0b1001,
Db6BelowTarget = 0b1010,
Db5BelowTarget = 0b1011,
Db4BelowTarget = 0b1100,
Db3BelowTarget = 0b1101,
Db2BelowTarget = 0b1110,
Db1BelowTarget = 0b1111,
AtTarget = 0b0000,
Db1AboveTarget = 0b0001,
Db2AboveTarget = 0b0010,
Db3AboveTarget = 0b0011,
Db4AboveTarget = 0b0100,
Db5AboveTarget = 0b0101,
Db6AboveTarget = 0b0110,
Db7AboveTarget = 0b0111,
}
#[repr(u8)]
#[derive(Debug, BitfieldSpecifier)]
#[bits = 2]
pub enum HystLevel {
NoHysteresis,
LowHysteresis,
MediumHysteresis,
LargeHysteresis,
}
#[repr(u8)]
#[derive(Debug, BitfieldSpecifier)]
#[bits = 2]
pub enum WaitTime {
Samples8,
Samples16,
Samples24,
Samples32,
}
#[repr(u8)]
#[derive(Debug, BitfieldSpecifier)]
#[bits = 2]
pub enum AgcFreeze {
AlwaysAdjust,
GainFrozenOnSyncWord,
FreezeAnalogueAdjustDigital,
FreezeAnalogueAndDigital,
}
#[repr(u8)]
#[derive(Debug, BitfieldSpecifier)]
#[bits = 2]
pub enum FilterLength {
Samples8,
Samples16,
Samples24,
Samples32,
}
#[repr(u8)]
#[derive(Debug, BitfieldSpecifier)]
#[bits = 3]
pub enum Event1 {
Time4,
Time6,
Time8,
Time12,
Time16,
Time24,
Time32,
Time48,
}
#[repr(u8)]
#[derive(Debug, BitfieldSpecifier)]
#[bits = 2]
pub enum WorRes {
Period1,
Period2_5,
Period2_10,
Period2_15,
}
#[repr(u8)]
#[derive(Debug, BitfieldSpecifier)]
#[bits = 5]
pub enum MarcState {
Sleep,
Idle,
Xoff,
VcoonMc,
RegonMc,
Mancal,
Vcoon,
Regon,
Startcal,
Bwboost,
FsLock,
Ifadcon,
Endcal,
Rx,
RxEnd,
RxRst,
TxrxSwitch,
RxFifoOverflow,
Fstxon,
Tx,
TxEnd,
RxtxSwitch,
TxfifoUnderflow,
}
#[bitfield]
#[derive(Debug, Copy, Clone, BitfieldSpecifier)]
pub struct IOCFG2 {
#[skip]
__: bool,
pub gdo2_inv: bool,
pub gdo2_cfg: GDOCfg,
}
#[bitfield]
#[derive(Debug, Copy, Clone, BitfieldSpecifier)]
pub struct IOCFG1 {
pub gdo_ds: bool,
pub gdo1_inv: bool,
pub gdo1_cfg: GDOCfg,
}
#[bitfield]
#[derive(Debug, Copy, Clone, BitfieldSpecifier)]
pub struct IOCFG0 {
pub temp_sensor_enable: bool,
pub gdo0_inv: bool,
pub gdo0_cfg: GDOCfg,
}
#[bitfield]
#[derive(Debug, Copy, Clone, BitfieldSpecifier)]
pub struct FIFOTHR {
#[skip]
__: bool,
pub adc_retention: bool,
pub close_in_rx: RXAttenuation,
pub fifo_thr: FifoThreshold,
}
#[bitfield]
#[derive(Debug, Copy, Clone, BitfieldSpecifier)]
pub struct PKTCTRL1 {
pub pqt: B3,
#[skip]
__: bool,
pub crc_autoflush: bool,
pub append_status: bool,
pub adr_chk: AdrChk,
}
#[bitfield]
#[derive(Debug, Copy, Clone, BitfieldSpecifier)]
pub struct PKTCTRL0 {
#[skip]
__: bool,
pub white_data: bool,
pub pkt_format: PktFormat,
#[skip]
__: bool,
pub crc_en: bool,
pub length_config: LengthConfig,
}
#[bitfield]
#[derive(Debug, Copy, Clone, BitfieldSpecifier)]
pub struct FSCTRL1 {
#[skip]
__: B3,
pub freq_if: B5,
}
#[bitfield]
#[derive(Debug, Copy, Clone, BitfieldSpecifier)]
pub struct FSCTRL0 {
pub freq_off: B8,
}
#[bitfield]
#[derive(Debug, Copy, Clone, BitfieldSpecifier)]
pub struct MDMCFG4 {
pub chanbw_e: B2,
pub chanbw_m: B2,
pub drate_e: B4,
}
#[bitfield]
#[derive(Debug, Copy, Clone, BitfieldSpecifier)]
pub struct MDMCFG3 {
pub drate_m: B8,
}
#[bitfield]
#[derive(Debug, Copy, Clone, BitfieldSpecifier)]
pub struct MDMCFG2 {
pub dem_dcfilt_off: bool,
pub mod_format: ModFormat,
pub manchester_en: bool,
pub sync_mode: SyncMode,
}
#[bitfield]
#[derive(Debug, Copy, Clone, BitfieldSpecifier)]
pub struct MDMCFG1 {
pub fec_en: bool,
pub num_preamble: NumPreamble,
#[skip]
__: B2,
pub chanspc_e: B2,
}
#[bitfield]
#[derive(Debug, Copy, Clone, BitfieldSpecifier)]
pub struct MDMCFG0 {
pub chanspc_m: B8,
}
#[bitfield]
#[derive(Debug, Copy, Clone, BitfieldSpecifier)]
pub struct DEVIATN {
#[skip]
__: B1,
pub deviation_e: B3,
#[skip]
__: B1,
pub deviation_m: B3,
}
#[bitfield]
#[derive(Debug, Copy, Clone, BitfieldSpecifier)]
pub struct MCSM2 {
#[skip]
__: B3,
pub rx_time_rssi: bool,
pub rx_time_qual: bool,
pub rx_time: RxTime,
}
#[bitfield]
#[derive(Debug, Copy, Clone, BitfieldSpecifier)]
pub struct MCSM1 {
#[skip]
__: B2,
pub cca_mode: CcaMode,
pub rxoff_mode: RxoffMode,
pub txoff_mode: TxoffMode,
}
#[bitfield]
#[derive(Debug, Copy, Clone, BitfieldSpecifier)]
pub struct MCSM0 {
#[skip]
__: B2,
pub fs_autocal: FsAutocal,
pub po_timeout: PoTimeout,
pub pin_ctrl_en: bool,
pub xosc_force_on: bool,
}
#[bitfield]
#[derive(Debug, Copy, Clone, BitfieldSpecifier)]
pub struct FOCCFG {
#[skip]
__: B2,
pub foc_bs_cs_gate: bool,
pub foc_pre_k: FocPreK,
pub foc_post_k: FocPostK,
pub foc_limit: FocLimit,
}
#[bitfield]
#[derive(Debug, Copy, Clone, BitfieldSpecifier)]
pub struct BSCFG {
pub bs_pre_ki: BsPreKi,
pub bs_pre_kp: BsPreKp,
pub bs_post_ki: BsPostKi,
pub bs_post_kp: BsPostKp,
pub bs_limit: BsLimit,
}
#[bitfield]
#[derive(Debug, Copy, Clone, BitfieldSpecifier)]
pub struct AGCCTRL2 {
pub max_dvga_gain: MaxDvgaGain,
pub max_lna_gain: MaxLnaGain,
pub magn_target: MagnTarget,
}
#[bitfield]
#[derive(Debug, Copy, Clone, BitfieldSpecifier)]
pub struct AGCCTRL1 {
#[skip]
__: B1,
pub agc_lna_priority: bool,
pub carrier_sense_rel_thr: CarrierSenseRelThr,
pub carrier_sense_abs_thr: CarrierSenseAbsThr,
}
#[bitfield]
#[derive(Debug, Copy, Clone, BitfieldSpecifier)]
pub struct AGCCTRL0 {
pub hyst_level: HystLevel,
pub wait_time: WaitTime,
pub agc_freeze: AgcFreeze,
pub filter_length: FilterLength,
}
#[bitfield]
#[derive(Debug, Copy, Clone, BitfieldSpecifier)]
pub struct WORCTRL {
pub rc_pd: bool,
pub event1: Event1,
pub rc_cal: bool,
#[skip]
__: B1,
pub wor_res: WorRes,
}
#[bitfield]
#[derive(Debug, Copy, Clone, BitfieldSpecifier)]
pub struct FREND1 {
pub lna_current: B2,
pub lna2mix_current: B2,
pub lodiv_buf_current_rx: B2,
pub mix_current: B2,
}
#[bitfield]
#[derive(Debug, Copy, Clone, BitfieldSpecifier)]
pub struct FREND0 {
#[skip]
__: B2,
pub lodiv_buf_current_tx: B2,
#[skip]
__: B1,
pub pa_power: B3,
}
#[bitfield]
#[derive(Debug, Copy, Clone, BitfieldSpecifier)]
pub struct FSCAL3 {
pub fscal3: B2,
pub chp_curr_cal_en: B2,
pub fscal3_res: B4,
}
#[bitfield]
#[derive(Debug, Copy, Clone, BitfieldSpecifier)]
pub struct FSCAL2 {
#[skip]
__: B2,
pub vco_core_h_en: bool,
pub fscal2_res: B5,
}
#[bitfield]
#[derive(Debug, Copy, Clone, BitfieldSpecifier)]
pub struct FSCAL1 {
#[skip]
__: B2,
pub fscal1_res: B6,
}
#[bitfield]
#[derive(Debug, Copy, Clone, BitfieldSpecifier)]
pub struct FSCAL0 {
#[skip]
__: B1,
pub fscal0_res: B7,
}
#[bitfield]
#[derive(Debug, Copy, Clone, BitfieldSpecifier)]
pub struct RCCTRL1 {
#[skip]
__: B1,
pub rcctrl1: B7,
}
#[bitfield]
#[derive(Debug, Copy, Clone, BitfieldSpecifier)]
pub struct RCCTRL0 {
#[skip]
__: B1,
pub rcctrl0: B7,
}
#[bitfield]
#[derive(Debug, Copy, Clone, BitfieldSpecifier)]
pub struct TEST0 {
pub test0a: B6,
pub vco_sel_cal_en: bool,
pub test0b: bool,
}
#[bitfield]
#[derive(Debug, Copy, Clone, BitfieldSpecifier)]
pub struct LQI {
pub crc_ok: bool,
pub lqi_est: B7,
}
#[bitfield]
#[derive(Debug, Copy, Clone, BitfieldSpecifier)]
pub struct MARCSTATE {
#[skip]
__: B3,
pub marc_state: MarcState,
}
#[bitfield]
#[derive(Debug, Copy, Clone, BitfieldSpecifier)]
pub struct PKTSTATUS {
pub crc_ok: bool,
pub cs: bool,
pub pqt_reached: bool,
pub cca: bool,
pub sfd: bool,
pub gdo2: bool,
#[skip]
__: B1,
pub gdo0: bool,
}
#[bitfield]
#[derive(Debug, Copy, Clone, BitfieldSpecifier)]
pub struct RXBYTES {
pub rxfifo_overflow: bool,
pub num_rxbytes: B7,
}
#[bitfield]
#[derive(Debug, Copy, Clone, BitfieldSpecifier)]
pub struct TXBYTES {
pub txfifo_underflow: bool,
pub num_txbytes: B7,
}
#[bitfield]
#[derive(Debug, Copy, Clone, BitfieldSpecifier)]
#[allow(non_camel_case_types)]
pub struct RCCTRL_STATUS {
#[skip]
__: B1,
pub status: B7,
}
#[bitfield]
#[derive(Debug, Copy, Clone)]
pub struct Regs {
pub iocfg2: IOCFG2,
pub iocfg1: IOCFG1,
pub iocfg0: IOCFG0,
pub fifothr: FIFOTHR,
pub sync: B16,
pub pktlen: B8,
pub pktctrl1: PKTCTRL1,
pub pktctrl0: PKTCTRL0,
pub addr: B8,
pub channr: B8,
pub fsctrl1: FSCTRL1,
pub fsctrl0: FSCTRL0,
#[skip]
__: B2,
pub freq: B22,
pub mdmcfg4: MDMCFG4,
pub mdmcfg3: MDMCFG3,
pub mdmcfg2: MDMCFG2,
pub mdmcfg1: MDMCFG1,
pub mdmcfg0: MDMCFG0,
pub deviatn: DEVIATN,
pub mcsm2: MCSM2,
pub mcsm1: MCSM1,
pub mcsm0: MCSM0,
pub foccfg: FOCCFG,
pub bscfg: BSCFG,
pub agcctrl2: AGCCTRL2,
pub agcctrl1: AGCCTRL1,
pub agcctrl0: AGCCTRL0,
pub worevt: B16,
pub worctrl: WORCTRL,
pub frend1: FREND1,
pub frend0: FREND0,
pub fscal3: FSCAL3,
pub fscal2: FSCAL2,
pub fscal1: FSCAL1,
pub fscal0: FSCAL0,
pub rcctrl1: RCCTRL1,
pub rcctrl0: RCCTRL0,
pub fstest: B8,
pub ptest: B8,
pub agctest: B8,
pub test2: B8,
pub test1: B8,
pub test0: TEST0,
}
assert_eq_size!([u8; 47], Regs);