43constexpr float FSTEP = 61.03515625;
53 bus_config.csHoldTimeUs = 3;
77namespace RegDioMapping
80inline constexpr uint16_t
make(
int dio0,
int dio1,
int dio2,
int dio3,
int dio4,
81 int dio5,
bool map_preamble_detect)
83 return (((dio0 & 0b11) << 14) | ((dio1 & 0b11) << 12) |
84 ((dio2 & 0b11) << 10) | ((dio3 & 0b11) << 8) |
85 ((dio4 & 0b11) << 6) | ((dio5 & 0b11) << 4) |
86 (map_preamble_detect ? 1 : 0));
95 constexpr Mapping(
int dio0,
int dio1,
int dio2,
int dio3,
int dio4,
96 int dio5,
bool map_preamble_detect =
false)
97 :
raw(
make(dio0, dio1, dio2, dio3, dio4, dio5, map_preamble_detect))
106 return (
raw >> 14) & 0b11;
108 return (
raw >> 12) & 0b11;
110 return (
raw >> 10) & 0b11;
112 return (
raw >> 8) & 0b11;
114 return (
raw >> 6) & 0b11;
116 return (
raw >> 4) & 0b11;
161inline constexpr uint8_t
make(
Mode mode,
bool low_frequency_mode_on,
164 return mode | (low_frequency_mode_on ? (1 << 3) : 0) |
165 (modulation_type << 5);
173inline constexpr uint8_t
make(uint8_t output_power, uint8_t max_power,
176 return (output_power & 0b1111) | ((max_power & 0b111) << 4) |
177 (pa_select ? 1 << 7 : 0);
215 return pa_ramp | (modulation_shaping << 5);
223inline constexpr uint8_t
make(uint8_t ocp_trim,
bool ocp_on)
225 return (ocp_trim & 0b11111) | (ocp_on ? 1 << 5 : 0);
233inline constexpr uint8_t
make(
bool rx_trigger_rssi_interrupt,
234 bool rx_trigger_preable_detect,
bool agc_auto_on,
235 bool afc_auto_on,
bool restart_rx_with_pll_lock,
236 bool restart_rx_without_pll_lock,
237 bool restart_rx_on_collision)
239 return (rx_trigger_rssi_interrupt ? 0b001 : 0) |
240 (rx_trigger_preable_detect ? 0b110 : 0) |
241 (agc_auto_on ? 1 << 3 : 0) | (afc_auto_on ? 1 << 4 : 0) |
242 (restart_rx_with_pll_lock ? 1 << 5 : 0) |
243 (restart_rx_without_pll_lock ? 1 << 6 : 0) |
244 (restart_rx_on_collision ? 1 << 7 : 0);
277inline constexpr uint8_t
make(
RxBw rx_bw) {
return rx_bw; }
286inline constexpr uint8_t
make(
RxBwAfc rx_bw_afc) {
return rx_bw_afc; }
290namespace RegPreambleDetector
300inline constexpr uint8_t
make(
int tol,
Size size,
bool on)
302 return (tol & 0b11111) | (size << 5) | (on ? 1 << 7 : 0);
307namespace RegSyncConfig
322inline constexpr uint8_t
make(
int size,
bool on,
326 return ((size - 1) & 0b111) | (on ? 1 << 4 : 0) | (preamble_polarity << 5) |
327 (auto_restart_rx_mode << 6);
332namespace RegPacketConfig1
362 bool crc_auto_clear_off,
bool crc_on,
365 return crc_whitening_type | (address_filtering << 1) |
366 (crc_auto_clear_off ? 1 << 3 : 0) | (crc_on ? 1 << 4 : 0) |
367 (dc_free << 5) | (packet_format << 7);
372namespace RegPacketConfig2
380inline constexpr uint8_t
make(
bool beacon_on,
bool io_home_power_frame,
381 bool io_home_on,
DataMode data_mode)
383 return (beacon_on ? 1 << 3 : 0) | (io_home_power_frame ? 1 << 4 : 0) |
384 (io_home_on ? 1 << 5 : 0) | (data_mode << 6);
389namespace RegFifoThresh
397inline constexpr uint8_t
make(
int fifo_threshold,
400 return (fifo_threshold & 0b111111) | (tx_start_condition << 7);
438inline constexpr uint8_t
make(
PaDac pa_dac) {
return pa_dac | (0x10 << 3); }
566inline constexpr uint8_t
make(
Mode mode,
bool low_frequency_mode_on,
567 bool access_shared_reg)
569 return mode | (low_frequency_mode_on ? (1 << 3) : 0) |
570 (access_shared_reg ? (1 << 6) : 0) | (1 << 7);
578inline constexpr uint8_t
make(uint8_t output_power, uint8_t max_power,
581 return (output_power & 0b1111) | ((max_power & 0b111) << 4) |
582 (pa_select ? 1 << 7 : 0);
590inline constexpr uint8_t
make(uint8_t ocp_trim,
bool ocp_on)
592 return (ocp_trim & 0b11111) | (ocp_on ? 1 << 5 : 0);
614namespace RegModemConfig1
669inline constexpr uint8_t
make(
bool implicit_mode_on,
Cr coding_rate,
Bw bw)
671 return (implicit_mode_on ? 1 : 0) | (coding_rate << 1) | (bw << 4);
676namespace RegModemConfig2
690inline constexpr uint8_t
make(
bool rx_payload_crc_on,
bool tx_continuous_mode,
693 return (rx_payload_crc_on ? 1 << 2 : 0) |
694 (tx_continuous_mode ? 1 << 3 : 0) | (spreading_factor << 4);
699namespace RegModemConfig3
702inline constexpr uint8_t
make(
bool agc_auto_on,
bool low_data_rate_optimize)
704 return (agc_auto_on ? 1 << 2 : 0) | (low_data_rate_optimize ? 1 << 3 : 0);
709namespace RegDetectOptimize
712inline constexpr uint8_t
make(uint8_t detection_optimize,
bool automatic_if_on)
714 return (detection_optimize & 0b11) | (automatic_if_on ? 1 << 7 : 0);
722inline constexpr uint8_t
make(
bool pa_boost)
724 return (pa_boost ? 0x07 : 0x04) | (0x10 << 3);
@ MODE_0
CPOL = 0, CPHA = 0 -> Clock low when idle, sample on first edge.
ClockDivider
SPI Clock divider.
@ INVERTED
Inverted write bit settings (1 for write, 0 for reads)
constexpr uint8_t make(RxBwAfc rx_bw_afc)
constexpr uint8_t make(int fifo_threshold, TxStartCondition tx_start_condition)
@ TX_START_CONDITION_FIFO_LEVEL
@ TX_START_CONDITION_FIFO_NOT_EMPTY
constexpr uint8_t make(uint8_t ocp_trim, bool ocp_on)
constexpr uint8_t make(Mode mode, bool low_frequency_mode_on, ModulationType modulation_type)
constexpr uint8_t make(uint8_t output_power, uint8_t max_power, bool pa_select)
constexpr uint8_t make(PaDac pa_dac)
@ MODULATION_SHAPING_GAUSSIAN_BT_1_0
@ MODULATION_SHAPING_NONE
@ MODULATION_SHAPING_GAUSSIAN_BT_0_5
@ MODULATION_SHAPING_GAUSSIAN_BT_0_3
constexpr uint8_t make(PaRamp pa_ramp, ModulationShaping modulation_shaping)
@ ADDRESS_FILTERING_MATCH_NODE
@ ADDRESS_FILTERING_MATCH_NODE_OR_BROADCAST
@ CRC_WHITENING_TYPE_IBM_CRC
@ CRC_WHITENING_TYPE_CCITT_CRC
@ PACKET_FORMAT_FIXED_LENGTH
@ PACKET_FORMAT_VARIABLE_LENGTH
constexpr uint8_t make(CrcWhiteningType crc_whitening_type, AddressFiltering address_filtering, bool crc_auto_clear_off, bool crc_on, DcFree dc_free, PacketFormat packet_format)
constexpr uint8_t make(bool beacon_on, bool io_home_power_frame, bool io_home_on, DataMode data_mode)
@ PREAMBLE_DETECTOR_SIZE_2_BYTES
@ PREAMBLE_DETECTOR_SIZE_3_BYTES
@ PREAMBLE_DETECTOR_SIZE_1_BYTE
constexpr uint8_t make(int tol, Size size, bool on)
constexpr uint8_t make(RxBw rx_bw)
constexpr uint8_t make(bool rx_trigger_rssi_interrupt, bool rx_trigger_preable_detect, bool agc_auto_on, bool afc_auto_on, bool restart_rx_with_pll_lock, bool restart_rx_without_pll_lock, bool restart_rx_on_collision)
constexpr uint8_t make(int size, bool on, PreamblePolarity preamble_polarity, AutoRestartRxMode auto_restart_rx_mode)
@ AUTO_RESTART_RX_MODE_ON_WITH_PILL_LOCK
@ AUTO_RESTART_RX_MODE_ON_WITHOUT_PILL_LOCK
@ AUTO_RESTART_RX_MODE_OFF
@ REG_PACKET_PAYLOAD_LENGTH
constexpr int FIFO_LEN
Length of the internal FIFO.
constexpr uint8_t make(uint8_t detection_optimize, bool automatic_if_on)
constexpr uint8_t make(bool implicit_mode_on, Cr coding_rate, Bw bw)
constexpr uint32_t bandwidthToInt(Bw bw)
constexpr uint8_t make(bool rx_payload_crc_on, bool tx_continuous_mode, Sf spreading_factor)
constexpr uint8_t make(bool agc_auto_on, bool low_data_rate_optimize)
constexpr uint8_t make(uint8_t ocp_trim, bool ocp_on)
constexpr uint8_t make(Mode mode, bool low_frequency_mode_on, bool access_shared_reg)
constexpr uint8_t make(uint8_t output_power, uint8_t max_power, bool pa_select)
constexpr uint8_t make(bool pa_boost)
@ REG_RX_PACKET_CNT_VALUE_LSB
@ REG_RX_HEADER_CNT_VALUE_LSB
@ REG_RX_PACKET_CNT_VALUE_MSB
@ REG_FIFO_RX_CURRENT_ADDR
@ REG_RX_HEADER_CNT_VALUE_MSB
@ REG_DETECTION_THRESHOLD
constexpr uint16_t make(int dio0, int dio1, int dio2, int dio3, int dio4, int dio5, bool map_preamble_detect)
constexpr int MIN_FREQ_DEV
constexpr float FSTEP
Frequency step (Hz) used in some calculations.
SPIBusConfig getSpiBusConfig(SPI::ClockDivider clock_divider)
constexpr int MAX_FREQ_DEV
constexpr int MIN_FREQ_RF
constexpr int MAX_FREQ_RF
constexpr int FXOSC
Main oscillator frequency (Hz)
This file includes all the types the logdecoder script will decode.
SPI Bus configuration for a specific slave.
SPI::ClockDivider clockDivider
< Peripheral clock division
Represents an actual Dio mapping..
bool operator==(const Mapping &other) const
int getMapping(Dio dio) const
bool operator!=(const Mapping &other) const
constexpr Mapping(int dio0, int dio1, int dio2, int dio3, int dio4, int dio5, bool map_preamble_detect=false)