
REG_00_DEVICE_TYPE                         = 0x00
REG_01_VERSION_CODE                        = 0x01
REG_02_DEVICE_STATUS                       = 0x02
REG_03_INTERRUPT_STATUS1                   = 0x03
REG_04_INTERRUPT_STATUS2                   = 0x04
REG_05_INTERRUPT_ENABLE1                   = 0x05
REG_06_INTERRUPT_ENABLE2                   = 0x06
REG_07_OPERATING_MODE1                     = 0x07
REG_08_OPERATING_MODE2                     = 0x08
REG_09_OSCILLATOR_LOAD_CAPACITANCE         = 0x09
REG_0A_UC_OUTPUT_CLOCK                     = 0x0a
REG_0B_GPIO_CONFIGURATION0                 = 0x0b
REG_0C_GPIO_CONFIGURATION1                 = 0x0c
REG_0D_GPIO_CONFIGURATION2                 = 0x0d
REG_0E_IO_PORT_CONFIGURATION               = 0x0e
REG_0F_ADC_CONFIGURATION                   = 0x0f
REG_10_ADC_SENSOR_AMP_OFFSET               = 0x10
REG_11_ADC_VALUE                           = 0x11
REG_12_TEMPERATURE_SENSOR_CALIBRATION      = 0x12
REG_13_TEMPERATURE_VALUE_OFFSET            = 0x13
REG_14_WAKEUP_TIMER_PERIOD1                = 0x14
REG_15_WAKEUP_TIMER_PERIOD2                = 0x15
REG_16_WAKEUP_TIMER_PERIOD3                = 0x16
REG_17_WAKEUP_TIMER_VALUE1                 = 0x17
REG_18_WAKEUP_TIMER_VALUE2                 = 0x18
REG_19_LDC_MODE_DURATION                   = 0x19
REG_1A_LOW_BATTERY_DETECTOR_THRESHOLD      = 0x1a
REG_1B_BATTERY_VOLTAGE_LEVEL               = 0x1b
REG_1C_IF_FILTER_BANDWIDTH                 = 0x1c
REG_1D_AFC_LOOP_GEARSHIFT_OVERRIDE         = 0x1d
REG_1E_AFC_TIMING_CONTROL                  = 0x1e
REG_1F_CLOCK_RECOVERY_GEARSHIFT_OVERRIDE   = 0x1f
REG_20_CLOCK_RECOVERY_OVERSAMPLING_RATE    = 0x20
REG_21_CLOCk_RECOVERY_OFFSET2              = 0x21
REG_22_CLOCk_RECOVERY_OFFSET1              = 0x22
REG_23_CLOCk_RECOVERY_OFFSET0              = 0x23
REG_24_CLOCk_RECOVERY_TIMING_LOOP_GAIN1    = 0x24
REG_25_CLOCk_RECOVERY_TIMING_LOOP_GAIN0    = 0x25
REG_26_RSSI                                = 0x26
REG_27_RSSI_THRESHOLD                      = 0x27
REG_28_ANTENNA_DIVERSITY1                  = 0x28
REG_29_ANTENNA_DIVERSITY2                  = 0x29
REG_2A_AFC_LIMITER                         = 0x2a
REG_2B_AFC_CORRECTION_READ                 = 0x2b
REG_2C_OOK_COUNTER_VALUE_1                 = 0x2c
REG_2D_OOK_COUNTER_VALUE_2                 = 0x2d
REG_2E_SLICER_PEAK_HOLD                    = 0x2e
REG_30_DATA_ACCESS_CONTROL                 = 0x30
REG_31_EZMAC_STATUS                        = 0x31
REG_32_HEADER_CONTROL1                     = 0x32
REG_33_HEADER_CONTROL2                     = 0x33
REG_34_PREAMBLE_LENGTH                     = 0x34
REG_35_PREAMBLE_DETECTION_CONTROL1         = 0x35
REG_36_SYNC_WORD3                          = 0x36
REG_37_SYNC_WORD2                          = 0x37
REG_38_SYNC_WORD1                          = 0x38
REG_39_SYNC_WORD0                          = 0x39
REG_3A_TRANSMIT_HEADER3                    = 0x3a
REG_3B_TRANSMIT_HEADER2                    = 0x3b
REG_3C_TRANSMIT_HEADER1                    = 0x3c
REG_3D_TRANSMIT_HEADER0                    = 0x3d
REG_3E_PACKET_LENGTH                       = 0x3e
REG_3F_CHECK_HEADER3                       = 0x3f
REG_40_CHECK_HEADER2                       = 0x40
REG_41_CHECK_HEADER1                       = 0x41
REG_42_CHECK_HEADER0                       = 0x42
REG_43_HEADER_ENABLE3                      = 0x43
REG_44_HEADER_ENABLE2                      = 0x44
REG_45_HEADER_ENABLE1                      = 0x45
REG_46_HEADER_ENABLE0                      = 0x46
REG_47_RECEIVED_HEADER3                    = 0x47
REG_48_RECEIVED_HEADER2                    = 0x48
REG_49_RECEIVED_HEADER1                    = 0x49
REG_4A_RECEIVED_HEADER0                    = 0x4a
REG_4B_RECEIVED_PACKET_LENGTH              = 0x4b
REG_50_ANALOG_TEST_BUS_SELECT              = 0x50
REG_51_DIGITAL_TEST_BUS_SELECT             = 0x51
REG_52_TX_RAMP_CONTROL                     = 0x52
REG_53_PLL_TUNE_TIME                       = 0x53
REG_55_CALIBRATION_CONTROL                 = 0x55
REG_56_MODEM_TEST                          = 0x56
REG_57_CHARGE_PUMP_TEST                    = 0x57
REG_58_CHARGE_PUMP_CURRENT_TRIMMING        = 0x58
REG_59_DIVIDER_CURRENT_TRIMMING            = 0x59
REG_5A_VCO_CURRENT_TRIMMING                = 0x5a
REG_5B_VCO_CALIBRATION                     = 0x5b
REG_5C_SYNTHESIZER_TEST                    = 0x5c
REG_5D_BLOCK_ENABLE_OVERRIDE1              = 0x5d
REG_5E_BLOCK_ENABLE_OVERRIDE2              = 0x5e
REG_5F_BLOCK_ENABLE_OVERRIDE3              = 0x5f
REG_60_CHANNEL_FILTER_COEFFICIENT_ADDRESS  = 0x60
REG_61_CHANNEL_FILTER_COEFFICIENT_VALUE    = 0x61
REG_62_CRYSTAL_OSCILLATOR_POR_CONTROL      = 0x62
REG_63_RC_OSCILLATOR_COARSE_CALIBRATION    = 0x63
REG_64_RC_OSCILLATOR_FINE_CALIBRATION      = 0x64
REG_65_LDO_CONTROL_OVERRIDE                = 0x65
REG_66_LDO_LEVEL_SETTINGS                  = 0x66
REG_67_DELTA_SIGMA_ADC_TUNING1             = 0x67
REG_68_DELTA_SIGMA_ADC_TUNING2             = 0x68
REG_69_AGC_OVERRIDE1                       = 0x69
REG_6A_AGC_OVERRIDE2                       = 0x6a
REG_6B_GFSK_FIR_FILTER_COEFFICIENT_ADDRESS = 0x6b
REG_6C_GFSK_FIR_FILTER_COEFFICIENT_VALUE   = 0x6c
REG_6D_TX_POWER                            = 0x6d
REG_6E_TX_DATA_RATE1                       = 0x6e
REG_6F_TX_DATA_RATE0                       = 0x6f
REG_70_MODULATION_CONTROL1                 = 0x70
REG_71_MODULATION_CONTROL2                 = 0x71
REG_72_FREQUENCY_DEVIATION                 = 0x72
REG_73_FREQUENCY_OFFSET1                   = 0x73
REG_74_FREQUENCY_OFFSET2                   = 0x74
REG_75_FREQUENCY_BAND_SELECT               = 0x75
REG_76_NOMINAL_CARRIER_FREQUENCY1          = 0x76
REG_77_NOMINAL_CARRIER_FREQUENCY0          = 0x77
REG_79_FREQUENCY_HOPPING_CHANNEL_SELECT    = 0x79
REG_7A_FREQUENCY_HOPPING_STEP_SIZE         = 0x7a
REG_7C_TX_FIFO_CONTROL1                    = 0x7c
REG_7D_TX_FIFO_CONTROL2                    = 0x7d
REG_7E_RX_FIFO_CONTROL                     = 0x7e
REG_7F_FIFO_ACCESS                         = 0x7f


# These register masks etc are named wherever possible
# corresponding to the bit and field names in the RF-22 Manual
# REG_00_DEVICE_TYPE                      = 0x00
DEVICE_TYPE_RX_TRX                 = 0x08
DEVICE_TYPE_TX                     = 0x07

# REG_02_DEVICE_STATUS                    = 0x02
FFOVL                              = 0x80
FFUNFL                             = 0x40
RXFFEM                             = 0x20
HEADERR                            = 0x10
FREQERR                            = 0x08
LOCKDET                            = 0x04
CPS                                = 0x03
CPS_IDLE                           = 0x00
CPS_RX                             = 0x01
CPS_TX                             = 0x10

# REG_03_INTERRUPT_STATUS1                = 0x03
IFFERROR                           = 0x80
ITXFFAFULL                         = 0x40
ITXFFAEM                           = 0x20
IRXFFAFULL                         = 0x10
IEXT                               = 0x08
IPKSENT                            = 0x04
IPKVALID                           = 0x02
ICRCERROR                          = 0x01

# REG_04_INTERRUPT_STATUS2                = 0x04
ISWDET                             = 0x80
IPREAVAL                           = 0x40
IPREAINVAL                         = 0x20
IRSSI                              = 0x10
IWUT                               = 0x08
ILBD                               = 0x04
ICHIPRDY                           = 0x02
IPOR                               = 0x01

# REG_05_INTERRUPT_ENABLE1                = 0x05
ENFFERR                            = 0x80
ENTXFFAFULL                        = 0x40
ENTXFFAEM                          = 0x20
ENRXFFAFULL                        = 0x10
ENEXT                              = 0x08
ENPKSENT                           = 0x04
ENPKVALID                          = 0x02
ENCRCERROR                         = 0x01
EN_DISABLE                         = 0x00

# REG_06_INTERRUPT_ENABLE2                = 0x06
ENSWDET                            = 0x80
ENPREAVAL                          = 0x40
ENPREAINVAL                        = 0x20
ENRSSI                             = 0x10
ENWUT                              = 0x08
ENLBD                              = 0x04
ENCHIPRDY                          = 0x02
ENPOR                              = 0x01
EN_DISABLE                         = 0x00

# REG_07_OPERATING_MODE1                  = 0x07
SWRES                              = 0x80
ENLBD                              = 0x40
ENWT                               = 0x20
X32KSEL                            = 0x10
TXON                               = 0x08
RXON                               = 0x04
PLLON                              = 0x02
XTON                               = 0x01

# REG_08_OPERATING_MODE2                  = 0x08
ANTDIV                             = 0xc0
RXMPK                              = 0x10
AUTOTX                             = 0x08
ENLDM                              = 0x04
FFCLRRX                            = 0x02
FFCLRTX                            = 0x01

# REG_0F_ADC_CONFIGURATION                = 0x0f
ADCSTART                           = 0x80
ADCDONE                            = 0x80
ADCSEL                             = 0x70
ADCSEL_INTERNAL_TEMPERATURE_SENSOR = 0x00
ADCSEL_GPIO0_SINGLE_ENDED          = 0x10
ADCSEL_GPIO1_SINGLE_ENDED          = 0x20
ADCSEL_GPIO2_SINGLE_ENDED          = 0x30
ADCSEL_GPIO0_GPIO1_DIFFERENTIAL    = 0x40
ADCSEL_GPIO1_GPIO2_DIFFERENTIAL    = 0x50
ADCSEL_GPIO0_GPIO2_DIFFERENTIAL    = 0x60
ADCSEL_GND                         = 0x70
ADCREF                             = 0x0c
ADCREF_BANDGAP_VOLTAGE             = 0x00
ADCREF_VDD_ON_3                    = 0x08
ADCREF_VDD_ON_2                    = 0x0c
ADCGAIN                            = 0x03

# REG_10_ADC_SENSOR_AMP_OFFSET            = 0x10
ADCOFFS                            = 0x0f

# REG_12_TEMPERATURE_SENSOR_CALIBRATION   = 0x12
TSRANGE                            = 0xc0
TSRANGE_M64_64C                    = 0x00
TSRANGE_M64_192C                   = 0x40
TSRANGE_0_128C                     = 0x80
TSRANGE_M40_216F                   = 0xc0
ENTSOFFS                           = 0x20
ENTSTRIM                           = 0x10
TSTRIM                             = 0x0f

# REG_14_WAKEUP_TIMER_PERIOD1             = 0x14
WTR                                = 0x3c
WTD                                = 0x03

# REG_30_DATA_ACCESS_CONTROL              = 0x30
ENPACRX                            = 0x80
LSBFRST                            = 0x40
CRCDONLY                           = 0x20
ENPACTX                            = 0x08
ENCRC                              = 0x04
CRC                                = 0x03
CRC_CCITT                          = 0x00
CRC_CRC_16_IBM                     = 0x01
CRC_IEC_16                         = 0x02
CRC_BIACHEVA                       = 0x03

# REG_32_HEADER_CONTROL1                  = 0x32
BCEN                               = 0xf0
BCEN_NONE                          = 0x00
BCEN_HEADER0                       = 0x10
BCEN_HEADER1                       = 0x20
BCEN_HEADER2                       = 0x40
BCEN_HEADER3                       = 0x80
HDCH                               = 0x0f
HDCH_NONE                          = 0x00
HDCH_HEADER0                       = 0x01
HDCH_HEADER1                       = 0x02
HDCH_HEADER2                       = 0x04
HDCH_HEADER3                       = 0x08

# REG_33_HEADER_CONTROL2                  = 0x33
HDLEN                              = 0x70
HDLEN_0                            = 0x00
HDLEN_1                            = 0x10
HDLEN_2                            = 0x20
HDLEN_3                            = 0x30
HDLEN_4                            = 0x40
FIXPKLEN                           = 0x08
SYNCLEN                            = 0x06
SYNCLEN_1                          = 0x00
SYNCLEN_2                          = 0x02
SYNCLEN_3                          = 0x04
SYNCLEN_4                          = 0x06
PREALEN8                           = 0x01

# REG_6D_TX_POWER                         = 0x6d
TXPOW                              = 0x07
TXPOW_4X31                         = 0x08
TXPOW_8DBM                         = 0x00
TXPOW_11DBM                        = 0x01
TXPOW_14DBM                        = 0x02
TXPOW_17DBM                        = 0x03

# REG_71_MODULATION_CONTROL2              = 0x71
TRCLK                              = 0xc0
TRCLK_NONE                         = 0x00
TRCLK_GPIO                         = 0x40
TRCLK_SDO                          = 0x80
TRCLK_NIRQ                         = 0xc0
DTMOD                              = 0x30
DTMOD_DIRECT_GPIO                  = 0x00
DTMOD_DIRECT_SDI                   = 0x10
DTMOD_FIFO                         = 0x20
DTMOD_PN9                          = 0x30
ENINV                              = 0x08
FD8                                = 0x04
MODTYP                             = 0x30
MODTYP_UNMODULATED                 = 0x00
MODTYP_OOK                         = 0x01
MODTYP_FSK                         = 0x02
MODTYP_GFSK                        = 0x03

# REG_75_FREQUENCY_BAND_SELECT            = 0x75
SBSEL                              = 0x40
HBSEL                              = 0x20
FB                                 = 0x1f

