31 #ifndef PIOS_OPENLRS_PRIV_H
32 #define PIOS_OPENLRS_PRIV_H
36 #ifdef PIOS_INCLUDE_OPENLRS
42 #define OPENLRSNG_VERSION 0x0382
45 #define OPENLRS_PPM_NUM_CHANNELS 20
58 #define DEFAULT_RF_POWER 7
60 #define DEFAULT_CHANNEL_SPACING 5 // 50kHz
61 #define DEFAULT_HOPLIST 22,10,19,34,49,41
62 #define DEFAULT_RF_MAGIC 0xDEADFEED
67 #define DEFAULT_DATARATE 2
70 #define TELEMETRY_OFF 0x00
71 #define TELEMETRY_PASSTHRU 0x08
72 #define TELEMETRY_FRSKY 0x10 // covers smartport if used with &
73 #define TELEMETRY_SMARTPORT 0x18
74 #define TELEMETRY_MASK 0x18
75 #define CHANNELS_4 0x00
76 #define CHANNELS_4_4 0x01
77 #define CHANNELS_8 0x02
78 #define CHANNELS_8_4 0x03
79 #define CHANNELS_12 0x04
80 #define CHANNELS_12_4 0x05
81 #define CHANNELS_16 0x06
82 #define CHANNELS_16_4 0x07
84 #define DIVERSITY_ENABLED 0x80
85 #define DEFAULT_FLAGS (CHANNELS_8 | TELEMETRY_PASSTHRU)
86 #define EXT_FLAG_FASTDATA 0x80
89 #define EU_PMR_CH(x) (445993750L + 12500L * (x)) // valid for ch1-ch8
92 #define US_FRS_CH(x) (462537500L + 25000L * (x)) // valid for ch1-ch7
94 #define DEFAULT_BEACON_FREQUENCY 0 // disable beacon
95 #define DEFAULT_BEACON_DEADTIME 30 // time to wait until go into beacon mode (30s)
96 #define DEFAULT_BEACON_INTERVAL 10 // interval between beacon transmits (10s)
98 #define TELEMETRY_PACKETSIZE 9
100 #define BIND_MAGIC (0xDEC1BE15 + (OPENLRSNG_VERSION & 0xfff0))
101 #define BINDING_VERSION ((OPENLRSNG_VERSION & 0x0ff0)>>4)
104 #define MIN_RFM_FREQUENCY_868 848000000
105 #define MAX_RFM_FREQUENCY_868 888000000
106 #define DEFAULT_CARRIER_FREQUENCY_868 868000000 // Hz (ch 0)
107 #define BINDING_FREQUENCY_868 868000000 // Hz
109 #define MIN_RFM_FREQUENCY_915 895000000
110 #define MAX_RFM_FREQUENCY_915 935000000
111 #define DEFAULT_CARRIER_FREQUENCY_915 915000000 // Hz (ch 0)
112 #define BINDING_FREQUENCY_915 915000000 // Hz
114 #define MIN_RFM_FREQUENCY_433 413000000
115 #define MAX_RFM_FREQUENCY_433 463000000
116 #define DEFAULT_CARRIER_FREQUENCY_433 435000000 // Hz (ch 0)
117 #define BINDING_FREQUENCY_433 435000000 // Hz
119 #define RFM22_DEVICE_TYPE 0x00 // R
120 #define RFM22_DT_MASK 0x1F
122 const static uint8_t openlrs_pktsizes[8] = { 6, 7, 11, 12, 16, 17, 21, 22 };
123 #define MAX_PACKET_SIZE 22
135 uint32_t rf_frequency;
138 uint8_t rf_channel_spacing;
139 uint8_t hopchannel[MAXHOPS];
140 uint8_t modem_params;
145 Available, Transmit, Receive, Transmitted, Received,
148 enum pios_openlrs_dev_magic {
149 PIOS_OPENLRS_DEV_MAGIC = 0x18c97ab6,
152 struct pios_openlrs_dev {
153 enum pios_openlrs_dev_magic
magic;
154 struct pios_openlrs_cfg
cfg;
160 HwSharedRfBandOptions band;
161 HwSharedMaxRfPowerOptions max_power;
170 uintptr_t rx_in_context;
172 uintptr_t tx_out_context;
178 int16_t ppm[OPENLRS_PPM_NUM_CHANNELS];
181 uintptr_t openlrs_rcvr_id;
184 struct bind_data bind_data;
187 uint32_t beacon_frequency;
188 uint8_t beacon_delay;
189 uint8_t beacon_period;
195 volatile enum RF_MODE rf_mode;
203 uint32_t lastPacketTimeUs;
204 uint32_t numberOfLostPackets;
205 uint16_t lastAFCCvalue;
206 uint32_t nextBeaconTimeMs;
207 uint32_t linkLossTimeMs;
208 uint32_t failsafeDelay;
209 uint32_t beacon_rssi_avg;
212 uint16_t scale_min, scale_max;
214 OpenLRStx_sourceOptions tx_source;
215 bool tx_ok_to_telemeter;
216 uint8_t tx_prev_rxtelem_hdr;
217 uint8_t tx_startup_bind_duration;
218 uint8_t tx_bind_button_duration;
220 uint8_t tx_buf[MAX_PACKET_SIZE];
static struct pios_thread * taskHandle
static struct flyingpicmd_cfg_fa cfg
Implements an OpenLRS driver for the RFM22B.
uint16_t(* pios_com_callback)(uintptr_t context, uint8_t *buf, uint16_t buf_len, uint16_t *headroom, bool *task_woken)