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