
test sending sensor results over lora radio. Accelerometer and temp/pressure.
Serial terminal operates at 115200.
This project provides a text-based menu over serial port.
Operating the program only requires using the arrow keys, enter key to activate a control, or entering numbers.
Two sensors provided:
LIS12DH12
accelerometer operates in a continuous sampling mode. Enable control for accelerometer enables this continuous sampling, approx every 3 seconds.
LPS22HH temperature / pressure sensor operates as single shot, where pressing the control button on terminal causes single sample to be performed.
poll rate
control will enable repeated reading of pressure/temperature-sensor or photo-sensor when poll rate is greater than zero.
target must be: DISCO_L072CZ_LRWAN1
radio_sx127x.cpp@0:e1e70da93044, 2019-04-24 (annotated)
- Committer:
- Wayne Roberts
- Date:
- Wed Apr 24 10:11:06 2019 -0700
- Revision:
- 0:e1e70da93044
initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Wayne Roberts |
0:e1e70da93044 | 1 | #include "radio.h" |
Wayne Roberts |
0:e1e70da93044 | 2 | #ifdef SX127x_H |
Wayne Roberts |
0:e1e70da93044 | 3 | |
Wayne Roberts |
0:e1e70da93044 | 4 | const char* const Radio::chipNum_str = "SX127x"; |
Wayne Roberts |
0:e1e70da93044 | 5 | |
Wayne Roberts |
0:e1e70da93044 | 6 | const RadioEvents_t* Radio::RadioEvents; |
Wayne Roberts |
0:e1e70da93044 | 7 | LowPowerTimer Radio::lpt; |
Wayne Roberts |
0:e1e70da93044 | 8 | uint8_t Radio::bw_idx; |
Wayne Roberts |
0:e1e70da93044 | 9 | |
Wayne Roberts |
0:e1e70da93044 | 10 | RegPaRamp_t Radio::RegPaRamp; |
Wayne Roberts |
0:e1e70da93044 | 11 | |
Wayne Roberts |
0:e1e70da93044 | 12 | const char* opModes[] = { |
Wayne Roberts |
0:e1e70da93044 | 13 | "SLEEP ", // 0 |
Wayne Roberts |
0:e1e70da93044 | 14 | "STANDBY ", // 1 |
Wayne Roberts |
0:e1e70da93044 | 15 | "FS_TX ", // 2 |
Wayne Roberts |
0:e1e70da93044 | 16 | "TX ", // 3 |
Wayne Roberts |
0:e1e70da93044 | 17 | "FS_RX ", // 4 |
Wayne Roberts |
0:e1e70da93044 | 18 | "RX ", // 5 |
Wayne Roberts |
0:e1e70da93044 | 19 | "RX_SINGLE", // 6 |
Wayne Roberts |
0:e1e70da93044 | 20 | "CAD " // 7 |
Wayne Roberts |
0:e1e70da93044 | 21 | }; |
Wayne Roberts |
0:e1e70da93044 | 22 | |
Wayne Roberts |
0:e1e70da93044 | 23 | const char* Radio::tx_ramp_strs[] = { |
Wayne Roberts |
0:e1e70da93044 | 24 | "3400", // 0 |
Wayne Roberts |
0:e1e70da93044 | 25 | "2000", // 1 |
Wayne Roberts |
0:e1e70da93044 | 26 | "1000", // 2 |
Wayne Roberts |
0:e1e70da93044 | 27 | "500 ", // 3 |
Wayne Roberts |
0:e1e70da93044 | 28 | "250 ", // 4 |
Wayne Roberts |
0:e1e70da93044 | 29 | "125 ", // 5 |
Wayne Roberts |
0:e1e70da93044 | 30 | "100 ", // 6 |
Wayne Roberts |
0:e1e70da93044 | 31 | "62 ", // 7 |
Wayne Roberts |
0:e1e70da93044 | 32 | "50 ", // 8 |
Wayne Roberts |
0:e1e70da93044 | 33 | "40 ", // 9 |
Wayne Roberts |
0:e1e70da93044 | 34 | "31 ", // 10 |
Wayne Roberts |
0:e1e70da93044 | 35 | "25 ", // 11 |
Wayne Roberts |
0:e1e70da93044 | 36 | "20 ", // 12 |
Wayne Roberts |
0:e1e70da93044 | 37 | "15 ", // 13 |
Wayne Roberts |
0:e1e70da93044 | 38 | "12 ", // 14 |
Wayne Roberts |
0:e1e70da93044 | 39 | "10 ", // 15 |
Wayne Roberts |
0:e1e70da93044 | 40 | NULL |
Wayne Roberts |
0:e1e70da93044 | 41 | }; |
Wayne Roberts |
0:e1e70da93044 | 42 | |
Wayne Roberts |
0:e1e70da93044 | 43 | unsigned Radio::tx_ramp_read(bool fw) |
Wayne Roberts |
0:e1e70da93044 | 44 | { |
Wayne Roberts |
0:e1e70da93044 | 45 | RegPaRamp.octet = radio.read_reg(REG_PARAMP); |
Wayne Roberts |
0:e1e70da93044 | 46 | return RegPaRamp.bits.PaRamp; |
Wayne Roberts |
0:e1e70da93044 | 47 | } |
Wayne Roberts |
0:e1e70da93044 | 48 | |
Wayne Roberts |
0:e1e70da93044 | 49 | menuMode_e Radio::tx_ramp_write(unsigned val) |
Wayne Roberts |
0:e1e70da93044 | 50 | { |
Wayne Roberts |
0:e1e70da93044 | 51 | RegPaRamp.octet = radio.read_reg(REG_PARAMP); |
Wayne Roberts |
0:e1e70da93044 | 52 | |
Wayne Roberts |
0:e1e70da93044 | 53 | RegPaRamp.bits.PaRamp = val; |
Wayne Roberts |
0:e1e70da93044 | 54 | radio.write_reg(REG_PARAMP, RegPaRamp.octet); |
Wayne Roberts |
0:e1e70da93044 | 55 | |
Wayne Roberts |
0:e1e70da93044 | 56 | return MENUMODE_REDRAW; |
Wayne Roberts |
0:e1e70da93044 | 57 | } |
Wayne Roberts |
0:e1e70da93044 | 58 | |
Wayne Roberts |
0:e1e70da93044 | 59 | const char* const Radio::pktType_strs[] = { |
Wayne Roberts |
0:e1e70da93044 | 60 | "FSK ", // 0 |
Wayne Roberts |
0:e1e70da93044 | 61 | "OOK ", // 1 |
Wayne Roberts |
0:e1e70da93044 | 62 | "LORA", // 2 |
Wayne Roberts |
0:e1e70da93044 | 63 | NULL |
Wayne Roberts |
0:e1e70da93044 | 64 | }; |
Wayne Roberts |
0:e1e70da93044 | 65 | |
Wayne Roberts |
0:e1e70da93044 | 66 | unsigned Radio::pktType_read(bool fw) |
Wayne Roberts |
0:e1e70da93044 | 67 | { |
Wayne Roberts |
0:e1e70da93044 | 68 | radio.RegOpMode.octet = radio.read_reg(REG_OPMODE); |
Wayne Roberts |
0:e1e70da93044 | 69 | if (radio.RegOpMode.bits.LongRangeMode) |
Wayne Roberts |
0:e1e70da93044 | 70 | return 2; |
Wayne Roberts |
0:e1e70da93044 | 71 | else |
Wayne Roberts |
0:e1e70da93044 | 72 | return radio.RegOpMode.bits.ModulationType; |
Wayne Roberts |
0:e1e70da93044 | 73 | } |
Wayne Roberts |
0:e1e70da93044 | 74 | |
Wayne Roberts |
0:e1e70da93044 | 75 | menuMode_e Radio::pktType_write(unsigned idx) |
Wayne Roberts |
0:e1e70da93044 | 76 | { |
Wayne Roberts |
0:e1e70da93044 | 77 | if (idx == 2) { |
Wayne Roberts |
0:e1e70da93044 | 78 | if (!radio.RegOpMode.bits.LongRangeMode) { |
Wayne Roberts |
0:e1e70da93044 | 79 | /* to lora */ |
Wayne Roberts |
0:e1e70da93044 | 80 | radio.set_opmode(RF_OPMODE_SLEEP); |
Wayne Roberts |
0:e1e70da93044 | 81 | radio.RegOpMode.bits.LongRangeMode = 1; |
Wayne Roberts |
0:e1e70da93044 | 82 | wait_us(1000); |
Wayne Roberts |
0:e1e70da93044 | 83 | radio.write_reg(REG_OPMODE, radio.RegOpMode.octet); |
Wayne Roberts |
0:e1e70da93044 | 84 | } |
Wayne Roberts |
0:e1e70da93044 | 85 | } else { |
Wayne Roberts |
0:e1e70da93044 | 86 | if (radio.RegOpMode.bits.LongRangeMode) { |
Wayne Roberts |
0:e1e70da93044 | 87 | /* from lora */ |
Wayne Roberts |
0:e1e70da93044 | 88 | radio.set_opmode(RF_OPMODE_SLEEP); |
Wayne Roberts |
0:e1e70da93044 | 89 | radio.RegOpMode.bits.LongRangeMode = 0; |
Wayne Roberts |
0:e1e70da93044 | 90 | wait_us(1000); |
Wayne Roberts |
0:e1e70da93044 | 91 | radio.write_reg(REG_OPMODE, radio.RegOpMode.octet); |
Wayne Roberts |
0:e1e70da93044 | 92 | } |
Wayne Roberts |
0:e1e70da93044 | 93 | |
Wayne Roberts |
0:e1e70da93044 | 94 | if (radio.RegOpMode.bits.ModulationType != idx) { |
Wayne Roberts |
0:e1e70da93044 | 95 | radio.RegOpMode.bits.ModulationType = idx; |
Wayne Roberts |
0:e1e70da93044 | 96 | radio.write_reg(REG_OPMODE, radio.RegOpMode.octet); |
Wayne Roberts |
0:e1e70da93044 | 97 | } |
Wayne Roberts |
0:e1e70da93044 | 98 | } |
Wayne Roberts |
0:e1e70da93044 | 99 | |
Wayne Roberts |
0:e1e70da93044 | 100 | return MENUMODE_REINIT_MENU; |
Wayne Roberts |
0:e1e70da93044 | 101 | } |
Wayne Roberts |
0:e1e70da93044 | 102 | |
Wayne Roberts |
0:e1e70da93044 | 103 | void Radio::hw_reset() |
Wayne Roberts |
0:e1e70da93044 | 104 | { |
Wayne Roberts |
0:e1e70da93044 | 105 | radio.hw_reset(); |
Wayne Roberts |
0:e1e70da93044 | 106 | } |
Wayne Roberts |
0:e1e70da93044 | 107 | |
Wayne Roberts |
0:e1e70da93044 | 108 | void Radio::clearIrqFlags() |
Wayne Roberts |
0:e1e70da93044 | 109 | { |
Wayne Roberts |
0:e1e70da93044 | 110 | if (radio.RegOpMode.bits.LongRangeMode) { |
Wayne Roberts |
0:e1e70da93044 | 111 | radio.write_reg(REG_LR_IRQFLAGS, 0xff); // clear flags in radio |
Wayne Roberts |
0:e1e70da93044 | 112 | } else { |
Wayne Roberts |
0:e1e70da93044 | 113 | radio.write_reg(REG_FSK_IRQFLAGS1, 0x0b); |
Wayne Roberts |
0:e1e70da93044 | 114 | radio.write_reg(REG_FSK_IRQFLAGS2, 0x11); |
Wayne Roberts |
0:e1e70da93044 | 115 | } |
Wayne Roberts |
0:e1e70da93044 | 116 | } |
Wayne Roberts |
0:e1e70da93044 | 117 | |
Wayne Roberts |
0:e1e70da93044 | 118 | void Radio::readChip() |
Wayne Roberts |
0:e1e70da93044 | 119 | { |
Wayne Roberts |
0:e1e70da93044 | 120 | } |
Wayne Roberts |
0:e1e70da93044 | 121 | |
Wayne Roberts |
0:e1e70da93044 | 122 | uint8_t Radio::get_payload_length() |
Wayne Roberts |
0:e1e70da93044 | 123 | { |
Wayne Roberts |
0:e1e70da93044 | 124 | if (radio.RegOpMode.bits.LongRangeMode) { |
Wayne Roberts |
0:e1e70da93044 | 125 | lora.RegPayloadLength = radio.read_reg(REG_LR_PAYLOADLENGTH); |
Wayne Roberts |
0:e1e70da93044 | 126 | return lora.RegPayloadLength; |
Wayne Roberts |
0:e1e70da93044 | 127 | } else { |
Wayne Roberts |
0:e1e70da93044 | 128 | fsk.RegPktConfig2.word = radio.read_u16(REG_FSK_PACKETCONFIG2); |
Wayne Roberts |
0:e1e70da93044 | 129 | return fsk.RegPktConfig2.bits.PayloadLength; |
Wayne Roberts |
0:e1e70da93044 | 130 | } |
Wayne Roberts |
0:e1e70da93044 | 131 | } |
Wayne Roberts |
0:e1e70da93044 | 132 | |
Wayne Roberts |
0:e1e70da93044 | 133 | void Radio::set_payload_length(uint8_t len) |
Wayne Roberts |
0:e1e70da93044 | 134 | { |
Wayne Roberts |
0:e1e70da93044 | 135 | if (radio.RegOpMode.bits.LongRangeMode) { |
Wayne Roberts |
0:e1e70da93044 | 136 | lora.RegPayloadLength = len; |
Wayne Roberts |
0:e1e70da93044 | 137 | radio.write_reg(REG_LR_PAYLOADLENGTH, lora.RegPayloadLength); |
Wayne Roberts |
0:e1e70da93044 | 138 | } else { |
Wayne Roberts |
0:e1e70da93044 | 139 | fsk.RegPktConfig2.bits.PayloadLength = len; |
Wayne Roberts |
0:e1e70da93044 | 140 | radio.write_u16(REG_FSK_PACKETCONFIG2, fsk.RegPktConfig2.word); |
Wayne Roberts |
0:e1e70da93044 | 141 | } |
Wayne Roberts |
0:e1e70da93044 | 142 | } |
Wayne Roberts |
0:e1e70da93044 | 143 | |
Wayne Roberts |
0:e1e70da93044 | 144 | void Radio::Rx() |
Wayne Roberts |
0:e1e70da93044 | 145 | { |
Wayne Roberts |
0:e1e70da93044 | 146 | if (radio.RegOpMode.bits.LongRangeMode) |
Wayne Roberts |
0:e1e70da93044 | 147 | lora.start_rx(RF_OPMODE_RECEIVER); |
Wayne Roberts |
0:e1e70da93044 | 148 | else |
Wayne Roberts |
0:e1e70da93044 | 149 | fsk.start_rx(); |
Wayne Roberts |
0:e1e70da93044 | 150 | } |
Wayne Roberts |
0:e1e70da93044 | 151 | |
Wayne Roberts |
0:e1e70da93044 | 152 | void Radio::txPkt() |
Wayne Roberts |
0:e1e70da93044 | 153 | { |
Wayne Roberts |
0:e1e70da93044 | 154 | if (radio.RegOpMode.bits.LongRangeMode) { |
Wayne Roberts |
0:e1e70da93044 | 155 | lora.RegPayloadLength = radio.read_reg(REG_LR_PAYLOADLENGTH); |
Wayne Roberts |
0:e1e70da93044 | 156 | lora.start_tx(lora.RegPayloadLength); |
Wayne Roberts |
0:e1e70da93044 | 157 | } else { |
Wayne Roberts |
0:e1e70da93044 | 158 | fsk.RegPktConfig2.word = radio.read_u16(REG_FSK_PACKETCONFIG2); |
Wayne Roberts |
0:e1e70da93044 | 159 | //log_printf("fsk payLen %u\r\n", fsk.RegPktConfig2.bits.PayloadLength); |
Wayne Roberts |
0:e1e70da93044 | 160 | fsk.start_tx(fsk.RegPktConfig2.bits.PayloadLength); |
Wayne Roberts |
0:e1e70da93044 | 161 | } |
Wayne Roberts |
0:e1e70da93044 | 162 | } |
Wayne Roberts |
0:e1e70da93044 | 163 | |
Wayne Roberts |
0:e1e70da93044 | 164 | void Radio::tx_carrier() |
Wayne Roberts |
0:e1e70da93044 | 165 | { |
Wayne Roberts |
0:e1e70da93044 | 166 | radio.set_opmode(RF_OPMODE_SLEEP); |
Wayne Roberts |
0:e1e70da93044 | 167 | fsk.enable(false); |
Wayne Roberts |
0:e1e70da93044 | 168 | radio.write_u16(REG_FSK_FDEVMSB, 0); |
Wayne Roberts |
0:e1e70da93044 | 169 | radio.write_u16(REG_FSK_PREAMBLEMSB, 0xffff); |
Wayne Roberts |
0:e1e70da93044 | 170 | fsk.start_tx(8); |
Wayne Roberts |
0:e1e70da93044 | 171 | } |
Wayne Roberts |
0:e1e70da93044 | 172 | |
Wayne Roberts |
0:e1e70da93044 | 173 | void Radio::tx_preamble() |
Wayne Roberts |
0:e1e70da93044 | 174 | { |
Wayne Roberts |
0:e1e70da93044 | 175 | if (radio.RegOpMode.bits.LongRangeMode) { |
Wayne Roberts |
0:e1e70da93044 | 176 | radio.write_u16(REG_LR_PREAMBLEMSB, 0xffff); |
Wayne Roberts |
0:e1e70da93044 | 177 | lora.start_tx(8); |
Wayne Roberts |
0:e1e70da93044 | 178 | } else { |
Wayne Roberts |
0:e1e70da93044 | 179 | radio.write_u16(REG_FSK_PREAMBLEMSB, 0xffff); |
Wayne Roberts |
0:e1e70da93044 | 180 | fsk.start_tx(8); |
Wayne Roberts |
0:e1e70da93044 | 181 | } |
Wayne Roberts |
0:e1e70da93044 | 182 | } |
Wayne Roberts |
0:e1e70da93044 | 183 | |
Wayne Roberts |
0:e1e70da93044 | 184 | bool Radio::service(int8_t statusRow) |
Wayne Roberts |
0:e1e70da93044 | 185 | { |
Wayne Roberts |
0:e1e70da93044 | 186 | bool ret = false; |
Wayne Roberts |
0:e1e70da93044 | 187 | static RegIrqFlags1_t prevRegIrqFlags1; |
Wayne Roberts |
0:e1e70da93044 | 188 | static RegIrqFlags2_t prevRegIrqFlags2; |
Wayne Roberts |
0:e1e70da93044 | 189 | static us_timestamp_t prev_now; |
Wayne Roberts |
0:e1e70da93044 | 190 | us_timestamp_t now = lpt.read_us(); |
Wayne Roberts |
0:e1e70da93044 | 191 | |
Wayne Roberts |
0:e1e70da93044 | 192 | if (radio.RegOpMode.bits.LongRangeMode) { |
Wayne Roberts |
0:e1e70da93044 | 193 | const float bws[] = {7.8, 10.4, 15.6, 20.8, 31.25, 41.7, 62.5, 125, 250, 500}; |
Wayne Roberts |
0:e1e70da93044 | 194 | int32_t est_freq_error; |
Wayne Roberts |
0:e1e70da93044 | 195 | int idx, hz; |
Wayne Roberts |
0:e1e70da93044 | 196 | service_action_e act = lora.service(); |
Wayne Roberts |
0:e1e70da93044 | 197 | switch (act) { |
Wayne Roberts |
0:e1e70da93044 | 198 | case SERVICE_READ_FIFO: |
Wayne Roberts |
0:e1e70da93044 | 199 | est_freq_error = radio.read_reg(REG_LR_TEST28); |
Wayne Roberts |
0:e1e70da93044 | 200 | est_freq_error <<= 8; |
Wayne Roberts |
0:e1e70da93044 | 201 | est_freq_error += radio.read_reg(REG_LR_TEST29); |
Wayne Roberts |
0:e1e70da93044 | 202 | est_freq_error <<= 8; |
Wayne Roberts |
0:e1e70da93044 | 203 | est_freq_error += radio.read_reg(REG_LR_TEST2A); |
Wayne Roberts |
0:e1e70da93044 | 204 | |
Wayne Roberts |
0:e1e70da93044 | 205 | if (est_freq_error & 0x80000) |
Wayne Roberts |
0:e1e70da93044 | 206 | est_freq_error |= 0xfff00000; // extend sign from 20bit to 32bit |
Wayne Roberts |
0:e1e70da93044 | 207 | |
Wayne Roberts |
0:e1e70da93044 | 208 | //log_printf("est_freq_error:%08x\r\n", est_freq_error); |
Wayne Roberts |
0:e1e70da93044 | 209 | if (radio.type == SX1272) |
Wayne Roberts |
0:e1e70da93044 | 210 | idx = bw_idx + 7; |
Wayne Roberts |
0:e1e70da93044 | 211 | else |
Wayne Roberts |
0:e1e70da93044 | 212 | idx = bw_idx; |
Wayne Roberts |
0:e1e70da93044 | 213 | |
Wayne Roberts |
0:e1e70da93044 | 214 | hz = est_freq_error * -0.524288 * bws[idx] / 500; |
Wayne Roberts |
0:e1e70da93044 | 215 | log_printf("hz:%d\r\n", hz); |
Wayne Roberts |
0:e1e70da93044 | 216 | |
Wayne Roberts |
0:e1e70da93044 | 217 | RadioEvents->RxDone(lora.RegRxNbBytes, lora.get_pkt_rssi(), lora.RegPktSnrValue / 4.0); |
Wayne Roberts |
0:e1e70da93044 | 218 | break; |
Wayne Roberts |
0:e1e70da93044 | 219 | case SERVICE_TX_DONE: |
Wayne Roberts |
0:e1e70da93044 | 220 | if (RadioEvents->TxDone_botHalf) |
Wayne Roberts |
0:e1e70da93044 | 221 | RadioEvents->TxDone_botHalf(); |
Wayne Roberts |
0:e1e70da93044 | 222 | break; |
Wayne Roberts |
0:e1e70da93044 | 223 | case SERVICE_ERROR: |
Wayne Roberts |
0:e1e70da93044 | 224 | case SERVICE_NONE: |
Wayne Roberts |
0:e1e70da93044 | 225 | break; |
Wayne Roberts |
0:e1e70da93044 | 226 | } |
Wayne Roberts |
0:e1e70da93044 | 227 | |
Wayne Roberts |
0:e1e70da93044 | 228 | if (radio.RegOpMode.bits.Mode == RF_OPMODE_CAD) { |
Wayne Roberts |
0:e1e70da93044 | 229 | if (radio.dio1 || radio.dio0) { |
Wayne Roberts |
0:e1e70da93044 | 230 | RegIrqFlags_t irqFlags; |
Wayne Roberts |
0:e1e70da93044 | 231 | irqFlags.octet = 0; |
Wayne Roberts |
0:e1e70da93044 | 232 | log_printf("Cad: "); |
Wayne Roberts |
0:e1e70da93044 | 233 | if (radio.dio0) { |
Wayne Roberts |
0:e1e70da93044 | 234 | pc.printf("Done "); |
Wayne Roberts |
0:e1e70da93044 | 235 | radio.RegOpMode.bits.Mode = RF_OPMODE_STANDBY; |
Wayne Roberts |
0:e1e70da93044 | 236 | irqFlags.bits.CadDone = 1; |
Wayne Roberts |
0:e1e70da93044 | 237 | } |
Wayne Roberts |
0:e1e70da93044 | 238 | if (radio.dio1) { |
Wayne Roberts |
0:e1e70da93044 | 239 | pc.printf("Detected"); |
Wayne Roberts |
0:e1e70da93044 | 240 | irqFlags.bits.CadDetected = 1; |
Wayne Roberts |
0:e1e70da93044 | 241 | } |
Wayne Roberts |
0:e1e70da93044 | 242 | pc.printf("\r\n"); |
Wayne Roberts |
0:e1e70da93044 | 243 | radio.write_reg(REG_LR_IRQFLAGS, irqFlags.octet); |
Wayne Roberts |
0:e1e70da93044 | 244 | } |
Wayne Roberts |
0:e1e70da93044 | 245 | } |
Wayne Roberts |
0:e1e70da93044 | 246 | } else { |
Wayne Roberts |
0:e1e70da93044 | 247 | service_action_e act = fsk.service(); |
Wayne Roberts |
0:e1e70da93044 | 248 | switch (act) { |
Wayne Roberts |
0:e1e70da93044 | 249 | case SERVICE_READ_FIFO: |
Wayne Roberts |
0:e1e70da93044 | 250 | /*if (fsk.RegRxConfig.bits.AfcAutoOn) { |
Wayne Roberts |
0:e1e70da93044 | 251 | printf("%dHz ", (int)(FREQ_STEP_HZ * fsk.RegAfcValue)); |
Wayne Roberts |
0:e1e70da93044 | 252 | if (rssi != 0) { |
Wayne Roberts |
0:e1e70da93044 | 253 | printf("pkt:-%.1fdBm ", rssi / 2.0); |
Wayne Roberts |
0:e1e70da93044 | 254 | rssi = 0; |
Wayne Roberts |
0:e1e70da93044 | 255 | } |
Wayne Roberts |
0:e1e70da93044 | 256 | }*/ |
Wayne Roberts |
0:e1e70da93044 | 257 | if (fsk.RegRxConfig.bits.AfcAutoOn) |
Wayne Roberts |
0:e1e70da93044 | 258 | log_printf("%dHz\r\n", (int)(FREQ_STEP_HZ * fsk.RegAfcValue)); |
Wayne Roberts |
0:e1e70da93044 | 259 | |
Wayne Roberts |
0:e1e70da93044 | 260 | RadioEvents->RxDone(fsk.rx_buf_length, /*TODO rssi*/0, 0); |
Wayne Roberts |
0:e1e70da93044 | 261 | break; |
Wayne Roberts |
0:e1e70da93044 | 262 | case SERVICE_TX_DONE: |
Wayne Roberts |
0:e1e70da93044 | 263 | if (RadioEvents->TxDone_botHalf) |
Wayne Roberts |
0:e1e70da93044 | 264 | RadioEvents->TxDone_botHalf(); |
Wayne Roberts |
0:e1e70da93044 | 265 | break; |
Wayne Roberts |
0:e1e70da93044 | 266 | case SERVICE_ERROR: |
Wayne Roberts |
0:e1e70da93044 | 267 | case SERVICE_NONE: |
Wayne Roberts |
0:e1e70da93044 | 268 | break; |
Wayne Roberts |
0:e1e70da93044 | 269 | } |
Wayne Roberts |
0:e1e70da93044 | 270 | |
Wayne Roberts |
0:e1e70da93044 | 271 | if (statusRow > 0 && now-prev_now > 50000) { |
Wayne Roberts |
0:e1e70da93044 | 272 | RegIrqFlags1_t RegIrqFlags1; |
Wayne Roberts |
0:e1e70da93044 | 273 | RegIrqFlags2_t RegIrqFlags2; |
Wayne Roberts |
0:e1e70da93044 | 274 | |
Wayne Roberts |
0:e1e70da93044 | 275 | RegIrqFlags1.octet = radio.read_reg(REG_FSK_IRQFLAGS1); |
Wayne Roberts |
0:e1e70da93044 | 276 | RegIrqFlags2.octet = radio.read_reg(REG_FSK_IRQFLAGS2); |
Wayne Roberts |
0:e1e70da93044 | 277 | prev_now = now; |
Wayne Roberts |
0:e1e70da93044 | 278 | |
Wayne Roberts |
0:e1e70da93044 | 279 | if (RegIrqFlags1.octet != prevRegIrqFlags1.octet || RegIrqFlags2.octet != prevRegIrqFlags2.octet) { |
Wayne Roberts |
0:e1e70da93044 | 280 | |
Wayne Roberts |
0:e1e70da93044 | 281 | pc.printf("\e[%u;1f", statusRow); // set (force) cursor to row;column |
Wayne Roberts |
0:e1e70da93044 | 282 | |
Wayne Roberts |
0:e1e70da93044 | 283 | if (RegIrqFlags1.bits.ModeReady) |
Wayne Roberts |
0:e1e70da93044 | 284 | pc.printf("ModeReady "); |
Wayne Roberts |
0:e1e70da93044 | 285 | if (RegIrqFlags1.bits.RxReady) |
Wayne Roberts |
0:e1e70da93044 | 286 | pc.printf("RxReady "); |
Wayne Roberts |
0:e1e70da93044 | 287 | if (RegIrqFlags1.bits.TxReady) |
Wayne Roberts |
0:e1e70da93044 | 288 | pc.printf("TxReady "); |
Wayne Roberts |
0:e1e70da93044 | 289 | if (RegIrqFlags1.bits.PllLock) |
Wayne Roberts |
0:e1e70da93044 | 290 | pc.printf("PllLock "); |
Wayne Roberts |
0:e1e70da93044 | 291 | if (RegIrqFlags1.bits.Rssi) |
Wayne Roberts |
0:e1e70da93044 | 292 | pc.printf("Rssi "); |
Wayne Roberts |
0:e1e70da93044 | 293 | if (RegIrqFlags1.bits.Timeout) |
Wayne Roberts |
0:e1e70da93044 | 294 | pc.printf("Timeout "); |
Wayne Roberts |
0:e1e70da93044 | 295 | if (RegIrqFlags1.bits.PreambleDetect) |
Wayne Roberts |
0:e1e70da93044 | 296 | pc.printf("PreambleDetect "); |
Wayne Roberts |
0:e1e70da93044 | 297 | if (RegIrqFlags1.bits.SyncAddressMatch) |
Wayne Roberts |
0:e1e70da93044 | 298 | pc.printf("SyncAddressMatch "); |
Wayne Roberts |
0:e1e70da93044 | 299 | |
Wayne Roberts |
0:e1e70da93044 | 300 | pc.printf(" | "); |
Wayne Roberts |
0:e1e70da93044 | 301 | if (RegIrqFlags2.bits.FifoFull) |
Wayne Roberts |
0:e1e70da93044 | 302 | pc.printf("FifoFull "); |
Wayne Roberts |
0:e1e70da93044 | 303 | if (RegIrqFlags2.bits.FifoEmpty) |
Wayne Roberts |
0:e1e70da93044 | 304 | pc.printf("FifoEmpty "); |
Wayne Roberts |
0:e1e70da93044 | 305 | if (RegIrqFlags2.bits.FifoLevel) |
Wayne Roberts |
0:e1e70da93044 | 306 | pc.printf("FifoLevel "); |
Wayne Roberts |
0:e1e70da93044 | 307 | if (RegIrqFlags2.bits.FifoOverrun) |
Wayne Roberts |
0:e1e70da93044 | 308 | pc.printf("FifoOverrun "); |
Wayne Roberts |
0:e1e70da93044 | 309 | if (RegIrqFlags2.bits.PacketSent) |
Wayne Roberts |
0:e1e70da93044 | 310 | pc.printf("PacketSent "); |
Wayne Roberts |
0:e1e70da93044 | 311 | if (RegIrqFlags2.bits.PayloadReady) |
Wayne Roberts |
0:e1e70da93044 | 312 | pc.printf("PayloadReady "); |
Wayne Roberts |
0:e1e70da93044 | 313 | if (RegIrqFlags2.bits.CrcOk) |
Wayne Roberts |
0:e1e70da93044 | 314 | pc.printf("CrcOk "); |
Wayne Roberts |
0:e1e70da93044 | 315 | if (RegIrqFlags2.bits.LowBat) |
Wayne Roberts |
0:e1e70da93044 | 316 | pc.printf("LowBat "); |
Wayne Roberts |
0:e1e70da93044 | 317 | |
Wayne Roberts |
0:e1e70da93044 | 318 | prevRegIrqFlags1.octet = RegIrqFlags1.octet; |
Wayne Roberts |
0:e1e70da93044 | 319 | prevRegIrqFlags2.octet = RegIrqFlags2.octet; |
Wayne Roberts |
0:e1e70da93044 | 320 | |
Wayne Roberts |
0:e1e70da93044 | 321 | pc.printf("\e[K"); |
Wayne Roberts |
0:e1e70da93044 | 322 | ret = true; |
Wayne Roberts |
0:e1e70da93044 | 323 | } // ..if irq flag changed |
Wayne Roberts |
0:e1e70da93044 | 324 | } // ..if (++cnt > X) |
Wayne Roberts |
0:e1e70da93044 | 325 | } // ..!radio.RegOpMode.bits.LongRangeMode |
Wayne Roberts |
0:e1e70da93044 | 326 | |
Wayne Roberts |
0:e1e70da93044 | 327 | return ret; |
Wayne Roberts |
0:e1e70da93044 | 328 | } |
Wayne Roberts |
0:e1e70da93044 | 329 | |
Wayne Roberts |
0:e1e70da93044 | 330 | void Radio::setFS() |
Wayne Roberts |
0:e1e70da93044 | 331 | { |
Wayne Roberts |
0:e1e70da93044 | 332 | radio.set_opmode(RF_OPMODE_SYNTHESIZER_RX); |
Wayne Roberts |
0:e1e70da93044 | 333 | } |
Wayne Roberts |
0:e1e70da93044 | 334 | |
Wayne Roberts |
0:e1e70da93044 | 335 | const menu_t* Radio::get_modem_sub_menu() |
Wayne Roberts |
0:e1e70da93044 | 336 | { |
Wayne Roberts |
0:e1e70da93044 | 337 | radio.RegOpMode.octet = radio.read_reg(REG_OPMODE); |
Wayne Roberts |
0:e1e70da93044 | 338 | if (radio.RegOpMode.bits.LongRangeMode) { |
Wayne Roberts |
0:e1e70da93044 | 339 | return NULL; |
Wayne Roberts |
0:e1e70da93044 | 340 | } else { |
Wayne Roberts |
0:e1e70da93044 | 341 | if (radio.RegOpMode.bits.ModulationType == 1) { |
Wayne Roberts |
0:e1e70da93044 | 342 | fsk.RegOokPeak.octet = radio.read_reg(REG_FSK_OOKPEAK); |
Wayne Roberts |
0:e1e70da93044 | 343 | if (fsk.RegOokPeak.bits.OokThreshType == 0) { |
Wayne Roberts |
0:e1e70da93044 | 344 | return ook_fixed_menu; |
Wayne Roberts |
0:e1e70da93044 | 345 | } else if (fsk.RegOokPeak.bits.OokThreshType == 1) { |
Wayne Roberts |
0:e1e70da93044 | 346 | return ook_peak_menu; |
Wayne Roberts |
0:e1e70da93044 | 347 | } else if (fsk.RegOokPeak.bits.OokThreshType == 2) { |
Wayne Roberts |
0:e1e70da93044 | 348 | return ook_average_menu; |
Wayne Roberts |
0:e1e70da93044 | 349 | } |
Wayne Roberts |
0:e1e70da93044 | 350 | } else |
Wayne Roberts |
0:e1e70da93044 | 351 | return NULL; |
Wayne Roberts |
0:e1e70da93044 | 352 | } |
Wayne Roberts |
0:e1e70da93044 | 353 | |
Wayne Roberts |
0:e1e70da93044 | 354 | return NULL; |
Wayne Roberts |
0:e1e70da93044 | 355 | } |
Wayne Roberts |
0:e1e70da93044 | 356 | |
Wayne Roberts |
0:e1e70da93044 | 357 | const menu_t* Radio::get_modem_menu() |
Wayne Roberts |
0:e1e70da93044 | 358 | { |
Wayne Roberts |
0:e1e70da93044 | 359 | radio.RegOpMode.octet = radio.read_reg(REG_OPMODE); |
Wayne Roberts |
0:e1e70da93044 | 360 | |
Wayne Roberts |
0:e1e70da93044 | 361 | if (radio.RegOpMode.bits.LongRangeMode) { |
Wayne Roberts |
0:e1e70da93044 | 362 | return lora_menu; |
Wayne Roberts |
0:e1e70da93044 | 363 | } else { |
Wayne Roberts |
0:e1e70da93044 | 364 | if (radio.RegOpMode.bits.ModulationType == 0) |
Wayne Roberts |
0:e1e70da93044 | 365 | return fsk_menu; |
Wayne Roberts |
0:e1e70da93044 | 366 | else { |
Wayne Roberts |
0:e1e70da93044 | 367 | return ook_menu; |
Wayne Roberts |
0:e1e70da93044 | 368 | } |
Wayne Roberts |
0:e1e70da93044 | 369 | } |
Wayne Roberts |
0:e1e70da93044 | 370 | } |
Wayne Roberts |
0:e1e70da93044 | 371 | |
Wayne Roberts |
0:e1e70da93044 | 372 | void Radio::tx_payload_length_print() |
Wayne Roberts |
0:e1e70da93044 | 373 | { |
Wayne Roberts |
0:e1e70da93044 | 374 | pc.printf("%u", get_payload_length()); |
Wayne Roberts |
0:e1e70da93044 | 375 | } |
Wayne Roberts |
0:e1e70da93044 | 376 | |
Wayne Roberts |
0:e1e70da93044 | 377 | bool Radio::tx_payload_length_write(const char* txt) |
Wayne Roberts |
0:e1e70da93044 | 378 | { |
Wayne Roberts |
0:e1e70da93044 | 379 | unsigned len; |
Wayne Roberts |
0:e1e70da93044 | 380 | |
Wayne Roberts |
0:e1e70da93044 | 381 | sscanf(txt, "%u", &len); |
Wayne Roberts |
0:e1e70da93044 | 382 | //log_printf("scanned %u from \"%s\"\r\n", len, txt); |
Wayne Roberts |
0:e1e70da93044 | 383 | |
Wayne Roberts |
0:e1e70da93044 | 384 | set_payload_length(len); |
Wayne Roberts |
0:e1e70da93044 | 385 | |
Wayne Roberts |
0:e1e70da93044 | 386 | return false; |
Wayne Roberts |
0:e1e70da93044 | 387 | } |
Wayne Roberts |
0:e1e70da93044 | 388 | |
Wayne Roberts |
0:e1e70da93044 | 389 | const char* const Radio::opmode_status_strs[] = { |
Wayne Roberts |
0:e1e70da93044 | 390 | "SLEEP ", // 0 |
Wayne Roberts |
0:e1e70da93044 | 391 | "STANDBY ", // 1 |
Wayne Roberts |
0:e1e70da93044 | 392 | "FS_TX ", // 2 |
Wayne Roberts |
0:e1e70da93044 | 393 | "TX ", // 3 |
Wayne Roberts |
0:e1e70da93044 | 394 | "FS_RX ", // 4 |
Wayne Roberts |
0:e1e70da93044 | 395 | "RX ", // 5 |
Wayne Roberts |
0:e1e70da93044 | 396 | "RX_SINGLE", // 6 |
Wayne Roberts |
0:e1e70da93044 | 397 | "CAD ", // 7 |
Wayne Roberts |
0:e1e70da93044 | 398 | NULL |
Wayne Roberts |
0:e1e70da93044 | 399 | }; |
Wayne Roberts |
0:e1e70da93044 | 400 | |
Wayne Roberts |
0:e1e70da93044 | 401 | const char* const Radio::opmode_select_strs[] = { |
Wayne Roberts |
0:e1e70da93044 | 402 | "SLEEP ", // 0 |
Wayne Roberts |
0:e1e70da93044 | 403 | "STANDBY ", // 1 |
Wayne Roberts |
0:e1e70da93044 | 404 | "FS_TX ", // 2 |
Wayne Roberts |
0:e1e70da93044 | 405 | "TX ", // 3 |
Wayne Roberts |
0:e1e70da93044 | 406 | "FS_RX ", // 4 |
Wayne Roberts |
0:e1e70da93044 | 407 | "RX ", // 5 |
Wayne Roberts |
0:e1e70da93044 | 408 | "RX_SINGLE", // 6 |
Wayne Roberts |
0:e1e70da93044 | 409 | "CAD ", // 7 |
Wayne Roberts |
0:e1e70da93044 | 410 | NULL |
Wayne Roberts |
0:e1e70da93044 | 411 | }; |
Wayne Roberts |
0:e1e70da93044 | 412 | |
Wayne Roberts |
0:e1e70da93044 | 413 | unsigned Radio::opmode_read(bool forWriting) |
Wayne Roberts |
0:e1e70da93044 | 414 | { |
Wayne Roberts |
0:e1e70da93044 | 415 | radio.RegOpMode.octet = radio.read_reg(REG_OPMODE); |
Wayne Roberts |
0:e1e70da93044 | 416 | return radio.RegOpMode.bits.Mode; |
Wayne Roberts |
0:e1e70da93044 | 417 | } |
Wayne Roberts |
0:e1e70da93044 | 418 | |
Wayne Roberts |
0:e1e70da93044 | 419 | menuMode_e Radio::opmode_write(unsigned sel) |
Wayne Roberts |
0:e1e70da93044 | 420 | { |
Wayne Roberts |
0:e1e70da93044 | 421 | radio.RegOpMode.bits.Mode = sel; |
Wayne Roberts |
0:e1e70da93044 | 422 | radio.write_reg(REG_OPMODE, radio.RegOpMode.octet); |
Wayne Roberts |
0:e1e70da93044 | 423 | |
Wayne Roberts |
0:e1e70da93044 | 424 | return MENUMODE_REDRAW; |
Wayne Roberts |
0:e1e70da93044 | 425 | } |
Wayne Roberts |
0:e1e70da93044 | 426 | |
Wayne Roberts |
0:e1e70da93044 | 427 | void Radio::ocp_print(void) |
Wayne Roberts |
0:e1e70da93044 | 428 | { |
Wayne Roberts |
0:e1e70da93044 | 429 | unsigned i; |
Wayne Roberts |
0:e1e70da93044 | 430 | |
Wayne Roberts |
0:e1e70da93044 | 431 | radio.RegOcp.octet = radio.read_reg(REG_OCP); |
Wayne Roberts |
0:e1e70da93044 | 432 | if (radio.RegOcp.bits.OcpTrim < 16) |
Wayne Roberts |
0:e1e70da93044 | 433 | i = 45 + (5 * radio.RegOcp.bits.OcpTrim); |
Wayne Roberts |
0:e1e70da93044 | 434 | else if (radio.RegOcp.bits.OcpTrim < 28) |
Wayne Roberts |
0:e1e70da93044 | 435 | i = (10 * radio.RegOcp.bits.OcpTrim) - 30; |
Wayne Roberts |
0:e1e70da93044 | 436 | else |
Wayne Roberts |
0:e1e70da93044 | 437 | i = 240; |
Wayne Roberts |
0:e1e70da93044 | 438 | |
Wayne Roberts |
0:e1e70da93044 | 439 | pc.printf("%u", i); |
Wayne Roberts |
0:e1e70da93044 | 440 | } |
Wayne Roberts |
0:e1e70da93044 | 441 | |
Wayne Roberts |
0:e1e70da93044 | 442 | bool Radio::ocp_write(const char* txt) |
Wayne Roberts |
0:e1e70da93044 | 443 | { |
Wayne Roberts |
0:e1e70da93044 | 444 | unsigned i; |
Wayne Roberts |
0:e1e70da93044 | 445 | |
Wayne Roberts |
0:e1e70da93044 | 446 | sscanf(txt, "%u", &i); |
Wayne Roberts |
0:e1e70da93044 | 447 | |
Wayne Roberts |
0:e1e70da93044 | 448 | if (i < 130) |
Wayne Roberts |
0:e1e70da93044 | 449 | radio.RegOcp.bits.OcpTrim = (i - 45) / 5; |
Wayne Roberts |
0:e1e70da93044 | 450 | else |
Wayne Roberts |
0:e1e70da93044 | 451 | radio.RegOcp.bits.OcpTrim = (i + 30) / 10; |
Wayne Roberts |
0:e1e70da93044 | 452 | |
Wayne Roberts |
0:e1e70da93044 | 453 | radio.write_reg(REG_OCP, radio.RegOcp.octet); |
Wayne Roberts |
0:e1e70da93044 | 454 | |
Wayne Roberts |
0:e1e70da93044 | 455 | return MENUMODE_REDRAW; |
Wayne Roberts |
0:e1e70da93044 | 456 | } |
Wayne Roberts |
0:e1e70da93044 | 457 | |
Wayne Roberts |
0:e1e70da93044 | 458 | const value_item_t Radio::ocp_item = { _ITEM_VALUE, 4, ocp_print, ocp_write}; |
Wayne Roberts |
0:e1e70da93044 | 459 | |
Wayne Roberts |
0:e1e70da93044 | 460 | static const char* const lora_bws_1276[] = { |
Wayne Roberts |
0:e1e70da93044 | 461 | " 7.8KHz", // 0 |
Wayne Roberts |
0:e1e70da93044 | 462 | " 10.4KHz", // 1 |
Wayne Roberts |
0:e1e70da93044 | 463 | " 15.6KHz", // 2 |
Wayne Roberts |
0:e1e70da93044 | 464 | " 20.8KHz", // 3 |
Wayne Roberts |
0:e1e70da93044 | 465 | "31.25KHz", // 4 |
Wayne Roberts |
0:e1e70da93044 | 466 | " 41.7KHz", // 5 |
Wayne Roberts |
0:e1e70da93044 | 467 | " 62.5KHz", // 6 |
Wayne Roberts |
0:e1e70da93044 | 468 | " 125KHz", // 7 |
Wayne Roberts |
0:e1e70da93044 | 469 | " 250KHz", // 8 |
Wayne Roberts |
0:e1e70da93044 | 470 | " 500KHz", // 9 |
Wayne Roberts |
0:e1e70da93044 | 471 | NULL |
Wayne Roberts |
0:e1e70da93044 | 472 | }; |
Wayne Roberts |
0:e1e70da93044 | 473 | static const char* const lora_bws_1272[] = { |
Wayne Roberts |
0:e1e70da93044 | 474 | "125KHz", // 0 |
Wayne Roberts |
0:e1e70da93044 | 475 | "250KHz", // 1 |
Wayne Roberts |
0:e1e70da93044 | 476 | "500KHz", // 2 |
Wayne Roberts |
0:e1e70da93044 | 477 | NULL |
Wayne Roberts |
0:e1e70da93044 | 478 | }; |
Wayne Roberts |
0:e1e70da93044 | 479 | |
Wayne Roberts |
0:e1e70da93044 | 480 | unsigned Radio::lora_bw_read(bool fw) |
Wayne Roberts |
0:e1e70da93044 | 481 | { |
Wayne Roberts |
0:e1e70da93044 | 482 | bw_idx = lora.getBw(); |
Wayne Roberts |
0:e1e70da93044 | 483 | return bw_idx; |
Wayne Roberts |
0:e1e70da93044 | 484 | } |
Wayne Roberts |
0:e1e70da93044 | 485 | |
Wayne Roberts |
0:e1e70da93044 | 486 | menuMode_e Radio::lora_bw_write(unsigned sidx) |
Wayne Roberts |
0:e1e70da93044 | 487 | { |
Wayne Roberts |
0:e1e70da93044 | 488 | lora.setBw(sidx); |
Wayne Roberts |
0:e1e70da93044 | 489 | bw_idx = sidx; |
Wayne Roberts |
0:e1e70da93044 | 490 | |
Wayne Roberts |
0:e1e70da93044 | 491 | return MENUMODE_REDRAW; |
Wayne Roberts |
0:e1e70da93044 | 492 | } |
Wayne Roberts |
0:e1e70da93044 | 493 | |
Wayne Roberts |
0:e1e70da93044 | 494 | dropdown_item_t Radio::lora_bw_item = { _ITEM_DROPDOWN, NULL, NULL, lora_bw_read, lora_bw_write}; |
Wayne Roberts |
0:e1e70da93044 | 495 | |
Wayne Roberts |
0:e1e70da93044 | 496 | void Radio::lora_sf_print() |
Wayne Roberts |
0:e1e70da93044 | 497 | { |
Wayne Roberts |
0:e1e70da93044 | 498 | pc.printf("%u", lora.getSf()); |
Wayne Roberts |
0:e1e70da93044 | 499 | } |
Wayne Roberts |
0:e1e70da93044 | 500 | |
Wayne Roberts |
0:e1e70da93044 | 501 | bool Radio::lora_sf_write(const char* txt) |
Wayne Roberts |
0:e1e70da93044 | 502 | { |
Wayne Roberts |
0:e1e70da93044 | 503 | unsigned sf; |
Wayne Roberts |
0:e1e70da93044 | 504 | |
Wayne Roberts |
0:e1e70da93044 | 505 | sscanf(txt, "%u", &sf); |
Wayne Roberts |
0:e1e70da93044 | 506 | lora.setSf(sf); |
Wayne Roberts |
0:e1e70da93044 | 507 | |
Wayne Roberts |
0:e1e70da93044 | 508 | return false; |
Wayne Roberts |
0:e1e70da93044 | 509 | } |
Wayne Roberts |
0:e1e70da93044 | 510 | |
Wayne Roberts |
0:e1e70da93044 | 511 | const value_item_t Radio::lora_sf_item = { _ITEM_VALUE, 3, lora_sf_print, lora_sf_write }; |
Wayne Roberts |
0:e1e70da93044 | 512 | |
Wayne Roberts |
0:e1e70da93044 | 513 | const char* const lora_crs[] = { |
Wayne Roberts |
0:e1e70da93044 | 514 | "4/5", // 0 |
Wayne Roberts |
0:e1e70da93044 | 515 | "4/6", // 1 |
Wayne Roberts |
0:e1e70da93044 | 516 | "4/7", // 2 |
Wayne Roberts |
0:e1e70da93044 | 517 | "4/8", // 3 |
Wayne Roberts |
0:e1e70da93044 | 518 | NULL |
Wayne Roberts |
0:e1e70da93044 | 519 | }; |
Wayne Roberts |
0:e1e70da93044 | 520 | |
Wayne Roberts |
0:e1e70da93044 | 521 | unsigned Radio::lora_cr_read(bool) |
Wayne Roberts |
0:e1e70da93044 | 522 | { |
Wayne Roberts |
0:e1e70da93044 | 523 | return lora.getCodingRate(false); |
Wayne Roberts |
0:e1e70da93044 | 524 | } |
Wayne Roberts |
0:e1e70da93044 | 525 | |
Wayne Roberts |
0:e1e70da93044 | 526 | menuMode_e Radio::lora_cr_write(unsigned sidx) |
Wayne Roberts |
0:e1e70da93044 | 527 | { |
Wayne Roberts |
0:e1e70da93044 | 528 | lora.setCodingRate(sidx); |
Wayne Roberts |
0:e1e70da93044 | 529 | |
Wayne Roberts |
0:e1e70da93044 | 530 | return MENUMODE_REDRAW; |
Wayne Roberts |
0:e1e70da93044 | 531 | } |
Wayne Roberts |
0:e1e70da93044 | 532 | |
Wayne Roberts |
0:e1e70da93044 | 533 | const dropdown_item_t Radio::lora_cr_item = { _ITEM_DROPDOWN, lora_crs, lora_crs, lora_cr_read, lora_cr_write}; |
Wayne Roberts |
0:e1e70da93044 | 534 | |
Wayne Roberts |
0:e1e70da93044 | 535 | void Radio::lora_pblLen_print() |
Wayne Roberts |
0:e1e70da93044 | 536 | { |
Wayne Roberts |
0:e1e70da93044 | 537 | lora.RegPreamble = radio.read_u16(REG_LR_PREAMBLEMSB); |
Wayne Roberts |
0:e1e70da93044 | 538 | pc.printf("%u", lora.RegPreamble); |
Wayne Roberts |
0:e1e70da93044 | 539 | } |
Wayne Roberts |
0:e1e70da93044 | 540 | |
Wayne Roberts |
0:e1e70da93044 | 541 | bool Radio::lora_pblLen_write(const char* str) |
Wayne Roberts |
0:e1e70da93044 | 542 | { |
Wayne Roberts |
0:e1e70da93044 | 543 | unsigned n; |
Wayne Roberts |
0:e1e70da93044 | 544 | |
Wayne Roberts |
0:e1e70da93044 | 545 | sscanf(str, "%u", &n); |
Wayne Roberts |
0:e1e70da93044 | 546 | |
Wayne Roberts |
0:e1e70da93044 | 547 | lora.RegPreamble = n; |
Wayne Roberts |
0:e1e70da93044 | 548 | radio.write_u16(REG_LR_PREAMBLEMSB, lora.RegPreamble); |
Wayne Roberts |
0:e1e70da93044 | 549 | |
Wayne Roberts |
0:e1e70da93044 | 550 | return false; |
Wayne Roberts |
0:e1e70da93044 | 551 | } |
Wayne Roberts |
0:e1e70da93044 | 552 | |
Wayne Roberts |
0:e1e70da93044 | 553 | const value_item_t Radio::lora_pblLen_item = { _ITEM_VALUE, 5, lora_pblLen_print, lora_pblLen_write}; |
Wayne Roberts |
0:e1e70da93044 | 554 | |
Wayne Roberts |
0:e1e70da93044 | 555 | static const char* const lora_fixlen[] = { |
Wayne Roberts |
0:e1e70da93044 | 556 | "EXPLICIT", // 0 |
Wayne Roberts |
0:e1e70da93044 | 557 | "IMPLICIT", // 1 |
Wayne Roberts |
0:e1e70da93044 | 558 | NULL |
Wayne Roberts |
0:e1e70da93044 | 559 | }; |
Wayne Roberts |
0:e1e70da93044 | 560 | |
Wayne Roberts |
0:e1e70da93044 | 561 | unsigned Radio::lora_fixlen_read(bool f) |
Wayne Roberts |
0:e1e70da93044 | 562 | { |
Wayne Roberts |
0:e1e70da93044 | 563 | if (lora.getHeaderMode()) |
Wayne Roberts |
0:e1e70da93044 | 564 | return 1; |
Wayne Roberts |
0:e1e70da93044 | 565 | else |
Wayne Roberts |
0:e1e70da93044 | 566 | return 0; |
Wayne Roberts |
0:e1e70da93044 | 567 | } |
Wayne Roberts |
0:e1e70da93044 | 568 | |
Wayne Roberts |
0:e1e70da93044 | 569 | menuMode_e Radio::lora_fixlen_write(unsigned sidx) |
Wayne Roberts |
0:e1e70da93044 | 570 | { |
Wayne Roberts |
0:e1e70da93044 | 571 | lora.setHeaderMode(sidx == 1); // true = implicit |
Wayne Roberts |
0:e1e70da93044 | 572 | |
Wayne Roberts |
0:e1e70da93044 | 573 | return MENUMODE_REDRAW; |
Wayne Roberts |
0:e1e70da93044 | 574 | } |
Wayne Roberts |
0:e1e70da93044 | 575 | |
Wayne Roberts |
0:e1e70da93044 | 576 | const dropdown_item_t Radio::lora_fixlen_item = { _ITEM_DROPDOWN, lora_fixlen, lora_fixlen, lora_fixlen_read, lora_fixlen_write}; |
Wayne Roberts |
0:e1e70da93044 | 577 | |
Wayne Roberts |
0:e1e70da93044 | 578 | bool Radio::lora_crcon_read() |
Wayne Roberts |
0:e1e70da93044 | 579 | { |
Wayne Roberts |
0:e1e70da93044 | 580 | return lora.getRxPayloadCrcOn(); |
Wayne Roberts |
0:e1e70da93044 | 581 | } |
Wayne Roberts |
0:e1e70da93044 | 582 | |
Wayne Roberts |
0:e1e70da93044 | 583 | bool Radio::lora_crcon_push() |
Wayne Roberts |
0:e1e70da93044 | 584 | { |
Wayne Roberts |
0:e1e70da93044 | 585 | lora.setRxPayloadCrcOn(!lora.getRxPayloadCrcOn()); |
Wayne Roberts |
0:e1e70da93044 | 586 | return lora.getRxPayloadCrcOn(); |
Wayne Roberts |
0:e1e70da93044 | 587 | } |
Wayne Roberts |
0:e1e70da93044 | 588 | |
Wayne Roberts |
0:e1e70da93044 | 589 | const toggle_item_t Radio::lora_crcon_item = { _ITEM_TOGGLE, "CrcOn", NULL, lora_crcon_read, lora_crcon_push}; |
Wayne Roberts |
0:e1e70da93044 | 590 | |
Wayne Roberts |
0:e1e70da93044 | 591 | bool Radio::lora_iqinvTX_read() |
Wayne Roberts |
0:e1e70da93044 | 592 | { |
Wayne Roberts |
0:e1e70da93044 | 593 | lora.RegTest33.octet = radio.read_reg(REG_LR_TEST33); |
Wayne Roberts |
0:e1e70da93044 | 594 | return !lora.RegTest33.bits.chirp_invert_tx; |
Wayne Roberts |
0:e1e70da93044 | 595 | } |
Wayne Roberts |
0:e1e70da93044 | 596 | |
Wayne Roberts |
0:e1e70da93044 | 597 | bool Radio::lora_iqinvTX_push() |
Wayne Roberts |
0:e1e70da93044 | 598 | { |
Wayne Roberts |
0:e1e70da93044 | 599 | lora.invert_tx(lora.RegTest33.bits.chirp_invert_tx); |
Wayne Roberts |
0:e1e70da93044 | 600 | return !lora.RegTest33.bits.chirp_invert_tx; |
Wayne Roberts |
0:e1e70da93044 | 601 | } |
Wayne Roberts |
0:e1e70da93044 | 602 | |
Wayne Roberts |
0:e1e70da93044 | 603 | const toggle_item_t Radio::lora_iqinvTX_item = { _ITEM_TOGGLE, "iqInvTX", NULL, lora_iqinvTX_read, lora_iqinvTX_push}; |
Wayne Roberts |
0:e1e70da93044 | 604 | |
Wayne Roberts |
0:e1e70da93044 | 605 | bool Radio::lora_iqinvRX_read() |
Wayne Roberts |
0:e1e70da93044 | 606 | { |
Wayne Roberts |
0:e1e70da93044 | 607 | lora.RegTest33.octet = radio.read_reg(REG_LR_TEST33); |
Wayne Roberts |
0:e1e70da93044 | 608 | return lora.RegTest33.bits.invert_i_q; |
Wayne Roberts |
0:e1e70da93044 | 609 | } |
Wayne Roberts |
0:e1e70da93044 | 610 | |
Wayne Roberts |
0:e1e70da93044 | 611 | bool Radio::lora_iqinvRX_push() |
Wayne Roberts |
0:e1e70da93044 | 612 | { |
Wayne Roberts |
0:e1e70da93044 | 613 | lora.invert_rx(!lora.RegTest33.bits.invert_i_q); |
Wayne Roberts |
0:e1e70da93044 | 614 | lora.RegTest33.octet = radio.read_reg(REG_LR_TEST33); |
Wayne Roberts |
0:e1e70da93044 | 615 | return lora.RegTest33.bits.invert_i_q; |
Wayne Roberts |
0:e1e70da93044 | 616 | } |
Wayne Roberts |
0:e1e70da93044 | 617 | |
Wayne Roberts |
0:e1e70da93044 | 618 | const toggle_item_t Radio::lora_iqinvRX_item = { _ITEM_TOGGLE, "iqInvRX", NULL, lora_iqinvRX_read, lora_iqinvRX_push}; |
Wayne Roberts |
0:e1e70da93044 | 619 | |
Wayne Roberts |
0:e1e70da93044 | 620 | void Radio::lora_ppg_print() |
Wayne Roberts |
0:e1e70da93044 | 621 | { |
Wayne Roberts |
0:e1e70da93044 | 622 | pc.printf("%02x", radio.read_reg(REG_LR_SYNC_BYTE)); |
Wayne Roberts |
0:e1e70da93044 | 623 | } |
Wayne Roberts |
0:e1e70da93044 | 624 | |
Wayne Roberts |
0:e1e70da93044 | 625 | bool Radio::lora_ppg_write(const char* str) |
Wayne Roberts |
0:e1e70da93044 | 626 | { |
Wayne Roberts |
0:e1e70da93044 | 627 | unsigned ppg; |
Wayne Roberts |
0:e1e70da93044 | 628 | sscanf(str, "%x", &ppg); |
Wayne Roberts |
0:e1e70da93044 | 629 | |
Wayne Roberts |
0:e1e70da93044 | 630 | radio.write_reg(REG_LR_SYNC_BYTE, ppg); |
Wayne Roberts |
0:e1e70da93044 | 631 | |
Wayne Roberts |
0:e1e70da93044 | 632 | return false; |
Wayne Roberts |
0:e1e70da93044 | 633 | } |
Wayne Roberts |
0:e1e70da93044 | 634 | |
Wayne Roberts |
0:e1e70da93044 | 635 | const value_item_t Radio::lora_ppg_item = { _ITEM_VALUE, 4, lora_ppg_print, lora_ppg_write}; |
Wayne Roberts |
0:e1e70da93044 | 636 | |
Wayne Roberts |
0:e1e70da93044 | 637 | void Radio::cadrx_push() |
Wayne Roberts |
0:e1e70da93044 | 638 | { |
Wayne Roberts |
0:e1e70da93044 | 639 | if (radio.RegDioMapping1.bits.Dio0Mapping != 2 || radio.RegDioMapping1.bits.Dio1Mapping != 2) { |
Wayne Roberts |
0:e1e70da93044 | 640 | radio.RegDioMapping1.bits.Dio0Mapping = 2; // DIO0 to CadDone |
Wayne Roberts |
0:e1e70da93044 | 641 | radio.RegDioMapping1.bits.Dio1Mapping = 2; // DIO1 to CadDetected |
Wayne Roberts |
0:e1e70da93044 | 642 | radio.write_reg(REG_DIOMAPPING1, radio.RegDioMapping1.octet); |
Wayne Roberts |
0:e1e70da93044 | 643 | } |
Wayne Roberts |
0:e1e70da93044 | 644 | |
Wayne Roberts |
0:e1e70da93044 | 645 | radio.set_opmode(RF_OPMODE_CAD); |
Wayne Roberts |
0:e1e70da93044 | 646 | } |
Wayne Roberts |
0:e1e70da93044 | 647 | |
Wayne Roberts |
0:e1e70da93044 | 648 | const button_item_t Radio::lora_cadrx_item = { _ITEM_BUTTON, "CADRX", cadrx_push }; |
Wayne Roberts |
0:e1e70da93044 | 649 | |
Wayne Roberts |
0:e1e70da93044 | 650 | const menu_t Radio::lora_menu[] = { |
Wayne Roberts |
0:e1e70da93044 | 651 | { {FIRST_CHIP_MENU_ROW, 22}, "bw:", &lora_bw_item, FLAG_MSGTYPE_ALL }, |
Wayne Roberts |
0:e1e70da93044 | 652 | { {FIRST_CHIP_MENU_ROW, 35}, "sf:", &lora_sf_item, FLAG_MSGTYPE_ALL }, |
Wayne Roberts |
0:e1e70da93044 | 653 | { {FIRST_CHIP_MENU_ROW, 42}, "cr:", &lora_cr_item, FLAG_MSGTYPE_ALL }, |
Wayne Roberts |
0:e1e70da93044 | 654 | { {FIRST_CHIP_MENU_ROW, 50}, "PreambleLength:", &lora_pblLen_item, FLAG_MSGTYPE_ALL }, |
Wayne Roberts |
0:e1e70da93044 | 655 | |
Wayne Roberts |
0:e1e70da93044 | 656 | { {FIRST_CHIP_MENU_ROW+1, 1}, NULL, &lora_fixlen_item, FLAG_MSGTYPE_ALL }, |
Wayne Roberts |
0:e1e70da93044 | 657 | { {FIRST_CHIP_MENU_ROW+1, 10}, NULL, &lora_crcon_item, FLAG_MSGTYPE_ALL }, |
Wayne Roberts |
0:e1e70da93044 | 658 | { {FIRST_CHIP_MENU_ROW+1, 20}, NULL, &lora_iqinvTX_item, FLAG_MSGTYPE_ALL }, |
Wayne Roberts |
0:e1e70da93044 | 659 | { {FIRST_CHIP_MENU_ROW+1, 30}, NULL, &lora_iqinvRX_item, FLAG_MSGTYPE_ALL }, |
Wayne Roberts |
0:e1e70da93044 | 660 | { {FIRST_CHIP_MENU_ROW+1, 40}, "ppg:", &lora_ppg_item, FLAG_MSGTYPE_ALL }, |
Wayne Roberts |
0:e1e70da93044 | 661 | |
Wayne Roberts |
0:e1e70da93044 | 662 | { {FIRST_CHIP_MENU_ROW+2, 1}, NULL, &lora_cadrx_item, FLAG_MSGTYPE_ALL }, |
Wayne Roberts |
0:e1e70da93044 | 663 | |
Wayne Roberts |
0:e1e70da93044 | 664 | { {0, 0}, NULL, NULL } |
Wayne Roberts |
0:e1e70da93044 | 665 | }; |
Wayne Roberts |
0:e1e70da93044 | 666 | |
Wayne Roberts |
0:e1e70da93044 | 667 | void Radio::fsk_ook_bps_print(void) |
Wayne Roberts |
0:e1e70da93044 | 668 | { |
Wayne Roberts |
0:e1e70da93044 | 669 | pc.printf("%lu", fsk.get_bitrate()); |
Wayne Roberts |
0:e1e70da93044 | 670 | } |
Wayne Roberts |
0:e1e70da93044 | 671 | |
Wayne Roberts |
0:e1e70da93044 | 672 | bool Radio::fsk_ook_bps_write(const char* txt) |
Wayne Roberts |
0:e1e70da93044 | 673 | { |
Wayne Roberts |
0:e1e70da93044 | 674 | unsigned bps; |
Wayne Roberts |
0:e1e70da93044 | 675 | |
Wayne Roberts |
0:e1e70da93044 | 676 | sscanf(txt, "%u", &bps); |
Wayne Roberts |
0:e1e70da93044 | 677 | fsk.set_bitrate(bps); |
Wayne Roberts |
0:e1e70da93044 | 678 | |
Wayne Roberts |
0:e1e70da93044 | 679 | return false; |
Wayne Roberts |
0:e1e70da93044 | 680 | } |
Wayne Roberts |
0:e1e70da93044 | 681 | |
Wayne Roberts |
0:e1e70da93044 | 682 | const value_item_t Radio::fsk_ook_bitrate_item = { _ITEM_VALUE, 8, fsk_ook_bps_print, fsk_ook_bps_write }; |
Wayne Roberts |
0:e1e70da93044 | 683 | |
Wayne Roberts |
0:e1e70da93044 | 684 | void Radio::gfsk_fdev_print(void) |
Wayne Roberts |
0:e1e70da93044 | 685 | { |
Wayne Roberts |
0:e1e70da93044 | 686 | pc.printf("%lu", fsk.get_tx_fdev_hz()); |
Wayne Roberts |
0:e1e70da93044 | 687 | |
Wayne Roberts |
0:e1e70da93044 | 688 | } |
Wayne Roberts |
0:e1e70da93044 | 689 | |
Wayne Roberts |
0:e1e70da93044 | 690 | bool Radio::gfsk_fdev_write(const char* txt) |
Wayne Roberts |
0:e1e70da93044 | 691 | { |
Wayne Roberts |
0:e1e70da93044 | 692 | unsigned hz; |
Wayne Roberts |
0:e1e70da93044 | 693 | |
Wayne Roberts |
0:e1e70da93044 | 694 | sscanf(txt, "%u", &hz); |
Wayne Roberts |
0:e1e70da93044 | 695 | |
Wayne Roberts |
0:e1e70da93044 | 696 | fsk.set_tx_fdev_hz(hz); |
Wayne Roberts |
0:e1e70da93044 | 697 | |
Wayne Roberts |
0:e1e70da93044 | 698 | return false; |
Wayne Roberts |
0:e1e70da93044 | 699 | } |
Wayne Roberts |
0:e1e70da93044 | 700 | |
Wayne Roberts |
0:e1e70da93044 | 701 | const value_item_t Radio::gfsk_fdev_item = { _ITEM_VALUE, 8, gfsk_fdev_print, gfsk_fdev_write}; |
Wayne Roberts |
0:e1e70da93044 | 702 | |
Wayne Roberts |
0:e1e70da93044 | 703 | const char* const gfsk_bts[] = { |
Wayne Roberts |
0:e1e70da93044 | 704 | "off", // 0 |
Wayne Roberts |
0:e1e70da93044 | 705 | "1.0", // 1 |
Wayne Roberts |
0:e1e70da93044 | 706 | "0.5", // 2 |
Wayne Roberts |
0:e1e70da93044 | 707 | "0.3", // 3 |
Wayne Roberts |
0:e1e70da93044 | 708 | NULL |
Wayne Roberts |
0:e1e70da93044 | 709 | }; |
Wayne Roberts |
0:e1e70da93044 | 710 | |
Wayne Roberts |
0:e1e70da93044 | 711 | const char* const ook_bts[] = { |
Wayne Roberts |
0:e1e70da93044 | 712 | "off ", // 0 |
Wayne Roberts |
0:e1e70da93044 | 713 | "bitRate ", // 1 |
Wayne Roberts |
0:e1e70da93044 | 714 | "2*bitRate", // 2 |
Wayne Roberts |
0:e1e70da93044 | 715 | NULL |
Wayne Roberts |
0:e1e70da93044 | 716 | }; |
Wayne Roberts |
0:e1e70da93044 | 717 | |
Wayne Roberts |
0:e1e70da93044 | 718 | unsigned Radio::bt_read(bool forWriting) |
Wayne Roberts |
0:e1e70da93044 | 719 | { |
Wayne Roberts |
0:e1e70da93044 | 720 | if (radio.type == SX1276) { |
Wayne Roberts |
0:e1e70da93044 | 721 | RegPaRamp.octet = radio.read_reg(REG_PARAMP); |
Wayne Roberts |
0:e1e70da93044 | 722 | return RegPaRamp.bits.ModulationShaping; |
Wayne Roberts |
0:e1e70da93044 | 723 | } else if (radio.type == SX1272) { |
Wayne Roberts |
0:e1e70da93044 | 724 | radio.RegOpMode.octet = radio.read_reg(REG_OPMODE); |
Wayne Roberts |
0:e1e70da93044 | 725 | return radio.RegOpMode.bits.ModulationShaping; |
Wayne Roberts |
0:e1e70da93044 | 726 | } |
Wayne Roberts |
0:e1e70da93044 | 727 | return 3; |
Wayne Roberts |
0:e1e70da93044 | 728 | } |
Wayne Roberts |
0:e1e70da93044 | 729 | |
Wayne Roberts |
0:e1e70da93044 | 730 | menuMode_e Radio::bt_write(unsigned sel) |
Wayne Roberts |
0:e1e70da93044 | 731 | { |
Wayne Roberts |
0:e1e70da93044 | 732 | if (radio.type == SX1276) { |
Wayne Roberts |
0:e1e70da93044 | 733 | RegPaRamp.bits.ModulationShaping = sel; |
Wayne Roberts |
0:e1e70da93044 | 734 | radio.write_reg(REG_PARAMP, RegPaRamp.octet); |
Wayne Roberts |
0:e1e70da93044 | 735 | } else if (radio.type == SX1272) { |
Wayne Roberts |
0:e1e70da93044 | 736 | radio.RegOpMode.bits.ModulationShaping = sel; |
Wayne Roberts |
0:e1e70da93044 | 737 | radio.write_reg(REG_OPMODE, radio.RegOpMode.octet); |
Wayne Roberts |
0:e1e70da93044 | 738 | } |
Wayne Roberts |
0:e1e70da93044 | 739 | return MENUMODE_REDRAW; |
Wayne Roberts |
0:e1e70da93044 | 740 | } |
Wayne Roberts |
0:e1e70da93044 | 741 | |
Wayne Roberts |
0:e1e70da93044 | 742 | const dropdown_item_t Radio::gfsk_bt_item = { _ITEM_DROPDOWN, gfsk_bts, gfsk_bts, bt_read, bt_write}; |
Wayne Roberts |
0:e1e70da93044 | 743 | const dropdown_item_t Radio::ook_bt_item = { _ITEM_DROPDOWN, ook_bts, ook_bts, bt_read, bt_write}; |
Wayne Roberts |
0:e1e70da93044 | 744 | |
Wayne Roberts |
0:e1e70da93044 | 745 | bool Radio::paSelect_read() |
Wayne Roberts |
0:e1e70da93044 | 746 | { |
Wayne Roberts |
0:e1e70da93044 | 747 | radio.RegPaConfig.octet = radio.read_reg(REG_PACONFIG); |
Wayne Roberts |
0:e1e70da93044 | 748 | return radio.RegPaConfig.bits.PaSelect; |
Wayne Roberts |
0:e1e70da93044 | 749 | } |
Wayne Roberts |
0:e1e70da93044 | 750 | |
Wayne Roberts |
0:e1e70da93044 | 751 | bool Radio::paSelect_push() |
Wayne Roberts |
0:e1e70da93044 | 752 | { |
Wayne Roberts |
0:e1e70da93044 | 753 | radio.RegPaConfig.bits.PaSelect ^= 1; |
Wayne Roberts |
0:e1e70da93044 | 754 | radio.write_reg(REG_PACONFIG, radio.RegPaConfig.octet); |
Wayne Roberts |
0:e1e70da93044 | 755 | return radio.RegPaConfig.bits.PaSelect; |
Wayne Roberts |
0:e1e70da93044 | 756 | } |
Wayne Roberts |
0:e1e70da93044 | 757 | |
Wayne Roberts |
0:e1e70da93044 | 758 | const toggle_item_t Radio::paSelect_item = { _ITEM_TOGGLE, |
Wayne Roberts |
0:e1e70da93044 | 759 | "RFO ", // 0 |
Wayne Roberts |
0:e1e70da93044 | 760 | "PA_BOOST", // 1 |
Wayne Roberts |
0:e1e70da93044 | 761 | paSelect_read, paSelect_push |
Wayne Roberts |
0:e1e70da93044 | 762 | }; |
Wayne Roberts |
0:e1e70da93044 | 763 | |
Wayne Roberts |
0:e1e70da93044 | 764 | const char* const rxbws[] = { |
Wayne Roberts |
0:e1e70da93044 | 765 | " 2.6", // 0 |
Wayne Roberts |
0:e1e70da93044 | 766 | " 3.1", // 1 |
Wayne Roberts |
0:e1e70da93044 | 767 | " 3.9", // 2 |
Wayne Roberts |
0:e1e70da93044 | 768 | " 5.2", // 3 |
Wayne Roberts |
0:e1e70da93044 | 769 | " 6.3", // 4 |
Wayne Roberts |
0:e1e70da93044 | 770 | " 7.8", // 5 |
Wayne Roberts |
0:e1e70da93044 | 771 | " 10.4", // 6 |
Wayne Roberts |
0:e1e70da93044 | 772 | " 12.5", // 7 |
Wayne Roberts |
0:e1e70da93044 | 773 | " 15.6", // 8 |
Wayne Roberts |
0:e1e70da93044 | 774 | " 20.8", // 9 |
Wayne Roberts |
0:e1e70da93044 | 775 | " 25.0", // 10 |
Wayne Roberts |
0:e1e70da93044 | 776 | " 31.3", // 11 |
Wayne Roberts |
0:e1e70da93044 | 777 | " 41.7", // 12 |
Wayne Roberts |
0:e1e70da93044 | 778 | " 50.0", // 13 |
Wayne Roberts |
0:e1e70da93044 | 779 | " 62.5", // 14 |
Wayne Roberts |
0:e1e70da93044 | 780 | " 83.3", // 15 |
Wayne Roberts |
0:e1e70da93044 | 781 | "100.0", // 16 |
Wayne Roberts |
0:e1e70da93044 | 782 | "125.0", // 17 |
Wayne Roberts |
0:e1e70da93044 | 783 | "166.7", // 18 |
Wayne Roberts |
0:e1e70da93044 | 784 | "200.0", // 19 |
Wayne Roberts |
0:e1e70da93044 | 785 | "250.0", // 20 |
Wayne Roberts |
0:e1e70da93044 | 786 | NULL |
Wayne Roberts |
0:e1e70da93044 | 787 | }; |
Wayne Roberts |
0:e1e70da93044 | 788 | |
Wayne Roberts |
0:e1e70da93044 | 789 | unsigned Radio::bw_read(uint8_t regAddr) |
Wayne Roberts |
0:e1e70da93044 | 790 | { |
Wayne Roberts |
0:e1e70da93044 | 791 | RegRxBw_t reg_bw; |
Wayne Roberts |
0:e1e70da93044 | 792 | |
Wayne Roberts |
0:e1e70da93044 | 793 | reg_bw.octet = radio.read_reg(regAddr); |
Wayne Roberts |
0:e1e70da93044 | 794 | |
Wayne Roberts |
0:e1e70da93044 | 795 | switch (reg_bw.bits.Exponent) { |
Wayne Roberts |
0:e1e70da93044 | 796 | case 7: |
Wayne Roberts |
0:e1e70da93044 | 797 | if (reg_bw.bits.Mantissa == 2) |
Wayne Roberts |
0:e1e70da93044 | 798 | return 0; |
Wayne Roberts |
0:e1e70da93044 | 799 | if (reg_bw.bits.Mantissa == 1) |
Wayne Roberts |
0:e1e70da93044 | 800 | return 1; |
Wayne Roberts |
0:e1e70da93044 | 801 | if (reg_bw.bits.Mantissa == 0) |
Wayne Roberts |
0:e1e70da93044 | 802 | return 2; |
Wayne Roberts |
0:e1e70da93044 | 803 | break; |
Wayne Roberts |
0:e1e70da93044 | 804 | case 6: |
Wayne Roberts |
0:e1e70da93044 | 805 | if (reg_bw.bits.Mantissa == 2) |
Wayne Roberts |
0:e1e70da93044 | 806 | return 3; |
Wayne Roberts |
0:e1e70da93044 | 807 | if (reg_bw.bits.Mantissa == 1) |
Wayne Roberts |
0:e1e70da93044 | 808 | return 4; |
Wayne Roberts |
0:e1e70da93044 | 809 | if (reg_bw.bits.Mantissa == 0) |
Wayne Roberts |
0:e1e70da93044 | 810 | return 5; |
Wayne Roberts |
0:e1e70da93044 | 811 | break; |
Wayne Roberts |
0:e1e70da93044 | 812 | case 5: |
Wayne Roberts |
0:e1e70da93044 | 813 | if (reg_bw.bits.Mantissa == 2) |
Wayne Roberts |
0:e1e70da93044 | 814 | return 6; |
Wayne Roberts |
0:e1e70da93044 | 815 | if (reg_bw.bits.Mantissa == 1) |
Wayne Roberts |
0:e1e70da93044 | 816 | return 7; |
Wayne Roberts |
0:e1e70da93044 | 817 | if (reg_bw.bits.Mantissa == 0) |
Wayne Roberts |
0:e1e70da93044 | 818 | return 8; |
Wayne Roberts |
0:e1e70da93044 | 819 | break; |
Wayne Roberts |
0:e1e70da93044 | 820 | case 4: |
Wayne Roberts |
0:e1e70da93044 | 821 | if (reg_bw.bits.Mantissa == 2) |
Wayne Roberts |
0:e1e70da93044 | 822 | return 9; |
Wayne Roberts |
0:e1e70da93044 | 823 | if (reg_bw.bits.Mantissa == 1) |
Wayne Roberts |
0:e1e70da93044 | 824 | return 10; |
Wayne Roberts |
0:e1e70da93044 | 825 | if (reg_bw.bits.Mantissa == 0) |
Wayne Roberts |
0:e1e70da93044 | 826 | return 11; |
Wayne Roberts |
0:e1e70da93044 | 827 | break; |
Wayne Roberts |
0:e1e70da93044 | 828 | case 3: |
Wayne Roberts |
0:e1e70da93044 | 829 | if (reg_bw.bits.Mantissa == 2) |
Wayne Roberts |
0:e1e70da93044 | 830 | return 12; |
Wayne Roberts |
0:e1e70da93044 | 831 | if (reg_bw.bits.Mantissa == 1) |
Wayne Roberts |
0:e1e70da93044 | 832 | return 13; |
Wayne Roberts |
0:e1e70da93044 | 833 | if (reg_bw.bits.Mantissa == 0) |
Wayne Roberts |
0:e1e70da93044 | 834 | return 14; |
Wayne Roberts |
0:e1e70da93044 | 835 | break; |
Wayne Roberts |
0:e1e70da93044 | 836 | case 2: |
Wayne Roberts |
0:e1e70da93044 | 837 | if (reg_bw.bits.Mantissa == 2) |
Wayne Roberts |
0:e1e70da93044 | 838 | return 15; |
Wayne Roberts |
0:e1e70da93044 | 839 | if (reg_bw.bits.Mantissa == 1) |
Wayne Roberts |
0:e1e70da93044 | 840 | return 16; |
Wayne Roberts |
0:e1e70da93044 | 841 | if (reg_bw.bits.Mantissa == 0) |
Wayne Roberts |
0:e1e70da93044 | 842 | return 17; |
Wayne Roberts |
0:e1e70da93044 | 843 | break; |
Wayne Roberts |
0:e1e70da93044 | 844 | case 1: |
Wayne Roberts |
0:e1e70da93044 | 845 | if (reg_bw.bits.Mantissa == 2) |
Wayne Roberts |
0:e1e70da93044 | 846 | return 18; |
Wayne Roberts |
0:e1e70da93044 | 847 | if (reg_bw.bits.Mantissa == 1) |
Wayne Roberts |
0:e1e70da93044 | 848 | return 19; |
Wayne Roberts |
0:e1e70da93044 | 849 | if (reg_bw.bits.Mantissa == 0) |
Wayne Roberts |
0:e1e70da93044 | 850 | return 20; |
Wayne Roberts |
0:e1e70da93044 | 851 | break; |
Wayne Roberts |
0:e1e70da93044 | 852 | } |
Wayne Roberts |
0:e1e70da93044 | 853 | |
Wayne Roberts |
0:e1e70da93044 | 854 | return 21; |
Wayne Roberts |
0:e1e70da93044 | 855 | } |
Wayne Roberts |
0:e1e70da93044 | 856 | |
Wayne Roberts |
0:e1e70da93044 | 857 | unsigned Radio::rxbw_read(bool) |
Wayne Roberts |
0:e1e70da93044 | 858 | { |
Wayne Roberts |
0:e1e70da93044 | 859 | return bw_read(REG_FSK_RXBW); |
Wayne Roberts |
0:e1e70da93044 | 860 | } |
Wayne Roberts |
0:e1e70da93044 | 861 | |
Wayne Roberts |
0:e1e70da93044 | 862 | unsigned Radio::afcbw_read(bool) |
Wayne Roberts |
0:e1e70da93044 | 863 | { |
Wayne Roberts |
0:e1e70da93044 | 864 | return bw_read(REG_FSK_AFCBW); |
Wayne Roberts |
0:e1e70da93044 | 865 | } |
Wayne Roberts |
0:e1e70da93044 | 866 | |
Wayne Roberts |
0:e1e70da93044 | 867 | void Radio::bw_write(unsigned sidx, uint8_t regAddr) |
Wayne Roberts |
0:e1e70da93044 | 868 | { |
Wayne Roberts |
0:e1e70da93044 | 869 | RegRxBw_t reg_bw; |
Wayne Roberts |
0:e1e70da93044 | 870 | |
Wayne Roberts |
0:e1e70da93044 | 871 | reg_bw.octet = radio.read_reg(regAddr); |
Wayne Roberts |
0:e1e70da93044 | 872 | |
Wayne Roberts |
0:e1e70da93044 | 873 | switch (sidx) { |
Wayne Roberts |
0:e1e70da93044 | 874 | case 0: |
Wayne Roberts |
0:e1e70da93044 | 875 | reg_bw.bits.Mantissa = 2; |
Wayne Roberts |
0:e1e70da93044 | 876 | reg_bw.bits.Exponent = 7; |
Wayne Roberts |
0:e1e70da93044 | 877 | break; |
Wayne Roberts |
0:e1e70da93044 | 878 | case 1: |
Wayne Roberts |
0:e1e70da93044 | 879 | reg_bw.bits.Mantissa = 1; |
Wayne Roberts |
0:e1e70da93044 | 880 | reg_bw.bits.Exponent = 7; |
Wayne Roberts |
0:e1e70da93044 | 881 | break; |
Wayne Roberts |
0:e1e70da93044 | 882 | case 2: |
Wayne Roberts |
0:e1e70da93044 | 883 | reg_bw.bits.Mantissa = 0; |
Wayne Roberts |
0:e1e70da93044 | 884 | reg_bw.bits.Exponent = 7; |
Wayne Roberts |
0:e1e70da93044 | 885 | break; |
Wayne Roberts |
0:e1e70da93044 | 886 | case 3: |
Wayne Roberts |
0:e1e70da93044 | 887 | reg_bw.bits.Mantissa = 2; |
Wayne Roberts |
0:e1e70da93044 | 888 | reg_bw.bits.Exponent = 6; |
Wayne Roberts |
0:e1e70da93044 | 889 | break; |
Wayne Roberts |
0:e1e70da93044 | 890 | case 4: |
Wayne Roberts |
0:e1e70da93044 | 891 | reg_bw.bits.Mantissa = 1; |
Wayne Roberts |
0:e1e70da93044 | 892 | reg_bw.bits.Exponent = 6; |
Wayne Roberts |
0:e1e70da93044 | 893 | break; |
Wayne Roberts |
0:e1e70da93044 | 894 | case 5: |
Wayne Roberts |
0:e1e70da93044 | 895 | reg_bw.bits.Mantissa = 0; |
Wayne Roberts |
0:e1e70da93044 | 896 | reg_bw.bits.Exponent = 6; |
Wayne Roberts |
0:e1e70da93044 | 897 | break; |
Wayne Roberts |
0:e1e70da93044 | 898 | case 6: |
Wayne Roberts |
0:e1e70da93044 | 899 | reg_bw.bits.Mantissa = 2; |
Wayne Roberts |
0:e1e70da93044 | 900 | reg_bw.bits.Exponent = 5; |
Wayne Roberts |
0:e1e70da93044 | 901 | break; |
Wayne Roberts |
0:e1e70da93044 | 902 | case 7: |
Wayne Roberts |
0:e1e70da93044 | 903 | reg_bw.bits.Mantissa = 1; |
Wayne Roberts |
0:e1e70da93044 | 904 | reg_bw.bits.Exponent = 5; |
Wayne Roberts |
0:e1e70da93044 | 905 | break; |
Wayne Roberts |
0:e1e70da93044 | 906 | case 8: |
Wayne Roberts |
0:e1e70da93044 | 907 | reg_bw.bits.Mantissa = 0; |
Wayne Roberts |
0:e1e70da93044 | 908 | reg_bw.bits.Exponent = 5; |
Wayne Roberts |
0:e1e70da93044 | 909 | break; |
Wayne Roberts |
0:e1e70da93044 | 910 | case 9: |
Wayne Roberts |
0:e1e70da93044 | 911 | reg_bw.bits.Mantissa = 2; |
Wayne Roberts |
0:e1e70da93044 | 912 | reg_bw.bits.Exponent = 4; |
Wayne Roberts |
0:e1e70da93044 | 913 | break; |
Wayne Roberts |
0:e1e70da93044 | 914 | case 10: |
Wayne Roberts |
0:e1e70da93044 | 915 | reg_bw.bits.Mantissa = 1; |
Wayne Roberts |
0:e1e70da93044 | 916 | reg_bw.bits.Exponent = 4; |
Wayne Roberts |
0:e1e70da93044 | 917 | break; |
Wayne Roberts |
0:e1e70da93044 | 918 | case 11: |
Wayne Roberts |
0:e1e70da93044 | 919 | reg_bw.bits.Mantissa = 0; |
Wayne Roberts |
0:e1e70da93044 | 920 | reg_bw.bits.Exponent = 4; |
Wayne Roberts |
0:e1e70da93044 | 921 | break; |
Wayne Roberts |
0:e1e70da93044 | 922 | case 12: |
Wayne Roberts |
0:e1e70da93044 | 923 | reg_bw.bits.Mantissa = 2; |
Wayne Roberts |
0:e1e70da93044 | 924 | reg_bw.bits.Exponent = 3; |
Wayne Roberts |
0:e1e70da93044 | 925 | break; |
Wayne Roberts |
0:e1e70da93044 | 926 | case 13: |
Wayne Roberts |
0:e1e70da93044 | 927 | reg_bw.bits.Mantissa = 1; |
Wayne Roberts |
0:e1e70da93044 | 928 | reg_bw.bits.Exponent = 3; |
Wayne Roberts |
0:e1e70da93044 | 929 | break; |
Wayne Roberts |
0:e1e70da93044 | 930 | case 14: |
Wayne Roberts |
0:e1e70da93044 | 931 | reg_bw.bits.Mantissa = 0; |
Wayne Roberts |
0:e1e70da93044 | 932 | reg_bw.bits.Exponent = 3; |
Wayne Roberts |
0:e1e70da93044 | 933 | break; |
Wayne Roberts |
0:e1e70da93044 | 934 | case 15: |
Wayne Roberts |
0:e1e70da93044 | 935 | reg_bw.bits.Mantissa = 2; |
Wayne Roberts |
0:e1e70da93044 | 936 | reg_bw.bits.Exponent = 2; |
Wayne Roberts |
0:e1e70da93044 | 937 | break; |
Wayne Roberts |
0:e1e70da93044 | 938 | case 16: |
Wayne Roberts |
0:e1e70da93044 | 939 | reg_bw.bits.Mantissa = 1; |
Wayne Roberts |
0:e1e70da93044 | 940 | reg_bw.bits.Exponent = 2; |
Wayne Roberts |
0:e1e70da93044 | 941 | break; |
Wayne Roberts |
0:e1e70da93044 | 942 | case 17: |
Wayne Roberts |
0:e1e70da93044 | 943 | reg_bw.bits.Mantissa = 0; |
Wayne Roberts |
0:e1e70da93044 | 944 | reg_bw.bits.Exponent = 2; |
Wayne Roberts |
0:e1e70da93044 | 945 | break; |
Wayne Roberts |
0:e1e70da93044 | 946 | case 18: |
Wayne Roberts |
0:e1e70da93044 | 947 | reg_bw.bits.Mantissa = 2; |
Wayne Roberts |
0:e1e70da93044 | 948 | reg_bw.bits.Exponent = 1; |
Wayne Roberts |
0:e1e70da93044 | 949 | break; |
Wayne Roberts |
0:e1e70da93044 | 950 | case 19: |
Wayne Roberts |
0:e1e70da93044 | 951 | reg_bw.bits.Mantissa = 1; |
Wayne Roberts |
0:e1e70da93044 | 952 | reg_bw.bits.Exponent = 1; |
Wayne Roberts |
0:e1e70da93044 | 953 | break; |
Wayne Roberts |
0:e1e70da93044 | 954 | case 20: |
Wayne Roberts |
0:e1e70da93044 | 955 | reg_bw.bits.Mantissa = 0; |
Wayne Roberts |
0:e1e70da93044 | 956 | reg_bw.bits.Exponent = 1; |
Wayne Roberts |
0:e1e70da93044 | 957 | break; |
Wayne Roberts |
0:e1e70da93044 | 958 | } |
Wayne Roberts |
0:e1e70da93044 | 959 | |
Wayne Roberts |
0:e1e70da93044 | 960 | radio.write_reg(regAddr, reg_bw.octet); |
Wayne Roberts |
0:e1e70da93044 | 961 | } |
Wayne Roberts |
0:e1e70da93044 | 962 | |
Wayne Roberts |
0:e1e70da93044 | 963 | menuMode_e Radio::rxbw_write(unsigned sidx) |
Wayne Roberts |
0:e1e70da93044 | 964 | { |
Wayne Roberts |
0:e1e70da93044 | 965 | bw_write(sidx, REG_FSK_RXBW); |
Wayne Roberts |
0:e1e70da93044 | 966 | return MENUMODE_REDRAW; |
Wayne Roberts |
0:e1e70da93044 | 967 | } |
Wayne Roberts |
0:e1e70da93044 | 968 | |
Wayne Roberts |
0:e1e70da93044 | 969 | menuMode_e Radio::afcbw_write(unsigned sidx) |
Wayne Roberts |
0:e1e70da93044 | 970 | { |
Wayne Roberts |
0:e1e70da93044 | 971 | bw_write(sidx, REG_FSK_AFCBW); |
Wayne Roberts |
0:e1e70da93044 | 972 | return MENUMODE_REDRAW; |
Wayne Roberts |
0:e1e70da93044 | 973 | } |
Wayne Roberts |
0:e1e70da93044 | 974 | |
Wayne Roberts |
0:e1e70da93044 | 975 | const dropdown_item_t Radio::rxbw_item = { _ITEM_DROPDOWN, rxbws, rxbws, rxbw_read, rxbw_write}; |
Wayne Roberts |
0:e1e70da93044 | 976 | const dropdown_item_t Radio::afcbw_item = { _ITEM_DROPDOWN, rxbws, rxbws, afcbw_read, afcbw_write}; |
Wayne Roberts |
0:e1e70da93044 | 977 | |
Wayne Roberts |
0:e1e70da93044 | 978 | void Radio::pblLen_print() |
Wayne Roberts |
0:e1e70da93044 | 979 | { |
Wayne Roberts |
0:e1e70da93044 | 980 | pc.printf("%u", radio.read_u16(REG_FSK_PREAMBLEMSB)); |
Wayne Roberts |
0:e1e70da93044 | 981 | } |
Wayne Roberts |
0:e1e70da93044 | 982 | |
Wayne Roberts |
0:e1e70da93044 | 983 | bool Radio::pblLen_write(const char* txt) |
Wayne Roberts |
0:e1e70da93044 | 984 | { |
Wayne Roberts |
0:e1e70da93044 | 985 | unsigned n; |
Wayne Roberts |
0:e1e70da93044 | 986 | sscanf(txt, "%u", &n); |
Wayne Roberts |
0:e1e70da93044 | 987 | radio.write_u16(REG_FSK_PREAMBLEMSB, n); |
Wayne Roberts |
0:e1e70da93044 | 988 | return false; |
Wayne Roberts |
0:e1e70da93044 | 989 | } |
Wayne Roberts |
0:e1e70da93044 | 990 | |
Wayne Roberts |
0:e1e70da93044 | 991 | const value_item_t Radio::pblLen_item = { _ITEM_VALUE, 6, pblLen_print, pblLen_write}; |
Wayne Roberts |
0:e1e70da93044 | 992 | |
Wayne Roberts |
0:e1e70da93044 | 993 | |
Wayne Roberts |
0:e1e70da93044 | 994 | const char* const rxTriggers[] = { |
Wayne Roberts |
0:e1e70da93044 | 995 | "off ", // 0 |
Wayne Roberts |
0:e1e70da93044 | 996 | "RSSI ", // 1 |
Wayne Roberts |
0:e1e70da93044 | 997 | "Preamble ", // 2 |
Wayne Roberts |
0:e1e70da93044 | 998 | "RSSI+Preamble", // 3 |
Wayne Roberts |
0:e1e70da93044 | 999 | NULL |
Wayne Roberts |
0:e1e70da93044 | 1000 | }; |
Wayne Roberts |
0:e1e70da93044 | 1001 | |
Wayne Roberts |
0:e1e70da93044 | 1002 | unsigned Radio::rxTrigger_read(bool fw) |
Wayne Roberts |
0:e1e70da93044 | 1003 | { |
Wayne Roberts |
0:e1e70da93044 | 1004 | fsk.RegRxConfig.octet = radio.read_reg(REG_FSK_RXCONFIG); |
Wayne Roberts |
0:e1e70da93044 | 1005 | return fsk.RegRxConfig.bits.RxTrigger; |
Wayne Roberts |
0:e1e70da93044 | 1006 | } |
Wayne Roberts |
0:e1e70da93044 | 1007 | |
Wayne Roberts |
0:e1e70da93044 | 1008 | menuMode_e Radio::rxTrigger_write(unsigned sidx) |
Wayne Roberts |
0:e1e70da93044 | 1009 | { |
Wayne Roberts |
0:e1e70da93044 | 1010 | fsk.RegRxConfig.bits.RxTrigger = sidx; |
Wayne Roberts |
0:e1e70da93044 | 1011 | radio.write_reg(REG_FSK_RXCONFIG, fsk.RegRxConfig.octet); |
Wayne Roberts |
0:e1e70da93044 | 1012 | return MENUMODE_REDRAW; |
Wayne Roberts |
0:e1e70da93044 | 1013 | } |
Wayne Roberts |
0:e1e70da93044 | 1014 | |
Wayne Roberts |
0:e1e70da93044 | 1015 | const dropdown_item_t Radio::rxTrigger_item = { _ITEM_DROPDOWN, rxTriggers, rxTriggers, rxTrigger_read, rxTrigger_write}; |
Wayne Roberts |
0:e1e70da93044 | 1016 | |
Wayne Roberts |
0:e1e70da93044 | 1017 | bool Radio::AgcAutoOn_read() |
Wayne Roberts |
0:e1e70da93044 | 1018 | { |
Wayne Roberts |
0:e1e70da93044 | 1019 | fsk.RegRxConfig.octet = radio.read_reg(REG_FSK_RXCONFIG); |
Wayne Roberts |
0:e1e70da93044 | 1020 | return fsk.RegRxConfig.bits.AgcAutoOn; |
Wayne Roberts |
0:e1e70da93044 | 1021 | } |
Wayne Roberts |
0:e1e70da93044 | 1022 | |
Wayne Roberts |
0:e1e70da93044 | 1023 | bool Radio::AgcAutoOn_push() |
Wayne Roberts |
0:e1e70da93044 | 1024 | { |
Wayne Roberts |
0:e1e70da93044 | 1025 | fsk.RegRxConfig.bits.AgcAutoOn ^= 1; |
Wayne Roberts |
0:e1e70da93044 | 1026 | radio.write_reg(REG_FSK_RXCONFIG, fsk.RegRxConfig.octet); |
Wayne Roberts |
0:e1e70da93044 | 1027 | return fsk.RegRxConfig.bits.AgcAutoOn; |
Wayne Roberts |
0:e1e70da93044 | 1028 | } |
Wayne Roberts |
0:e1e70da93044 | 1029 | |
Wayne Roberts |
0:e1e70da93044 | 1030 | bool Radio::AfcAutoOn_read() |
Wayne Roberts |
0:e1e70da93044 | 1031 | { |
Wayne Roberts |
0:e1e70da93044 | 1032 | fsk.RegRxConfig.octet = radio.read_reg(REG_FSK_RXCONFIG); |
Wayne Roberts |
0:e1e70da93044 | 1033 | return fsk.RegRxConfig.bits.AfcAutoOn; |
Wayne Roberts |
0:e1e70da93044 | 1034 | } |
Wayne Roberts |
0:e1e70da93044 | 1035 | |
Wayne Roberts |
0:e1e70da93044 | 1036 | bool Radio::AfcAutoOn_push() |
Wayne Roberts |
0:e1e70da93044 | 1037 | { |
Wayne Roberts |
0:e1e70da93044 | 1038 | fsk.RegRxConfig.bits.AfcAutoOn ^= 1; |
Wayne Roberts |
0:e1e70da93044 | 1039 | radio.write_reg(REG_FSK_RXCONFIG, fsk.RegRxConfig.octet); |
Wayne Roberts |
0:e1e70da93044 | 1040 | return fsk.RegRxConfig.bits.AfcAutoOn; |
Wayne Roberts |
0:e1e70da93044 | 1041 | } |
Wayne Roberts |
0:e1e70da93044 | 1042 | |
Wayne Roberts |
0:e1e70da93044 | 1043 | const toggle_item_t Radio::agcautoon_item = { _ITEM_TOGGLE, "AgcAutoOn", NULL, AgcAutoOn_read, AgcAutoOn_push}; |
Wayne Roberts |
0:e1e70da93044 | 1044 | |
Wayne Roberts |
0:e1e70da93044 | 1045 | const toggle_item_t Radio::afcautoon_item = { _ITEM_TOGGLE, "AfcAutoOn", NULL, AfcAutoOn_read, AfcAutoOn_push}; |
Wayne Roberts |
0:e1e70da93044 | 1046 | |
Wayne Roberts |
0:e1e70da93044 | 1047 | bool Radio::RestartRxOnCollision_read() |
Wayne Roberts |
0:e1e70da93044 | 1048 | { |
Wayne Roberts |
0:e1e70da93044 | 1049 | fsk.RegRxConfig.octet = radio.read_reg(REG_FSK_RXCONFIG); |
Wayne Roberts |
0:e1e70da93044 | 1050 | return fsk.RegRxConfig.bits.RestartRxOnCollision; |
Wayne Roberts |
0:e1e70da93044 | 1051 | } |
Wayne Roberts |
0:e1e70da93044 | 1052 | |
Wayne Roberts |
0:e1e70da93044 | 1053 | bool Radio::RestartRxOnCollision_push() |
Wayne Roberts |
0:e1e70da93044 | 1054 | { |
Wayne Roberts |
0:e1e70da93044 | 1055 | fsk.RegRxConfig.bits.RestartRxOnCollision ^= 1; |
Wayne Roberts |
0:e1e70da93044 | 1056 | radio.write_reg(REG_FSK_RXCONFIG, fsk.RegRxConfig.octet); |
Wayne Roberts |
0:e1e70da93044 | 1057 | return fsk.RegRxConfig.bits.RestartRxOnCollision; |
Wayne Roberts |
0:e1e70da93044 | 1058 | } |
Wayne Roberts |
0:e1e70da93044 | 1059 | |
Wayne Roberts |
0:e1e70da93044 | 1060 | const toggle_item_t Radio::RestartRxOnCollision_item = { _ITEM_TOGGLE, |
Wayne Roberts |
0:e1e70da93044 | 1061 | "RestartRxOnCollision", NULL, |
Wayne Roberts |
0:e1e70da93044 | 1062 | RestartRxOnCollision_read, RestartRxOnCollision_push |
Wayne Roberts |
0:e1e70da93044 | 1063 | }; |
Wayne Roberts |
0:e1e70da93044 | 1064 | |
Wayne Roberts |
0:e1e70da93044 | 1065 | void Radio::RestartRxWithPllLock_push() |
Wayne Roberts |
0:e1e70da93044 | 1066 | { |
Wayne Roberts |
0:e1e70da93044 | 1067 | fsk.RegRxConfig.bits.RestartRxWithPllLock = 1; |
Wayne Roberts |
0:e1e70da93044 | 1068 | radio.write_reg(REG_FSK_RXCONFIG, fsk.RegRxConfig.octet); |
Wayne Roberts |
0:e1e70da93044 | 1069 | fsk.RegRxConfig.bits.RestartRxWithPllLock = 0; |
Wayne Roberts |
0:e1e70da93044 | 1070 | } |
Wayne Roberts |
0:e1e70da93044 | 1071 | |
Wayne Roberts |
0:e1e70da93044 | 1072 | const button_item_t Radio::RestartRxWithPllLock_item = { _ITEM_BUTTON, |
Wayne Roberts |
0:e1e70da93044 | 1073 | "RestartRxWithPllLock", |
Wayne Roberts |
0:e1e70da93044 | 1074 | RestartRxWithPllLock_push |
Wayne Roberts |
0:e1e70da93044 | 1075 | }; |
Wayne Roberts |
0:e1e70da93044 | 1076 | |
Wayne Roberts |
0:e1e70da93044 | 1077 | void Radio::RestartRxWithoutPllLock_push() |
Wayne Roberts |
0:e1e70da93044 | 1078 | { |
Wayne Roberts |
0:e1e70da93044 | 1079 | fsk.RegRxConfig.bits.RestartRxWithoutPllLock = 1; |
Wayne Roberts |
0:e1e70da93044 | 1080 | radio.write_reg(REG_FSK_RXCONFIG, fsk.RegRxConfig.octet); |
Wayne Roberts |
0:e1e70da93044 | 1081 | fsk.RegRxConfig.bits.RestartRxWithoutPllLock = 0; |
Wayne Roberts |
0:e1e70da93044 | 1082 | } |
Wayne Roberts |
0:e1e70da93044 | 1083 | |
Wayne Roberts |
0:e1e70da93044 | 1084 | const button_item_t Radio::RestartRxWithoutPllLock_item = { _ITEM_BUTTON, |
Wayne Roberts |
0:e1e70da93044 | 1085 | "RestartRxWithoutPllLock", |
Wayne Roberts |
0:e1e70da93044 | 1086 | RestartRxWithoutPllLock_push |
Wayne Roberts |
0:e1e70da93044 | 1087 | }; |
Wayne Roberts |
0:e1e70da93044 | 1088 | |
Wayne Roberts |
0:e1e70da93044 | 1089 | bool Radio::AfcAutoClearOn_read(void) |
Wayne Roberts |
0:e1e70da93044 | 1090 | { |
Wayne Roberts |
0:e1e70da93044 | 1091 | fsk.RegAfcFei.octet = radio.read_reg(REG_FSK_AFCFEI); |
Wayne Roberts |
0:e1e70da93044 | 1092 | return fsk.RegAfcFei.bits.AfcAutoClearOn; |
Wayne Roberts |
0:e1e70da93044 | 1093 | } |
Wayne Roberts |
0:e1e70da93044 | 1094 | |
Wayne Roberts |
0:e1e70da93044 | 1095 | bool Radio::AfcAutoClearOn_push(void) |
Wayne Roberts |
0:e1e70da93044 | 1096 | { |
Wayne Roberts |
0:e1e70da93044 | 1097 | fsk.RegAfcFei.bits.AfcAutoClearOn ^= 1; |
Wayne Roberts |
0:e1e70da93044 | 1098 | radio.write_reg(REG_FSK_AFCFEI, fsk.RegAfcFei.octet); |
Wayne Roberts |
0:e1e70da93044 | 1099 | return fsk.RegAfcFei.bits.AfcAutoClearOn; |
Wayne Roberts |
0:e1e70da93044 | 1100 | } |
Wayne Roberts |
0:e1e70da93044 | 1101 | |
Wayne Roberts |
0:e1e70da93044 | 1102 | const toggle_item_t Radio::AfcAutoClearOn_item = { _ITEM_TOGGLE, "AfcAutoClearOn", NULL, AfcAutoClearOn_read, AfcAutoClearOn_push}; |
Wayne Roberts |
0:e1e70da93044 | 1103 | |
Wayne Roberts |
0:e1e70da93044 | 1104 | void Radio::AgcStart_push() |
Wayne Roberts |
0:e1e70da93044 | 1105 | { |
Wayne Roberts |
0:e1e70da93044 | 1106 | fsk.RegAfcFei.bits.AgcStart = 1; |
Wayne Roberts |
0:e1e70da93044 | 1107 | radio.write_reg(REG_FSK_AFCFEI, fsk.RegAfcFei.octet); |
Wayne Roberts |
0:e1e70da93044 | 1108 | fsk.RegAfcFei.bits.AgcStart = 1; |
Wayne Roberts |
0:e1e70da93044 | 1109 | } |
Wayne Roberts |
0:e1e70da93044 | 1110 | |
Wayne Roberts |
0:e1e70da93044 | 1111 | const button_item_t Radio::AgcStart_item = { _ITEM_BUTTON, "AgcStart", AgcStart_push}; |
Wayne Roberts |
0:e1e70da93044 | 1112 | |
Wayne Roberts |
0:e1e70da93044 | 1113 | void Radio::AfcClear_push() |
Wayne Roberts |
0:e1e70da93044 | 1114 | { |
Wayne Roberts |
0:e1e70da93044 | 1115 | fsk.RegAfcFei.bits.AfcClear = 1; |
Wayne Roberts |
0:e1e70da93044 | 1116 | radio.write_reg(REG_FSK_AFCFEI, fsk.RegAfcFei.octet); |
Wayne Roberts |
0:e1e70da93044 | 1117 | fsk.RegAfcFei.bits.AfcClear = 0; |
Wayne Roberts |
0:e1e70da93044 | 1118 | } |
Wayne Roberts |
0:e1e70da93044 | 1119 | const button_item_t Radio::AfcClear_item = { _ITEM_BUTTON, "AfcClear", AfcClear_push}; |
Wayne Roberts |
0:e1e70da93044 | 1120 | |
Wayne Roberts |
0:e1e70da93044 | 1121 | void Radio::syncWord_print(void) |
Wayne Roberts |
0:e1e70da93044 | 1122 | { |
Wayne Roberts |
0:e1e70da93044 | 1123 | unsigned n, stop; |
Wayne Roberts |
0:e1e70da93044 | 1124 | |
Wayne Roberts |
0:e1e70da93044 | 1125 | fsk.RegSyncConfig.octet = radio.read_reg(REG_FSK_SYNCCONFIG); |
Wayne Roberts |
0:e1e70da93044 | 1126 | |
Wayne Roberts |
0:e1e70da93044 | 1127 | stop = fsk.RegSyncConfig.bits.SyncSize + 1; |
Wayne Roberts |
0:e1e70da93044 | 1128 | for (n = 0; n < stop; n++) { |
Wayne Roberts |
0:e1e70da93044 | 1129 | pc.printf("%02x", radio.read_reg(REG_FSK_SYNCVALUE1+n)); |
Wayne Roberts |
0:e1e70da93044 | 1130 | } |
Wayne Roberts |
0:e1e70da93044 | 1131 | } |
Wayne Roberts |
0:e1e70da93044 | 1132 | |
Wayne Roberts |
0:e1e70da93044 | 1133 | bool Radio::syncWord_write(const char* txt) |
Wayne Roberts |
0:e1e70da93044 | 1134 | { |
Wayne Roberts |
0:e1e70da93044 | 1135 | const char* ptr; |
Wayne Roberts |
0:e1e70da93044 | 1136 | const char* endPtr; |
Wayne Roberts |
0:e1e70da93044 | 1137 | unsigned o, n = 0; |
Wayne Roberts |
0:e1e70da93044 | 1138 | |
Wayne Roberts |
0:e1e70da93044 | 1139 | endPtr = txt + strlen(txt); |
Wayne Roberts |
0:e1e70da93044 | 1140 | for (ptr = txt; sscanf(ptr, "%02x", &o) == 1; ) { |
Wayne Roberts |
0:e1e70da93044 | 1141 | radio.write_reg(REG_FSK_SYNCVALUE1+n, o); |
Wayne Roberts |
0:e1e70da93044 | 1142 | n++; |
Wayne Roberts |
0:e1e70da93044 | 1143 | ptr += 2; |
Wayne Roberts |
0:e1e70da93044 | 1144 | if (ptr >= endPtr) |
Wayne Roberts |
0:e1e70da93044 | 1145 | break; |
Wayne Roberts |
0:e1e70da93044 | 1146 | } |
Wayne Roberts |
0:e1e70da93044 | 1147 | |
Wayne Roberts |
0:e1e70da93044 | 1148 | fsk.RegSyncConfig.bits.SyncSize = n - 1; |
Wayne Roberts |
0:e1e70da93044 | 1149 | radio.write_reg(REG_FSK_SYNCCONFIG, fsk.RegSyncConfig.octet); |
Wayne Roberts |
0:e1e70da93044 | 1150 | |
Wayne Roberts |
0:e1e70da93044 | 1151 | return false; |
Wayne Roberts |
0:e1e70da93044 | 1152 | } |
Wayne Roberts |
0:e1e70da93044 | 1153 | |
Wayne Roberts |
0:e1e70da93044 | 1154 | const value_item_t Radio::syncWord_item = { _ITEM_VALUE, 17, syncWord_print, syncWord_write}; |
Wayne Roberts |
0:e1e70da93044 | 1155 | |
Wayne Roberts |
0:e1e70da93044 | 1156 | void Radio::syncSize_print(void) |
Wayne Roberts |
0:e1e70da93044 | 1157 | { |
Wayne Roberts |
0:e1e70da93044 | 1158 | fsk.RegSyncConfig.octet = radio.read_reg(REG_FSK_SYNCCONFIG); |
Wayne Roberts |
0:e1e70da93044 | 1159 | |
Wayne Roberts |
0:e1e70da93044 | 1160 | pc.printf("%u", fsk.RegSyncConfig.bits.SyncSize + 1); |
Wayne Roberts |
0:e1e70da93044 | 1161 | } |
Wayne Roberts |
0:e1e70da93044 | 1162 | |
Wayne Roberts |
0:e1e70da93044 | 1163 | bool Radio::syncSize_write(const char* txt) |
Wayne Roberts |
0:e1e70da93044 | 1164 | { |
Wayne Roberts |
0:e1e70da93044 | 1165 | unsigned n; |
Wayne Roberts |
0:e1e70da93044 | 1166 | sscanf(txt, "%u", &n); |
Wayne Roberts |
0:e1e70da93044 | 1167 | if (n > 0) { |
Wayne Roberts |
0:e1e70da93044 | 1168 | fsk.RegSyncConfig.bits.SyncSize = n - 1; |
Wayne Roberts |
0:e1e70da93044 | 1169 | radio.write_reg(REG_FSK_SYNCCONFIG, fsk.RegSyncConfig.octet); |
Wayne Roberts |
0:e1e70da93044 | 1170 | } |
Wayne Roberts |
0:e1e70da93044 | 1171 | return false; |
Wayne Roberts |
0:e1e70da93044 | 1172 | } |
Wayne Roberts |
0:e1e70da93044 | 1173 | |
Wayne Roberts |
0:e1e70da93044 | 1174 | const value_item_t Radio::syncSize_item = { _ITEM_VALUE, 2, syncSize_print, syncSize_write}; |
Wayne Roberts |
0:e1e70da93044 | 1175 | |
Wayne Roberts |
0:e1e70da93044 | 1176 | bool Radio::SyncOn_read() |
Wayne Roberts |
0:e1e70da93044 | 1177 | { |
Wayne Roberts |
0:e1e70da93044 | 1178 | fsk.RegSyncConfig.octet = radio.read_reg(REG_FSK_SYNCCONFIG); |
Wayne Roberts |
0:e1e70da93044 | 1179 | return fsk.RegSyncConfig.bits.SyncOn; |
Wayne Roberts |
0:e1e70da93044 | 1180 | } |
Wayne Roberts |
0:e1e70da93044 | 1181 | |
Wayne Roberts |
0:e1e70da93044 | 1182 | bool Radio::SyncOn_push() |
Wayne Roberts |
0:e1e70da93044 | 1183 | { |
Wayne Roberts |
0:e1e70da93044 | 1184 | fsk.RegSyncConfig.bits.SyncOn ^= 1; |
Wayne Roberts |
0:e1e70da93044 | 1185 | radio.write_reg(REG_FSK_SYNCCONFIG, fsk.RegSyncConfig.octet); |
Wayne Roberts |
0:e1e70da93044 | 1186 | return fsk.RegSyncConfig.bits.SyncOn; |
Wayne Roberts |
0:e1e70da93044 | 1187 | } |
Wayne Roberts |
0:e1e70da93044 | 1188 | |
Wayne Roberts |
0:e1e70da93044 | 1189 | const toggle_item_t Radio::syncOn_item = { _ITEM_TOGGLE, "SyncOn", NULL, SyncOn_read, SyncOn_push}; |
Wayne Roberts |
0:e1e70da93044 | 1190 | |
Wayne Roberts |
0:e1e70da93044 | 1191 | bool Radio::fsk_pktfmt_read() |
Wayne Roberts |
0:e1e70da93044 | 1192 | { |
Wayne Roberts |
0:e1e70da93044 | 1193 | fsk.RegPktConfig1.octet = radio.read_reg(REG_FSK_PACKETCONFIG1); |
Wayne Roberts |
0:e1e70da93044 | 1194 | return fsk.RegPktConfig1.bits.PacketFormatVariable; |
Wayne Roberts |
0:e1e70da93044 | 1195 | } |
Wayne Roberts |
0:e1e70da93044 | 1196 | |
Wayne Roberts |
0:e1e70da93044 | 1197 | bool Radio::fsk_pktfmt_push() |
Wayne Roberts |
0:e1e70da93044 | 1198 | { |
Wayne Roberts |
0:e1e70da93044 | 1199 | fsk.RegPktConfig1.bits.PacketFormatVariable ^= 1; |
Wayne Roberts |
0:e1e70da93044 | 1200 | radio.write_reg(REG_FSK_PACKETCONFIG1, fsk.RegPktConfig1.octet); |
Wayne Roberts |
0:e1e70da93044 | 1201 | return fsk.RegPktConfig1.bits.PacketFormatVariable; |
Wayne Roberts |
0:e1e70da93044 | 1202 | } |
Wayne Roberts |
0:e1e70da93044 | 1203 | |
Wayne Roberts |
0:e1e70da93044 | 1204 | const toggle_item_t Radio::fskook_pktfmt_item = { _ITEM_TOGGLE, |
Wayne Roberts |
0:e1e70da93044 | 1205 | "fixed ", |
Wayne Roberts |
0:e1e70da93044 | 1206 | "variable", |
Wayne Roberts |
0:e1e70da93044 | 1207 | fsk_pktfmt_read, fsk_pktfmt_push |
Wayne Roberts |
0:e1e70da93044 | 1208 | }; |
Wayne Roberts |
0:e1e70da93044 | 1209 | |
Wayne Roberts |
0:e1e70da93044 | 1210 | |
Wayne Roberts |
0:e1e70da93044 | 1211 | void Radio::rssiOffset_print(void) |
Wayne Roberts |
0:e1e70da93044 | 1212 | { |
Wayne Roberts |
0:e1e70da93044 | 1213 | int ro; |
Wayne Roberts |
0:e1e70da93044 | 1214 | fsk.RegRssiConfig.octet = radio.read_reg(REG_FSK_RSSICONFIG); |
Wayne Roberts |
0:e1e70da93044 | 1215 | ro = fsk.RegRssiConfig.bits.RssiOffset; |
Wayne Roberts |
0:e1e70da93044 | 1216 | pc.printf("%d", ro); |
Wayne Roberts |
0:e1e70da93044 | 1217 | } |
Wayne Roberts |
0:e1e70da93044 | 1218 | |
Wayne Roberts |
0:e1e70da93044 | 1219 | bool Radio::rssiOffset_write(const char* txt) |
Wayne Roberts |
0:e1e70da93044 | 1220 | { |
Wayne Roberts |
0:e1e70da93044 | 1221 | int ro; |
Wayne Roberts |
0:e1e70da93044 | 1222 | sscanf(txt, "%d", &ro); |
Wayne Roberts |
0:e1e70da93044 | 1223 | fsk.RegRssiConfig.bits.RssiOffset = ro; |
Wayne Roberts |
0:e1e70da93044 | 1224 | radio.write_reg(REG_FSK_RSSICONFIG, fsk.RegRssiConfig.octet); |
Wayne Roberts |
0:e1e70da93044 | 1225 | return false; |
Wayne Roberts |
0:e1e70da93044 | 1226 | } |
Wayne Roberts |
0:e1e70da93044 | 1227 | |
Wayne Roberts |
0:e1e70da93044 | 1228 | const value_item_t Radio::rssiOffset_item = { _ITEM_VALUE, 2, rssiOffset_print, rssiOffset_write}; |
Wayne Roberts |
0:e1e70da93044 | 1229 | |
Wayne Roberts |
0:e1e70da93044 | 1230 | const char* const rssiSmoothings[] = { |
Wayne Roberts |
0:e1e70da93044 | 1231 | "2 ", // 0 |
Wayne Roberts |
0:e1e70da93044 | 1232 | "4 ", // 1 |
Wayne Roberts |
0:e1e70da93044 | 1233 | "8 ", // 2 |
Wayne Roberts |
0:e1e70da93044 | 1234 | "16 ", // 3 |
Wayne Roberts |
0:e1e70da93044 | 1235 | "32 ", // 4 |
Wayne Roberts |
0:e1e70da93044 | 1236 | "64 ", // 5 |
Wayne Roberts |
0:e1e70da93044 | 1237 | "128", // 6 |
Wayne Roberts |
0:e1e70da93044 | 1238 | "256", // 7 |
Wayne Roberts |
0:e1e70da93044 | 1239 | NULL |
Wayne Roberts |
0:e1e70da93044 | 1240 | }; |
Wayne Roberts |
0:e1e70da93044 | 1241 | |
Wayne Roberts |
0:e1e70da93044 | 1242 | unsigned Radio::rssiSmoothing_read(bool fw) |
Wayne Roberts |
0:e1e70da93044 | 1243 | { |
Wayne Roberts |
0:e1e70da93044 | 1244 | fsk.RegRssiConfig.octet = radio.read_reg(REG_FSK_RSSICONFIG); |
Wayne Roberts |
0:e1e70da93044 | 1245 | return fsk.RegRssiConfig.bits.RssiSmoothing; |
Wayne Roberts |
0:e1e70da93044 | 1246 | } |
Wayne Roberts |
0:e1e70da93044 | 1247 | |
Wayne Roberts |
0:e1e70da93044 | 1248 | menuMode_e Radio::rssiSmoothing_write(unsigned sidx) |
Wayne Roberts |
0:e1e70da93044 | 1249 | { |
Wayne Roberts |
0:e1e70da93044 | 1250 | radio.write_reg(REG_FSK_RSSICONFIG, fsk.RegRssiConfig.octet); |
Wayne Roberts |
0:e1e70da93044 | 1251 | fsk.RegRssiConfig.bits.RssiSmoothing = sidx; |
Wayne Roberts |
0:e1e70da93044 | 1252 | return MENUMODE_REDRAW; |
Wayne Roberts |
0:e1e70da93044 | 1253 | } |
Wayne Roberts |
0:e1e70da93044 | 1254 | |
Wayne Roberts |
0:e1e70da93044 | 1255 | const dropdown_item_t Radio::rssiSmoothing_item = { _ITEM_DROPDOWN, rssiSmoothings, rssiSmoothings, rssiSmoothing_read, rssiSmoothing_write}; |
Wayne Roberts |
0:e1e70da93044 | 1256 | |
Wayne Roberts |
0:e1e70da93044 | 1257 | bool Radio::dataMode_read() |
Wayne Roberts |
0:e1e70da93044 | 1258 | { |
Wayne Roberts |
0:e1e70da93044 | 1259 | fsk.RegPktConfig2.word = radio.read_u16(REG_FSK_PACKETCONFIG2); |
Wayne Roberts |
0:e1e70da93044 | 1260 | return fsk.RegPktConfig2.bits.DataModePacket; |
Wayne Roberts |
0:e1e70da93044 | 1261 | } |
Wayne Roberts |
0:e1e70da93044 | 1262 | |
Wayne Roberts |
0:e1e70da93044 | 1263 | bool Radio::dataMode_push() |
Wayne Roberts |
0:e1e70da93044 | 1264 | { |
Wayne Roberts |
0:e1e70da93044 | 1265 | fsk.RegPktConfig2.bits.DataModePacket ^= 1; |
Wayne Roberts |
0:e1e70da93044 | 1266 | radio.write_u16(REG_FSK_PACKETCONFIG2, fsk.RegPktConfig2.word); |
Wayne Roberts |
0:e1e70da93044 | 1267 | return fsk.RegPktConfig2.bits.DataModePacket; |
Wayne Roberts |
0:e1e70da93044 | 1268 | } |
Wayne Roberts |
0:e1e70da93044 | 1269 | |
Wayne Roberts |
0:e1e70da93044 | 1270 | const toggle_item_t Radio::dataMode_item = { _ITEM_TOGGLE, |
Wayne Roberts |
0:e1e70da93044 | 1271 | "continuous", |
Wayne Roberts |
0:e1e70da93044 | 1272 | "packet ", |
Wayne Roberts |
0:e1e70da93044 | 1273 | dataMode_read, dataMode_push |
Wayne Roberts |
0:e1e70da93044 | 1274 | }; |
Wayne Roberts |
0:e1e70da93044 | 1275 | |
Wayne Roberts |
0:e1e70da93044 | 1276 | bool Radio::bitSyncOn_read(void) |
Wayne Roberts |
0:e1e70da93044 | 1277 | { |
Wayne Roberts |
0:e1e70da93044 | 1278 | fsk.RegOokPeak.octet = radio.read_reg(REG_FSK_OOKPEAK); |
Wayne Roberts |
0:e1e70da93044 | 1279 | return fsk.RegOokPeak.bits.BitSyncOn; |
Wayne Roberts |
0:e1e70da93044 | 1280 | } |
Wayne Roberts |
0:e1e70da93044 | 1281 | |
Wayne Roberts |
0:e1e70da93044 | 1282 | bool Radio::bitSyncOn_push(void) |
Wayne Roberts |
0:e1e70da93044 | 1283 | { |
Wayne Roberts |
0:e1e70da93044 | 1284 | fsk.RegOokPeak.bits.BitSyncOn ^= 1; |
Wayne Roberts |
0:e1e70da93044 | 1285 | radio.write_reg(REG_FSK_OOKPEAK, fsk.RegOokPeak.octet); |
Wayne Roberts |
0:e1e70da93044 | 1286 | return fsk.RegOokPeak.bits.BitSyncOn; |
Wayne Roberts |
0:e1e70da93044 | 1287 | } |
Wayne Roberts |
0:e1e70da93044 | 1288 | |
Wayne Roberts |
0:e1e70da93044 | 1289 | const toggle_item_t Radio::bitSyncOn_item = { _ITEM_TOGGLE, |
Wayne Roberts |
0:e1e70da93044 | 1290 | "BitSyncOn", NULL, |
Wayne Roberts |
0:e1e70da93044 | 1291 | bitSyncOn_read, bitSyncOn_push |
Wayne Roberts |
0:e1e70da93044 | 1292 | }; |
Wayne Roberts |
0:e1e70da93044 | 1293 | |
Wayne Roberts |
0:e1e70da93044 | 1294 | const button_item_t Radio::pdLabel_item = { _ITEM_BUTTON, "PreambleDetector", NULL}; |
Wayne Roberts |
0:e1e70da93044 | 1295 | |
Wayne Roberts |
0:e1e70da93044 | 1296 | bool Radio::pdOn_read(void) |
Wayne Roberts |
0:e1e70da93044 | 1297 | { |
Wayne Roberts |
0:e1e70da93044 | 1298 | fsk.RegPreambleDetect.octet = radio.read_reg(REG_FSK_PREAMBLEDETECT); |
Wayne Roberts |
0:e1e70da93044 | 1299 | return fsk.RegPreambleDetect.bits.PreambleDetectorOn; |
Wayne Roberts |
0:e1e70da93044 | 1300 | } |
Wayne Roberts |
0:e1e70da93044 | 1301 | |
Wayne Roberts |
0:e1e70da93044 | 1302 | bool Radio::pdOn_push(void) |
Wayne Roberts |
0:e1e70da93044 | 1303 | { |
Wayne Roberts |
0:e1e70da93044 | 1304 | fsk.RegPreambleDetect.bits.PreambleDetectorOn ^= 1; |
Wayne Roberts |
0:e1e70da93044 | 1305 | radio.write_reg(REG_FSK_PREAMBLEDETECT, fsk.RegPreambleDetect.octet); |
Wayne Roberts |
0:e1e70da93044 | 1306 | return fsk.RegPreambleDetect.bits.PreambleDetectorOn; |
Wayne Roberts |
0:e1e70da93044 | 1307 | } |
Wayne Roberts |
0:e1e70da93044 | 1308 | |
Wayne Roberts |
0:e1e70da93044 | 1309 | const toggle_item_t Radio::pdOn_item = { _ITEM_TOGGLE, |
Wayne Roberts |
0:e1e70da93044 | 1310 | "On", NULL, |
Wayne Roberts |
0:e1e70da93044 | 1311 | pdOn_read, pdOn_push |
Wayne Roberts |
0:e1e70da93044 | 1312 | }; |
Wayne Roberts |
0:e1e70da93044 | 1313 | |
Wayne Roberts |
0:e1e70da93044 | 1314 | const char* const pdsizes[] = { |
Wayne Roberts |
0:e1e70da93044 | 1315 | "1 byte ", // 0 |
Wayne Roberts |
0:e1e70da93044 | 1316 | "2 bytes", // 1 |
Wayne Roberts |
0:e1e70da93044 | 1317 | "3 bytes", // 2 |
Wayne Roberts |
0:e1e70da93044 | 1318 | NULL |
Wayne Roberts |
0:e1e70da93044 | 1319 | }; |
Wayne Roberts |
0:e1e70da93044 | 1320 | |
Wayne Roberts |
0:e1e70da93044 | 1321 | unsigned Radio::pdSize_read(bool) |
Wayne Roberts |
0:e1e70da93044 | 1322 | { |
Wayne Roberts |
0:e1e70da93044 | 1323 | fsk.RegPreambleDetect.octet = radio.read_reg(REG_FSK_PREAMBLEDETECT); |
Wayne Roberts |
0:e1e70da93044 | 1324 | return fsk.RegPreambleDetect.bits.PreambleDetectorSize; |
Wayne Roberts |
0:e1e70da93044 | 1325 | } |
Wayne Roberts |
0:e1e70da93044 | 1326 | |
Wayne Roberts |
0:e1e70da93044 | 1327 | menuMode_e Radio::pdSize_write(unsigned sidx) |
Wayne Roberts |
0:e1e70da93044 | 1328 | { |
Wayne Roberts |
0:e1e70da93044 | 1329 | fsk.RegPreambleDetect.bits.PreambleDetectorSize = sidx; |
Wayne Roberts |
0:e1e70da93044 | 1330 | radio.write_reg(REG_FSK_PREAMBLEDETECT, fsk.RegPreambleDetect.octet); |
Wayne Roberts |
0:e1e70da93044 | 1331 | return MENUMODE_REDRAW; |
Wayne Roberts |
0:e1e70da93044 | 1332 | } |
Wayne Roberts |
0:e1e70da93044 | 1333 | |
Wayne Roberts |
0:e1e70da93044 | 1334 | const dropdown_item_t Radio::pdSize_item = { _ITEM_DROPDOWN, pdsizes, pdsizes, pdSize_read, pdSize_write}; |
Wayne Roberts |
0:e1e70da93044 | 1335 | |
Wayne Roberts |
0:e1e70da93044 | 1336 | void Radio::pdTol_print(void) |
Wayne Roberts |
0:e1e70da93044 | 1337 | { |
Wayne Roberts |
0:e1e70da93044 | 1338 | fsk.RegPreambleDetect.octet = radio.read_reg(REG_FSK_PREAMBLEDETECT); |
Wayne Roberts |
0:e1e70da93044 | 1339 | pc.printf("%u", fsk.RegPreambleDetect.bits.PreambleDetectorTol); |
Wayne Roberts |
0:e1e70da93044 | 1340 | } |
Wayne Roberts |
0:e1e70da93044 | 1341 | |
Wayne Roberts |
0:e1e70da93044 | 1342 | bool Radio::pdTol_write(const char* txt) |
Wayne Roberts |
0:e1e70da93044 | 1343 | { |
Wayne Roberts |
0:e1e70da93044 | 1344 | unsigned n; |
Wayne Roberts |
0:e1e70da93044 | 1345 | sscanf(txt, "%u", &n); |
Wayne Roberts |
0:e1e70da93044 | 1346 | fsk.RegPreambleDetect.bits.PreambleDetectorTol = n; |
Wayne Roberts |
0:e1e70da93044 | 1347 | radio.write_reg(REG_FSK_PREAMBLEDETECT, fsk.RegPreambleDetect.octet); |
Wayne Roberts |
0:e1e70da93044 | 1348 | return false; |
Wayne Roberts |
0:e1e70da93044 | 1349 | } |
Wayne Roberts |
0:e1e70da93044 | 1350 | |
Wayne Roberts |
0:e1e70da93044 | 1351 | const value_item_t Radio::pdTol_item = { _ITEM_VALUE, 3, pdTol_print, pdTol_write}; |
Wayne Roberts |
0:e1e70da93044 | 1352 | |
Wayne Roberts |
0:e1e70da93044 | 1353 | bool Radio::TxStartCondition_read() |
Wayne Roberts |
0:e1e70da93044 | 1354 | { |
Wayne Roberts |
0:e1e70da93044 | 1355 | fsk.RegFifoThreshold.octet = radio.read_reg(REG_FSK_FIFOTHRESH); |
Wayne Roberts |
0:e1e70da93044 | 1356 | return fsk.RegFifoThreshold.bits.TxStartCondition; |
Wayne Roberts |
0:e1e70da93044 | 1357 | } |
Wayne Roberts |
0:e1e70da93044 | 1358 | |
Wayne Roberts |
0:e1e70da93044 | 1359 | bool Radio::TxStartCondition_push() |
Wayne Roberts |
0:e1e70da93044 | 1360 | { |
Wayne Roberts |
0:e1e70da93044 | 1361 | fsk.RegFifoThreshold.bits.TxStartCondition ^= 1; |
Wayne Roberts |
0:e1e70da93044 | 1362 | radio.write_reg(REG_FSK_FIFOTHRESH, fsk.RegFifoThreshold.octet); |
Wayne Roberts |
0:e1e70da93044 | 1363 | return fsk.RegFifoThreshold.bits.TxStartCondition; |
Wayne Roberts |
0:e1e70da93044 | 1364 | } |
Wayne Roberts |
0:e1e70da93044 | 1365 | |
Wayne Roberts |
0:e1e70da93044 | 1366 | const toggle_item_t Radio::TxStartCondition_item = { _ITEM_TOGGLE, |
Wayne Roberts |
0:e1e70da93044 | 1367 | "FifoLevel ", // 0 |
Wayne Roberts |
0:e1e70da93044 | 1368 | "FifoNotEmpty", // 1 |
Wayne Roberts |
0:e1e70da93044 | 1369 | TxStartCondition_read, TxStartCondition_push |
Wayne Roberts |
0:e1e70da93044 | 1370 | }; |
Wayne Roberts |
0:e1e70da93044 | 1371 | |
Wayne Roberts |
0:e1e70da93044 | 1372 | void Radio::FifoThreshold_print(void) |
Wayne Roberts |
0:e1e70da93044 | 1373 | { |
Wayne Roberts |
0:e1e70da93044 | 1374 | fsk.RegFifoThreshold.octet = radio.read_reg(REG_FSK_FIFOTHRESH); |
Wayne Roberts |
0:e1e70da93044 | 1375 | pc.printf("%u", fsk.RegFifoThreshold.bits.FifoThreshold); |
Wayne Roberts |
0:e1e70da93044 | 1376 | } |
Wayne Roberts |
0:e1e70da93044 | 1377 | |
Wayne Roberts |
0:e1e70da93044 | 1378 | bool Radio::FifoThreshold_write(const char* txt) |
Wayne Roberts |
0:e1e70da93044 | 1379 | { |
Wayne Roberts |
0:e1e70da93044 | 1380 | unsigned n; |
Wayne Roberts |
0:e1e70da93044 | 1381 | sscanf(txt, "%u", &n); |
Wayne Roberts |
0:e1e70da93044 | 1382 | fsk.RegFifoThreshold.bits.FifoThreshold = n; |
Wayne Roberts |
0:e1e70da93044 | 1383 | radio.write_reg(REG_FSK_FIFOTHRESH, fsk.RegFifoThreshold.octet); |
Wayne Roberts |
0:e1e70da93044 | 1384 | return false; |
Wayne Roberts |
0:e1e70da93044 | 1385 | } |
Wayne Roberts |
0:e1e70da93044 | 1386 | |
Wayne Roberts |
0:e1e70da93044 | 1387 | const value_item_t Radio::FifoThreshold_item = { _ITEM_VALUE, 3, FifoThreshold_print, FifoThreshold_write}; |
Wayne Roberts |
0:e1e70da93044 | 1388 | |
Wayne Roberts |
0:e1e70da93044 | 1389 | const char* const dcFrees[] = { |
Wayne Roberts |
0:e1e70da93044 | 1390 | "none ", // 0 |
Wayne Roberts |
0:e1e70da93044 | 1391 | "manchester", // 1 |
Wayne Roberts |
0:e1e70da93044 | 1392 | "whitening ", // 2 |
Wayne Roberts |
0:e1e70da93044 | 1393 | NULL |
Wayne Roberts |
0:e1e70da93044 | 1394 | }; |
Wayne Roberts |
0:e1e70da93044 | 1395 | |
Wayne Roberts |
0:e1e70da93044 | 1396 | unsigned Radio::dcFree_read(bool fw) |
Wayne Roberts |
0:e1e70da93044 | 1397 | { |
Wayne Roberts |
0:e1e70da93044 | 1398 | fsk.RegPktConfig1.octet = radio.read_reg(REG_FSK_PACKETCONFIG1); |
Wayne Roberts |
0:e1e70da93044 | 1399 | return fsk.RegPktConfig1.bits.DcFree; |
Wayne Roberts |
0:e1e70da93044 | 1400 | } |
Wayne Roberts |
0:e1e70da93044 | 1401 | |
Wayne Roberts |
0:e1e70da93044 | 1402 | menuMode_e Radio::dcFree_write(unsigned sidx) |
Wayne Roberts |
0:e1e70da93044 | 1403 | { |
Wayne Roberts |
0:e1e70da93044 | 1404 | fsk.RegPktConfig1.bits.DcFree = sidx; |
Wayne Roberts |
0:e1e70da93044 | 1405 | radio.write_reg(REG_FSK_PACKETCONFIG1, fsk.RegPktConfig1.octet); |
Wayne Roberts |
0:e1e70da93044 | 1406 | return MENUMODE_REDRAW; |
Wayne Roberts |
0:e1e70da93044 | 1407 | } |
Wayne Roberts |
0:e1e70da93044 | 1408 | |
Wayne Roberts |
0:e1e70da93044 | 1409 | const dropdown_item_t Radio::dcFree_item = { _ITEM_DROPDOWN, dcFrees, dcFrees, dcFree_read, dcFree_write}; |
Wayne Roberts |
0:e1e70da93044 | 1410 | |
Wayne Roberts |
0:e1e70da93044 | 1411 | bool Radio::fskook_crcon_read() |
Wayne Roberts |
0:e1e70da93044 | 1412 | { |
Wayne Roberts |
0:e1e70da93044 | 1413 | fsk.RegPktConfig1.octet = radio.read_reg(REG_FSK_PACKETCONFIG1); |
Wayne Roberts |
0:e1e70da93044 | 1414 | return fsk.RegPktConfig1.bits.CrcOn; |
Wayne Roberts |
0:e1e70da93044 | 1415 | } |
Wayne Roberts |
0:e1e70da93044 | 1416 | |
Wayne Roberts |
0:e1e70da93044 | 1417 | bool Radio::fskook_crcon_push() |
Wayne Roberts |
0:e1e70da93044 | 1418 | { |
Wayne Roberts |
0:e1e70da93044 | 1419 | fsk.RegPktConfig1.bits.CrcOn ^= 1; |
Wayne Roberts |
0:e1e70da93044 | 1420 | radio.write_reg(REG_FSK_PACKETCONFIG1, fsk.RegPktConfig1.octet); |
Wayne Roberts |
0:e1e70da93044 | 1421 | |
Wayne Roberts |
0:e1e70da93044 | 1422 | if (radio.RegOpMode.bits.Mode == RF_OPMODE_RECEIVER) |
Wayne Roberts |
0:e1e70da93044 | 1423 | fsk.config_dio0_for_pktmode_rx(); |
Wayne Roberts |
0:e1e70da93044 | 1424 | |
Wayne Roberts |
0:e1e70da93044 | 1425 | return fsk.RegPktConfig1.bits.CrcOn; |
Wayne Roberts |
0:e1e70da93044 | 1426 | } |
Wayne Roberts |
0:e1e70da93044 | 1427 | |
Wayne Roberts |
0:e1e70da93044 | 1428 | const toggle_item_t Radio::fskook_crcon_item = { _ITEM_TOGGLE, |
Wayne Roberts |
0:e1e70da93044 | 1429 | "CrcOn", NULL, |
Wayne Roberts |
0:e1e70da93044 | 1430 | fskook_crcon_read, fskook_crcon_push |
Wayne Roberts |
0:e1e70da93044 | 1431 | }; |
Wayne Roberts |
0:e1e70da93044 | 1432 | |
Wayne Roberts |
0:e1e70da93044 | 1433 | void Radio::rssiThresh_print() |
Wayne Roberts |
0:e1e70da93044 | 1434 | { |
Wayne Roberts |
0:e1e70da93044 | 1435 | fsk.RegRssiThresh = radio.read_reg(REG_FSK_RSSITHRESH); |
Wayne Roberts |
0:e1e70da93044 | 1436 | pc.printf("%.1f", fsk.RegRssiThresh / -2.0); |
Wayne Roberts |
0:e1e70da93044 | 1437 | } |
Wayne Roberts |
0:e1e70da93044 | 1438 | |
Wayne Roberts |
0:e1e70da93044 | 1439 | bool Radio::rssiThresh_write(const char* txt) |
Wayne Roberts |
0:e1e70da93044 | 1440 | { |
Wayne Roberts |
0:e1e70da93044 | 1441 | float dbm; |
Wayne Roberts |
0:e1e70da93044 | 1442 | sscanf(txt, "%f", &dbm); |
Wayne Roberts |
0:e1e70da93044 | 1443 | fsk.RegRssiThresh = dbm * -2.0; |
Wayne Roberts |
0:e1e70da93044 | 1444 | radio.write_reg(REG_FSK_RSSITHRESH, fsk.RegRssiThresh); |
Wayne Roberts |
0:e1e70da93044 | 1445 | return false; |
Wayne Roberts |
0:e1e70da93044 | 1446 | } |
Wayne Roberts |
0:e1e70da93044 | 1447 | |
Wayne Roberts |
0:e1e70da93044 | 1448 | const value_item_t Radio::rssiThresh_item = { _ITEM_VALUE, 3, rssiThresh_print, rssiThresh_write}; |
Wayne Roberts |
0:e1e70da93044 | 1449 | |
Wayne Roberts |
0:e1e70da93044 | 1450 | bool Radio::pblPol_read() |
Wayne Roberts |
0:e1e70da93044 | 1451 | { |
Wayne Roberts |
0:e1e70da93044 | 1452 | fsk.RegSyncConfig.octet = radio.read_reg(REG_FSK_SYNCCONFIG); |
Wayne Roberts |
0:e1e70da93044 | 1453 | return fsk.RegSyncConfig.bits.PreamblePolarity; |
Wayne Roberts |
0:e1e70da93044 | 1454 | } |
Wayne Roberts |
0:e1e70da93044 | 1455 | |
Wayne Roberts |
0:e1e70da93044 | 1456 | bool Radio::pblPol_push() |
Wayne Roberts |
0:e1e70da93044 | 1457 | { |
Wayne Roberts |
0:e1e70da93044 | 1458 | fsk.RegSyncConfig.bits.PreamblePolarity ^= 1; |
Wayne Roberts |
0:e1e70da93044 | 1459 | radio.write_reg(REG_FSK_SYNCCONFIG, fsk.RegSyncConfig.octet); |
Wayne Roberts |
0:e1e70da93044 | 1460 | return fsk.RegSyncConfig.bits.PreamblePolarity; |
Wayne Roberts |
0:e1e70da93044 | 1461 | } |
Wayne Roberts |
0:e1e70da93044 | 1462 | |
Wayne Roberts |
0:e1e70da93044 | 1463 | const toggle_item_t Radio::pblPol_item = { _ITEM_TOGGLE, |
Wayne Roberts |
0:e1e70da93044 | 1464 | "0xaa", |
Wayne Roberts |
0:e1e70da93044 | 1465 | "0x55", |
Wayne Roberts |
0:e1e70da93044 | 1466 | pblPol_read, pblPol_push |
Wayne Roberts |
0:e1e70da93044 | 1467 | }; |
Wayne Roberts |
0:e1e70da93044 | 1468 | |
Wayne Roberts |
0:e1e70da93044 | 1469 | const menu_t Radio::fsk_menu[] = { |
Wayne Roberts |
0:e1e70da93044 | 1470 | { {FIRST_CHIP_MENU_ROW, 22}, "bps:", &fsk_ook_bitrate_item, FLAG_MSGTYPE_ALL }, |
Wayne Roberts |
0:e1e70da93044 | 1471 | { {FIRST_CHIP_MENU_ROW, 34}, "fdev:", &gfsk_fdev_item, FLAG_MSGTYPE_ALL }, |
Wayne Roberts |
0:e1e70da93044 | 1472 | { {FIRST_CHIP_MENU_ROW, 47}, "BT:", &gfsk_bt_item, FLAG_MSGTYPE_ALL }, |
Wayne Roberts |
0:e1e70da93044 | 1473 | { {FIRST_CHIP_MENU_ROW, 57}, "length:", &fskook_pktfmt_item, FLAG_MSGTYPE_ALL }, |
Wayne Roberts |
0:e1e70da93044 | 1474 | |
Wayne Roberts |
0:e1e70da93044 | 1475 | { {FIRST_CHIP_MENU_ROW+1, 1}, "rxbw:", &rxbw_item, FLAG_MSGTYPE_ALL }, |
Wayne Roberts |
0:e1e70da93044 | 1476 | { {FIRST_CHIP_MENU_ROW+1, 14}, "afcbw:", &afcbw_item, FLAG_MSGTYPE_ALL }, |
Wayne Roberts |
0:e1e70da93044 | 1477 | { {FIRST_CHIP_MENU_ROW+1, 27}, "preambleLen:", &pblLen_item, FLAG_MSGTYPE_ALL }, |
Wayne Roberts |
0:e1e70da93044 | 1478 | { {FIRST_CHIP_MENU_ROW+1, 47}, "RxTrigger:", &rxTrigger_item, FLAG_MSGTYPE_ALL }, |
Wayne Roberts |
0:e1e70da93044 | 1479 | { {FIRST_CHIP_MENU_ROW+1, 72}, NULL, &pblPol_item, FLAG_MSGTYPE_ALL }, |
Wayne Roberts |
0:e1e70da93044 | 1480 | |
Wayne Roberts |
0:e1e70da93044 | 1481 | { {FIRST_CHIP_MENU_ROW+2, 1}, "syncWord:", &syncWord_item, FLAG_MSGTYPE_ALL, &syncSize_item}, |
Wayne Roberts |
0:e1e70da93044 | 1482 | { {FIRST_CHIP_MENU_ROW+2, 27}, "syncSize:", &syncSize_item, FLAG_MSGTYPE_ALL }, |
Wayne Roberts |
0:e1e70da93044 | 1483 | { {FIRST_CHIP_MENU_ROW+2, 39}, NULL, &syncOn_item, FLAG_MSGTYPE_ALL }, |
Wayne Roberts |
0:e1e70da93044 | 1484 | { {FIRST_CHIP_MENU_ROW+2, 47}, "DataMode:", &dataMode_item, FLAG_MSGTYPE_ALL }, |
Wayne Roberts |
0:e1e70da93044 | 1485 | { {FIRST_CHIP_MENU_ROW+2, 69}, NULL, &bitSyncOn_item, FLAG_MSGTYPE_ALL }, |
Wayne Roberts |
0:e1e70da93044 | 1486 | |
Wayne Roberts |
0:e1e70da93044 | 1487 | { {FIRST_CHIP_MENU_ROW+3, 1}, NULL, &pdLabel_item, FLAG_MSGTYPE_ALL }, |
Wayne Roberts |
0:e1e70da93044 | 1488 | { {FIRST_CHIP_MENU_ROW+3, 18}, NULL, &pdOn_item, FLAG_MSGTYPE_ALL }, |
Wayne Roberts |
0:e1e70da93044 | 1489 | { {FIRST_CHIP_MENU_ROW+3, 23}, "size:", &pdSize_item , FLAG_MSGTYPE_ALL }, |
Wayne Roberts |
0:e1e70da93044 | 1490 | { {FIRST_CHIP_MENU_ROW+3, 36}, "tol:", &pdTol_item , FLAG_MSGTYPE_ALL }, |
Wayne Roberts |
0:e1e70da93044 | 1491 | { {FIRST_CHIP_MENU_ROW+3, 48}, "rssiThresh:", &rssiThresh_item , FLAG_MSGTYPE_ALL }, |
Wayne Roberts |
0:e1e70da93044 | 1492 | |
Wayne Roberts |
0:e1e70da93044 | 1493 | { {FIRST_CHIP_MENU_ROW+4, 1}, NULL, &agcautoon_item, FLAG_MSGTYPE_ALL }, |
Wayne Roberts |
0:e1e70da93044 | 1494 | { {FIRST_CHIP_MENU_ROW+4, 11}, NULL, &afcautoon_item, FLAG_MSGTYPE_ALL }, |
Wayne Roberts |
0:e1e70da93044 | 1495 | { {FIRST_CHIP_MENU_ROW+4, 22}, NULL, &RestartRxOnCollision_item, FLAG_MSGTYPE_ALL }, |
Wayne Roberts |
0:e1e70da93044 | 1496 | { {FIRST_CHIP_MENU_ROW+4, 43}, NULL, &RestartRxWithPllLock_item, FLAG_MSGTYPE_ALL }, |
Wayne Roberts |
0:e1e70da93044 | 1497 | { {FIRST_CHIP_MENU_ROW+4, 64}, NULL, &RestartRxWithoutPllLock_item, FLAG_MSGTYPE_ALL }, |
Wayne Roberts |
0:e1e70da93044 | 1498 | |
Wayne Roberts |
0:e1e70da93044 | 1499 | { {FIRST_CHIP_MENU_ROW+5, 1}, NULL, &AfcAutoClearOn_item, FLAG_MSGTYPE_ALL }, |
Wayne Roberts |
0:e1e70da93044 | 1500 | { {FIRST_CHIP_MENU_ROW+5, 17}, NULL, &AgcStart_item, FLAG_MSGTYPE_ALL }, |
Wayne Roberts |
0:e1e70da93044 | 1501 | { {FIRST_CHIP_MENU_ROW+5, 27}, NULL, &AfcClear_item, FLAG_MSGTYPE_ALL }, |
Wayne Roberts |
0:e1e70da93044 | 1502 | { {FIRST_CHIP_MENU_ROW+5, 37}, "rssiOffset:", &rssiOffset_item, FLAG_MSGTYPE_ALL }, |
Wayne Roberts |
0:e1e70da93044 | 1503 | { {FIRST_CHIP_MENU_ROW+5, 52}, "rssiSmoothing:", &rssiSmoothing_item, FLAG_MSGTYPE_ALL }, |
Wayne Roberts |
0:e1e70da93044 | 1504 | |
Wayne Roberts |
0:e1e70da93044 | 1505 | { {FIRST_CHIP_MENU_ROW+6, 1}, "TxStartCondition:", &TxStartCondition_item, FLAG_MSGTYPE_ALL }, |
Wayne Roberts |
0:e1e70da93044 | 1506 | { {FIRST_CHIP_MENU_ROW+6, 32}, "FifoThreshold:", &FifoThreshold_item, FLAG_MSGTYPE_ALL }, |
Wayne Roberts |
0:e1e70da93044 | 1507 | { {FIRST_CHIP_MENU_ROW+6, 50}, "dcFree:", &dcFree_item, FLAG_MSGTYPE_ALL }, |
Wayne Roberts |
0:e1e70da93044 | 1508 | { {FIRST_CHIP_MENU_ROW+6, 68}, NULL, &fskook_crcon_item, FLAG_MSGTYPE_ALL }, |
Wayne Roberts |
0:e1e70da93044 | 1509 | |
Wayne Roberts |
0:e1e70da93044 | 1510 | { {0, 0}, NULL, NULL } |
Wayne Roberts |
0:e1e70da93044 | 1511 | }; |
Wayne Roberts |
0:e1e70da93044 | 1512 | |
Wayne Roberts |
0:e1e70da93044 | 1513 | const button_item_t Radio::ookLabel_item = { _ITEM_BUTTON, "Ook", NULL}; |
Wayne Roberts |
0:e1e70da93044 | 1514 | |
Wayne Roberts |
0:e1e70da93044 | 1515 | const menu_t Radio::common_menu[] = { |
Wayne Roberts |
0:e1e70da93044 | 1516 | { {FIRST_CHIP_MENU_ROW, 1}, NULL, &paSelect_item, FLAG_MSGTYPE_ALL }, |
Wayne Roberts |
0:e1e70da93044 | 1517 | { {FIRST_CHIP_MENU_ROW, 10}, "ocp mA:", &ocp_item, FLAG_MSGTYPE_ALL }, |
Wayne Roberts |
0:e1e70da93044 | 1518 | { {0, 0}, NULL, NULL } |
Wayne Roberts |
0:e1e70da93044 | 1519 | }; |
Wayne Roberts |
0:e1e70da93044 | 1520 | |
Wayne Roberts |
0:e1e70da93044 | 1521 | const char* const ook_peak_steps[] = { |
Wayne Roberts |
0:e1e70da93044 | 1522 | "0.5", // 0 |
Wayne Roberts |
0:e1e70da93044 | 1523 | "1.0", // 1 |
Wayne Roberts |
0:e1e70da93044 | 1524 | "1.5", // 2 |
Wayne Roberts |
0:e1e70da93044 | 1525 | "2.0", // 3 |
Wayne Roberts |
0:e1e70da93044 | 1526 | "3.0", // 4 |
Wayne Roberts |
0:e1e70da93044 | 1527 | "4.0", // 5 |
Wayne Roberts |
0:e1e70da93044 | 1528 | "5.0", // 6 |
Wayne Roberts |
0:e1e70da93044 | 1529 | "6.0", // 7 |
Wayne Roberts |
0:e1e70da93044 | 1530 | NULL |
Wayne Roberts |
0:e1e70da93044 | 1531 | }; |
Wayne Roberts |
0:e1e70da93044 | 1532 | |
Wayne Roberts |
0:e1e70da93044 | 1533 | unsigned Radio::ook_peak_step_read(bool fw) |
Wayne Roberts |
0:e1e70da93044 | 1534 | { |
Wayne Roberts |
0:e1e70da93044 | 1535 | fsk.RegOokPeak.octet = radio.read_reg(REG_FSK_OOKPEAK); |
Wayne Roberts |
0:e1e70da93044 | 1536 | return fsk.RegOokPeak.bits.OokPeakThreshStep; |
Wayne Roberts |
0:e1e70da93044 | 1537 | } |
Wayne Roberts |
0:e1e70da93044 | 1538 | |
Wayne Roberts |
0:e1e70da93044 | 1539 | menuMode_e Radio::ook_peak_step_write(unsigned sidx) |
Wayne Roberts |
0:e1e70da93044 | 1540 | { |
Wayne Roberts |
0:e1e70da93044 | 1541 | fsk.RegOokPeak.bits.OokPeakThreshStep = sidx; |
Wayne Roberts |
0:e1e70da93044 | 1542 | radio.write_reg(REG_FSK_OOKPEAK, fsk.RegOokPeak.octet); |
Wayne Roberts |
0:e1e70da93044 | 1543 | return MENUMODE_REDRAW; |
Wayne Roberts |
0:e1e70da93044 | 1544 | } |
Wayne Roberts |
0:e1e70da93044 | 1545 | |
Wayne Roberts |
0:e1e70da93044 | 1546 | const dropdown_item_t Radio::ook_peak_step_item = { _ITEM_DROPDOWN, ook_peak_steps, ook_peak_steps, ook_peak_step_read, ook_peak_step_write}; |
Wayne Roberts |
0:e1e70da93044 | 1547 | |
Wayne Roberts |
0:e1e70da93044 | 1548 | const char* const ook_peak_decs[] = { |
Wayne Roberts |
0:e1e70da93044 | 1549 | "once per chip ", // 0 |
Wayne Roberts |
0:e1e70da93044 | 1550 | "once every 2 chips ", // 1 |
Wayne Roberts |
0:e1e70da93044 | 1551 | "once every 4 chips ", // 2 |
Wayne Roberts |
0:e1e70da93044 | 1552 | "once every 8 chips ", // 3 |
Wayne Roberts |
0:e1e70da93044 | 1553 | "twice in each chip ", // 4 |
Wayne Roberts |
0:e1e70da93044 | 1554 | "4 times in each chip ", // 5 |
Wayne Roberts |
0:e1e70da93044 | 1555 | "8 times in each chip ", // 6 |
Wayne Roberts |
0:e1e70da93044 | 1556 | "16 times in each chip", // 7 |
Wayne Roberts |
0:e1e70da93044 | 1557 | NULL |
Wayne Roberts |
0:e1e70da93044 | 1558 | }; |
Wayne Roberts |
0:e1e70da93044 | 1559 | |
Wayne Roberts |
0:e1e70da93044 | 1560 | unsigned Radio::ook_peak_dec_read(bool fw) |
Wayne Roberts |
0:e1e70da93044 | 1561 | { |
Wayne Roberts |
0:e1e70da93044 | 1562 | RegOokAvg_t RegOokAvg; |
Wayne Roberts |
0:e1e70da93044 | 1563 | RegOokAvg.octet = radio.read_reg(REG_FSK_OOKAVG); |
Wayne Roberts |
0:e1e70da93044 | 1564 | return RegOokAvg.bits.OokPeakThreshDec; |
Wayne Roberts |
0:e1e70da93044 | 1565 | } |
Wayne Roberts |
0:e1e70da93044 | 1566 | |
Wayne Roberts |
0:e1e70da93044 | 1567 | menuMode_e Radio::ook_peak_dec_write(unsigned sidx) |
Wayne Roberts |
0:e1e70da93044 | 1568 | { |
Wayne Roberts |
0:e1e70da93044 | 1569 | RegOokAvg_t RegOokAvg; |
Wayne Roberts |
0:e1e70da93044 | 1570 | RegOokAvg.octet = radio.read_reg(REG_FSK_OOKAVG); |
Wayne Roberts |
0:e1e70da93044 | 1571 | RegOokAvg.bits.OokPeakThreshDec = sidx; |
Wayne Roberts |
0:e1e70da93044 | 1572 | radio.write_reg(REG_FSK_OOKAVG, RegOokAvg.octet); |
Wayne Roberts |
0:e1e70da93044 | 1573 | return MENUMODE_REDRAW; |
Wayne Roberts |
0:e1e70da93044 | 1574 | } |
Wayne Roberts |
0:e1e70da93044 | 1575 | |
Wayne Roberts |
0:e1e70da93044 | 1576 | const dropdown_item_t Radio::ook_peak_dec_item = { _ITEM_DROPDOWN, ook_peak_decs, ook_peak_decs, ook_peak_dec_read, ook_peak_dec_write}; |
Wayne Roberts |
0:e1e70da93044 | 1577 | |
Wayne Roberts |
0:e1e70da93044 | 1578 | void Radio::ookFixedThresh_print() |
Wayne Roberts |
0:e1e70da93044 | 1579 | { |
Wayne Roberts |
0:e1e70da93044 | 1580 | pc.printf("%u", radio.read_reg(REG_FSK_OOKFIX)); |
Wayne Roberts |
0:e1e70da93044 | 1581 | } |
Wayne Roberts |
0:e1e70da93044 | 1582 | |
Wayne Roberts |
0:e1e70da93044 | 1583 | bool Radio::ookFixedThresh_write(const char* txt) |
Wayne Roberts |
0:e1e70da93044 | 1584 | { |
Wayne Roberts |
0:e1e70da93044 | 1585 | unsigned n; |
Wayne Roberts |
0:e1e70da93044 | 1586 | sscanf(txt, "%u", &n); |
Wayne Roberts |
0:e1e70da93044 | 1587 | radio.write_reg(REG_FSK_OOKFIX, n); |
Wayne Roberts |
0:e1e70da93044 | 1588 | return false; |
Wayne Roberts |
0:e1e70da93044 | 1589 | } |
Wayne Roberts |
0:e1e70da93044 | 1590 | |
Wayne Roberts |
0:e1e70da93044 | 1591 | const value_item_t Radio::ookFixedThresh_item = { _ITEM_VALUE, 3, ookFixedThresh_print, ookFixedThresh_write}; |
Wayne Roberts |
0:e1e70da93044 | 1592 | |
Wayne Roberts |
0:e1e70da93044 | 1593 | const char* const ook_avgOffsets[] = { |
Wayne Roberts |
0:e1e70da93044 | 1594 | "0.0dB", // 0 |
Wayne Roberts |
0:e1e70da93044 | 1595 | "2.0dB", // 1 |
Wayne Roberts |
0:e1e70da93044 | 1596 | "4.0dB", // 2 |
Wayne Roberts |
0:e1e70da93044 | 1597 | "6.0dB", // 3 |
Wayne Roberts |
0:e1e70da93044 | 1598 | NULL |
Wayne Roberts |
0:e1e70da93044 | 1599 | }; |
Wayne Roberts |
0:e1e70da93044 | 1600 | |
Wayne Roberts |
0:e1e70da93044 | 1601 | unsigned Radio::ook_avgOffset_read(bool fw) |
Wayne Roberts |
0:e1e70da93044 | 1602 | { |
Wayne Roberts |
0:e1e70da93044 | 1603 | RegOokAvg_t RegOokAvg; |
Wayne Roberts |
0:e1e70da93044 | 1604 | RegOokAvg.octet = radio.read_reg(REG_FSK_OOKAVG); |
Wayne Roberts |
0:e1e70da93044 | 1605 | return RegOokAvg.bits.OokAverageOffset; |
Wayne Roberts |
0:e1e70da93044 | 1606 | } |
Wayne Roberts |
0:e1e70da93044 | 1607 | |
Wayne Roberts |
0:e1e70da93044 | 1608 | menuMode_e Radio::ook_avgOffset_write(unsigned sidx) |
Wayne Roberts |
0:e1e70da93044 | 1609 | { |
Wayne Roberts |
0:e1e70da93044 | 1610 | RegOokAvg_t RegOokAvg; |
Wayne Roberts |
0:e1e70da93044 | 1611 | RegOokAvg.octet = radio.read_reg(REG_FSK_OOKAVG); |
Wayne Roberts |
0:e1e70da93044 | 1612 | RegOokAvg.bits.OokAverageOffset = sidx; |
Wayne Roberts |
0:e1e70da93044 | 1613 | radio.write_reg(REG_FSK_OOKAVG, RegOokAvg.octet); |
Wayne Roberts |
0:e1e70da93044 | 1614 | return MENUMODE_REDRAW; |
Wayne Roberts |
0:e1e70da93044 | 1615 | } |
Wayne Roberts |
0:e1e70da93044 | 1616 | |
Wayne Roberts |
0:e1e70da93044 | 1617 | const dropdown_item_t Radio::ook_avgOffset_item = { _ITEM_DROPDOWN, ook_avgOffsets, ook_avgOffsets, ook_avgOffset_read, ook_avgOffset_write}; |
Wayne Roberts |
0:e1e70da93044 | 1618 | |
Wayne Roberts |
0:e1e70da93044 | 1619 | const char* const ook_avgFilters[] = { |
Wayne Roberts |
0:e1e70da93044 | 1620 | "chip rate / 32.π", // 0 |
Wayne Roberts |
0:e1e70da93044 | 1621 | "chip rate / 8.π ", // 1 |
Wayne Roberts |
0:e1e70da93044 | 1622 | "chip rate / 4.π ", // 2 |
Wayne Roberts |
0:e1e70da93044 | 1623 | "chip rate / 2.π ", // 3 |
Wayne Roberts |
0:e1e70da93044 | 1624 | NULL |
Wayne Roberts |
0:e1e70da93044 | 1625 | }; |
Wayne Roberts |
0:e1e70da93044 | 1626 | |
Wayne Roberts |
0:e1e70da93044 | 1627 | unsigned Radio::ook_avgFilter_read(bool fw) |
Wayne Roberts |
0:e1e70da93044 | 1628 | { |
Wayne Roberts |
0:e1e70da93044 | 1629 | RegOokAvg_t RegOokAvg; |
Wayne Roberts |
0:e1e70da93044 | 1630 | RegOokAvg.octet = radio.read_reg(REG_FSK_OOKAVG); |
Wayne Roberts |
0:e1e70da93044 | 1631 | return RegOokAvg.bits.OokAverageThreshFilt; |
Wayne Roberts |
0:e1e70da93044 | 1632 | } |
Wayne Roberts |
0:e1e70da93044 | 1633 | |
Wayne Roberts |
0:e1e70da93044 | 1634 | menuMode_e Radio::ook_avgFilter_write(unsigned sidx) |
Wayne Roberts |
0:e1e70da93044 | 1635 | { |
Wayne Roberts |
0:e1e70da93044 | 1636 | RegOokAvg_t RegOokAvg; |
Wayne Roberts |
0:e1e70da93044 | 1637 | RegOokAvg.octet = radio.read_reg(REG_FSK_OOKAVG); |
Wayne Roberts |
0:e1e70da93044 | 1638 | RegOokAvg.bits.OokAverageThreshFilt = sidx; |
Wayne Roberts |
0:e1e70da93044 | 1639 | radio.write_reg(REG_FSK_OOKAVG, RegOokAvg.octet); |
Wayne Roberts |
0:e1e70da93044 | 1640 | return MENUMODE_REDRAW; |
Wayne Roberts |
0:e1e70da93044 | 1641 | } |
Wayne Roberts |
0:e1e70da93044 | 1642 | |
Wayne Roberts |
0:e1e70da93044 | 1643 | const dropdown_item_t Radio::ook_avgFilter_item = { _ITEM_DROPDOWN, ook_avgFilters, ook_avgFilters, ook_avgFilter_read, ook_avgFilter_write}; |
Wayne Roberts |
0:e1e70da93044 | 1644 | |
Wayne Roberts |
0:e1e70da93044 | 1645 | const char* const ookthreshs[] = { |
Wayne Roberts |
0:e1e70da93044 | 1646 | "fixed ", // 0 |
Wayne Roberts |
0:e1e70da93044 | 1647 | "peak ", // 1 |
Wayne Roberts |
0:e1e70da93044 | 1648 | "average", // 2 |
Wayne Roberts |
0:e1e70da93044 | 1649 | NULL |
Wayne Roberts |
0:e1e70da93044 | 1650 | }; |
Wayne Roberts |
0:e1e70da93044 | 1651 | |
Wayne Roberts |
0:e1e70da93044 | 1652 | |
Wayne Roberts |
0:e1e70da93044 | 1653 | unsigned Radio::ookthreshtype_read(bool) |
Wayne Roberts |
0:e1e70da93044 | 1654 | { |
Wayne Roberts |
0:e1e70da93044 | 1655 | fsk.RegOokPeak.octet = radio.read_reg(REG_FSK_OOKPEAK); |
Wayne Roberts |
0:e1e70da93044 | 1656 | |
Wayne Roberts |
0:e1e70da93044 | 1657 | return fsk.RegOokPeak.bits.OokThreshType; |
Wayne Roberts |
0:e1e70da93044 | 1658 | } |
Wayne Roberts |
0:e1e70da93044 | 1659 | |
Wayne Roberts |
0:e1e70da93044 | 1660 | menuMode_e Radio::ookthreshtype_write(unsigned sidx) |
Wayne Roberts |
0:e1e70da93044 | 1661 | { |
Wayne Roberts |
0:e1e70da93044 | 1662 | fsk.RegOokPeak.bits.OokThreshType = sidx; |
Wayne Roberts |
0:e1e70da93044 | 1663 | radio.write_reg(REG_FSK_OOKPEAK, fsk.RegOokPeak.octet); |
Wayne Roberts |
0:e1e70da93044 | 1664 | |
Wayne Roberts |
0:e1e70da93044 | 1665 | return MENUMODE_REINIT_MENU; |
Wayne Roberts |
0:e1e70da93044 | 1666 | } |
Wayne Roberts |
0:e1e70da93044 | 1667 | |
Wayne Roberts |
0:e1e70da93044 | 1668 | const dropdown_item_t Radio::ookthreshtype_item = { _ITEM_DROPDOWN, ookthreshs, ookthreshs, ookthreshtype_read, ookthreshtype_write}; |
Wayne Roberts |
0:e1e70da93044 | 1669 | |
Wayne Roberts |
0:e1e70da93044 | 1670 | const menu_t Radio::ook_menu[] = { |
Wayne Roberts |
0:e1e70da93044 | 1671 | { {FIRST_CHIP_MENU_ROW, 22}, "bps:", &fsk_ook_bitrate_item, FLAG_MSGTYPE_ALL }, |
Wayne Roberts |
0:e1e70da93044 | 1672 | { {FIRST_CHIP_MENU_ROW, 34}, "Fcutoff=", &ook_bt_item, FLAG_MSGTYPE_ALL }, |
Wayne Roberts |
0:e1e70da93044 | 1673 | { {FIRST_CHIP_MENU_ROW, 56}, "length:", &fskook_pktfmt_item, FLAG_MSGTYPE_ALL }, |
Wayne Roberts |
0:e1e70da93044 | 1674 | |
Wayne Roberts |
0:e1e70da93044 | 1675 | { {FIRST_CHIP_MENU_ROW+1, 1}, "rxbw:", &rxbw_item, FLAG_MSGTYPE_ALL }, |
Wayne Roberts |
0:e1e70da93044 | 1676 | { {FIRST_CHIP_MENU_ROW+1, 12}, "afcbw:", &afcbw_item, FLAG_MSGTYPE_ALL }, |
Wayne Roberts |
0:e1e70da93044 | 1677 | { {FIRST_CHIP_MENU_ROW+1, 25}, "preambleLen:", &pblLen_item, FLAG_MSGTYPE_ALL }, |
Wayne Roberts |
0:e1e70da93044 | 1678 | { {FIRST_CHIP_MENU_ROW+1, 47}, "RxTrigger:", &rxTrigger_item, FLAG_MSGTYPE_ALL }, |
Wayne Roberts |
0:e1e70da93044 | 1679 | |
Wayne Roberts |
0:e1e70da93044 | 1680 | { {FIRST_CHIP_MENU_ROW+2, 1}, "syncWord:", &syncWord_item, FLAG_MSGTYPE_ALL, &syncSize_item}, |
Wayne Roberts |
0:e1e70da93044 | 1681 | { {FIRST_CHIP_MENU_ROW+2, 27}, "syncSize:", &syncSize_item, FLAG_MSGTYPE_ALL }, |
Wayne Roberts |
0:e1e70da93044 | 1682 | { {FIRST_CHIP_MENU_ROW+2, 39}, NULL, &syncOn_item, FLAG_MSGTYPE_ALL }, |
Wayne Roberts |
0:e1e70da93044 | 1683 | { {FIRST_CHIP_MENU_ROW+2, 47}, "DataMode:", &dataMode_item, FLAG_MSGTYPE_ALL }, |
Wayne Roberts |
0:e1e70da93044 | 1684 | { {FIRST_CHIP_MENU_ROW+2, 69}, NULL, &bitSyncOn_item, FLAG_MSGTYPE_ALL }, |
Wayne Roberts |
0:e1e70da93044 | 1685 | |
Wayne Roberts |
0:e1e70da93044 | 1686 | { {FIRST_CHIP_MENU_ROW+3, 1}, NULL, &pdLabel_item, FLAG_MSGTYPE_ALL }, |
Wayne Roberts |
0:e1e70da93044 | 1687 | { {FIRST_CHIP_MENU_ROW+3, 18}, NULL, &pdOn_item, FLAG_MSGTYPE_ALL }, |
Wayne Roberts |
0:e1e70da93044 | 1688 | { {FIRST_CHIP_MENU_ROW+3, 23}, "size:", &pdSize_item , FLAG_MSGTYPE_ALL }, |
Wayne Roberts |
0:e1e70da93044 | 1689 | { {FIRST_CHIP_MENU_ROW+3, 36}, "tol:", &pdTol_item , FLAG_MSGTYPE_ALL }, |
Wayne Roberts |
0:e1e70da93044 | 1690 | { {FIRST_CHIP_MENU_ROW+3, 48}, "rssiThresh:", &rssiThresh_item , FLAG_MSGTYPE_ALL }, |
Wayne Roberts |
0:e1e70da93044 | 1691 | |
Wayne Roberts |
0:e1e70da93044 | 1692 | { {FIRST_CHIP_MENU_ROW+4, 1}, "TxStartCondition:", &TxStartCondition_item, FLAG_MSGTYPE_ALL }, |
Wayne Roberts |
0:e1e70da93044 | 1693 | { {FIRST_CHIP_MENU_ROW+4, 32}, "FifoThreshold:", &FifoThreshold_item, FLAG_MSGTYPE_ALL }, |
Wayne Roberts |
0:e1e70da93044 | 1694 | { {FIRST_CHIP_MENU_ROW+4, 50}, "dcFree:", &dcFree_item, FLAG_MSGTYPE_ALL }, |
Wayne Roberts |
0:e1e70da93044 | 1695 | { {FIRST_CHIP_MENU_ROW+4, 68}, NULL, &fskook_crcon_item, FLAG_MSGTYPE_ALL }, |
Wayne Roberts |
0:e1e70da93044 | 1696 | |
Wayne Roberts |
0:e1e70da93044 | 1697 | { {FIRST_CHIP_MENU_ROW+5, 1}, NULL, &ookLabel_item, FLAG_MSGTYPE_ALL }, |
Wayne Roberts |
0:e1e70da93044 | 1698 | { {FIRST_CHIP_MENU_ROW+5, 5}, "threshType:", &ookthreshtype_item, FLAG_MSGTYPE_ALL }, |
Wayne Roberts |
0:e1e70da93044 | 1699 | |
Wayne Roberts |
0:e1e70da93044 | 1700 | { {0, 0}, NULL, NULL } |
Wayne Roberts |
0:e1e70da93044 | 1701 | }; |
Wayne Roberts |
0:e1e70da93044 | 1702 | |
Wayne Roberts |
0:e1e70da93044 | 1703 | const menu_t Radio::ook_fixed_menu[] = { |
Wayne Roberts |
0:e1e70da93044 | 1704 | { {FIRST_CHIP_MENU_ROW+5, 25}, "threshold:", &ookFixedThresh_item, FLAG_MSGTYPE_ALL }, |
Wayne Roberts |
0:e1e70da93044 | 1705 | { {0, 0}, NULL, NULL } |
Wayne Roberts |
0:e1e70da93044 | 1706 | }; |
Wayne Roberts |
0:e1e70da93044 | 1707 | |
Wayne Roberts |
0:e1e70da93044 | 1708 | const menu_t Radio::ook_peak_menu[] = { |
Wayne Roberts |
0:e1e70da93044 | 1709 | { {FIRST_CHIP_MENU_ROW+5, 25}, "step:", &ook_peak_step_item, FLAG_MSGTYPE_ALL }, |
Wayne Roberts |
0:e1e70da93044 | 1710 | { {FIRST_CHIP_MENU_ROW+5, 40}, "dec:", &ook_peak_dec_item, FLAG_MSGTYPE_ALL }, |
Wayne Roberts |
0:e1e70da93044 | 1711 | { {0, 0}, NULL, NULL } |
Wayne Roberts |
0:e1e70da93044 | 1712 | }; |
Wayne Roberts |
0:e1e70da93044 | 1713 | |
Wayne Roberts |
0:e1e70da93044 | 1714 | const menu_t Radio::ook_average_menu[] = { |
Wayne Roberts |
0:e1e70da93044 | 1715 | { {FIRST_CHIP_MENU_ROW+5, 25}, "offset:", &ook_avgOffset_item, FLAG_MSGTYPE_ALL }, |
Wayne Roberts |
0:e1e70da93044 | 1716 | { {FIRST_CHIP_MENU_ROW+5, 45}, "filter:", &ook_avgFilter_item, FLAG_MSGTYPE_ALL }, |
Wayne Roberts |
0:e1e70da93044 | 1717 | { {0, 0}, NULL, NULL } |
Wayne Roberts |
0:e1e70da93044 | 1718 | }; |
Wayne Roberts |
0:e1e70da93044 | 1719 | |
Wayne Roberts |
0:e1e70da93044 | 1720 | void Radio::boardInit(const RadioEvents_t* e) |
Wayne Roberts |
0:e1e70da93044 | 1721 | { |
Wayne Roberts |
0:e1e70da93044 | 1722 | targetInit(); |
Wayne Roberts |
0:e1e70da93044 | 1723 | |
Wayne Roberts |
0:e1e70da93044 | 1724 | RadioEvents = e; |
Wayne Roberts |
0:e1e70da93044 | 1725 | |
Wayne Roberts |
0:e1e70da93044 | 1726 | RegPaRamp.octet = radio.read_reg(REG_PARAMP); |
Wayne Roberts |
0:e1e70da93044 | 1727 | |
Wayne Roberts |
0:e1e70da93044 | 1728 | if (radio.type == SX1276) { |
Wayne Roberts |
0:e1e70da93044 | 1729 | lora_bw_item.printed_strs = lora_bws_1276; |
Wayne Roberts |
0:e1e70da93044 | 1730 | lora_bw_item.selectable_strs = lora_bws_1276; |
Wayne Roberts |
0:e1e70da93044 | 1731 | } else if (radio.type == SX1272) { |
Wayne Roberts |
0:e1e70da93044 | 1732 | lora_bw_item.printed_strs = lora_bws_1272; |
Wayne Roberts |
0:e1e70da93044 | 1733 | lora_bw_item.selectable_strs = lora_bws_1272; |
Wayne Roberts |
0:e1e70da93044 | 1734 | } |
Wayne Roberts |
0:e1e70da93044 | 1735 | |
Wayne Roberts |
0:e1e70da93044 | 1736 | lpt.start(); |
Wayne Roberts |
0:e1e70da93044 | 1737 | } |
Wayne Roberts |
0:e1e70da93044 | 1738 | |
Wayne Roberts |
0:e1e70da93044 | 1739 | unsigned Radio::read_register(unsigned addr) |
Wayne Roberts |
0:e1e70da93044 | 1740 | { |
Wayne Roberts |
0:e1e70da93044 | 1741 | return radio.read_reg(addr); |
Wayne Roberts |
0:e1e70da93044 | 1742 | } |
Wayne Roberts |
0:e1e70da93044 | 1743 | |
Wayne Roberts |
0:e1e70da93044 | 1744 | void Radio::write_register(unsigned addr, unsigned val) |
Wayne Roberts |
0:e1e70da93044 | 1745 | { |
Wayne Roberts |
0:e1e70da93044 | 1746 | radio.write_reg(addr, val); |
Wayne Roberts |
0:e1e70da93044 | 1747 | } |
Wayne Roberts |
0:e1e70da93044 | 1748 | |
Wayne Roberts |
0:e1e70da93044 | 1749 | void Radio::test() { } |
Wayne Roberts |
0:e1e70da93044 | 1750 | |
Wayne Roberts |
0:e1e70da93044 | 1751 | #endif /* ..SX127x_H */ |
Wayne Roberts |
0:e1e70da93044 | 1752 |