from typing import TypedDict

class ConfigRegs(TypedDict):
    IOCFG2: int
    IOCFG1: int
    IOCFG0: int
    FIFOTHR: int
    SYNC1: int
    SYNC0: int
    PKTLEN: int
    PKTCTRL1: int
    PKTCTRL0: int
    ADDR: int
    CHANNR: int
    FSCTRL1: int
    FSCTRL0: int
    FREQ2: int
    FREQ1: int
    FREQ0: int
    MDMCFG4: int
    MDMCFG3: int
    MDMCFG2: int
    MDMCFG1: int
    MDMCFG0: int
    DEVIATN: int
    MCSM2: int
    MCSM1: int
    MCSM0: int
    FOCCFG: int
    BSCFG: int
    AGCCTRL2: int
    AGCCTRL1: int
    AGCCTRL0: int
    WOREVT1: int
    WOREVT0: int
    WORCTRL: int
    FREND1: int
    FREND0: int
    FSCAL3: int
    FSCAL2: int
    FSCAL1: int
    FSCAL0: int
    RCCTRL1: int
    RCCTRL0: int
    FSTEST: int
    PTEST: int
    AGCTEST: int
    TEST2: int
    TEST1: int
    TEST0: int

class Strobes(TypedDict):
    SRES: int
    SFSTXON: int
    SXOFF: int
    SCAL: int
    SRX: int
    STX: int
    SIDLE: int
    SAFC: int
    SWOR: int
    SPWD: int
    SFRX: int
    SFTX: int
    SWORRST: int
    SNOP: int

class Status(TypedDict):
    PARTNUM: int
    VERSION: int
    FREQEST: int
    LQI: int
    RSSI: int
    MARCSTATE: int
    WORTIME1: int
    WORTIME0: int
    PKTSTATUS: int
    VCO_VC_DAC: int
    TXBYTES: int
    RXBYTES: int
    NUM_RXBYTES: int

class Memory(TypedDict):
    PATABLE: int
    TXFIFO: int
    RXFIFO: int

class Masks(TypedDict):
    LQI_RX: int
    CRC_OK: int

class Access(TypedDict):
    WRITE_BURST: int
    READ_SINGLE: int
    READ_BURST: int

class RegsAddr(TypedDict):
    CONFIG_REGS: ConfigRegs
    STROBES: Strobes
    STATUS: Status
    MEMORY: Memory
    MASKS: Masks
    ACCESS: Access


regs_addr: RegsAddr = {
    "CONFIG_REGS": {
        "IOCFG2": 0x00,
        "IOCFG1": 0x01,
        "IOCFG0": 0x02,
        "FIFOTHR": 0x03,
        "SYNC1": 0x04,
        "SYNC0": 0x05,
        "PKTLEN": 0x06,
        "PKTCTRL1": 0x07,
        "PKTCTRL0": 0x08,
        "ADDR": 0x09,
        "CHANNR": 0x0A,
        "FSCTRL1": 0x0B,
        "FSCTRL0": 0x0C,
        "FREQ2": 0x0D,
        "FREQ1": 0x0E,
        "FREQ0": 0x0F,
        "MDMCFG4": 0x10,
        "MDMCFG3": 0x11,
        "MDMCFG2": 0x12,
        "MDMCFG1": 0x13,
        "MDMCFG0": 0x14,
        "DEVIATN": 0x15,
        "MCSM2": 0x16,
        "MCSM1": 0x17,
        "MCSM0": 0x18,
        "FOCCFG": 0x19,
        "BSCFG": 0x1A,
        "AGCCTRL2": 0x1B,
        "AGCCTRL1": 0x1C,
        "AGCCTRL0": 0x1D,
        "WOREVT1": 0x1E,
        "WOREVT0": 0x1F,
        "WORCTRL": 0x20,
        "FREND1": 0x21,
        "FREND0": 0x22,
        "FSCAL3": 0x23,
        "FSCAL2": 0x24,
        "FSCAL1": 0x25,
        "FSCAL0": 0x26,
        "RCCTRL1": 0x27,
        "RCCTRL0": 0x28,
        "FSTEST": 0x29,
        "PTEST": 0x2A,
        "AGCTEST": 0x2B,
        "TEST2": 0x2C,
        "TEST1": 0x2D,
        "TEST0": 0x2E
    },
    "STROBES": {
        "SRES": 0x30,
        "SFSTXON": 0x31,
        "SXOFF": 0x32,
        "SCAL": 0x33,
        "SRX": 0x34,
        "STX": 0x35,
        "SIDLE": 0x36,
        "SAFC": 0x37,
        "SWOR": 0x38,
        "SPWD": 0x39,
        "SFRX": 0x3A,
        "SFTX": 0x3B,
        "SWORRST": 0x3C,
        "SNOP": 0x3D
    },
    "STATUS": {
        "PARTNUM": 0x30,
        "VERSION": 0x31,
        "FREQEST": 0x32,
        "LQI": 0x33,
        "RSSI": 0x34,
        "MARCSTATE": 0x35,
        "WORTIME1": 0x36,
        "WORTIME0": 0x37,
        "PKTSTATUS": 0x38,
        "VCO_VC_DAC": 0x39,
        "TXBYTES": 0x3A,
        "RXBYTES": 0x3B,
        "NUM_RXBYTES": 0x7F
    },
    "MEMORY": {
        "PATABLE": 0x3E,
        "TXFIFO": 0x3F,
        "RXFIFO": 0x3F
    },
    "MASKS": {
        "LQI_RX": 0x01,
        "CRC_OK": 0x80
    },
    "ACCESS": {
        "WRITE_BURST": 0x40,
        "READ_SINGLE": 0x80,
        "READ_BURST": 0xC0
    }
}
