RadioLib
Universal wireless communication library for Arduino
Loading...
Searching...
No Matches
Si443x.h
1#if !defined(_RADIOLIB_SI443X_H)
2#define _RADIOLIB_SI443X_H
3
4#include "../../TypeDef.h"
5
6#if !RADIOLIB_EXCLUDE_SI443X
7
8#include "../../Module.h"
9
10#include "../../protocols/PhysicalLayer/PhysicalLayer.h"
11
12// Si443x physical layer properties
13#define RADIOLIB_SI443X_CRYSTAL_FREQ 10.0f
14#define RADIOLIB_SI443X_FREQUENCY_STEP_SIZE 156.25
15#define RADIOLIB_SI443X_MAX_PACKET_LENGTH 64
16#define RADIOLIB_SI4430_POUT_MIN -8
17#define RADIOLIB_SI4430_POUT_MAX 13
18#define RADIOLIB_SI4431_POUT_MIN -8
19#define RADIOLIB_SI4431_POUT_MAX 13
20#define RADIOLIB_SI4432_POUT_MIN -1
21#define RADIOLIB_SI4432_POUT_MAX 20
22
23// Si443x series common registers
24#define RADIOLIB_SI443X_REG_DEVICE_TYPE 0x00
25#define RADIOLIB_SI443X_REG_DEVICE_VERSION 0x01
26#define RADIOLIB_SI443X_REG_DEVICE_STATUS 0x02
27#define RADIOLIB_SI443X_REG_INTERRUPT_STATUS_1 0x03
28#define RADIOLIB_SI443X_REG_INTERRUPT_STATUS_2 0x04
29#define RADIOLIB_SI443X_REG_INTERRUPT_ENABLE_1 0x05
30#define RADIOLIB_SI443X_REG_INTERRUPT_ENABLE_2 0x06
31#define RADIOLIB_SI443X_REG_OP_FUNC_CONTROL_1 0x07
32#define RADIOLIB_SI443X_REG_OP_FUNC_CONTROL_2 0x08
33#define RADIOLIB_SI443X_REG_XOSC_LOAD_CAPACITANCE 0x09
34#define RADIOLIB_SI443X_REG_MCU_OUTPUT_CLOCK 0x0A
35#define RADIOLIB_SI443X_REG_GPIO0_CONFIG 0x0B
36#define RADIOLIB_SI443X_REG_GPIO1_CONFIG 0x0C
37#define RADIOLIB_SI443X_REG_GPIO2_CONFIG 0x0D
38#define RADIOLIB_SI443X_REG_IO_PORT_CONFIG 0x0E
39#define RADIOLIB_SI443X_REG_ADC_CONFIG 0x0F
40#define RADIOLIB_SI443X_REG_ADC_SENSOR_AMP_OFFSET 0x10
41#define RADIOLIB_SI443X_REG_ADC_VALUE 0x11
42#define RADIOLIB_SI443X_REG_TEMP_SENSOR_CONTROL 0x12
43#define RADIOLIB_SI443X_REG_TEMP_VALUE_OFFSET 0x13
44#define RADIOLIB_SI443X_REG_WAKEUP_TIMER_PERIOD_1 0x14
45#define RADIOLIB_SI443X_REG_WAKEUP_TIMER_PERIOD_2 0x15
46#define RADIOLIB_SI443X_REG_WAKEUP_TIMER_PERIOD_3 0x16
47#define RADIOLIB_SI443X_REG_WAKEUP_TIMER_VALUE_1 0x17
48#define RADIOLIB_SI443X_REG_WAKEUP_TIMER_VALUE_2 0x18
49#define RADIOLIB_SI443X_REG_LOW_DC_MODE_DURATION 0x19
50#define RADIOLIB_SI443X_REG_LOW_BATT_DET_THRESHOLD 0x1A
51#define RADIOLIB_SI443X_REG_BATT_VOLTAGE_LEVEL 0x1B
52#define RADIOLIB_SI443X_REG_IF_FILTER_BANDWIDTH 0x1C
53#define RADIOLIB_SI443X_REG_AFC_LOOP_GEARSHIFT_OVERRIDE 0x1D
54#define RADIOLIB_SI443X_REG_AFC_TIMING_CONTROL 0x1E
55#define RADIOLIB_SI443X_REG_CLOCK_REC_GEARSHIFT_OVERRIDE 0x1F
56#define RADIOLIB_SI443X_REG_CLOCK_REC_OVERSAMP_RATIO 0x20
57#define RADIOLIB_SI443X_REG_CLOCK_REC_OFFSET_2 0x21
58#define RADIOLIB_SI443X_REG_CLOCK_REC_OFFSET_1 0x22
59#define RADIOLIB_SI443X_REG_CLOCK_REC_OFFSET_0 0x23
60#define RADIOLIB_SI443X_REG_CLOCK_REC_TIMING_LOOP_GAIN_1 0x24
61#define RADIOLIB_SI443X_REG_CLOCK_REC_TIMING_LOOP_GAIN_0 0x25
62#define RADIOLIB_SI443X_REG_RSSI 0x26
63#define RADIOLIB_SI443X_REG_RSSI_CLEAR_CHANNEL_THRESHOLD 0x27
64#define RADIOLIB_SI443X_REG_ANTENNA_DIVERSITY_1 0x28
65#define RADIOLIB_SI443X_REG_ANTENNA_DIVERSITY_2 0x29
66#define RADIOLIB_SI443X_REG_AFC_LIMITER 0x2A
67#define RADIOLIB_SI443X_REG_AFC_CORRECTION 0x2B
68#define RADIOLIB_SI443X_REG_OOK_COUNTER_1 0x2C
69#define RADIOLIB_SI443X_REG_OOK_COUNTER_2 0x2D
70#define RADIOLIB_SI443X_REG_SLICER_PEAK_HOLD 0x2E
71#define RADIOLIB_SI443X_REG_DATA_ACCESS_CONTROL 0x30
72#define RADIOLIB_SI443X_REG_EZMAC_STATUS 0x31
73#define RADIOLIB_SI443X_REG_HEADER_CONTROL_1 0x32
74#define RADIOLIB_SI443X_REG_HEADER_CONTROL_2 0x33
75#define RADIOLIB_SI443X_REG_PREAMBLE_LENGTH 0x34
76#define RADIOLIB_SI443X_REG_PREAMBLE_DET_CONTROL 0x35
77#define RADIOLIB_SI443X_REG_SYNC_WORD_3 0x36
78#define RADIOLIB_SI443X_REG_SYNC_WORD_2 0x37
79#define RADIOLIB_SI443X_REG_SYNC_WORD_1 0x38
80#define RADIOLIB_SI443X_REG_SYNC_WORD_0 0x39
81#define RADIOLIB_SI443X_REG_TRANSMIT_HEADER_3 0x3A
82#define RADIOLIB_SI443X_REG_TRANSMIT_HEADER_2 0x3B
83#define RADIOLIB_SI443X_REG_TRANSMIT_HEADER_1 0x3C
84#define RADIOLIB_SI443X_REG_TRANSMIT_HEADER_0 0x3D
85#define RADIOLIB_SI443X_REG_TRANSMIT_PACKET_LENGTH 0x3E
86#define RADIOLIB_SI443X_REG_CHECK_HEADER_3 0x3F
87#define RADIOLIB_SI443X_REG_CHECK_HEADER_2 0x40
88#define RADIOLIB_SI443X_REG_CHECK_HEADER_1 0x41
89#define RADIOLIB_SI443X_REG_CHECK_HEADER_0 0x42
90#define RADIOLIB_SI443X_REG_HEADER_ENABLE_3 0x43
91#define RADIOLIB_SI443X_REG_HEADER_ENABLE_2 0x44
92#define RADIOLIB_SI443X_REG_HEADER_ENABLE_1 0x45
93#define RADIOLIB_SI443X_REG_HEADER_ENABLE_0 0x46
94#define RADIOLIB_SI443X_REG_RECEIVED_HEADER_3 0x47
95#define RADIOLIB_SI443X_REG_RECEIVED_HEADER_2 0x48
96#define RADIOLIB_SI443X_REG_RECEIVED_HEADER_1 0x49
97#define RADIOLIB_SI443X_REG_RECEIVED_HEADER_0 0x4A
98#define RADIOLIB_SI443X_REG_RECEIVED_PACKET_LENGTH 0x4B
99#define RADIOLIB_SI443X_REG_ADC8_CONTROL 0x4F
100#define RADIOLIB_SI443X_REG_CHANNEL_FILTER_COEFF 0x60
101#define RADIOLIB_SI443X_REG_XOSC_CONTROL_TEST 0x62
102#define RADIOLIB_SI443X_REG_AGC_OVERRIDE_1 0x69
103#define RADIOLIB_SI443X_REG_TX_POWER 0x6D
104#define RADIOLIB_SI443X_REG_TX_DATA_RATE_1 0x6E
105#define RADIOLIB_SI443X_REG_TX_DATA_RATE_0 0x6F
106#define RADIOLIB_SI443X_REG_MODULATION_MODE_CONTROL_1 0x70
107#define RADIOLIB_SI443X_REG_MODULATION_MODE_CONTROL_2 0x71
108#define RADIOLIB_SI443X_REG_FREQUENCY_DEVIATION 0x72
109#define RADIOLIB_SI443X_REG_FREQUENCY_OFFSET_1 0x73
110#define RADIOLIB_SI443X_REG_FREQUENCY_OFFSET_2 0x74
111#define RADIOLIB_SI443X_REG_FREQUENCY_BAND_SELECT 0x75
112#define RADIOLIB_SI443X_REG_NOM_CARRIER_FREQUENCY_1 0x76
113#define RADIOLIB_SI443X_REG_NOM_CARRIER_FREQUENCY_0 0x77
114#define RADIOLIB_SI443X_REG_FREQUENCY_HOPPING_CHANNEL_SEL 0x79
115#define RADIOLIB_SI443X_REG_FREQUENCY_HOPPING_STEP_SIZE 0x7A
116#define RADIOLIB_SI443X_REG_TX_FIFO_CONTROL_1 0x7C
117#define RADIOLIB_SI443X_REG_TX_FIFO_CONTROL_2 0x7D
118#define RADIOLIB_SI443X_REG_RX_FIFO_CONTROL 0x7E
119#define RADIOLIB_SI443X_REG_FIFO_ACCESS 0x7F
120
121// RADIOLIB_SI443X_REG_DEVICE_TYPE MSB LSB DESCRIPTION
122#define RADIOLIB_SI443X_DEVICE_TYPE 0x08 // 4 0 device identification register
123
124// RADIOLIB_SI443X_REG_DEVICE_VERSION
125#define RADIOLIB_SI443X_DEVICE_VERSION 0x06 // 4 0 chip version register
126
127// RADIOLIB_SI443X_REG_DEVICE_STATUS
128#define RADIOLIB_SI443X_RX_TX_FIFO_OVERFLOW 0b10000000 // 7 7 Rx/Tx FIFO overflow flag
129#define RADIOLIB_SI443X_RX_TX_FIFO_UNDERFLOW 0b01000000 // 6 6 Rx/Tx FIFO underflow flag
130#define RADIOLIB_SI443X_RX_FIFO_EMPTY 0b00100000 // 5 5 Rx FIFO empty flag
131#define RADIOLIB_SI443X_HEADER_ERROR 0b00010000 // 4 4 header error flag
132#define RADIOLIB_SI443X_FREQUENCY_ERROR 0b00001000 // 3 3 frequency error flag (frequency outside allowed range)
133#define RADIOLIB_SI443X_TX 0b00000010 // 1 0 power state: Tx
134#define RADIOLIB_SI443X_RX 0b00000001 // 1 0 Rx
135#define RADIOLIB_SI443X_IDLE 0b00000000 // 1 0 idle
136
137// RADIOLIB_SI443X_REG_INTERRUPT_STATUS_1
138#define RADIOLIB_SI443X_FIFO_LEVEL_ERROR_INTERRUPT 0b10000000 << 8 // 7 7 Tx/Rx FIFO overflow or underflow
139#define RADIOLIB_SI443X_TX_FIFO_ALMOST_FULL_INTERRUPT 0b01000000 << 8 // 6 6 Tx FIFO almost full
140#define RADIOLIB_SI443X_TX_FIFO_ALMOST_EMPTY_INTERRUPT 0b00100000 << 8 // 5 5 Tx FIFO almost empty
141#define RADIOLIB_SI443X_RX_FIFO_ALMOST_FULL_INTERRUPT 0b00010000 << 8 // 4 4 Rx FIFO almost full
142#define RADIOLIB_SI443X_EXTERNAL_INTERRUPT 0b00001000 << 8 // 3 3 external interrupt occurred on GPIOx
143#define RADIOLIB_SI443X_PACKET_SENT_INTERRUPT 0b00000100 << 8 // 2 2 packet transmission done
144#define RADIOLIB_SI443X_VALID_PACKET_RECEIVED_INTERRUPT 0b00000010 << 8 // 1 1 valid packet has been received
145#define RADIOLIB_SI443X_CRC_ERROR_INTERRUPT 0b00000001 << 8 // 0 0 CRC failed
146
147// RADIOLIB_SI443X_REG_INTERRUPT_STATUS_2
148#define RADIOLIB_SI443X_SYNC_WORD_DETECTED_INTERRUPT 0b10000000 // 7 7 sync word has been detected
149#define RADIOLIB_SI443X_VALID_PREAMBLE_DETECTED_INTERRUPT 0b01000000 // 6 6 valid preamble has been detected
150#define RADIOLIB_SI443X_INVALID_PREAMBLE_DETECTED_INTERRUPT 0b00100000 // 5 5 invalid preamble has been detected
151#define RADIOLIB_SI443X_RSSI_INTERRUPT 0b00010000 // 4 4 RSSI exceeded programmed threshold
152#define RADIOLIB_SI443X_WAKEUP_TIMER_INTERRUPT 0b00001000 // 3 3 wake-up timer expired
153#define RADIOLIB_SI443X_LOW_BATTERY_INTERRUPT 0b00000100 // 2 2 low battery detected
154#define RADIOLIB_SI443X_CHIP_READY_INTERRUPT 0b00000010 // 1 1 chip ready event detected
155#define RADIOLIB_SI443X_POWER_ON_RESET_INTERRUPT 0b00000001 // 0 0 power-on-reset detected
156
157// RADIOLIB_SI443X_REG_INTERRUPT_ENABLE_1
158#define RADIOLIB_SI443X_FIFO_LEVEL_ERROR_ENABLED 0b10000000 // 7 7 Tx/Rx FIFO overflow or underflow interrupt enabled
159#define RADIOLIB_SI443X_TX_FIFO_ALMOST_FULL_ENABLED 0b01000000 // 6 6 Tx FIFO almost full interrupt enabled
160#define RADIOLIB_SI443X_TX_FIFO_ALMOST_EMPTY_ENABLED 0b00100000 // 5 5 Tx FIFO almost empty interrupt enabled
161#define RADIOLIB_SI443X_RX_FIFO_ALMOST_FULL_ENABLED 0b00010000 // 4 4 Rx FIFO almost full interrupt enabled
162#define RADIOLIB_SI443X_EXTERNAL_ENABLED 0b00001000 // 3 3 external interrupt interrupt enabled
163#define RADIOLIB_SI443X_PACKET_SENT_ENABLED 0b00000100 // 2 2 packet transmission done interrupt enabled
164#define RADIOLIB_SI443X_VALID_PACKET_RECEIVED_ENABLED 0b00000010 // 1 1 valid packet received interrupt enabled
165#define RADIOLIB_SI443X_CRC_ERROR_ENABLED 0b00000001 // 0 0 CRC failed interrupt enabled
166
167// RADIOLIB_SI443X_REG_INTERRUPT_ENABLE_2
168#define RADIOLIB_SI443X_SYNC_WORD_DETECTED_ENABLED 0b10000000 // 7 7 sync word interrupt enabled
169#define RADIOLIB_SI443X_VALID_PREAMBLE_DETECTED_ENABLED 0b01000000 // 6 6 valid preamble interrupt enabled
170#define RADIOLIB_SI443X_INVALID_PREAMBLE_DETECTED_ENABLED 0b00100000 // 5 5 invalid preamble interrupt enabled
171#define RADIOLIB_SI443X_RSSI_ENABLED 0b00010000 // 4 4 RSSI exceeded programmed threshold interrupt enabled
172#define RADIOLIB_SI443X_WAKEUP_TIMER_ENABLED 0b00001000 // 3 3 wake-up timer interrupt enabled
173#define RADIOLIB_SI443X_LOW_BATTERY_ENABLED 0b00000100 // 2 2 low battery interrupt enabled
174#define RADIOLIB_SI443X_CHIP_READY_ENABLED 0b00000010 // 1 1 chip ready event interrupt enabled
175#define RADIOLIB_SI443X_POWER_ON_RESET_ENABLED 0b00000001 // 0 0 power-on-reset interrupt enabled
176
177// RADIOLIB_SI443X_REG_OP_FUNC_CONTROL_1
178#define RADIOLIB_SI443X_SOFTWARE_RESET 0b10000000 // 7 7 reset all registers to default values
179#define RADIOLIB_SI443X_ENABLE_LOW_BATTERY_DETECT 0b01000000 // 6 6 enable low battery detection
180#define RADIOLIB_SI443X_ENABLE_WAKEUP_TIMER 0b00100000 // 5 5 enable wakeup timer
181#define RADIOLIB_SI443X_32_KHZ_RC 0b00000000 // 4 4 32.768 kHz source: RC oscillator (default)
182#define RADIOLIB_SI443X_32_KHZ_XOSC 0b00010000 // 4 4 crystal oscillator
183#define RADIOLIB_SI443X_TX_ON 0b00001000 // 3 3 Tx on in manual transmit mode
184#define RADIOLIB_SI443X_RX_ON 0b00000100 // 2 2 Rx on in manual receive mode
185#define RADIOLIB_SI443X_PLL_ON 0b00000010 // 1 1 PLL on (tune mode)
186#define RADIOLIB_SI443X_XTAL_OFF 0b00000000 // 0 0 crystal oscillator: off (standby mode)
187#define RADIOLIB_SI443X_XTAL_ON 0b00000001 // 0 0 on (ready mode)
188
189// RADIOLIB_SI443X_REG_OP_FUNC_CONTROL_2
190#define RADIOLIB_SI443X_ANT_DIV_TR_HL_IDLE_L 0b00000000 // 7 5 GPIO1/2 states: Tx/Rx GPIO1 H, GPIO2 L; idle low (default)
191#define RADIOLIB_SI443X_ANT_DIV_TR_LH_IDLE_L 0b00100000 // 7 5 Tx/Rx GPIO1 L, GPIO2 H; idle low
192#define RADIOLIB_SI443X_ANT_DIV_TR_HL_IDLE_H 0b01000000 // 7 5 Tx/Rx GPIO1 H, GPIO2 L; idle high
193#define RADIOLIB_SI443X_ANT_DIV_TR_LH_IDLE_H 0b01100000 // 7 5 Tx/Rx GPIO1 L, GPIO2 H; idle high
194#define RADIOLIB_SI443X_ANT_DIV_TR_ALG_IDLE_L 0b10000000 // 7 5 Tx/Rx diversity algorithm; idle low
195#define RADIOLIB_SI443X_ANT_DIV_TR_ALG_IDLE_H 0b10100000 // 7 5 Tx/Rx diversity algorithm; idle high
196#define RADIOLIB_SI443X_ANT_DIV_TR_ALG_BEACON_IDLE_L 0b11000000 // 7 5 Tx/Rx diversity algorithm (beacon); idle low
197#define RADIOLIB_SI443X_ANT_DIV_TR_ALG_BEACON_IDLE_H 0b11100000 // 7 5 Tx/Rx diversity algorithm (beacon); idle high
198#define RADIOLIB_SI443X_RX_MULTIPACKET_OFF 0b00000000 // 4 4 Rx multipacket: disabled (default)
199#define RADIOLIB_SI443X_RX_MULTIPACKET_ON 0b00010000 // 4 4 enabled
200#define RADIOLIB_SI443X_AUTO_TX_OFF 0b00000000 // 3 3 Tx autotransmit on FIFO almost full: disabled (default)
201#define RADIOLIB_SI443X_AUTO_TX_ON 0b00001000 // 3 3 enabled
202#define RADIOLIB_SI443X_LOW_DUTY_CYCLE_OFF 0b00000000 // 2 2 low duty cycle mode: disabled (default)
203#define RADIOLIB_SI443X_LOW_DUTY_CYCLE_ON 0b00000100 // 2 2 enabled
204#define RADIOLIB_SI443X_RX_FIFO_RESET 0b00000010 // 1 1 Rx FIFO reset/clear: reset (call first)
205#define RADIOLIB_SI443X_RX_FIFO_CLEAR 0b00000000 // 1 1 clear (call second)
206#define RADIOLIB_SI443X_TX_FIFO_RESET 0b00000001 // 0 0 Tx FIFO reset/clear: reset (call first)
207#define RADIOLIB_SI443X_TX_FIFO_CLEAR 0b00000000 // 0 0 clear (call second)
208
209// RADIOLIB_SI443X_REG_XOSC_LOAD_CAPACITANCE
210#define RADIOLIB_SI443X_XTAL_SHIFT 0b00000000 // 7 7 crystal capacitance configuration:
211#define RADIOLIB_SI443X_XTAL_LOAD_CAPACITANCE 0b01111111 // 6 0 C_int = 1.8 pF + 0.085 pF * RADIOLIB_SI443X_XTAL_LOAD_CAPACITANCE + 3.7 pF * RADIOLIB_SI443X_XTAL_SHIFT
212
213// RADIOLIB_SI443X_REG_MCU_OUTPUT_CLOCK
214#define RADIOLIB_SI443X_CLOCK_TAIL_CYCLES_OFF 0b00000000 // 5 4 additional clock cycles: none (default)
215#define RADIOLIB_SI443X_CLOCK_TAIL_CYCLES_128 0b00010000 // 5 4 128
216#define RADIOLIB_SI443X_CLOCK_TAIL_CYCLES_256 0b00100000 // 5 4 256
217#define RADIOLIB_SI443X_CLOCK_TAIL_CYCLES_512 0b00110000 // 5 4 512
218#define RADIOLIB_SI443X_LOW_FREQ_CLOCK_OFF 0b00000000 // 3 3 32.768 kHz clock output: disabled (default)
219#define RADIOLIB_SI443X_LOW_FREQ_CLOCK_ON 0b00001000 // 3 3 enabled
220#define RADIOLIB_SI443X_MCU_CLOCK_30_MHZ 0b00000000 // 2 0 GPIO clock output: 30 MHz
221#define RADIOLIB_SI443X_MCU_CLOCK_15_MHZ 0b00000001 // 2 0 15 MHz
222#define RADIOLIB_SI443X_MCU_CLOCK_10_MHZ 0b00000010 // 2 0 10 MHz
223#define RADIOLIB_SI443X_MCU_CLOCK_4_MHZ 0b00000011 // 2 0 4 MHz
224#define RADIOLIB_SI443X_MCU_CLOCK_3_MHZ 0b00000100 // 2 0 3 MHz
225#define RADIOLIB_SI443X_MCU_CLOCK_2_MHZ 0b00000101 // 2 0 2 MHz
226#define RADIOLIB_SI443X_MCU_CLOCK_1_MHZ 0b00000110 // 2 0 1 MHz (default)
227#define RADIOLIB_SI443X_MCU_CLOCK_32_KHZ 0b00000111 // 2 0 32.768 kHz
228
229// RADIOLIB_SI443X_REG_GPIO0_CONFIG + RADIOLIB_SI443X_REG_GPIO1_CONFIG + RADIOLIB_SI443X_REG_GPIO2_CONFIG
230#define RADIOLIB_SI443X_GPIOX_DRIVE_STRENGTH 0b00000000 // 7 6 GPIOx drive strength (higher number = stronger drive)
231#define RADIOLIB_SI443X_GPIOX_PULLUP_OFF 0b00000000 // 5 5 GPIOx internal 200k pullup: disabled (default)
232#define RADIOLIB_SI443X_GPIOX_PULLUP_ON 0b00100000 // 5 5 enabled
233#define RADIOLIB_SI443X_GPIO0_POWER_ON_RESET_OUT 0b00000000 // 4 0 GPIOx function: power-on-reset output (GPIO0 only, default)
234#define RADIOLIB_SI443X_GPIO1_POWER_ON_RESET_INV_OUT 0b00000000 // 4 0 inverted power-on-reset output (GPIO1 only, default)
235#define RADIOLIB_SI443X_GPIO2_MCU_CLOCK_OUT 0b00000000 // 4 0 MCU clock output (GPIO2 only, default)
236#define RADIOLIB_SI443X_GPIOX_WAKEUP_OUT 0b00000001 // 4 0 wakeup timer expired output
237#define RADIOLIB_SI443X_GPIOX_LOW_BATTERY_OUT 0b00000010 // 4 0 low battery detect output
238#define RADIOLIB_SI443X_GPIOX_DIGITAL_OUT 0b00000011 // 4 0 direct digital output
239#define RADIOLIB_SI443X_GPIOX_EXT_INT_FALLING_IN 0b00000100 // 4 0 external interrupt, falling edge
240#define RADIOLIB_SI443X_GPIOX_EXT_INT_RISING_IN 0b00000101 // 4 0 external interrupt, rising edge
241#define RADIOLIB_SI443X_GPIOX_EXT_INT_CHANGE_IN 0b00000110 // 4 0 external interrupt, state change
242#define RADIOLIB_SI443X_GPIOX_ADC_IN 0b00000111 // 4 0 ADC analog input
243#define RADIOLIB_SI443X_GPIOX_ANALOG_TEST_N_IN 0b00001000 // 4 0 analog test N input
244#define RADIOLIB_SI443X_GPIOX_ANALOG_TEST_P_IN 0b00001001 // 4 0 analog test P input
245#define RADIOLIB_SI443X_GPIOX_DIGITAL_IN 0b00001010 // 4 0 direct digital input
246#define RADIOLIB_SI443X_GPIOX_DIGITAL_TEST_OUT 0b00001011 // 4 0 digital test output
247#define RADIOLIB_SI443X_GPIOX_ANALOG_TEST_N_OUT 0b00001100 // 4 0 analog test N output
248#define RADIOLIB_SI443X_GPIOX_ANALOG_TEST_P_OUT 0b00001101 // 4 0 analog test P output
249#define RADIOLIB_SI443X_GPIOX_REFERENCE_VOLTAGE_OUT 0b00001110 // 4 0 reference voltage output
250#define RADIOLIB_SI443X_GPIOX_TX_RX_DATA_CLK_OUT 0b00001111 // 4 0 Tx/Rx clock output in direct mode
251#define RADIOLIB_SI443X_GPIOX_TX_DATA_IN 0b00010000 // 4 0 Tx data input direct mode
252#define RADIOLIB_SI443X_GPIOX_EXT_RETRANSMIT_REQUEST_IN 0b00010001 // 4 0 external retransmission request input
253#define RADIOLIB_SI443X_GPIOX_TX_STATE_OUT 0b00010010 // 4 0 Tx state output
254#define RADIOLIB_SI443X_GPIOX_TX_FIFO_ALMOST_FULL_OUT 0b00010011 // 4 0 Tx FIFO almost full output
255#define RADIOLIB_SI443X_GPIOX_RX_DATA_OUT 0b00010100 // 4 0 Rx data output
256#define RADIOLIB_SI443X_GPIOX_RX_STATE_OUT 0b00010101 // 4 0 Rx state output
257#define RADIOLIB_SI443X_GPIOX_RX_FIFO_ALMOST_FULL_OUT 0b00010110 // 4 0 Rx FIFO almost full output
258#define RADIOLIB_SI443X_GPIOX_ANT_DIV_1_OUT 0b00010111 // 4 0 antenna diversity output 1
259#define RADIOLIB_SI443X_GPIOX_ANT_DIV_2_OUT 0b00011000 // 4 0 antenna diversity output 2
260#define RADIOLIB_SI443X_GPIOX_VALID_PREAMBLE_OUT 0b00011001 // 4 0 valid preamble detected output
261#define RADIOLIB_SI443X_GPIOX_INVALID_PREAMBLE_OUT 0b00011010 // 4 0 invalid preamble detected output
262#define RADIOLIB_SI443X_GPIOX_SYNC_WORD_DETECTED_OUT 0b00011011 // 4 0 sync word detected output
263#define RADIOLIB_SI443X_GPIOX_CLEAR_CHANNEL_OUT 0b00011100 // 4 0 clear channel assessment output
264#define RADIOLIB_SI443X_GPIOX_VDD 0b00011101 // 4 0 VDD
265#define RADIOLIB_SI443X_GPIOX_GND 0b00011110 // 4 0 GND
266
267// RADIOLIB_SI443X_REG_IO_PORT_CONFIG
268#define RADIOLIB_SI443X_GPIO2_EXT_INT_STATE_MASK 0b01000000 // 6 6 external interrupt state mask for: GPIO2
269#define RADIOLIB_SI443X_GPIO1_EXT_INT_STATE_MASK 0b00100000 // 5 5 GPIO1
270#define RADIOLIB_SI443X_GPIO0_EXT_INT_STATE_MASK 0b00010000 // 4 4 GPIO0
271#define RADIOLIB_SI443X_IRQ_BY_SDO_OFF 0b00000000 // 3 3 output IRQ state on SDO pin: disabled (default)
272#define RADIOLIB_SI443X_IRQ_BY_SDO_ON 0b00001000 // 3 3 enabled
273#define RADIOLIB_SI443X_GPIO2_DIGITAL_STATE_MASK 0b00000100 // 2 2 digital state mask for: GPIO2
274#define RADIOLIB_SI443X_GPIO1_DIGITAL_STATE_MASK 0b00000010 // 1 1 GPIO1
275#define RADIOLIB_SI443X_GPIO0_DIGITAL_STATE_MASK 0b00000001 // 0 0 GPIO0
276
277// RADIOLIB_SI443X_REG_ADC_CONFIG
278#define RADIOLIB_SI443X_ADC_START 0b10000000 // 7 7 ADC control: start measurement
279#define RADIOLIB_SI443X_ADC_RUNNING 0b00000000 // 7 7 measurement in progress
280#define RADIOLIB_SI443X_ADC_DONE 0b10000000 // 7 7 done
281#define RADIOLIB_SI443X_ADC_SOURCE_TEMPERATURE 0b00000000 // 6 4 ADC source: internal temperature sensor (default)
282#define RADIOLIB_SI443X_ADC_SOURCE_GPIO0_SINGLE 0b00010000 // 6 4 single-ended on GPIO0
283#define RADIOLIB_SI443X_ADC_SOURCE_GPIO1_SINGLE 0b00100000 // 6 4 single-ended on GPIO1
284#define RADIOLIB_SI443X_ADC_SOURCE_GPIO2_SINGLE 0b00110000 // 6 4 single-ended on GPIO2
285#define RADIOLIB_SI443X_ADC_SOURCE_GPIO01_DIFF 0b01000000 // 6 4 differential on GPIO0 (+) and GPIO1 (-)
286#define RADIOLIB_SI443X_ADC_SOURCE_GPIO12_DIFF 0b01010000 // 6 4 differential on GPIO1 (+) and GPIO2 (-)
287#define RADIOLIB_SI443X_ADC_SOURCE_GPIO02_DIFF 0b01100000 // 6 4 differential on GPIO0 (+) and GPIO2 (-)
288#define RADIOLIB_SI443X_ADC_SOURCE_GND 0b01110000 // 6 4 GND
289#define RADIOLIB_SI443X_ADC_REFERNCE_BAND_GAP 0b00000000 // 3 2 ADC reference: internal bandgap 1.2 V (default)
290#define RADIOLIB_SI443X_ADC_REFERNCE_VDD_3 0b00001000 // 3 2 VDD/3
291#define RADIOLIB_SI443X_ADC_REFERNCE_VDD_2 0b00001100 // 3 2 VDD/2
292#define RADIOLIB_SI443X_ADC_GAIN 0b00000000 // 1 0 ADC amplifier gain
293
294// RADIOLIB_SI443X_REG_ADC_SENSOR_AMP_OFFSET
295#define RADIOLIB_SI443X_ADC_OFFSET 0b00000000 // 3 0 ADC offset
296
297// RADIOLIB_SI443X_REG_TEMP_SENSOR_CONTROL
298#define RADIOLIB_SI443X_TEMP_SENSOR_RANGE_64_TO_64_C 0b00000000 // 7 6 temperature sensor range: -64 to 64 deg. C, 0.5 deg. C resolution (default)
299#define RADIOLIB_SI443X_TEMP_SENSOR_RANGE_64_TO_192_C 0b01000000 // 7 6 -64 to 192 deg. C, 1.0 deg. C resolution
300#define RADIOLIB_SI443X_TEMP_SENSOR_RANGE_0_TO_128_C 0b11000000 // 7 6 0 to 128 deg. C, 0.5 deg. C resolution
301#define RADIOLIB_SI443X_TEMP_SENSOR_RANGE_40_TO_216_F 0b10000000 // 7 6 -40 to 216 deg. F, 1.0 deg. F resolution
302#define RADIOLIB_SI443X_TEMP_SENSOR_KELVIN_TO_CELSIUS_OFF 0b00000000 // 5 5 Kelvin to Celsius offset: disabled
303#define RADIOLIB_SI443X_TEMP_SENSOR_KELVIN_TO_CELSIUS_ON 0b00100000 // 5 5 enabled (default)
304#define RADIOLIB_SI443X_TEMP_SENSOR_TRIM_OFF 0b00000000 // 4 4 temperature sensor trim: disabled (default)
305#define RADIOLIB_SI443X_TEMP_SENSOR_TRIM_ON 0b00010000 // 4 4 enabled
306#define RADIOLIB_SI443X_TEMP_SENSOR_TRIM_VALUE 0b00000000 // 3 0 temperature sensor trim value
307
308// RADIOLIB_SI443X_REG_WAKEUP_TIMER_PERIOD_1
309#define RADIOLIB_SI443X_WAKEUP_TIMER_EXPONENT 0b00000011 // 4 0 wakeup timer value exponent
310
311// RADIOLIB_SI443X_REG_WAKEUP_TIMER_PERIOD_2 + RADIOLIB_SI443X_REG_WAKEUP_TIMER_PERIOD_3
312#define RADIOLIB_SI443X_WAKEUP_TIMER_MANTISSA_MSB 0x00 // 7 0 wakeup timer value:
313#define RADIOLIB_SI443X_WAKEUP_TIMER_MANTISSA_LSB 0x01 // 7 0 T = (4 * RADIOLIB_SI443X_WAKEUP_TIMER_MANTISSA * 2 ^ RADIOLIB_SI443X_WAKEUP_TIMER_EXPONENT) / 32.768 ms
314
315// RADIOLIB_SI443X_REG_LOW_DC_MODE_DURATION
316#define RADIOLIB_SI443X_LOW_DC_MODE_DURATION_MANTISSA 0x01 // 7 0 low duty cycle mode duration: T = (4 * RADIOLIB_SI443X_LOW_DC_MODE_DURATION_MANTISSA * 2 ^ RADIOLIB_SI443X_WAKEUP_TIMER_EXPONENT) / 32.768 ms
317
318// RADIOLIB_SI443X_REG_LOW_BATT_DET_THRESHOLD
319#define RADIOLIB_SI443X_LOW_BATT_DET_THRESHOLD 0b00010100 // 4 0 low battery detection threshold: Vth = 1.7 + RADIOLIB_SI443X_LOW_BATT_DET_THRESHOLD * 0.05 V (defaults to 2.7 V)
320
321// RADIOLIB_SI443X_REG_IF_FILTER_BANDWIDTH
322#define RADIOLIB_SI443X_BYPASS_DEC_BY_3_OFF 0b00000000 // 7 7 bypass decimate-by-3 stage: disabled (default)
323#define RADIOLIB_SI443X_BYPASS_DEC_BY_3_ON 0b10000000 // 7 7 enabled
324#define RADIOLIB_SI443X_IF_FILTER_DEC_RATE 0b00000000 // 6 4 IF filter decimation rate
325#define RADIOLIB_SI443X_IF_FILTER_COEFF_SET 0b00000001 // 3 0 IF filter coefficient set selection
326
327// RADIOLIB_SI443X_REG_AFC_LOOP_GEARSHIFT_OVERRIDE
328#define RADIOLIB_SI443X_AFC_WIDEBAND_OFF 0b00000000 // 7 7 AFC wideband: disabled (default)
329#define RADIOLIB_SI443X_AFC_WIDEBAND_ON 0b10000000 // 7 7 enabled
330#define RADIOLIB_SI443X_AFC_OFF 0b00000000 // 6 6 AFC: disabled
331#define RADIOLIB_SI443X_AFC_ON 0b01000000 // 6 6 enabled (default)
332#define RADIOLIB_SI443X_AFC_HIGH_GEAR_SETTING 0b00000000 // 5 3 AFC high gear setting
333#define RADIOLIB_SI443X_SECOND_PHASE_BIAS_0_DB 0b00000100 // 2 2 second phase antenna selection bias: 0 dB (default)
334#define RADIOLIB_SI443X_SECOND_PHASE_BIAS_1_5_DB 0b00000000 // 2 2 1.5 dB
335#define RADIOLIB_SI443X_MOVING_AVERAGE_TAP_8 0b00000010 // 1 1 moving average filter tap length: 8*Tb
336#define RADIOLIB_SI443X_MOVING_AVERAGE_TAP_4 0b00000000 // 1 1 4*Tb after first preamble (default)
337#define RADIOLIB_SI443X_ZERO_PHASE_RESET_5 0b00000000 // 0 0 reset preamble detector after: 5 zero phases (default)
338#define RADIOLIB_SI443X_ZERO_PHASE_RESET_2 0b00000001 // 0 0 3 zero phases
339
340// RADIOLIB_SI443X_REG_AFC_TIMING_CONTROL
341#define RADIOLIB_SI443X_SW_ANT_TIMER 0b00000000 // 7 6 number of periods to wait for RSSI to stabilize during antenna switching
342#define RADIOLIB_SI443X_SHORT_WAIT 0b00001000 // 5 3 period to wait after AFC correction
343#define RADIOLIB_SI443X_ANTENNA_SWITCH_WAIT 0b00000010 // 2 0 antenna switching wait time
344
345// RADIOLIB_SI443X_REG_CLOCK_REC_GEARSHIFT_OVERRIDE
346#define RADIOLIB_SI443X_CLOCK_RECOVER_FAST_GEARSHIFT 0b00000000 // 5 3 clock recovery fast gearshift value
347#define RADIOLIB_SI443X_CLOCK_RECOVER_SLOW_GEARSHIFT 0b00000011 // 2 0 clock recovery slow gearshift value
348
349// RADIOLIB_SI443X_REG_CLOCK_REC_OVERSAMP_RATIO
350#define RADIOLIB_SI443X_CLOCK_REC_OVERSAMP_RATIO_LSB 0b01100100 // 7 0 oversampling rate LSB, defaults to 12.5 clock cycles per bit
351
352// RADIOLIB_SI443X_REG_CLOCK_REC_OFFSET_2
353#define RADIOLIB_SI443X_CLOCK_REC_OVERSAMP_RATIO_MSB 0b00000000 // 7 5 oversampling rate MSB, defaults to 12.5 clock cycles per bit
354#define RADIOLIB_SI443X_SECOND_PHASE_SKIP_THRESHOLD 0b00000000 // 4 4 skip seconds phase antenna diversity threshold
355#define RADIOLIB_SI443X_NCO_OFFSET_MSB 0b00000001 // 3 0 NCO offset MSB
356
357// RADIOLIB_SI443X_REG_CLOCK_REC_OFFSET_1
358#define RADIOLIB_SI443X_NCO_OFFSET_MID 0b01000111 // 7 0 NCO offset MID
359
360// RADIOLIB_SI443X_REG_CLOCK_REC_OFFSET_0
361#define RADIOLIB_SI443X_NCO_OFFSET_LSB 0b10101110 // 7 0 NCO offset LSB
362
363// RADIOLIB_SI443X_REG_CLOCK_REC_TIMING_LOOP_GAIN_1
364#define RADIOLIB_SI443X_RX_COMPENSATION_OFF 0b00000000 // 4 4 Rx compensation for high data rate: disabled (default)
365#define RADIOLIB_SI443X_RX_COMPENSATION_ON 0b00010000 // 4 4 enabled
366#define RADIOLIB_SI443X_CLOCK_REC_GAIN_DOUBLE_OFF 0b00000000 // 3 3 clock recovery gain doubling: disabled (default)
367#define RADIOLIB_SI443X_CLOCK_REC_GAIN_DOUBLE_ON 0b00001000 // 3 3 enabled
368#define RADIOLIB_SI443X_CLOCK_REC_LOOP_GAIN_MSB 0b00000010 // 2 0 clock recovery timing loop gain MSB
369
370// RADIOLIB_SI443X_REG_CLOCK_REC_TIMING_LOOP_GAIN_0
371#define RADIOLIB_SI443X_CLOCK_REC_LOOP_GAIN_LSB 0b10001111 // 7 0 clock recovery timing loop gain LSB
372
373// RADIOLIB_SI443X_REG_RSSI_CLEAR_CHANNEL_THRESHOLD
374#define RADIOLIB_SI443X_RSSI_CLEAR_CHANNEL_THRESHOLD 0b00011110 // 7 0 RSSI clear channel interrupt threshold
375
376// RADIOLIB_SI443X_REG_AFC_LIMITER
377#define RADIOLIB_SI443X_AFC_LIMITER 0x00 // 7 0 AFC limiter value
378
379// RADIOLIB_SI443X_REG_OOK_COUNTER_1
380#define RADIOLIB_SI443X_OOK_FREEZE_OFF 0b00000000 // 5 5 OOK moving average detector freeze: disabled (default)
381#define RADIOLIB_SI443X_OOK_FREEZE_ON 0b00100000 // 5 5 enabled
382#define RADIOLIB_SI443X_PEAK_DETECTOR_OFF 0b00000000 // 4 4 peak detector: disabled
383#define RADIOLIB_SI443X_PEAK_DETECTOR_ON 0b00010000 // 4 4 enabled (default)
384#define RADIOLIB_SI443X_OOK_MOVING_AVERAGE_OFF 0b00000000 // 3 3 OOK moving average: disabled
385#define RADIOLIB_SI443X_OOK_MOVING_AVERAGE_ON 0b00001000 // 3 3 enabled (default)
386#define RADIOLIB_SI443X_OOK_COUNTER_MSB 0b00000000 // 2 0 OOK counter MSB
387
388// RADIOLIB_SI443X_REG_OOK_COUNTER_2
389#define RADIOLIB_SI443X_OOK_COUNTER_LSB 0b10111100 // 7 0 OOK counter LSB
390
391// RADIOLIB_SI443X_REG_SLICER_PEAK_HOLD
392#define RADIOLIB_SI443X_PEAK_DETECTOR_ATTACK 0b00010000 // 6 4 OOK peak detector attach time
393#define RADIOLIB_SI443X_PEAK_DETECTOR_DECAY 0b00001100 // 3 0 OOK peak detector decay time
394
395// RADIOLIB_SI443X_REG_DATA_ACCESS_CONTROL
396#define RADIOLIB_SI443X_PACKET_RX_HANDLING_OFF 0b00000000 // 7 7 packet Rx handling: disabled
397#define RADIOLIB_SI443X_PACKET_RX_HANDLING_ON 0b10000000 // 7 7 enabled (default)
398#define RADIOLIB_SI443X_LSB_FIRST_OFF 0b00000000 // 6 6 LSB first transmission: disabled (default)
399#define RADIOLIB_SI443X_LSB_FIRST_ON 0b01000000 // 6 6 enabled
400#define RADIOLIB_SI443X_CRC_DATA_ONLY_OFF 0b00000000 // 5 5 CRC calculated only from data fields: disabled (default)
401#define RADIOLIB_SI443X_CRC_DATA_ONLY_ON 0b00100000 // 5 5 enabled
402#define RADIOLIB_SI443X_SKIP_SECOND_PHASE_PREAMBLE_DET_OFF 0b00000000 // 4 4 skip second phase of preamble detection: disabled (default)
403#define RADIOLIB_SI443X_SKIP_SECOND_PHASE_PREAMBLE_DET_ON 0b00010000 // 4 4 enabled
404#define RADIOLIB_SI443X_PACKET_TX_HANDLING_OFF 0b00000000 // 3 3 packet Tx handling: disabled
405#define RADIOLIB_SI443X_PACKET_TX_HANDLING_ON 0b00001000 // 3 3 enabled (default)
406#define RADIOLIB_SI443X_CRC_OFF 0b00000000 // 2 2 CRC: disabled
407#define RADIOLIB_SI443X_CRC_ON 0b00000100 // 2 2 enabled (default)
408#define RADIOLIB_SI443X_CRC_CCITT 0b00000000 // 1 0 CRC type: CCITT
409#define RADIOLIB_SI443X_CRC_IBM_CRC16 0b00000001 // 1 0 IBM CRC-16 (default)
410#define RADIOLIB_SI443X_CRC_IEC16 0b00000010 // 1 0 IEC-16
411#define RADIOLIB_SI443X_CRC_BIACHEVA 0b00000011 // 1 0 Biacheva
412
413// RADIOLIB_SI443X_REG_EZMAC_STATUS
414#define RADIOLIB_SI443X_CRC_ALL_ONE 0b01000000 // 6 6 last received CRC was all ones
415#define RADIOLIB_SI443X_PACKET_SEARCHING 0b00100000 // 5 5 radio is searching for a valid packet
416#define RADIOLIB_SI443X_PACKET_RECEIVING 0b00010000 // 4 4 radio is currently receiving packet
417#define RADIOLIB_SI443X_VALID_PACKET_RECEIVED 0b00001000 // 3 3 valid packet was received
418#define RADIOLIB_SI443X_CRC_ERROR 0b00000100 // 2 2 CRC check failed
419#define RADIOLIB_SI443X_PACKET_TRANSMITTING 0b00000010 // 1 1 radio is currently transmitting packet
420#define RADIOLIB_SI443X_PACKET_SENT 0b00000001 // 0 0 packet sent
421
422// RADIOLIB_SI443X_REG_HEADER_CONTROL_1
423#define RADIOLIB_SI443X_BROADCAST_ADDR_CHECK_NONE 0b00000000 // 7 4 broadcast address check: none (default)
424#define RADIOLIB_SI443X_BROADCAST_ADDR_CHECK_BYTE0 0b00010000 // 7 4 on byte 0
425#define RADIOLIB_SI443X_BROADCAST_ADDR_CHECK_BYTE1 0b00100000 // 7 4 on byte 1
426#define RADIOLIB_SI443X_BROADCAST_ADDR_CHECK_BYTE2 0b01000000 // 7 4 on byte 2
427#define RADIOLIB_SI443X_BROADCAST_ADDR_CHECK_BYTE3 0b10000000 // 7 4 on byte 3
428#define RADIOLIB_SI443X_RECEIVED_HEADER_CHECK_NONE 0b00000000 // 3 0 received header check: none
429#define RADIOLIB_SI443X_RECEIVED_HEADER_CHECK_BYTE0 0b00000001 // 3 0 on byte 0
430#define RADIOLIB_SI443X_RECEIVED_HEADER_CHECK_BYTE1 0b00000010 // 3 0 on byte 1
431#define RADIOLIB_SI443X_RECEIVED_HEADER_CHECK_BYTE2 0b00000100 // 3 0 on byte 2 (default)
432#define RADIOLIB_SI443X_RECEIVED_HEADER_CHECK_BYTE3 0b00001000 // 3 0 on byte 3 (default)
433
434// RADIOLIB_SI443X_REG_HEADER_CONTROL_2
435#define RADIOLIB_SI443X_SYNC_WORD_TIMEOUT_OFF 0b00000000 // 7 7 ignore timeout period when searching for sync word: disabled (default)
436#define RADIOLIB_SI443X_SYNC_WORD_TIMEOUT_ON 0b10000000 // 7 7 enabled
437#define RADIOLIB_SI443X_HEADER_LENGTH_HEADER_NONE 0b00000000 // 6 4 header length: none
438#define RADIOLIB_SI443X_HEADER_LENGTH_HEADER_3 0b00010000 // 6 4 header 3
439#define RADIOLIB_SI443X_HEADER_LENGTH_HEADER_32 0b00100000 // 6 4 header 3 and 2
440#define RADIOLIB_SI443X_HEADER_LENGTH_HEADER_321 0b00110000 // 6 4 header 3, 2 and 1 (default)
441#define RADIOLIB_SI443X_HEADER_LENGTH_HEADER_3210 0b01000000 // 6 4 header 3, 2, 1, and 0
442#define RADIOLIB_SI443X_FIXED_PACKET_LENGTH_OFF 0b00000000 // 3 3 fixed packet length mode: disabled (default)
443#define RADIOLIB_SI443X_FIXED_PACKET_LENGTH_ON 0b00001000 // 3 3 enabled
444#define RADIOLIB_SI443X_SYNC_LENGTH_SYNC_3 0b00000000 // 2 1 sync word length: sync 3
445#define RADIOLIB_SI443X_SYNC_LENGTH_SYNC_32 0b00000010 // 2 1 sync 3 and 2 (default)
446#define RADIOLIB_SI443X_SYNC_LENGTH_SYNC_321 0b00000100 // 2 1 sync 3, 2 and 1
447#define RADIOLIB_SI443X_SYNC_LENGTH_SYNC_3210 0b00000110 // 2 1 sync 3, 2, 1 and 0
448#define RADIOLIB_SI443X_PREAMBLE_LENGTH_MSB 0b00000000 // 0 0 preamble length MSB
449
450// RADIOLIB_SI443X_REG_PREAMBLE_LENGTH
451#define RADIOLIB_SI443X_PREAMBLE_LENGTH_LSB 0b00001000 // 0 0 preamble length LSB, defaults to 32 bits
452
453// RADIOLIB_SI443X_REG_PREAMBLE_DET_CONTROL
454#define RADIOLIB_SI443X_PREAMBLE_DET_THRESHOLD 0b00101000 // 7 3 number of 4-bit nibbles in valid preamble, defaults to 20 bits
455#define RADIOLIB_SI443X_RSSI_OFFSET 0b00000010 // 2 0 RSSI calculation offset, defaults to +8 dB
456
457// RADIOLIB_SI443X_REG_SYNC_WORD_3 - RADIOLIB_SI443X_REG_SYNC_WORD_0
458#define RADIOLIB_SI443X_SYNC_WORD_3 0x2D // 7 0 sync word: 4th byte (MSB)
459#define RADIOLIB_SI443X_SYNC_WORD_2 0xD4 // 7 0 3rd byte
460#define RADIOLIB_SI443X_SYNC_WORD_1 0x00 // 7 0 2nd byte
461#define RADIOLIB_SI443X_SYNC_WORD_0 0x00 // 7 0 1st byte (LSB)
462
463// RADIOLIB_SI443X_REG_CHANNEL_FILTER_COEFF
464#define RADIOLIB_SI443X_INVALID_PREAMBLE_THRESHOLD 0b00000000 // 7 4 invalid preamble threshold in nibbles
465
466// RADIOLIB_SI443X_REG_XOSC_CONTROL_TEST
467#define RADIOLIB_SI443X_STATE_LOW_POWER 0b00000000 // 7 5 chip power state: low power
468#define RADIOLIB_SI443X_STATE_READY 0b00100000 // 7 5 ready
469#define RADIOLIB_SI443X_STATE_TUNE 0b01100000 // 7 5 tune
470#define RADIOLIB_SI443X_STATE_TX 0b01000000 // 7 5 Tx
471#define RADIOLIB_SI443X_STATE_RX 0b11100000 // 7 5 Rx
472
473// RADIOLIB_SI443X_REG_AGC_OVERRIDE_1
474#define RADIOLIB_SI443X_AGC_GAIN_INCREASE_OFF 0b00000000 // 6 6 AGC gain increase override: disabled (default)
475#define RADIOLIB_SI443X_AGC_GAIN_INCREASE_ON 0b01000000 // 6 6 enabled
476#define RADIOLIB_SI443X_AGC_OFF 0b00000000 // 5 5 AGC loop: disabled
477#define RADIOLIB_SI443X_AGC_ON 0b00100000 // 5 5 enabled (default)
478#define RADIOLIB_SI443X_LNA_GAIN_MIN 0b00000000 // 4 4 LNA gain select: 5 dB (default)
479#define RADIOLIB_SI443X_LNA_GAIN_MAX 0b00010000 // 4 4 25 dB
480#define RADIOLIB_SI443X_PGA_GAIN_OVERRIDE 0b00000000 // 3 0 PGA gain override, gain = RADIOLIB_SI443X_PGA_GAIN_OVERRIDE * 3 dB
481
482// RADIOLIB_SI443X_REG_TX_POWER
483#define RADIOLIB_SI443X_LNA_SWITCH_OFF 0b00000000 // 3 3 LNA switch control: disabled
484#define RADIOLIB_SI443X_LNA_SWITCH_ON 0b00001000 // 3 3 enabled (default)
485#define RADIOLIB_SI443X_OUTPUT_POWER 0b00000000 // 2 0 output power in 3 dB steps, 0 is chip min, 7 is chip max
486
487// RADIOLIB_SI443X_REG_TX_DATA_RATE_1 + RADIOLIB_SI443X_REG_TX_DATA_RATE_0
488#define RADIOLIB_SI443X_DATA_RATE_MSB 0x0A // 7 0 data rate: DR = 10^6 * (RADIOLIB_SI443X_DATA_RATE / 2^16) in high data rate mode or
489#define RADIOLIB_SI443X_DATA_RATE_LSB 0x3D // 7 0 DR = 10^6 * (RADIOLIB_SI443X_DATA_RATE / 2^21) in low data rate mode (defaults to 40 kbps)
490
491// RADIOLIB_SI443X_REG_MODULATION_MODE_CONTROL_1
492#define RADIOLIB_SI443X_HIGH_DATA_RATE_MODE 0b00000000 // 5 5 data rate: above 30 kbps (default)
493#define RADIOLIB_SI443X_LOW_DATA_RATE_MODE 0b00100000 // 5 5 below 30 kbps
494#define RADIOLIB_SI443X_PACKET_HANDLER_POWER_DOWN_OFF 0b00000000 // 4 4 power off packet handler in low power mode: disabled (default)
495#define RADIOLIB_SI443X_PACKET_HANDLER_POWER_DOWN_ON 0b00010000 // 4 4 enabled
496#define RADIOLIB_SI443X_MANCHESTER_PREAMBLE_POL_LOW 0b00000000 // 3 3 preamble polarity in Manchester mode: low
497#define RADIOLIB_SI443X_MANCHESTER_PREAMBLE_POL_HIGH 0b00001000 // 3 3 high (default)
498#define RADIOLIB_SI443X_MANCHESTER_INVERTED_OFF 0b00000000 // 2 2 inverted Manchester encoding: disabled
499#define RADIOLIB_SI443X_MANCHESTER_INVERTED_ON 0b00000100 // 2 2 enabled (default)
500#define RADIOLIB_SI443X_MANCHESTER_OFF 0b00000000 // 1 1 Manchester encoding: disabled (default)
501#define RADIOLIB_SI443X_MANCHESTER_ON 0b00000010 // 1 1 enabled
502#define RADIOLIB_SI443X_WHITENING_OFF 0b00000000 // 0 0 data whitening: disabled (default)
503#define RADIOLIB_SI443X_WHITENING_ON 0b00000001 // 0 0 enabled
504
505// RADIOLIB_SI443X_REG_MODULATION_MODE_CONTROL_2
506#define RADIOLIB_SI443X_TX_DATA_CLOCK_NONE 0b00000000 // 7 6 Tx data clock: disabled (default)
507#define RADIOLIB_SI443X_TX_DATA_CLOCK_GPIO 0b01000000 // 7 6 GPIO pin
508#define RADIOLIB_SI443X_TX_DATA_CLOCK_SDI 0b10000000 // 7 6 SDI pin
509#define RADIOLIB_SI443X_TX_DATA_CLOCK_NIRQ 0b11000000 // 7 6 nIRQ pin
510#define RADIOLIB_SI443X_TX_DATA_SOURCE_GPIO 0b00000000 // 5 4 Tx data source in direct mode: GPIO pin (default)
511#define RADIOLIB_SI443X_TX_DATA_SOURCE_SDI 0b00010000 // 5 4 SDI pin
512#define RADIOLIB_SI443X_TX_DATA_SOURCE_FIFO 0b00100000 // 5 4 FIFO
513#define RADIOLIB_SI443X_TX_DATA_SOURCE_PN9 0b00110000 // 5 4 PN9 internal
514#define RADIOLIB_SI443X_TX_RX_INVERTED_OFF 0b00000000 // 3 3 Tx/Rx data inverted: disabled (default)
515#define RADIOLIB_SI443X_TX_RX_INVERTED_ON 0b00001000 // 3 3 enabled
516#define RADIOLIB_SI443X_FREQUENCY_DEVIATION_MSB 0b00000000 // 2 2 frequency deviation MSB
517#define RADIOLIB_SI443X_MODULATION_NONE 0b00000000 // 1 0 modulation type: unmodulated carrier (default)
518#define RADIOLIB_SI443X_MODULATION_OOK 0b00000001 // 1 0 OOK
519#define RADIOLIB_SI443X_MODULATION_FSK 0b00000010 // 1 0 FSK
520#define RADIOLIB_SI443X_MODULATION_GFSK 0b00000011 // 1 0 GFSK
521
522// RADIOLIB_SI443X_REG_FREQUENCY_DEVIATION
523#define RADIOLIB_SI443X_FREQUENCY_DEVIATION_LSB 0b00100000 // 7 0 frequency deviation LSB, Fd = 625 Hz * RADIOLIB_SI443X_FREQUENCY_DEVIATION, defaults to 20 kHz
524
525// RADIOLIB_SI443X_REG_FREQUENCY_OFFSET_1 + RADIOLIB_SI443X_REG_FREQUENCY_OFFSET_2
526#define RADIOLIB_SI443X_FREQUENCY_OFFSET_MSB 0x00 // 7 0 frequency offset:
527#define RADIOLIB_SI443X_FREQUENCY_OFFSET_LSB 0x00 // 1 0 Foff = 156.25 Hz * (RADIOLIB_SI443X_BAND_SELECT + 1) * RADIOLIB_SI443X_FREQUENCY_OFFSET, defaults to 156.25 Hz
528
529// RADIOLIB_SI443X_REG_FREQUENCY_BAND_SELECT
530#define RADIOLIB_SI443X_SIDE_BAND_SELECT_LOW 0b00000000 // 6 6 Rx LO tuning: below channel frequency (default)
531#define RADIOLIB_SI443X_SIDE_BAND_SELECT_HIGH 0b01000000 // 6 6 above channel frequency
532#define RADIOLIB_SI443X_BAND_SELECT_LOW 0b00000000 // 5 5 band select: low, 240 - 479.9 MHz
533#define RADIOLIB_SI443X_BAND_SELECT_HIGH 0b00100000 // 5 5 high, 480 - 960 MHz (default)
534#define RADIOLIB_SI443X_FREQUENCY_BAND_SELECT 0b00010101 // 4 0 frequency band select
535
536// RADIOLIB_SI443X_REG_NOM_CARRIER_FREQUENCY_1 + RADIOLIB_SI443X_REG_NOM_CARRIER_FREQUENCY_0
537#define RADIOLIB_SI443X_NOM_CARRIER_FREQUENCY_MSB 0b10111011 // 7 0 nominal carrier frequency:
538#define RADIOLIB_SI443X_NOM_CARRIER_FREQUENCY_LSB 0b10000000 // 7 0 Fc = (RADIOLIB_SI443X_BAND_SELECT + 1)*10*(RADIOLIB_SI443X_FREQUENCY_BAND_SELECT + 24) + (RADIOLIB_SI443X_NOM_CARRIER_FREQUENCY - RADIOLIB_SI443X_FREQUENCY_OFFSET)/6400 [MHz]
539
540// RADIOLIB_SI443X_REG_FREQUENCY_HOPPING_CHANNEL_SEL
541#define RADIOLIB_SI443X_FREQUENCY_HOPPING_CHANNEL 0x00 // 7 0 frequency hopping channel number
542
543// RADIOLIB_SI443X_REG_FREQUENCY_HOPPING_STEP_SIZE
544#define RADIOLIB_SI443X_FREQUENCY_HOPPING_STEP_SIZE 0x00 // 7 0 frequency hopping step size
545
546// RADIOLIB_SI443X_REG_TX_FIFO_CONTROL_1
547#define RADIOLIB_SI443X_TX_FIFO_ALMOST_FULL_THRESHOLD 0x37 // 5 0 Tx FIFO almost full threshold
548
549// RADIOLIB_SI443X_REG_TX_FIFO_CONTROL_2
550#define RADIOLIB_SI443X_TX_FIFO_ALMOST_EMPTY_THRESHOLD 0x04 // 5 0 Tx FIFO almost full threshold
551
552// RADIOLIB_SI443X_REG_RX_FIFO_CONTROL
553#define RADIOLIB_SI443X_RX_FIFO_ALMOST_FULL_THRESHOLD 0x37 // 5 0 Rx FIFO almost full threshold
554
560class Si443x: public PhysicalLayer {
561 public:
562 // introduce PhysicalLayer overloads
567
568 // constructor
569
574 explicit Si443x(Module* mod);
575
576 // basic methods
577
586 int16_t begin(uint32_t br, uint32_t freqDev, uint32_t rxBw, uint8_t preambleLen);
587
591 void reset();
592
601 int16_t transmit(const uint8_t* data, size_t len, uint8_t addr = 0) override;
602
612 int16_t receive(uint8_t* data, size_t len, RadioLibTime_t timeout = 0) override;
613
619 int16_t sleep() override;
620
625 int16_t standby() override;
626
632 int16_t standby(uint8_t mode) override;
633
639 int16_t transmitDirect(uint32_t frf = 0) override;
640
645 int16_t receiveDirect() override;
646
651 int16_t packetMode();
652
653 // interrupt methods
654
662 int16_t startTransmit(const uint8_t* data, size_t len, uint8_t addr = 0) override;
663
668 int16_t finishTransmit() override;
669
674 int16_t startReceive() override;
675
684 int16_t startReceive(uint32_t timeout, uint32_t irqFlags, uint32_t irqMask, size_t len) override;
685
694 int16_t readData(uint8_t* data, size_t len) override;
695
700 int16_t finishReceive() override;
701
702 // configuration methods
703
709 int16_t setBitRate(uint32_t br) override;
710
716 int16_t setFrequencyDeviation(uint32_t freqDev) override;
717
723 int16_t setRxBandwidth(uint32_t rxBw);
724
730 int16_t setSyncWord(uint8_t* syncWord, size_t len) override;
731
738 int16_t setPreambleLength(size_t len, size_t detLen = 0) override;
739
745 size_t getPacketLength(bool update = true) override;
746
753 int16_t setEncoding(uint8_t encoding) override;
754
761 int16_t setDataShaping(uint8_t sh) override;
762
764 void setRfSwitchPins(uint32_t rxEn, uint32_t txEn);
765
767 void setRfSwitchTable(const uint32_t (&pins)[Module::RFSWITCH_MAX_PINS], const Module::RfSwitchMode_t table[]);
768
773 uint8_t randomByte() override;
774
779 int16_t getChipVersion();
780
781 #if !RADIOLIB_EXCLUDE_DIRECT_RECEIVE
786 void setDirectAction(void (*func)(void)) override;
787
792 void readBit(uint32_t pin) override;
793 #endif
794
800 int16_t fixedPacketLengthMode(uint8_t len = RADIOLIB_SI443X_MAX_PACKET_LENGTH);
801
807 int16_t variablePacketLengthMode(uint8_t maxLen = RADIOLIB_SI443X_MAX_PACKET_LENGTH);
808
813 uint32_t getIrqFlags() override;
814
820 int16_t clearIrqFlags(uint32_t irq) override;
821
828 int16_t setCRC(bool enable, bool mode = false);
829
830#if !RADIOLIB_GODMODE && !RADIOLIB_LOW_LEVEL
831 protected:
832#endif
833 Module* getMod() override;
834
835#if !RADIOLIB_GODMODE
836 protected:
837#endif
838 int16_t setFrequencyRaw(uint32_t newFreq);
839
840#if !RADIOLIB_GODMODE
841 private:
842#endif
843 Module* mod;
844
845 uint32_t bitRate = 0;
846 uint32_t frequencyDev = 0;
847 uint32_t frequency = 0;
848
849 size_t packetLength = 0;
850 bool packetLengthQueried = false;
851 uint8_t packetLengthConfig = RADIOLIB_SI443X_FIXED_PACKET_LENGTH_ON;
852 bool crcEnabled = false;
853
854 bool findChip();
855 void clearIrqStatus();
856 void clearFIFO(size_t count);
857 int16_t config();
858 int16_t updateClockRecovery();
859 int16_t directMode();
860 int16_t setPacketMode(uint8_t mode, uint8_t len);
861};
862
863#endif
864
865#endif
Implements all common low-level methods to control the wireless module. Every module class contains o...
Definition Module.h:74
static const size_t RFSWITCH_MAX_PINS
The maximum number of pins supported by the RF switch code. Note: It is not recommended to use this c...
Definition Module.h:83
virtual int16_t readData(uint8_t *data, size_t len)
Reads data that was received after calling startReceive method.
Definition PhysicalLayer.cpp:226
int16_t transmit(const char *str, uint8_t addr=0)
C-string transmit method.
Definition PhysicalLayer.cpp:53
int16_t startTransmit(const char *str, uint8_t addr=0)
Interrupt-driven Arduino String transmit method. Unlike the standard transmit method,...
Definition PhysicalLayer.cpp:157
virtual int16_t receive(uint8_t *data, size_t len, RadioLibTime_t timeout=0)
Binary receive method. Must be implemented in module class.
Definition PhysicalLayer.cpp:111
PhysicalLayer()
Default constructor.
Definition PhysicalLayer.cpp:5
int16_t setEncoding(uint8_t encoding) override
Sets transmission encoding. Only available in FSK mode. Allowed values are RADIOLIB_ENCODING_NRZ,...
Definition Si443x.cpp:490
uint8_t randomByte() override
Get one truly random byte from RSSI noise.
Definition Si443x.cpp:533
int16_t receiveDirect() override
Enables direct reception mode. While in direct mode, the module will not be able to transmit or recei...
Definition Si443x.cpp:195
int16_t startTransmit(const uint8_t *data, size_t len, uint8_t addr=0) override
Interrupt-driven binary transmit method. Will start transmitting arbitrary binary data up to 64 bytes...
Definition Si443x.cpp:215
int16_t clearIrqFlags(uint32_t irq) override
Clear interrupt on a specific IRQ bit (e.g. RxTimeout, CadDone).
Definition Si443x.cpp:580
void readBit(uint32_t pin) override
Function to read and process data bit in direct reception mode.
Definition Si443x.cpp:561
size_t getPacketLength(bool update=true) override
Query modem for the packet length of received payload.
Definition Si443x.cpp:477
int16_t transmit(const uint8_t *data, size_t len, uint8_t addr=0) override
Binary transmit method. Will transmit arbitrary binary data up to 64 bytes long. For overloads to tra...
Definition Si443x.cpp:82
int16_t receive(uint8_t *data, size_t len, RadioLibTime_t timeout=0) override
Binary receive method. Will attempt to receive arbitrary binary data up to 64 bytes long....
Definition Si443x.cpp:103
void setRfSwitchPins(uint32_t rxEn, uint32_t txEn)
Some modules contain external RF switch controlled by pins. This function gives RadioLib control over...
Definition Si443x.cpp:525
void setDirectAction(void(*func)(void)) override
Set interrupt service routine function to call when data bit is received in direct mode.
Definition Si443x.cpp:557
int16_t getChipVersion()
Read version SPI register. Should return RADIOLIB_SI443X_DEVICE_VERSION (0x06) if Si443x is connected...
Definition Si443x.cpp:552
int16_t transmitDirect(uint32_t frf=0) override
Enables direct transmission mode. While in direct mode, the module will not be able to transmit or re...
Definition Si443x.cpp:153
int16_t packetMode()
Disables direct mode and enables packet mode, allowing the module to receive packets.
Definition Si443x.cpp:208
int16_t finishReceive() override
Clean up after reception is done.
Definition Si443x.cpp:332
int16_t finishTransmit() override
Clean up after transmission is done.
Definition Si443x.cpp:256
void setRfSwitchTable(const uint32_t(&pins)[Module::RFSWITCH_MAX_PINS], const Module::RfSwitchMode_t table[])
Some modules contain external RF switch controlled by pins. This function gives RadioLib control over...
Definition Si443x.cpp:529
int16_t setBitRate(uint32_t br) override
Sets FSK bit rate. Allowed values range from 123 bps to 256 kbps.
Definition Si443x.cpp:341
int16_t setFrequencyDeviation(uint32_t freqDev) override
Sets FSK frequency deviation from carrier frequency. Allowed values range from 625 Hz to 320 kHz.
Definition Si443x.cpp:370
int16_t sleep() override
Sets the module to sleep to save power. Module will not be able to transmit or receive any data while...
Definition Si443x.cpp:127
int16_t setPreambleLength(size_t len, size_t detLen=0) override
Sets preamble length.
Definition Si443x.cpp:459
int16_t setRxBandwidth(uint32_t rxBw)
Sets receiver bandwidth. Allowed values range from 2.6 to 620.7 kHz.
Definition Si443x.cpp:388
int16_t variablePacketLengthMode(uint8_t maxLen=RADIOLIB_SI443X_MAX_PACKET_LENGTH)
Set modem in variable packet length mode.
Definition Si443x.cpp:570
int16_t begin(uint32_t br, uint32_t freqDev, uint32_t rxBw, uint8_t preambleLen)
Initialization method.
Definition Si443x.cpp:12
int16_t standby() override
Sets the module to standby (with XTAL on).
Definition Si443x.cpp:143
int16_t setCRC(bool enable, bool mode=false)
Enables/disables CRC of transmitted or received packets.
Definition Si443x.cpp:586
int16_t readData(uint8_t *data, size_t len) override
Reads data that was received after calling startReceive method. When the packet length is not known i...
Definition Si443x.cpp:298
int16_t fixedPacketLengthMode(uint8_t len=RADIOLIB_SI443X_MAX_PACKET_LENGTH)
Set modem in fixed packet length mode.
Definition Si443x.cpp:566
uint32_t getIrqFlags() override
Read currently active IRQ flags.
Definition Si443x.cpp:574
int16_t setDataShaping(uint8_t sh) override
Sets Gaussian filter bandwidth-time product that will be used for data shaping. Only available in FSK...
Definition Si443x.cpp:509
int16_t startReceive() override
Interrupt-driven receive method. IRQ will be activated when full valid packet is received.
Definition Si443x.cpp:264
void reset()
Reset method. Will reset the chip to the default state using SDN pin.
Definition Si443x.cpp:74
Si443x(Module *mod)
Default constructor.
Definition Si443x.cpp:6
int16_t setSyncWord(uint8_t *syncWord, size_t len) override
Sets sync word. Up to 4 bytes can be set as sync word.
Definition Si443x.cpp:443
unsigned long RadioLibTime_t
Type used for durations in RadioLib.
Definition TypeDef.h:784
Description of RF switch pin states for a single mode. See setRfSwitchTable for details.
Definition Module.h:90