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_lr1110.cpp@10:db4e11a55bda, 2020-05-19 (annotated)
- Committer:
- Wayne Roberts
- Date:
- Tue May 19 15:35:50 2020 -0700
- Revision:
- 10:db4e11a55bda
- Parent:
- 9:295e37c38fb3
- Child:
- 13:8ce61a1897ab
complete LR1110
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| Wayne Roberts |
9:295e37c38fb3 | 1 | #include "radio.h" |
| Wayne Roberts |
9:295e37c38fb3 | 2 | #ifdef SX1265_H |
| Wayne Roberts |
9:295e37c38fb3 | 3 | |
| Wayne Roberts |
9:295e37c38fb3 | 4 | SPI spi(D11, D12, D13); // mosi, miso, sclk |
| Wayne Roberts |
9:295e37c38fb3 | 5 | //spi, nss, busy, dio9, nreset |
| Wayne Roberts |
9:295e37c38fb3 | 6 | SX1265 Radio::radio(spi, D7, D3, D5, A0, 0x3ffffcf); |
| Wayne Roberts |
9:295e37c38fb3 | 7 | |
| Wayne Roberts |
9:295e37c38fb3 | 8 | #define DIO_en_IDX 0 |
| Wayne Roberts |
9:295e37c38fb3 | 9 | #define DIO_stby_IDX 1 |
| Wayne Roberts |
9:295e37c38fb3 | 10 | #define DIO_rx_IDX 2 |
| Wayne Roberts |
9:295e37c38fb3 | 11 | #define DIO_tx_IDX 3 |
| Wayne Roberts |
9:295e37c38fb3 | 12 | #define DIO_txhp_IDX 4 |
| Wayne Roberts |
9:295e37c38fb3 | 13 | #define DIO_gnss_IDX 6 |
| Wayne Roberts |
9:295e37c38fb3 | 14 | #define DIO_wifi_IDX 7 |
| Wayne Roberts |
9:295e37c38fb3 | 15 | |
| Wayne Roberts |
9:295e37c38fb3 | 16 | #define DIO5_BIT 0x01 |
| Wayne Roberts |
9:295e37c38fb3 | 17 | #define DIO6_BIT 0x02 |
| Wayne Roberts |
9:295e37c38fb3 | 18 | #define DIO7_BIT 0x04 |
| Wayne Roberts |
9:295e37c38fb3 | 19 | #define DIO8_BIT 0x08 |
| Wayne Roberts |
9:295e37c38fb3 | 20 | #define DIO10_BIT 0x10 |
| Wayne Roberts |
9:295e37c38fb3 | 21 | |
| Wayne Roberts |
9:295e37c38fb3 | 22 | uint8_t dioBuf[8]; |
| Wayne Roberts |
9:295e37c38fb3 | 23 | uint8_t Radio::gfsk_pp_buf[9]; |
| Wayne Roberts |
9:295e37c38fb3 | 24 | uint8_t Radio::gfsk_mp_buf[10]; |
| Wayne Roberts |
9:295e37c38fb3 | 25 | uint8_t Radio::lora_pp_buf[6]; |
| Wayne Roberts |
9:295e37c38fb3 | 26 | uint8_t Radio::lora_mp_buf[4]; |
| Wayne Roberts |
9:295e37c38fb3 | 27 | const RadioEvents_t* Radio::RadioEvents; |
| Wayne Roberts |
9:295e37c38fb3 | 28 | uint8_t Radio::pktType; |
| Wayne Roberts |
9:295e37c38fb3 | 29 | uint8_t Radio::tx_param_buf[2]; |
| Wayne Roberts |
9:295e37c38fb3 | 30 | uint8_t Radio::pa_config_buf[4]; |
| Wayne Roberts |
9:295e37c38fb3 | 31 | unsigned Radio::recalCnt; |
| Wayne Roberts |
10:db4e11a55bda | 32 | uint32_t gfsk_crc_initValue; |
| Wayne Roberts |
10:db4e11a55bda | 33 | uint32_t gfsk_crc_Poly; |
| Wayne Roberts |
9:295e37c38fb3 | 34 | |
| Wayne Roberts |
9:295e37c38fb3 | 35 | uint8_t wifiScan_buf[9]; |
| Wayne Roberts |
9:295e37c38fb3 | 36 | uint8_t gnssAutonomous_buf[9]; |
| Wayne Roberts |
10:db4e11a55bda | 37 | uint8_t gnssAssisted_buf[7]; |
| Wayne Roberts |
10:db4e11a55bda | 38 | bool wifiResultFormatBasic; |
| Wayne Roberts |
10:db4e11a55bda | 39 | uint8_t tcxo_buf[5]; |
| Wayne Roberts |
9:295e37c38fb3 | 40 | |
| Wayne Roberts |
9:295e37c38fb3 | 41 | void Radio::hw_reset() |
| Wayne Roberts |
9:295e37c38fb3 | 42 | { |
| Wayne Roberts |
9:295e37c38fb3 | 43 | radio.hw_reset(); |
| Wayne Roberts |
10:db4e11a55bda | 44 | //radio.enable_default_irqs(); |
| Wayne Roberts |
9:295e37c38fb3 | 45 | initRfSwDIO(); |
| Wayne Roberts |
9:295e37c38fb3 | 46 | } |
| Wayne Roberts |
9:295e37c38fb3 | 47 | |
| Wayne Roberts |
9:295e37c38fb3 | 48 | void Radio::initRfSwDIO() |
| Wayne Roberts |
9:295e37c38fb3 | 49 | { |
| Wayne Roberts |
9:295e37c38fb3 | 50 | /* antenna truth table |
| Wayne Roberts |
9:295e37c38fb3 | 51 | * V1 V2 port |
| Wayne Roberts |
9:295e37c38fb3 | 52 | * 0 0 shutdown |
| Wayne Roberts |
9:295e37c38fb3 | 53 | * 1 0 J2 rx RFI |
| Wayne Roberts |
9:295e37c38fb3 | 54 | * 0 1 J1 HP tx RFO |
| Wayne Roberts |
9:295e37c38fb3 | 55 | * 1 1 J3 LP tx RFO |
| Wayne Roberts |
9:295e37c38fb3 | 56 | * DIO5 DIO6 |
| Wayne Roberts |
9:295e37c38fb3 | 57 | * */ |
| Wayne Roberts |
9:295e37c38fb3 | 58 | dioBuf[ DIO_en_IDX] = DIO5_BIT | DIO6_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 59 | dioBuf[DIO_stby_IDX] = 0; |
| Wayne Roberts |
9:295e37c38fb3 | 60 | dioBuf[ DIO_rx_IDX] = DIO5_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 61 | dioBuf[ DIO_tx_IDX] = DIO5_BIT | DIO6_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 62 | dioBuf[DIO_txhp_IDX] = DIO6_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 63 | dioBuf[DIO_gnss_IDX] = 0; |
| Wayne Roberts |
9:295e37c38fb3 | 64 | dioBuf[DIO_wifi_IDX] = 0; |
| Wayne Roberts |
9:295e37c38fb3 | 65 | radio.xfer(OPCODE_SET_DIO_AS_RFSWITCH, 8, 0, dioBuf); |
| Wayne Roberts |
9:295e37c38fb3 | 66 | } |
| Wayne Roberts |
9:295e37c38fb3 | 67 | |
| Wayne Roberts |
9:295e37c38fb3 | 68 | unsigned Radio::my_round(float x) |
| Wayne Roberts |
9:295e37c38fb3 | 69 | { |
| Wayne Roberts |
9:295e37c38fb3 | 70 | if (x >= 0) |
| Wayne Roberts |
9:295e37c38fb3 | 71 | return (unsigned) (x+0.5); |
| Wayne Roberts |
9:295e37c38fb3 | 72 | return (unsigned) (x-0.5); |
| Wayne Roberts |
9:295e37c38fb3 | 73 | } |
| Wayne Roberts |
9:295e37c38fb3 | 74 | |
| Wayne Roberts |
9:295e37c38fb3 | 75 | void Radio::readChip() |
| Wayne Roberts |
9:295e37c38fb3 | 76 | { |
| Wayne Roberts |
10:db4e11a55bda | 77 | uint32_t u32; |
| Wayne Roberts |
9:295e37c38fb3 | 78 | { |
| Wayne Roberts |
9:295e37c38fb3 | 79 | txParamsB_t txpb; // txpb.bits.PaSel |
| Wayne Roberts |
9:295e37c38fb3 | 80 | txParamsC_t txpc; |
| Wayne Roberts |
10:db4e11a55bda | 81 | radio.memRegRead(REG_ADDR_TX_PARAMS_C, 1, &txpc.dword); |
| Wayne Roberts |
9:295e37c38fb3 | 82 | tx_param_buf[1] = txpc.bits.pa_ramp_time; |
| Wayne Roberts |
9:295e37c38fb3 | 83 | |
| Wayne Roberts |
10:db4e11a55bda | 84 | radio.memRegRead(REG_ADDR_TX_PARAMS_B, 1, &txpb.dword); |
| Wayne Roberts |
9:295e37c38fb3 | 85 | if (txpb.bits.PaSel) |
| Wayne Roberts |
9:295e37c38fb3 | 86 | tx_param_buf[0] = txpc.bits.tx_dbm - 9; |
| Wayne Roberts |
9:295e37c38fb3 | 87 | else |
| Wayne Roberts |
9:295e37c38fb3 | 88 | tx_param_buf[0] = txpc.bits.tx_dbm - 17; |
| Wayne Roberts |
9:295e37c38fb3 | 89 | } |
| Wayne Roberts |
9:295e37c38fb3 | 90 | |
| Wayne Roberts |
10:db4e11a55bda | 91 | radio.GetPaConfig(pa_config_buf); |
| Wayne Roberts |
9:295e37c38fb3 | 92 | |
| Wayne Roberts |
9:295e37c38fb3 | 93 | { |
| Wayne Roberts |
9:295e37c38fb3 | 94 | dioEnable_t dio; |
| Wayne Roberts |
10:db4e11a55bda | 95 | radio.memRegRead(REG_ADDR_DIO10, 1, &dio.dword); |
| Wayne Roberts |
9:295e37c38fb3 | 96 | if (dio.bits.enable) |
| Wayne Roberts |
9:295e37c38fb3 | 97 | dioBuf[DIO_en_IDX] |= DIO10_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 98 | else |
| Wayne Roberts |
9:295e37c38fb3 | 99 | dioBuf[DIO_en_IDX] &= ~DIO10_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 100 | |
| Wayne Roberts |
10:db4e11a55bda | 101 | radio.memRegRead(REG_ADDR_DIO8, 1, &dio.dword); |
| Wayne Roberts |
9:295e37c38fb3 | 102 | if (dio.bits.enable) |
| Wayne Roberts |
9:295e37c38fb3 | 103 | dioBuf[DIO_en_IDX] |= DIO8_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 104 | else |
| Wayne Roberts |
9:295e37c38fb3 | 105 | dioBuf[DIO_en_IDX] &= ~DIO8_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 106 | |
| Wayne Roberts |
10:db4e11a55bda | 107 | radio.memRegRead(REG_ADDR_DIO7, 1, &dio.dword); |
| Wayne Roberts |
9:295e37c38fb3 | 108 | if (dio.bits.enable) |
| Wayne Roberts |
9:295e37c38fb3 | 109 | dioBuf[DIO_en_IDX] |= DIO7_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 110 | else |
| Wayne Roberts |
9:295e37c38fb3 | 111 | dioBuf[DIO_en_IDX] &= ~DIO7_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 112 | |
| Wayne Roberts |
10:db4e11a55bda | 113 | radio.memRegRead(REG_ADDR_DIO6, 1, &dio.dword); |
| Wayne Roberts |
9:295e37c38fb3 | 114 | if (dio.bits.enable) |
| Wayne Roberts |
9:295e37c38fb3 | 115 | dioBuf[DIO_en_IDX] |= DIO6_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 116 | else |
| Wayne Roberts |
9:295e37c38fb3 | 117 | dioBuf[DIO_en_IDX] &= ~DIO6_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 118 | |
| Wayne Roberts |
10:db4e11a55bda | 119 | radio.memRegRead(REG_ADDR_DIO5, 1, &dio.dword); |
| Wayne Roberts |
9:295e37c38fb3 | 120 | if (dio.bits.enable) |
| Wayne Roberts |
9:295e37c38fb3 | 121 | dioBuf[DIO_en_IDX] |= DIO5_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 122 | else |
| Wayne Roberts |
9:295e37c38fb3 | 123 | dioBuf[DIO_en_IDX] &= ~DIO5_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 124 | } |
| Wayne Roberts |
9:295e37c38fb3 | 125 | |
| Wayne Roberts |
9:295e37c38fb3 | 126 | { |
| Wayne Roberts |
9:295e37c38fb3 | 127 | gfskConfig4_t cfg4; |
| Wayne Roberts |
9:295e37c38fb3 | 128 | gfskConfig2_t cfg2; |
| Wayne Roberts |
10:db4e11a55bda | 129 | gfskConfig1_t cfg1; |
| Wayne Roberts |
9:295e37c38fb3 | 130 | gfskConfig3_t cfg3; |
| Wayne Roberts |
9:295e37c38fb3 | 131 | gfskConfig5_t cfg5; |
| Wayne Roberts |
9:295e37c38fb3 | 132 | |
| Wayne Roberts |
10:db4e11a55bda | 133 | radio.memRegRead(REG_ADDR_GFSK_CFG5, 1, &cfg5.dword); |
| Wayne Roberts |
9:295e37c38fb3 | 134 | gfsk_pp_buf[8] = cfg5.bits.whitening_enable; |
| Wayne Roberts |
9:295e37c38fb3 | 135 | |
| Wayne Roberts |
9:295e37c38fb3 | 136 | if (cfg5.bits.crc_off) |
| Wayne Roberts |
9:295e37c38fb3 | 137 | gfsk_pp_buf[7] |= 1; |
| Wayne Roberts |
9:295e37c38fb3 | 138 | else |
| Wayne Roberts |
9:295e37c38fb3 | 139 | gfsk_pp_buf[7] &= ~1; |
| Wayne Roberts |
9:295e37c38fb3 | 140 | |
| Wayne Roberts |
9:295e37c38fb3 | 141 | if (cfg5.bits.crc_size) |
| Wayne Roberts |
9:295e37c38fb3 | 142 | gfsk_pp_buf[7] |= 2; |
| Wayne Roberts |
9:295e37c38fb3 | 143 | else |
| Wayne Roberts |
9:295e37c38fb3 | 144 | gfsk_pp_buf[7] &= ~2; |
| Wayne Roberts |
9:295e37c38fb3 | 145 | |
| Wayne Roberts |
9:295e37c38fb3 | 146 | if (cfg5.bits.crc_invert) |
| Wayne Roberts |
9:295e37c38fb3 | 147 | gfsk_pp_buf[7] |= 4; |
| Wayne Roberts |
9:295e37c38fb3 | 148 | else |
| Wayne Roberts |
9:295e37c38fb3 | 149 | gfsk_pp_buf[7] &= ~4; |
| Wayne Roberts |
9:295e37c38fb3 | 150 | |
| Wayne Roberts |
10:db4e11a55bda | 151 | radio.memRegRead(REG_ADDR_GFSK_PAYLOAD_LENGTH_A, 1, &u32); |
| Wayne Roberts |
10:db4e11a55bda | 152 | gfsk_pp_buf[6] = u32 & 0xff; |
| Wayne Roberts |
10:db4e11a55bda | 153 | |
| Wayne Roberts |
10:db4e11a55bda | 154 | radio.memRegRead(REG_ADDR_GFSK_PAYLOAD_LENGTH_B, 1, &cfg4.dword); |
| Wayne Roberts |
9:295e37c38fb3 | 155 | gfsk_pp_buf[4] = cfg4.bits.addr_comp; |
| Wayne Roberts |
9:295e37c38fb3 | 156 | if (cfg4.bits.payload_length != gfsk_pp_buf[6]) |
| Wayne Roberts |
9:295e37c38fb3 | 157 | log_printf("length_mismatch_%02x_%02x\r\n", cfg4.bits.payload_length, gfsk_pp_buf[6]); |
| Wayne Roberts |
9:295e37c38fb3 | 158 | |
| Wayne Roberts |
10:db4e11a55bda | 159 | radio.memRegRead(REG_ADDR_GFSK_CFG3, 1, &cfg3.dword); |
| Wayne Roberts |
9:295e37c38fb3 | 160 | gfsk_pp_buf[5] = cfg3.bits.variable_length; |
| Wayne Roberts |
9:295e37c38fb3 | 161 | |
| Wayne Roberts |
10:db4e11a55bda | 162 | radio.memRegRead(REG_ADDR_GFSK_CFG2, 1, &cfg2.dword); |
| Wayne Roberts |
9:295e37c38fb3 | 163 | gfsk_pp_buf[3] = cfg2.bits.sync_word_length; |
| Wayne Roberts |
9:295e37c38fb3 | 164 | |
| Wayne Roberts |
10:db4e11a55bda | 165 | radio.memRegRead(REG_ADDR_GFSK_CFG1, 1, &cfg1.dword); |
| Wayne Roberts |
10:db4e11a55bda | 166 | radio.to_big_endian16(cfg1.bits.preamble_length, gfsk_pp_buf); |
| Wayne Roberts |
10:db4e11a55bda | 167 | if (cfg1.bits.preamble_det_enable) |
| Wayne Roberts |
10:db4e11a55bda | 168 | gfsk_pp_buf[2] = cfg1.bits.preamble_det_len; |
| Wayne Roberts |
9:295e37c38fb3 | 169 | else |
| Wayne Roberts |
9:295e37c38fb3 | 170 | gfsk_pp_buf[2] = 0; |
| Wayne Roberts |
9:295e37c38fb3 | 171 | |
| Wayne Roberts |
10:db4e11a55bda | 172 | { |
| Wayne Roberts |
10:db4e11a55bda | 173 | unsigned hz; |
| Wayne Roberts |
10:db4e11a55bda | 174 | radio.memRegRead(REG_ADDR_GFSK_BITRATE, 1, &u32); |
| Wayne Roberts |
10:db4e11a55bda | 175 | hz = GFSK_BITRATE_NUMERATOR / u32; |
| Wayne Roberts |
10:db4e11a55bda | 176 | radio.to_big_endian32(hz, gfsk_mp_buf); |
| Wayne Roberts |
10:db4e11a55bda | 177 | } |
| Wayne Roberts |
9:295e37c38fb3 | 178 | //gfsk_mp_buf[4] = bt; |
| Wayne Roberts |
9:295e37c38fb3 | 179 | //gfsk_mp_buf[5] = bwf; |
| Wayne Roberts |
9:295e37c38fb3 | 180 | //gfsk_mp_buf[6,7,8,9] = fdevHz; |
| Wayne Roberts |
9:295e37c38fb3 | 181 | { |
| Wayne Roberts |
9:295e37c38fb3 | 182 | unsigned hz; |
| Wayne Roberts |
10:db4e11a55bda | 183 | radio.memRegRead(REG_ADDR_GFSK_FDEV, 1, &u32); |
| Wayne Roberts |
10:db4e11a55bda | 184 | hz = my_round(u32 * FREQ_STEP); |
| Wayne Roberts |
9:295e37c38fb3 | 185 | radio.to_big_endian32(hz, gfsk_mp_buf+6); |
| Wayne Roberts |
9:295e37c38fb3 | 186 | } |
| Wayne Roberts |
9:295e37c38fb3 | 187 | |
| Wayne Roberts |
10:db4e11a55bda | 188 | radio.memRegRead(REG_ADDR_GFSK_CRC_INIT, 1, &gfsk_crc_initValue); |
| Wayne Roberts |
10:db4e11a55bda | 189 | radio.memRegRead(REG_ADDR_GFSK_CRC_POLY, 1, &gfsk_crc_Poly); |
| Wayne Roberts |
9:295e37c38fb3 | 190 | } |
| Wayne Roberts |
9:295e37c38fb3 | 191 | |
| Wayne Roberts |
9:295e37c38fb3 | 192 | /**********************************************/ |
| Wayne Roberts |
9:295e37c38fb3 | 193 | { |
| Wayne Roberts |
9:295e37c38fb3 | 194 | uint16_t u16; |
| Wayne Roberts |
9:295e37c38fb3 | 195 | loraConfig0_t cfg0; |
| Wayne Roberts |
9:295e37c38fb3 | 196 | loraConfigB_t cfgb; |
| Wayne Roberts |
9:295e37c38fb3 | 197 | loraConfigC_t cfgc; |
| Wayne Roberts |
10:db4e11a55bda | 198 | |
| Wayne Roberts |
10:db4e11a55bda | 199 | radio.GetLoRaModulationParameters(lora_mp_buf); |
| Wayne Roberts |
10:db4e11a55bda | 200 | |
| Wayne Roberts |
10:db4e11a55bda | 201 | radio.memRegRead(REG_ADDR_LORA_CONFIGC, 1, &cfgc.dword); |
| Wayne Roberts |
9:295e37c38fb3 | 202 | u16 = cfgc.bits.preamble_length; |
| Wayne Roberts |
9:295e37c38fb3 | 203 | lora_pp_buf[1] = u16 & 0xff; |
| Wayne Roberts |
9:295e37c38fb3 | 204 | u16 >>= 8; |
| Wayne Roberts |
9:295e37c38fb3 | 205 | lora_pp_buf[0] = u16; |
| Wayne Roberts |
9:295e37c38fb3 | 206 | |
| Wayne Roberts |
10:db4e11a55bda | 207 | radio.memRegRead(REG_ADDR_LORA_CONFIG0, 1, &cfg0.dword); |
| Wayne Roberts |
9:295e37c38fb3 | 208 | lora_pp_buf[2] = cfg0.bits.implicit_header; |
| Wayne Roberts |
9:295e37c38fb3 | 209 | lora_pp_buf[3] = cfg0.bits.payload_length; |
| Wayne Roberts |
9:295e37c38fb3 | 210 | lora_pp_buf[4] = cfg0.bits.crc_on; |
| Wayne Roberts |
9:295e37c38fb3 | 211 | |
| Wayne Roberts |
10:db4e11a55bda | 212 | radio.memRegRead(REG_ADDR_LORA_CONFIGB, 1, &cfgb.dword); |
| Wayne Roberts |
9:295e37c38fb3 | 213 | lora_pp_buf[5] = cfgb.bits.invertIQ; |
| Wayne Roberts |
9:295e37c38fb3 | 214 | |
| Wayne Roberts |
9:295e37c38fb3 | 215 | } |
| Wayne Roberts |
9:295e37c38fb3 | 216 | |
| Wayne Roberts |
9:295e37c38fb3 | 217 | { /* wifi scan defaults */ |
| Wayne Roberts |
9:295e37c38fb3 | 218 | unsigned chanmask = 0x0421; |
| Wayne Roberts |
9:295e37c38fb3 | 219 | unsigned timeout = 0x0046; |
| Wayne Roberts |
9:295e37c38fb3 | 220 | |
| Wayne Roberts |
9:295e37c38fb3 | 221 | wifiScan_buf[0] = 0x01; // wifi type |
| Wayne Roberts |
9:295e37c38fb3 | 222 | wifiScan_buf[2] = chanmask; // chanmask-lo |
| Wayne Roberts |
9:295e37c38fb3 | 223 | chanmask >>= 8; |
| Wayne Roberts |
9:295e37c38fb3 | 224 | wifiScan_buf[1] = chanmask; // chanmask-hi |
| Wayne Roberts |
9:295e37c38fb3 | 225 | wifiScan_buf[3] = 0x02; // acqMode |
| Wayne Roberts |
9:295e37c38fb3 | 226 | wifiScan_buf[4] = 0x0a; // NbMaxRes |
| Wayne Roberts |
9:295e37c38fb3 | 227 | wifiScan_buf[5] = 0x06; // NbScanPerChan |
| Wayne Roberts |
9:295e37c38fb3 | 228 | wifiScan_buf[7] = timeout; // Timeout-lo |
| Wayne Roberts |
9:295e37c38fb3 | 229 | timeout >>= 8; |
| Wayne Roberts |
9:295e37c38fb3 | 230 | wifiScan_buf[6] = timeout; // Timeout-hi |
| Wayne Roberts |
9:295e37c38fb3 | 231 | wifiScan_buf[8] = 0x00; // AbortOnTimeout |
| Wayne Roberts |
9:295e37c38fb3 | 232 | } |
| Wayne Roberts |
10:db4e11a55bda | 233 | |
| Wayne Roberts |
9:295e37c38fb3 | 234 | } |
| Wayne Roberts |
9:295e37c38fb3 | 235 | |
| Wayne Roberts |
9:295e37c38fb3 | 236 | void Radio::clearIrqFlags() |
| Wayne Roberts |
9:295e37c38fb3 | 237 | { |
| Wayne Roberts |
9:295e37c38fb3 | 238 | uint8_t buf[4]; |
| Wayne Roberts |
9:295e37c38fb3 | 239 | buf[0] = buf[1] = buf[2] = buf[3] = 0xff; |
| Wayne Roberts |
9:295e37c38fb3 | 240 | radio.xfer(OPCODE_CLEAR_IRQ, 4, 0, buf); |
| Wayne Roberts |
9:295e37c38fb3 | 241 | } |
| Wayne Roberts |
9:295e37c38fb3 | 242 | |
| Wayne Roberts |
9:295e37c38fb3 | 243 | uint8_t Radio::get_payload_length() |
| Wayne Roberts |
9:295e37c38fb3 | 244 | { |
| Wayne Roberts |
9:295e37c38fb3 | 245 | uint8_t pktType = radio.getPacketType(); |
| Wayne Roberts |
9:295e37c38fb3 | 246 | |
| Wayne Roberts |
9:295e37c38fb3 | 247 | if (pktType == PACKET_TYPE_LORA) { |
| Wayne Roberts |
10:db4e11a55bda | 248 | unsigned foo; |
| Wayne Roberts |
9:295e37c38fb3 | 249 | loraConfig0_t cfg0; |
| Wayne Roberts |
10:db4e11a55bda | 250 | radio.memRegRead(REG_ADDR_LORA_CONFIG0, 1, &cfg0.dword); |
| Wayne Roberts |
10:db4e11a55bda | 251 | foo = cfg0.dword; |
| Wayne Roberts |
10:db4e11a55bda | 252 | foo >>= 24; |
| Wayne Roberts |
9:295e37c38fb3 | 253 | lora_pp_buf[3] = cfg0.bits.payload_length; |
| Wayne Roberts |
9:295e37c38fb3 | 254 | return cfg0.bits.payload_length; |
| Wayne Roberts |
9:295e37c38fb3 | 255 | } else if (pktType == PACKET_TYPE_GFSK) { |
| Wayne Roberts |
10:db4e11a55bda | 256 | uint32_t u32; |
| Wayne Roberts |
10:db4e11a55bda | 257 | /* TODO: which is rx payloadLength vs tx payloadLength */ |
| Wayne Roberts |
10:db4e11a55bda | 258 | //gfskConfig4_t cfg4; |
| Wayne Roberts |
10:db4e11a55bda | 259 | radio.memRegRead(REG_ADDR_GFSK_PAYLOAD_LENGTH_A, 1, &u32); |
| Wayne Roberts |
10:db4e11a55bda | 260 | gfsk_pp_buf[6] = u32 & 0xff; |
| Wayne Roberts |
10:db4e11a55bda | 261 | /*radio.memRegRead(REG_ADDR_GFSK_PAYLOAD_LENGTH_B, 1, buf); |
| Wayne Roberts |
10:db4e11a55bda | 262 | cfg4.dword = radio.from_big_endian32(buf);*/ |
| Wayne Roberts |
10:db4e11a55bda | 263 | |
| Wayne Roberts |
10:db4e11a55bda | 264 | /* |
| Wayne Roberts |
9:295e37c38fb3 | 265 | if ((rb & 0xff) != cfg4.bits.payload_length) { |
| Wayne Roberts |
9:295e37c38fb3 | 266 | log_printf("gfsk payload length A:%u B:%u\r\n", rb & 0xff, cfg4.bits.payload_length); |
| Wayne Roberts |
9:295e37c38fb3 | 267 | // todo: which is tx-length vs rx-length |
| Wayne Roberts |
9:295e37c38fb3 | 268 | } |
| Wayne Roberts |
10:db4e11a55bda | 269 | */ |
| Wayne Roberts |
10:db4e11a55bda | 270 | |
| Wayne Roberts |
10:db4e11a55bda | 271 | return u32 & 0xff; |
| Wayne Roberts |
9:295e37c38fb3 | 272 | } |
| Wayne Roberts |
9:295e37c38fb3 | 273 | return 0; |
| Wayne Roberts |
9:295e37c38fb3 | 274 | } |
| Wayne Roberts |
9:295e37c38fb3 | 275 | |
| Wayne Roberts |
9:295e37c38fb3 | 276 | bool Radio::tx_payload_length_write(const char* txt) |
| Wayne Roberts |
9:295e37c38fb3 | 277 | { |
| Wayne Roberts |
9:295e37c38fb3 | 278 | unsigned len; |
| Wayne Roberts |
9:295e37c38fb3 | 279 | sscanf(txt, "%u", &len); |
| Wayne Roberts |
9:295e37c38fb3 | 280 | set_payload_length(len); |
| Wayne Roberts |
9:295e37c38fb3 | 281 | return false; |
| Wayne Roberts |
9:295e37c38fb3 | 282 | } |
| Wayne Roberts |
9:295e37c38fb3 | 283 | |
| Wayne Roberts |
9:295e37c38fb3 | 284 | unsigned Radio::read_register(unsigned addr) |
| Wayne Roberts |
9:295e37c38fb3 | 285 | { |
| Wayne Roberts |
10:db4e11a55bda | 286 | uint32_t u32; |
| Wayne Roberts |
10:db4e11a55bda | 287 | radio.memRegRead(addr, 1, &u32); |
| Wayne Roberts |
10:db4e11a55bda | 288 | return u32; |
| Wayne Roberts |
9:295e37c38fb3 | 289 | } |
| Wayne Roberts |
9:295e37c38fb3 | 290 | |
| Wayne Roberts |
9:295e37c38fb3 | 291 | void Radio::write_register(unsigned addr, unsigned val) |
| Wayne Roberts |
9:295e37c38fb3 | 292 | { |
| Wayne Roberts |
9:295e37c38fb3 | 293 | stat_t stat; |
| Wayne Roberts |
9:295e37c38fb3 | 294 | uint8_t buf[8]; |
| Wayne Roberts |
9:295e37c38fb3 | 295 | radio.to_big_endian32(addr, buf); |
| Wayne Roberts |
9:295e37c38fb3 | 296 | radio.to_big_endian32(val, buf); |
| Wayne Roberts |
9:295e37c38fb3 | 297 | stat.word = radio.xfer(OPCODE_WRITEREGMEM32, 8, 0, buf); |
| Wayne Roberts |
9:295e37c38fb3 | 298 | print_stat(stat); |
| Wayne Roberts |
9:295e37c38fb3 | 299 | } |
| Wayne Roberts |
9:295e37c38fb3 | 300 | |
| Wayne Roberts |
9:295e37c38fb3 | 301 | void Radio::txTimeout_print() |
| Wayne Roberts |
9:295e37c38fb3 | 302 | { |
| Wayne Roberts |
9:295e37c38fb3 | 303 | float sec = radio.txTimeout / 32768.0; |
| Wayne Roberts |
9:295e37c38fb3 | 304 | pc.printf("%.3f", sec); |
| Wayne Roberts |
9:295e37c38fb3 | 305 | } |
| Wayne Roberts |
9:295e37c38fb3 | 306 | |
| Wayne Roberts |
9:295e37c38fb3 | 307 | bool Radio::txTimeout_write(const char *txt) |
| Wayne Roberts |
9:295e37c38fb3 | 308 | { |
| Wayne Roberts |
9:295e37c38fb3 | 309 | float sec; |
| Wayne Roberts |
9:295e37c38fb3 | 310 | if (sscanf(txt, "%f", &sec) == 1) { |
| Wayne Roberts |
9:295e37c38fb3 | 311 | radio.txTimeout = sec * 32768; |
| Wayne Roberts |
9:295e37c38fb3 | 312 | log_printf("txTimeout:%u\r\n", radio.txTimeout); |
| Wayne Roberts |
9:295e37c38fb3 | 313 | } |
| Wayne Roberts |
9:295e37c38fb3 | 314 | return false; |
| Wayne Roberts |
9:295e37c38fb3 | 315 | } |
| Wayne Roberts |
9:295e37c38fb3 | 316 | |
| Wayne Roberts |
9:295e37c38fb3 | 317 | const value_item_t Radio::txTimeout_item = { _ITEM_VALUE, 6, txTimeout_print, txTimeout_write}; |
| Wayne Roberts |
9:295e37c38fb3 | 318 | |
| Wayne Roberts |
10:db4e11a55bda | 319 | bool regulator_read() |
| Wayne Roberts |
10:db4e11a55bda | 320 | { |
| Wayne Roberts |
10:db4e11a55bda | 321 | regulatorMode_t rm; |
| Wayne Roberts |
10:db4e11a55bda | 322 | Radio::radio.memRegRead(REG_ADDR_REGULATOR_MODE, 1, &rm.dword); |
| Wayne Roberts |
10:db4e11a55bda | 323 | return rm.bits.dcdc_en; |
| Wayne Roberts |
10:db4e11a55bda | 324 | } |
| Wayne Roberts |
10:db4e11a55bda | 325 | |
| Wayne Roberts |
10:db4e11a55bda | 326 | bool regulator_push() |
| Wayne Roberts |
10:db4e11a55bda | 327 | { |
| Wayne Roberts |
10:db4e11a55bda | 328 | uint8_t buf = regulator_read() ? 0 : 1; |
| Wayne Roberts |
10:db4e11a55bda | 329 | Radio::radio.xfer(OPCODE_SET_REGULATOR_MODE, 1, 0, &buf); |
| Wayne Roberts |
10:db4e11a55bda | 330 | return buf == 1; |
| Wayne Roberts |
10:db4e11a55bda | 331 | } |
| Wayne Roberts |
10:db4e11a55bda | 332 | |
| Wayne Roberts |
10:db4e11a55bda | 333 | const toggle_item_t regulator_item = { _ITEM_TOGGLE, |
| Wayne Roberts |
10:db4e11a55bda | 334 | " LDO ", |
| Wayne Roberts |
10:db4e11a55bda | 335 | "DC-DC", |
| Wayne Roberts |
10:db4e11a55bda | 336 | regulator_read, |
| Wayne Roberts |
10:db4e11a55bda | 337 | regulator_push |
| Wayne Roberts |
10:db4e11a55bda | 338 | }; |
| Wayne Roberts |
10:db4e11a55bda | 339 | |
| Wayne Roberts |
10:db4e11a55bda | 340 | const char* const tcxovolts_strs[] |
| Wayne Roberts |
10:db4e11a55bda | 341 | { |
| Wayne Roberts |
10:db4e11a55bda | 342 | "1.6", // 0 |
| Wayne Roberts |
10:db4e11a55bda | 343 | "1.8", // 1 |
| Wayne Roberts |
10:db4e11a55bda | 344 | "1.8", // 2 |
| Wayne Roberts |
10:db4e11a55bda | 345 | "2.2", // 3 |
| Wayne Roberts |
10:db4e11a55bda | 346 | "2.4", // 4 |
| Wayne Roberts |
10:db4e11a55bda | 347 | "2.7", // 5 |
| Wayne Roberts |
10:db4e11a55bda | 348 | "3.0", // 6 |
| Wayne Roberts |
10:db4e11a55bda | 349 | "3.3", // 7 |
| Wayne Roberts |
10:db4e11a55bda | 350 | NULL |
| Wayne Roberts |
10:db4e11a55bda | 351 | }; |
| Wayne Roberts |
10:db4e11a55bda | 352 | |
| Wayne Roberts |
10:db4e11a55bda | 353 | unsigned tcxovolts_read(bool for_writing) |
| Wayne Roberts |
10:db4e11a55bda | 354 | { |
| Wayne Roberts |
10:db4e11a55bda | 355 | tcxo_t tcxo; |
| Wayne Roberts |
10:db4e11a55bda | 356 | Radio::radio.memRegRead(REG_ADDR_TCXO, 1, &tcxo.dword); |
| Wayne Roberts |
10:db4e11a55bda | 357 | return tcxo.bits.volts; |
| Wayne Roberts |
10:db4e11a55bda | 358 | } |
| Wayne Roberts |
10:db4e11a55bda | 359 | |
| Wayne Roberts |
10:db4e11a55bda | 360 | menuMode_e tcxovolts_write(unsigned sidx) |
| Wayne Roberts |
10:db4e11a55bda | 361 | { |
| Wayne Roberts |
10:db4e11a55bda | 362 | tcxo_buf[0] = sidx; |
| Wayne Roberts |
10:db4e11a55bda | 363 | Radio::radio.xfer(OPCODE_SET_TCXO_MODE, 5, 0, tcxo_buf); |
| Wayne Roberts |
10:db4e11a55bda | 364 | return MENUMODE_REDRAW; |
| Wayne Roberts |
10:db4e11a55bda | 365 | } |
| Wayne Roberts |
10:db4e11a55bda | 366 | |
| Wayne Roberts |
10:db4e11a55bda | 367 | const dropdown_item_t tcxo_volts_item = { _ITEM_DROPDOWN, tcxovolts_strs, tcxovolts_strs, tcxovolts_read, tcxovolts_write}; |
| Wayne Roberts |
10:db4e11a55bda | 368 | |
| Wayne Roberts |
10:db4e11a55bda | 369 | void tcxo_delay_print() |
| Wayne Roberts |
10:db4e11a55bda | 370 | { |
| Wayne Roberts |
10:db4e11a55bda | 371 | unsigned ticks = tcxo_buf[1]; |
| Wayne Roberts |
10:db4e11a55bda | 372 | ticks <<= 8; |
| Wayne Roberts |
10:db4e11a55bda | 373 | ticks |= tcxo_buf[2]; |
| Wayne Roberts |
10:db4e11a55bda | 374 | ticks <<= 8; |
| Wayne Roberts |
10:db4e11a55bda | 375 | ticks |= tcxo_buf[3]; |
| Wayne Roberts |
10:db4e11a55bda | 376 | pc.printf("%.1f", ticks / 32.768); |
| Wayne Roberts |
10:db4e11a55bda | 377 | } |
| Wayne Roberts |
10:db4e11a55bda | 378 | |
| Wayne Roberts |
10:db4e11a55bda | 379 | bool tcxo_delay_write(const char *txt) |
| Wayne Roberts |
10:db4e11a55bda | 380 | { |
| Wayne Roberts |
10:db4e11a55bda | 381 | float ms; |
| Wayne Roberts |
10:db4e11a55bda | 382 | if (sscanf(txt, "%f", &ms) == 1) { |
| Wayne Roberts |
10:db4e11a55bda | 383 | unsigned ticks = ms * 32.768; |
| Wayne Roberts |
10:db4e11a55bda | 384 | Radio::radio.to_big_endian24(ticks, tcxo_buf+1); |
| Wayne Roberts |
10:db4e11a55bda | 385 | Radio::radio.xfer(OPCODE_SET_TCXO_MODE, 5, 0, tcxo_buf); |
| Wayne Roberts |
10:db4e11a55bda | 386 | } |
| Wayne Roberts |
10:db4e11a55bda | 387 | return false; |
| Wayne Roberts |
10:db4e11a55bda | 388 | } |
| Wayne Roberts |
10:db4e11a55bda | 389 | |
| Wayne Roberts |
10:db4e11a55bda | 390 | const value_item_t tcxo_delay_item = { _ITEM_VALUE, 5, tcxo_delay_print, tcxo_delay_write}; |
| Wayne Roberts |
10:db4e11a55bda | 391 | |
| Wayne Roberts |
10:db4e11a55bda | 392 | void recalibrate_print() { } |
| Wayne Roberts |
10:db4e11a55bda | 393 | |
| Wayne Roberts |
10:db4e11a55bda | 394 | bool recalibrate_write(const char *txt) |
| Wayne Roberts |
10:db4e11a55bda | 395 | { |
| Wayne Roberts |
10:db4e11a55bda | 396 | unsigned bits; |
| Wayne Roberts |
10:db4e11a55bda | 397 | uint8_t buf = 0; |
| Wayne Roberts |
10:db4e11a55bda | 398 | if (sscanf(txt, "%x", &bits) == 1) { |
| Wayne Roberts |
10:db4e11a55bda | 399 | buf = bits; |
| Wayne Roberts |
10:db4e11a55bda | 400 | } |
| Wayne Roberts |
10:db4e11a55bda | 401 | Radio::radio.xfer(OPCODE_CALIBRATE, 1, 0, &buf); |
| Wayne Roberts |
10:db4e11a55bda | 402 | return false; |
| Wayne Roberts |
10:db4e11a55bda | 403 | } |
| Wayne Roberts |
10:db4e11a55bda | 404 | |
| Wayne Roberts |
10:db4e11a55bda | 405 | const value_item_t recalibrate_item = { _ITEM_VALUE, 5, recalibrate_print, recalibrate_write}; |
| Wayne Roberts |
10:db4e11a55bda | 406 | |
| Wayne Roberts |
10:db4e11a55bda | 407 | |
| Wayne Roberts |
9:295e37c38fb3 | 408 | void Radio::rxBuffer_push() |
| Wayne Roberts |
9:295e37c38fb3 | 409 | { |
| Wayne Roberts |
9:295e37c38fb3 | 410 | uint8_t buf[4]; |
| Wayne Roberts |
9:295e37c38fb3 | 411 | stat_t stat; |
| Wayne Roberts |
9:295e37c38fb3 | 412 | stat.word = radio.xfer(OPCODE_GET_RX_BUFFER_STATUS, 0, 0, NULL); |
| Wayne Roberts |
9:295e37c38fb3 | 413 | stat.word = radio.xfer(0x0000, 0, 2, buf); |
| Wayne Roberts |
9:295e37c38fb3 | 414 | log_printf("rxBufferStatus:%s\r\n", radio.cmdStatus_toString(stat.bits.cmdStatus)); |
| Wayne Roberts |
9:295e37c38fb3 | 415 | if (stat.bits.cmdStatus == CMD_DAT) { |
| Wayne Roberts |
9:295e37c38fb3 | 416 | uint8_t len = buf[0]; |
| Wayne Roberts |
9:295e37c38fb3 | 417 | uint8_t offset = buf[1]; |
| Wayne Roberts |
9:295e37c38fb3 | 418 | buf[0] = offset; |
| Wayne Roberts |
9:295e37c38fb3 | 419 | buf[1] = len; |
| Wayne Roberts |
9:295e37c38fb3 | 420 | stat.word = radio.xfer(OPCODE_READ_BUFFER8, 2, 0, NULL); |
| Wayne Roberts |
9:295e37c38fb3 | 421 | log_printf("len%u ofs:%u readBuffer8cmd:%s\r\n", len, offset, radio.cmdStatus_toString(stat.bits.cmdStatus)); |
| Wayne Roberts |
9:295e37c38fb3 | 422 | stat.word = radio.xfer(0x0000, 0, len, radio.rx_buf); |
| Wayne Roberts |
9:295e37c38fb3 | 423 | log_printf("readBuffer8resp:%s\r\n", radio.cmdStatus_toString(stat.bits.cmdStatus)); |
| Wayne Roberts |
9:295e37c38fb3 | 424 | printRxPkt(len); |
| Wayne Roberts |
9:295e37c38fb3 | 425 | } |
| Wayne Roberts |
9:295e37c38fb3 | 426 | } |
| Wayne Roberts |
9:295e37c38fb3 | 427 | |
| Wayne Roberts |
9:295e37c38fb3 | 428 | const button_item_t Radio::rxBufferStatus_item = { _ITEM_BUTTON, "rxbufStat", rxBuffer_push}; |
| Wayne Roberts |
9:295e37c38fb3 | 429 | |
| Wayne Roberts |
9:295e37c38fb3 | 430 | void Radio::getStats_push(void) |
| Wayne Roberts |
9:295e37c38fb3 | 431 | { |
| Wayne Roberts |
9:295e37c38fb3 | 432 | uint8_t buf[8]; |
| Wayne Roberts |
9:295e37c38fb3 | 433 | stat_t stat; |
| Wayne Roberts |
9:295e37c38fb3 | 434 | stat.word = radio.xfer(OPCODE_GET_STATS, 0, 0, NULL); |
| Wayne Roberts |
9:295e37c38fb3 | 435 | stat.word = radio.xfer(0x0000, 0, 8, buf); |
| Wayne Roberts |
9:295e37c38fb3 | 436 | if (stat.bits.cmdStatus == CMD_DAT) { |
| Wayne Roberts |
9:295e37c38fb3 | 437 | uint8_t pktType = radio.getPacketType(); |
| Wayne Roberts |
9:295e37c38fb3 | 438 | uint16_t data1, data2, nbPktCrcErr, nbPktRx = buf[0]; |
| Wayne Roberts |
9:295e37c38fb3 | 439 | nbPktRx <<= 8; |
| Wayne Roberts |
9:295e37c38fb3 | 440 | nbPktRx |= buf[1]; |
| Wayne Roberts |
9:295e37c38fb3 | 441 | nbPktCrcErr = buf[2]; |
| Wayne Roberts |
9:295e37c38fb3 | 442 | nbPktCrcErr <<= 8; |
| Wayne Roberts |
9:295e37c38fb3 | 443 | nbPktCrcErr |= buf[3]; |
| Wayne Roberts |
9:295e37c38fb3 | 444 | data1 = buf[4]; |
| Wayne Roberts |
9:295e37c38fb3 | 445 | data1 <<= 8; |
| Wayne Roberts |
9:295e37c38fb3 | 446 | data1 |= buf[5]; |
| Wayne Roberts |
9:295e37c38fb3 | 447 | data2 = buf[6]; |
| Wayne Roberts |
9:295e37c38fb3 | 448 | data2 <<= 8; |
| Wayne Roberts |
9:295e37c38fb3 | 449 | data2 |= buf[7]; |
| Wayne Roberts |
9:295e37c38fb3 | 450 | if (pktType == PACKET_TYPE_LORA) { |
| Wayne Roberts |
10:db4e11a55bda | 451 | log_printf("nbPktRx:%u nbPktCrcErr:%u hdrErr:%u falseSync:%u\r\n", nbPktRx, nbPktCrcErr, data1, data2); |
| Wayne Roberts |
9:295e37c38fb3 | 452 | } else if (pktType == PACKET_TYPE_GFSK) { |
| Wayne Roberts |
10:db4e11a55bda | 453 | log_printf("nbPktRx:%u nbPktCrcErr:%u nbLenErr:%u\r\n", nbPktRx, nbPktCrcErr, data1); |
| Wayne Roberts |
9:295e37c38fb3 | 454 | } |
| Wayne Roberts |
9:295e37c38fb3 | 455 | } |
| Wayne Roberts |
9:295e37c38fb3 | 456 | } |
| Wayne Roberts |
9:295e37c38fb3 | 457 | |
| Wayne Roberts |
9:295e37c38fb3 | 458 | const button_item_t Radio::getStats_item = { _ITEM_BUTTON, "getStats", getStats_push}; |
| Wayne Roberts |
9:295e37c38fb3 | 459 | |
| Wayne Roberts |
9:295e37c38fb3 | 460 | |
| Wayne Roberts |
9:295e37c38fb3 | 461 | void Radio::txPkt() |
| Wayne Roberts |
9:295e37c38fb3 | 462 | { |
| Wayne Roberts |
9:295e37c38fb3 | 463 | uint8_t txlen = get_payload_length(); |
| Wayne Roberts |
9:295e37c38fb3 | 464 | radio.start_tx(txlen); |
| Wayne Roberts |
9:295e37c38fb3 | 465 | } |
| Wayne Roberts |
9:295e37c38fb3 | 466 | |
| Wayne Roberts |
9:295e37c38fb3 | 467 | void Radio::Rx() |
| Wayne Roberts |
9:295e37c38fb3 | 468 | { |
| Wayne Roberts |
9:295e37c38fb3 | 469 | stat_t stat; |
| Wayne Roberts |
9:295e37c38fb3 | 470 | uint8_t buf[3]; |
| Wayne Roberts |
10:db4e11a55bda | 471 | unsigned rx_timeout = 0xffffff; // receive until instructed not to |
| Wayne Roberts |
10:db4e11a55bda | 472 | radio.to_big_endian24(rx_timeout, buf); |
| Wayne Roberts |
9:295e37c38fb3 | 473 | stat.word = radio.xfer(OPCODE_SET_RX, 3, 0, buf); |
| Wayne Roberts |
9:295e37c38fb3 | 474 | print_stat(stat); |
| Wayne Roberts |
9:295e37c38fb3 | 475 | } |
| Wayne Roberts |
9:295e37c38fb3 | 476 | |
| Wayne Roberts |
9:295e37c38fb3 | 477 | void Radio::tx_carrier() |
| Wayne Roberts |
9:295e37c38fb3 | 478 | { |
| Wayne Roberts |
9:295e37c38fb3 | 479 | stat_t stat; |
| Wayne Roberts |
9:295e37c38fb3 | 480 | stat.word = radio.xfer(OPCODE_SET_TXCW, 0, 0, NULL); |
| Wayne Roberts |
9:295e37c38fb3 | 481 | print_stat(stat); |
| Wayne Roberts |
9:295e37c38fb3 | 482 | } |
| Wayne Roberts |
9:295e37c38fb3 | 483 | |
| Wayne Roberts |
9:295e37c38fb3 | 484 | void Radio::tx_preamble() |
| Wayne Roberts |
9:295e37c38fb3 | 485 | { |
| Wayne Roberts |
9:295e37c38fb3 | 486 | stat_t stat; |
| Wayne Roberts |
9:295e37c38fb3 | 487 | stat.word = radio.xfer(OPCODE_SET_TX_PREAMBLE, 0, 0, NULL); |
| Wayne Roberts |
9:295e37c38fb3 | 488 | print_stat(stat); |
| Wayne Roberts |
9:295e37c38fb3 | 489 | } |
| Wayne Roberts |
9:295e37c38fb3 | 490 | |
| Wayne Roberts |
9:295e37c38fb3 | 491 | void Radio::print_stat(stat_t stat) |
| Wayne Roberts |
9:295e37c38fb3 | 492 | { |
| Wayne Roberts |
9:295e37c38fb3 | 493 | char out[96]; |
| Wayne Roberts |
9:295e37c38fb3 | 494 | char str[24]; |
| Wayne Roberts |
9:295e37c38fb3 | 495 | out[0] = 0; |
| Wayne Roberts |
9:295e37c38fb3 | 496 | if (stat.bits.rfu) |
| Wayne Roberts |
9:295e37c38fb3 | 497 | strcat(out, "\e[41m"); |
| Wayne Roberts |
9:295e37c38fb3 | 498 | if ((stat.word & 0xff) != 0xff) { // xfer returns 0xff for stat2 if stat2 didnt exist |
| Wayne Roberts |
9:295e37c38fb3 | 499 | if (stat.bits.bootloader) |
| Wayne Roberts |
9:295e37c38fb3 | 500 | strcat(out, "flash "); |
| Wayne Roberts |
9:295e37c38fb3 | 501 | else |
| Wayne Roberts |
9:295e37c38fb3 | 502 | strcat(out, "bootloader "); |
| Wayne Roberts |
9:295e37c38fb3 | 503 | switch (stat.bits.chipMode) { |
| Wayne Roberts |
9:295e37c38fb3 | 504 | case 0: strcat(out, "sleep"); break; |
| Wayne Roberts |
9:295e37c38fb3 | 505 | case 1: strcat(out, "stby-rc"); break; |
| Wayne Roberts |
9:295e37c38fb3 | 506 | case 2: strcat(out, "stby-xtal"); break; |
| Wayne Roberts |
9:295e37c38fb3 | 507 | case 3: strcat(out, "\e[33mfs"); break; |
| Wayne Roberts |
9:295e37c38fb3 | 508 | case 4: strcat(out, "\e[32mrx"); break; |
| Wayne Roberts |
9:295e37c38fb3 | 509 | case 5: strcat(out, "\e[31mtx"); break; |
| Wayne Roberts |
9:295e37c38fb3 | 510 | case 6: strcat(out, "\e[36mwifi/gnss"); break; |
| Wayne Roberts |
9:295e37c38fb3 | 511 | default: |
| Wayne Roberts |
9:295e37c38fb3 | 512 | sprintf(str, "\e[31mchipmode:%u", stat.bits.chipMode); |
| Wayne Roberts |
9:295e37c38fb3 | 513 | strcat(out, str); |
| Wayne Roberts |
9:295e37c38fb3 | 514 | break; |
| Wayne Roberts |
9:295e37c38fb3 | 515 | } |
| Wayne Roberts |
9:295e37c38fb3 | 516 | strcat(out, "\e[0m "); |
| Wayne Roberts |
9:295e37c38fb3 | 517 | if (stat.bits.resetStatus) { |
| Wayne Roberts |
9:295e37c38fb3 | 518 | strcat(out, "reset:"); |
| Wayne Roberts |
9:295e37c38fb3 | 519 | switch (stat.bits.resetStatus) { |
| Wayne Roberts |
9:295e37c38fb3 | 520 | case 1: strcat(out, "analog"); break; |
| Wayne Roberts |
9:295e37c38fb3 | 521 | case 2: strcat(out, "pin"); break; |
| Wayne Roberts |
9:295e37c38fb3 | 522 | case 3: strcat(out, "system"); break; |
| Wayne Roberts |
9:295e37c38fb3 | 523 | case 4: strcat(out, "watchdog"); break; |
| Wayne Roberts |
9:295e37c38fb3 | 524 | case 5: strcat(out, "iocd"); break; |
| Wayne Roberts |
9:295e37c38fb3 | 525 | case 6: strcat(out, "rtc"); break; |
| Wayne Roberts |
9:295e37c38fb3 | 526 | default: |
| Wayne Roberts |
9:295e37c38fb3 | 527 | sprintf(str, "<%u>", stat.bits.resetStatus); |
| Wayne Roberts |
9:295e37c38fb3 | 528 | strcat(out, str); |
| Wayne Roberts |
9:295e37c38fb3 | 529 | break; |
| Wayne Roberts |
9:295e37c38fb3 | 530 | } |
| Wayne Roberts |
9:295e37c38fb3 | 531 | strcat(out, " "); |
| Wayne Roberts |
9:295e37c38fb3 | 532 | } |
| Wayne Roberts |
9:295e37c38fb3 | 533 | } // ..if stat2 exists |
| Wayne Roberts |
9:295e37c38fb3 | 534 | |
| Wayne Roberts |
9:295e37c38fb3 | 535 | sprintf(str, " %s ", radio.cmdStatus_toString(stat.bits.cmdStatus)); |
| Wayne Roberts |
9:295e37c38fb3 | 536 | strcat(out, str); |
| Wayne Roberts |
9:295e37c38fb3 | 537 | if (stat.bits.intActive) |
| Wayne Roberts |
9:295e37c38fb3 | 538 | strcat(out, "intActive "); |
| Wayne Roberts |
9:295e37c38fb3 | 539 | if (stat.bits.rfu) |
| Wayne Roberts |
9:295e37c38fb3 | 540 | strcat(out, "\e[0m"); |
| Wayne Roberts |
9:295e37c38fb3 | 541 | |
| Wayne Roberts |
9:295e37c38fb3 | 542 | log_printf("%s\r\n", out); |
| Wayne Roberts |
9:295e37c38fb3 | 543 | } |
| Wayne Roberts |
9:295e37c38fb3 | 544 | |
| Wayne Roberts |
9:295e37c38fb3 | 545 | |
| Wayne Roberts |
9:295e37c38fb3 | 546 | void Radio::set_payload_length(uint8_t len) |
| Wayne Roberts |
9:295e37c38fb3 | 547 | { |
| Wayne Roberts |
9:295e37c38fb3 | 548 | uint8_t *buf_ptr = NULL; |
| Wayne Roberts |
9:295e37c38fb3 | 549 | uint8_t buf_len = 0; |
| Wayne Roberts |
9:295e37c38fb3 | 550 | uint8_t pktType = radio.getPacketType(); |
| Wayne Roberts |
9:295e37c38fb3 | 551 | if (pktType == PACKET_TYPE_LORA) { |
| Wayne Roberts |
9:295e37c38fb3 | 552 | buf_len = 6; |
| Wayne Roberts |
9:295e37c38fb3 | 553 | buf_ptr = lora_pp_buf; |
| Wayne Roberts |
9:295e37c38fb3 | 554 | lora_pp_buf[3] = len; |
| Wayne Roberts |
9:295e37c38fb3 | 555 | } else if (pktType == PACKET_TYPE_GFSK) { |
| Wayne Roberts |
9:295e37c38fb3 | 556 | buf_len = 9; |
| Wayne Roberts |
9:295e37c38fb3 | 557 | buf_ptr = gfsk_pp_buf; |
| Wayne Roberts |
9:295e37c38fb3 | 558 | gfsk_pp_buf[6] = len; |
| Wayne Roberts |
9:295e37c38fb3 | 559 | } |
| Wayne Roberts |
9:295e37c38fb3 | 560 | radio.xfer(OPCODE_SET_PACKET_PARAM, buf_len, 0, buf_ptr); |
| Wayne Roberts |
9:295e37c38fb3 | 561 | } |
| Wayne Roberts |
9:295e37c38fb3 | 562 | |
| Wayne Roberts |
9:295e37c38fb3 | 563 | bool Radio::PaSel_read() |
| Wayne Roberts |
9:295e37c38fb3 | 564 | { |
| Wayne Roberts |
9:295e37c38fb3 | 565 | txParamsB_t txpb; |
| Wayne Roberts |
10:db4e11a55bda | 566 | radio.memRegRead(REG_ADDR_TX_PARAMS_B, 1, &txpb.dword); |
| Wayne Roberts |
9:295e37c38fb3 | 567 | pa_config_buf[0] = txpb.bits.PaSel; |
| Wayne Roberts |
9:295e37c38fb3 | 568 | return txpb.bits.PaSel; |
| Wayne Roberts |
9:295e37c38fb3 | 569 | } |
| Wayne Roberts |
9:295e37c38fb3 | 570 | |
| Wayne Roberts |
9:295e37c38fb3 | 571 | bool Radio::PaSel_push() |
| Wayne Roberts |
9:295e37c38fb3 | 572 | { |
| Wayne Roberts |
9:295e37c38fb3 | 573 | pa_config_buf[0] ^= 1; |
| Wayne Roberts |
9:295e37c38fb3 | 574 | radio.xfer(OPCODE_SET_PA_CONFIG, 4, 0, pa_config_buf); |
| Wayne Roberts |
10:db4e11a55bda | 575 | return pa_config_buf[0] == 1; |
| Wayne Roberts |
9:295e37c38fb3 | 576 | } |
| Wayne Roberts |
9:295e37c38fb3 | 577 | |
| Wayne Roberts |
9:295e37c38fb3 | 578 | const toggle_item_t Radio::PaSel_item = { _ITEM_TOGGLE, "PaSel:LP", "PaSel:HP", PaSel_read, PaSel_push}; |
| Wayne Roberts |
9:295e37c38fb3 | 579 | |
| Wayne Roberts |
9:295e37c38fb3 | 580 | bool Radio::RegPASupply_read() |
| Wayne Roberts |
9:295e37c38fb3 | 581 | { |
| Wayne Roberts |
9:295e37c38fb3 | 582 | txParamsA_t tpa; |
| Wayne Roberts |
10:db4e11a55bda | 583 | radio.memRegRead(REG_ADDR_TX_PARAMS_A, 1, &tpa.dword); |
| Wayne Roberts |
9:295e37c38fb3 | 584 | pa_config_buf[1] = tpa.bits.RegPASupply; |
| Wayne Roberts |
9:295e37c38fb3 | 585 | return tpa.bits.RegPASupply; |
| Wayne Roberts |
9:295e37c38fb3 | 586 | } |
| Wayne Roberts |
9:295e37c38fb3 | 587 | |
| Wayne Roberts |
9:295e37c38fb3 | 588 | bool Radio::RegPASupply_push(void) |
| Wayne Roberts |
9:295e37c38fb3 | 589 | { |
| Wayne Roberts |
10:db4e11a55bda | 590 | pa_config_buf[1] ^= 1; |
| Wayne Roberts |
9:295e37c38fb3 | 591 | radio.xfer(OPCODE_SET_PA_CONFIG, 4, 0, pa_config_buf); |
| Wayne Roberts |
10:db4e11a55bda | 592 | return pa_config_buf[1] == 1; |
| Wayne Roberts |
9:295e37c38fb3 | 593 | } |
| Wayne Roberts |
9:295e37c38fb3 | 594 | |
| Wayne Roberts |
9:295e37c38fb3 | 595 | const toggle_item_t Radio::RegPASupply_item = { _ITEM_TOGGLE, |
| Wayne Roberts |
9:295e37c38fb3 | 596 | "PASupply:intreg", |
| Wayne Roberts |
9:295e37c38fb3 | 597 | "PASupply:vbat ", |
| Wayne Roberts |
9:295e37c38fb3 | 598 | RegPASupply_read, |
| Wayne Roberts |
9:295e37c38fb3 | 599 | RegPASupply_push |
| Wayne Roberts |
9:295e37c38fb3 | 600 | }; |
| Wayne Roberts |
9:295e37c38fb3 | 601 | |
| Wayne Roberts |
9:295e37c38fb3 | 602 | void Radio::PaDutyCycle_print() |
| Wayne Roberts |
9:295e37c38fb3 | 603 | { |
| Wayne Roberts |
9:295e37c38fb3 | 604 | txParamsB_t tpb; |
| Wayne Roberts |
10:db4e11a55bda | 605 | radio.memRegRead(REG_ADDR_TX_PARAMS_B, 1, &tpb.dword); |
| Wayne Roberts |
9:295e37c38fb3 | 606 | pa_config_buf[2] = tpb.bits.PaDutyCycle; |
| Wayne Roberts |
9:295e37c38fb3 | 607 | pc.printf("%u", tpb.bits.PaDutyCycle); |
| Wayne Roberts |
9:295e37c38fb3 | 608 | } |
| Wayne Roberts |
9:295e37c38fb3 | 609 | |
| Wayne Roberts |
9:295e37c38fb3 | 610 | bool Radio::PaDutyCycle_write(const char *txt) |
| Wayne Roberts |
9:295e37c38fb3 | 611 | { |
| Wayne Roberts |
9:295e37c38fb3 | 612 | unsigned n; |
| Wayne Roberts |
9:295e37c38fb3 | 613 | if (sscanf(txt, "%u", &n) == 1) { |
| Wayne Roberts |
9:295e37c38fb3 | 614 | pa_config_buf[2] = n; |
| Wayne Roberts |
9:295e37c38fb3 | 615 | radio.xfer(OPCODE_SET_PA_CONFIG, 4, 0, pa_config_buf); |
| Wayne Roberts |
9:295e37c38fb3 | 616 | } |
| Wayne Roberts |
9:295e37c38fb3 | 617 | return false; |
| Wayne Roberts |
9:295e37c38fb3 | 618 | } |
| Wayne Roberts |
9:295e37c38fb3 | 619 | |
| Wayne Roberts |
9:295e37c38fb3 | 620 | const value_item_t Radio::PaDutyCycle_item = { _ITEM_VALUE, 3, PaDutyCycle_print, PaDutyCycle_write}; |
| Wayne Roberts |
9:295e37c38fb3 | 621 | |
| Wayne Roberts |
9:295e37c38fb3 | 622 | void Radio::PaHPSel_print() |
| Wayne Roberts |
9:295e37c38fb3 | 623 | { |
| Wayne Roberts |
9:295e37c38fb3 | 624 | txParamsB_t tpb; |
| Wayne Roberts |
10:db4e11a55bda | 625 | radio.memRegRead(REG_ADDR_TX_PARAMS_B, 1, &tpb.dword); |
| Wayne Roberts |
9:295e37c38fb3 | 626 | pa_config_buf[3] = tpb.bits.PaHPSel; |
| Wayne Roberts |
9:295e37c38fb3 | 627 | pc.printf("%u", tpb.bits.PaHPSel); |
| Wayne Roberts |
9:295e37c38fb3 | 628 | } |
| Wayne Roberts |
9:295e37c38fb3 | 629 | |
| Wayne Roberts |
9:295e37c38fb3 | 630 | bool Radio::PaHPSel_write(const char *txt) |
| Wayne Roberts |
9:295e37c38fb3 | 631 | { |
| Wayne Roberts |
9:295e37c38fb3 | 632 | unsigned n; |
| Wayne Roberts |
9:295e37c38fb3 | 633 | if (sscanf(txt, "%u", &n) == 1) { |
| Wayne Roberts |
9:295e37c38fb3 | 634 | pa_config_buf[3] = n; |
| Wayne Roberts |
9:295e37c38fb3 | 635 | radio.xfer(OPCODE_SET_PA_CONFIG, 4, 0, pa_config_buf); |
| Wayne Roberts |
9:295e37c38fb3 | 636 | } |
| Wayne Roberts |
9:295e37c38fb3 | 637 | return false; |
| Wayne Roberts |
9:295e37c38fb3 | 638 | } |
| Wayne Roberts |
9:295e37c38fb3 | 639 | |
| Wayne Roberts |
9:295e37c38fb3 | 640 | const value_item_t Radio::PaHPSel_item = { _ITEM_VALUE, 3, PaHPSel_print, PaHPSel_write}; |
| Wayne Roberts |
9:295e37c38fb3 | 641 | |
| Wayne Roberts |
9:295e37c38fb3 | 642 | |
| Wayne Roberts |
9:295e37c38fb3 | 643 | void Radio::wifiScan_push() |
| Wayne Roberts |
9:295e37c38fb3 | 644 | { |
| Wayne Roberts |
9:295e37c38fb3 | 645 | radio.xfer(OPCODE_WIFI_SCAN, 9, 0, wifiScan_buf); |
| Wayne Roberts |
10:db4e11a55bda | 646 | log_printf("wifiScan...\r\n"); |
| Wayne Roberts |
9:295e37c38fb3 | 647 | } |
| Wayne Roberts |
9:295e37c38fb3 | 648 | |
| Wayne Roberts |
9:295e37c38fb3 | 649 | const char* const wifitype_strs[] = |
| Wayne Roberts |
9:295e37c38fb3 | 650 | { |
| Wayne Roberts |
9:295e37c38fb3 | 651 | "802.11b", // 1 |
| Wayne Roberts |
9:295e37c38fb3 | 652 | "802.11g", // 2 |
| Wayne Roberts |
9:295e37c38fb3 | 653 | "802.11n", // 3 |
| Wayne Roberts |
9:295e37c38fb3 | 654 | " all ", // 4 |
| Wayne Roberts |
9:295e37c38fb3 | 655 | NULL |
| Wayne Roberts |
9:295e37c38fb3 | 656 | }; |
| Wayne Roberts |
9:295e37c38fb3 | 657 | |
| Wayne Roberts |
9:295e37c38fb3 | 658 | unsigned wifitype_read(bool for_writing) |
| Wayne Roberts |
9:295e37c38fb3 | 659 | { |
| Wayne Roberts |
9:295e37c38fb3 | 660 | return wifiScan_buf[0] - 1; |
| Wayne Roberts |
9:295e37c38fb3 | 661 | } |
| Wayne Roberts |
9:295e37c38fb3 | 662 | |
| Wayne Roberts |
9:295e37c38fb3 | 663 | menuMode_e wifitype_write(unsigned sidx) |
| Wayne Roberts |
9:295e37c38fb3 | 664 | { |
| Wayne Roberts |
9:295e37c38fb3 | 665 | wifiScan_buf[0] = sidx + 1; |
| Wayne Roberts |
9:295e37c38fb3 | 666 | return MENUMODE_REDRAW; |
| Wayne Roberts |
9:295e37c38fb3 | 667 | } |
| Wayne Roberts |
9:295e37c38fb3 | 668 | |
| Wayne Roberts |
9:295e37c38fb3 | 669 | const dropdown_item_t wifiType_item = { _ITEM_DROPDOWN, wifitype_strs, wifitype_strs, wifitype_read, wifitype_write }; |
| Wayne Roberts |
9:295e37c38fb3 | 670 | |
| Wayne Roberts |
9:295e37c38fb3 | 671 | bool wifiAcqMode_read() |
| Wayne Roberts |
9:295e37c38fb3 | 672 | { |
| Wayne Roberts |
9:295e37c38fb3 | 673 | return wifiScan_buf[3] == 2; |
| Wayne Roberts |
9:295e37c38fb3 | 674 | } |
| Wayne Roberts |
9:295e37c38fb3 | 675 | |
| Wayne Roberts |
9:295e37c38fb3 | 676 | bool wifiAcqMode_push() |
| Wayne Roberts |
9:295e37c38fb3 | 677 | { |
| Wayne Roberts |
9:295e37c38fb3 | 678 | wifiScan_buf[3] == 2 ? wifiScan_buf[3] = 1 : wifiScan_buf[3] = 2; |
| Wayne Roberts |
9:295e37c38fb3 | 679 | return wifiScan_buf[3] == 2; |
| Wayne Roberts |
9:295e37c38fb3 | 680 | } |
| Wayne Roberts |
9:295e37c38fb3 | 681 | |
| Wayne Roberts |
9:295e37c38fb3 | 682 | const toggle_item_t wifiAcqMode_item = { _ITEM_TOGGLE, |
| Wayne Roberts |
9:295e37c38fb3 | 683 | "beacon-only ", |
| Wayne Roberts |
9:295e37c38fb3 | 684 | "beacon+Packet", |
| Wayne Roberts |
9:295e37c38fb3 | 685 | wifiAcqMode_read, |
| Wayne Roberts |
9:295e37c38fb3 | 686 | wifiAcqMode_push |
| Wayne Roberts |
9:295e37c38fb3 | 687 | }; |
| Wayne Roberts |
9:295e37c38fb3 | 688 | |
| Wayne Roberts |
9:295e37c38fb3 | 689 | void wifiNbMaxRes_print() |
| Wayne Roberts |
9:295e37c38fb3 | 690 | { |
| Wayne Roberts |
9:295e37c38fb3 | 691 | pc.printf("%u", wifiScan_buf[4]); |
| Wayne Roberts |
9:295e37c38fb3 | 692 | } |
| Wayne Roberts |
9:295e37c38fb3 | 693 | |
| Wayne Roberts |
9:295e37c38fb3 | 694 | bool wifiNbMaxRes_write(const char *txt) |
| Wayne Roberts |
9:295e37c38fb3 | 695 | { |
| Wayne Roberts |
9:295e37c38fb3 | 696 | unsigned n; |
| Wayne Roberts |
9:295e37c38fb3 | 697 | sscanf(txt, "%u", &n); |
| Wayne Roberts |
9:295e37c38fb3 | 698 | wifiScan_buf[4] = n; |
| Wayne Roberts |
9:295e37c38fb3 | 699 | return false; |
| Wayne Roberts |
9:295e37c38fb3 | 700 | } |
| Wayne Roberts |
9:295e37c38fb3 | 701 | |
| Wayne Roberts |
9:295e37c38fb3 | 702 | const value_item_t wifiNbMaxRes_item = { _ITEM_VALUE, 3, wifiNbMaxRes_print, wifiNbMaxRes_write}; |
| Wayne Roberts |
9:295e37c38fb3 | 703 | |
| Wayne Roberts |
9:295e37c38fb3 | 704 | void wifiNbScanPerChan_print() |
| Wayne Roberts |
9:295e37c38fb3 | 705 | { |
| Wayne Roberts |
9:295e37c38fb3 | 706 | pc.printf("%u", wifiScan_buf[5]); |
| Wayne Roberts |
9:295e37c38fb3 | 707 | } |
| Wayne Roberts |
9:295e37c38fb3 | 708 | |
| Wayne Roberts |
9:295e37c38fb3 | 709 | bool wifiNbScanPerChan_write(const char *txt) |
| Wayne Roberts |
9:295e37c38fb3 | 710 | { |
| Wayne Roberts |
9:295e37c38fb3 | 711 | unsigned n; |
| Wayne Roberts |
9:295e37c38fb3 | 712 | sscanf(txt, "%u", &n); |
| Wayne Roberts |
9:295e37c38fb3 | 713 | wifiScan_buf[5] = n; |
| Wayne Roberts |
9:295e37c38fb3 | 714 | return false; |
| Wayne Roberts |
9:295e37c38fb3 | 715 | } |
| Wayne Roberts |
9:295e37c38fb3 | 716 | |
| Wayne Roberts |
9:295e37c38fb3 | 717 | const value_item_t wifiNbScanPerChan_item = { _ITEM_VALUE, 3, wifiNbScanPerChan_print, wifiNbScanPerChan_write}; |
| Wayne Roberts |
9:295e37c38fb3 | 718 | |
| Wayne Roberts |
9:295e37c38fb3 | 719 | |
| Wayne Roberts |
9:295e37c38fb3 | 720 | |
| Wayne Roberts |
9:295e37c38fb3 | 721 | const button_item_t Radio::wifiScan_item = { _ITEM_BUTTON, "wifiScan", wifiScan_push }; |
| Wayne Roberts |
9:295e37c38fb3 | 722 | |
| Wayne Roberts |
9:295e37c38fb3 | 723 | bool wifi_ch14_read() { return (wifiScan_buf[1] & 0x20) == 0x20; } |
| Wayne Roberts |
9:295e37c38fb3 | 724 | bool wifi_ch14_push() { wifiScan_buf[1] ^= 0x20; return wifi_ch14_read(); } |
| Wayne Roberts |
9:295e37c38fb3 | 725 | const toggle_item_t wifi_ch14_item = { _ITEM_TOGGLE, "ch14", NULL, wifi_ch14_read, wifi_ch14_push}; |
| Wayne Roberts |
9:295e37c38fb3 | 726 | |
| Wayne Roberts |
9:295e37c38fb3 | 727 | bool wifi_ch13_read() { return (wifiScan_buf[1] & 0x10) == 0x10; } |
| Wayne Roberts |
9:295e37c38fb3 | 728 | bool wifi_ch13_push() { wifiScan_buf[1] ^= 0x10; return wifi_ch13_read(); } |
| Wayne Roberts |
9:295e37c38fb3 | 729 | const toggle_item_t wifi_ch13_item = { _ITEM_TOGGLE, "ch13", NULL, wifi_ch13_read, wifi_ch13_push}; |
| Wayne Roberts |
9:295e37c38fb3 | 730 | |
| Wayne Roberts |
9:295e37c38fb3 | 731 | bool wifi_ch12_read() { return (wifiScan_buf[1] & 0x08) == 0x08; } |
| Wayne Roberts |
9:295e37c38fb3 | 732 | bool wifi_ch12_push() { wifiScan_buf[1] ^= 0x08; return wifi_ch12_read(); } |
| Wayne Roberts |
9:295e37c38fb3 | 733 | const toggle_item_t wifi_ch12_item = { _ITEM_TOGGLE, "ch12", NULL, wifi_ch12_read, wifi_ch12_push}; |
| Wayne Roberts |
9:295e37c38fb3 | 734 | |
| Wayne Roberts |
9:295e37c38fb3 | 735 | bool wifi_ch11_read() { return (wifiScan_buf[1] & 0x04) == 0x04; } |
| Wayne Roberts |
9:295e37c38fb3 | 736 | bool wifi_ch11_push() { wifiScan_buf[1] ^= 0x08; return wifi_ch11_read(); } |
| Wayne Roberts |
9:295e37c38fb3 | 737 | const toggle_item_t wifi_ch11_item = { _ITEM_TOGGLE, "ch11", NULL, wifi_ch11_read, wifi_ch11_push}; |
| Wayne Roberts |
9:295e37c38fb3 | 738 | |
| Wayne Roberts |
9:295e37c38fb3 | 739 | bool wifi_ch10_read() { return (wifiScan_buf[1] & 0x02) == 0x02; } |
| Wayne Roberts |
9:295e37c38fb3 | 740 | bool wifi_ch10_push() { wifiScan_buf[1] ^= 0x02; return wifi_ch10_read(); } |
| Wayne Roberts |
9:295e37c38fb3 | 741 | const toggle_item_t wifi_ch10_item = { _ITEM_TOGGLE, "ch10", NULL, wifi_ch10_read, wifi_ch10_push}; |
| Wayne Roberts |
9:295e37c38fb3 | 742 | |
| Wayne Roberts |
9:295e37c38fb3 | 743 | bool wifi_ch9_read() { return (wifiScan_buf[1] & 0x01) == 0x01; } |
| Wayne Roberts |
9:295e37c38fb3 | 744 | bool wifi_ch9_push() { wifiScan_buf[1] ^= 0x01; return wifi_ch9_read(); } |
| Wayne Roberts |
9:295e37c38fb3 | 745 | const toggle_item_t wifi_ch9_item = { _ITEM_TOGGLE, "ch9", NULL, wifi_ch9_read, wifi_ch9_push}; |
| Wayne Roberts |
9:295e37c38fb3 | 746 | |
| Wayne Roberts |
9:295e37c38fb3 | 747 | bool wifi_ch8_read() { return (wifiScan_buf[2] & 0x80) == 0x80; } |
| Wayne Roberts |
9:295e37c38fb3 | 748 | bool wifi_ch8_push() { wifiScan_buf[2] ^= 0x80; return wifi_ch8_read(); } |
| Wayne Roberts |
9:295e37c38fb3 | 749 | const toggle_item_t wifi_ch8_item = { _ITEM_TOGGLE, "ch8", NULL, wifi_ch8_read, wifi_ch8_push}; |
| Wayne Roberts |
9:295e37c38fb3 | 750 | |
| Wayne Roberts |
9:295e37c38fb3 | 751 | bool wifi_ch7_read() { return (wifiScan_buf[2] & 0x40) == 0x40; } |
| Wayne Roberts |
9:295e37c38fb3 | 752 | bool wifi_ch7_push() { wifiScan_buf[2] ^= 0x40; return wifi_ch7_read(); } |
| Wayne Roberts |
9:295e37c38fb3 | 753 | const toggle_item_t wifi_ch7_item = { _ITEM_TOGGLE, "ch7", NULL, wifi_ch7_read, wifi_ch7_push}; |
| Wayne Roberts |
9:295e37c38fb3 | 754 | |
| Wayne Roberts |
9:295e37c38fb3 | 755 | bool wifi_ch6_read() { return (wifiScan_buf[2] & 0x20) == 0x20; } |
| Wayne Roberts |
9:295e37c38fb3 | 756 | bool wifi_ch6_push() { wifiScan_buf[2] ^= 0x20; return wifi_ch6_read(); } |
| Wayne Roberts |
9:295e37c38fb3 | 757 | const toggle_item_t wifi_ch6_item = { _ITEM_TOGGLE, "ch6", NULL, wifi_ch6_read, wifi_ch6_push}; |
| Wayne Roberts |
9:295e37c38fb3 | 758 | |
| Wayne Roberts |
9:295e37c38fb3 | 759 | bool wifi_ch5_read() { return (wifiScan_buf[2] & 0x10) == 0x10; } |
| Wayne Roberts |
9:295e37c38fb3 | 760 | bool wifi_ch5_push() { wifiScan_buf[2] ^= 0x10; return wifi_ch5_read(); } |
| Wayne Roberts |
9:295e37c38fb3 | 761 | const toggle_item_t wifi_ch5_item = { _ITEM_TOGGLE, "ch5", NULL, wifi_ch5_read, wifi_ch5_push}; |
| Wayne Roberts |
9:295e37c38fb3 | 762 | |
| Wayne Roberts |
10:db4e11a55bda | 763 | bool wifi_ch4_read() { return (wifiScan_buf[2] & 0x08) == 0x08; } |
| Wayne Roberts |
10:db4e11a55bda | 764 | bool wifi_ch4_push() { wifiScan_buf[2] ^= 0x08; return wifi_ch4_read(); } |
| Wayne Roberts |
10:db4e11a55bda | 765 | const toggle_item_t wifi_ch4_item = { _ITEM_TOGGLE, "ch4", NULL, wifi_ch4_read, wifi_ch4_push}; |
| Wayne Roberts |
10:db4e11a55bda | 766 | |
| Wayne Roberts |
10:db4e11a55bda | 767 | bool wifi_ch3_read() { return (wifiScan_buf[2] & 0x04) == 0x04; } |
| Wayne Roberts |
10:db4e11a55bda | 768 | bool wifi_ch3_push() { wifiScan_buf[2] ^= 0x04; return wifi_ch3_read(); } |
| Wayne Roberts |
10:db4e11a55bda | 769 | const toggle_item_t wifi_ch3_item = { _ITEM_TOGGLE, "ch3", NULL, wifi_ch3_read, wifi_ch3_push}; |
| Wayne Roberts |
10:db4e11a55bda | 770 | |
| Wayne Roberts |
10:db4e11a55bda | 771 | bool wifi_ch2_read() { return (wifiScan_buf[2] & 0x02) == 0x02; } |
| Wayne Roberts |
10:db4e11a55bda | 772 | bool wifi_ch2_push() { wifiScan_buf[2] ^= 0x02; return wifi_ch2_read(); } |
| Wayne Roberts |
10:db4e11a55bda | 773 | const toggle_item_t wifi_ch2_item = { _ITEM_TOGGLE, "ch2", NULL, wifi_ch2_read, wifi_ch2_push}; |
| Wayne Roberts |
10:db4e11a55bda | 774 | |
| Wayne Roberts |
10:db4e11a55bda | 775 | bool wifi_ch1_read() { return (wifiScan_buf[2] & 0x01) == 0x01; } |
| Wayne Roberts |
10:db4e11a55bda | 776 | bool wifi_ch1_push() { wifiScan_buf[2] ^= 0x01; return wifi_ch1_read(); } |
| Wayne Roberts |
10:db4e11a55bda | 777 | const toggle_item_t wifi_ch1_item = { _ITEM_TOGGLE, "ch1", NULL, wifi_ch1_read, wifi_ch1_push}; |
| Wayne Roberts |
10:db4e11a55bda | 778 | |
| Wayne Roberts |
10:db4e11a55bda | 779 | void wifiTimeout_print(void) |
| Wayne Roberts |
10:db4e11a55bda | 780 | { |
| Wayne Roberts |
10:db4e11a55bda | 781 | unsigned t; |
| Wayne Roberts |
10:db4e11a55bda | 782 | t = wifiScan_buf[6]; |
| Wayne Roberts |
10:db4e11a55bda | 783 | t <<= 8; |
| Wayne Roberts |
10:db4e11a55bda | 784 | t |= wifiScan_buf[7]; |
| Wayne Roberts |
10:db4e11a55bda | 785 | pc.printf("%u", t); |
| Wayne Roberts |
10:db4e11a55bda | 786 | } |
| Wayne Roberts |
10:db4e11a55bda | 787 | |
| Wayne Roberts |
10:db4e11a55bda | 788 | bool wifiTimeout_write(const char *txt) |
| Wayne Roberts |
10:db4e11a55bda | 789 | { |
| Wayne Roberts |
10:db4e11a55bda | 790 | unsigned t; |
| Wayne Roberts |
10:db4e11a55bda | 791 | sscanf(txt, "%u", &t); |
| Wayne Roberts |
10:db4e11a55bda | 792 | wifiScan_buf[7] = t; |
| Wayne Roberts |
10:db4e11a55bda | 793 | t >>= 8; |
| Wayne Roberts |
10:db4e11a55bda | 794 | wifiScan_buf[6] = t; |
| Wayne Roberts |
10:db4e11a55bda | 795 | return false; |
| Wayne Roberts |
10:db4e11a55bda | 796 | } |
| Wayne Roberts |
10:db4e11a55bda | 797 | |
| Wayne Roberts |
10:db4e11a55bda | 798 | const value_item_t wifiTimeout_item = { _ITEM_VALUE, 6, wifiTimeout_print, wifiTimeout_write}; |
| Wayne Roberts |
10:db4e11a55bda | 799 | |
| Wayne Roberts |
10:db4e11a55bda | 800 | bool AbortOnTimeout_read() |
| Wayne Roberts |
10:db4e11a55bda | 801 | { |
| Wayne Roberts |
10:db4e11a55bda | 802 | return wifiScan_buf[8] == 1; |
| Wayne Roberts |
10:db4e11a55bda | 803 | } |
| Wayne Roberts |
10:db4e11a55bda | 804 | |
| Wayne Roberts |
10:db4e11a55bda | 805 | bool AbortOnTimeout_push() |
| Wayne Roberts |
10:db4e11a55bda | 806 | { |
| Wayne Roberts |
10:db4e11a55bda | 807 | wifiScan_buf[8] ^= 1; |
| Wayne Roberts |
10:db4e11a55bda | 808 | return wifiScan_buf[8] == 1; |
| Wayne Roberts |
10:db4e11a55bda | 809 | } |
| Wayne Roberts |
10:db4e11a55bda | 810 | |
| Wayne Roberts |
10:db4e11a55bda | 811 | const toggle_item_t wifiAbort_item = { _ITEM_TOGGLE, "AbortOnTimeout", NULL, AbortOnTimeout_read, AbortOnTimeout_push}; |
| Wayne Roberts |
10:db4e11a55bda | 812 | |
| Wayne Roberts |
10:db4e11a55bda | 813 | bool wifiResultFormat_read() |
| Wayne Roberts |
10:db4e11a55bda | 814 | { |
| Wayne Roberts |
10:db4e11a55bda | 815 | // false=full, true=basic |
| Wayne Roberts |
10:db4e11a55bda | 816 | return wifiResultFormatBasic; |
| Wayne Roberts |
10:db4e11a55bda | 817 | } |
| Wayne Roberts |
10:db4e11a55bda | 818 | |
| Wayne Roberts |
10:db4e11a55bda | 819 | bool wifiResultFormat_push() |
| Wayne Roberts |
10:db4e11a55bda | 820 | { |
| Wayne Roberts |
10:db4e11a55bda | 821 | // false=full, true=basic |
| Wayne Roberts |
10:db4e11a55bda | 822 | wifiResultFormatBasic ^= true; |
| Wayne Roberts |
10:db4e11a55bda | 823 | return wifiResultFormatBasic; |
| Wayne Roberts |
10:db4e11a55bda | 824 | } |
| Wayne Roberts |
10:db4e11a55bda | 825 | |
| Wayne Roberts |
10:db4e11a55bda | 826 | const toggle_item_t wifiResultFormat_item = { _ITEM_TOGGLE, |
| Wayne Roberts |
10:db4e11a55bda | 827 | "full ", |
| Wayne Roberts |
10:db4e11a55bda | 828 | "basic", |
| Wayne Roberts |
10:db4e11a55bda | 829 | wifiResultFormat_read, |
| Wayne Roberts |
10:db4e11a55bda | 830 | wifiResultFormat_push |
| Wayne Roberts |
10:db4e11a55bda | 831 | }; |
| Wayne Roberts |
10:db4e11a55bda | 832 | |
| Wayne Roberts |
9:295e37c38fb3 | 833 | void Radio::gnssAutonomous_push() |
| Wayne Roberts |
9:295e37c38fb3 | 834 | { |
| Wayne Roberts |
9:295e37c38fb3 | 835 | gnssAutonomous_buf[4] = 0; // EffortMode |
| Wayne Roberts |
9:295e37c38fb3 | 836 | radio.xfer(OPCODE_GNSS_AUTONOMOUS, 7, 0, gnssAutonomous_buf); |
| Wayne Roberts |
10:db4e11a55bda | 837 | log_printf("gnssAutonomous...\r\n"); |
| Wayne Roberts |
9:295e37c38fb3 | 838 | } |
| Wayne Roberts |
9:295e37c38fb3 | 839 | |
| Wayne Roberts |
9:295e37c38fb3 | 840 | const button_item_t Radio::gnssAutonomous_item = { _ITEM_BUTTON, "gnssAutonomous", gnssAutonomous_push }; |
| Wayne Roberts |
9:295e37c38fb3 | 841 | |
| Wayne Roberts |
10:db4e11a55bda | 842 | void gnssAutonomous_time_print() |
| Wayne Roberts |
9:295e37c38fb3 | 843 | { |
| Wayne Roberts |
10:db4e11a55bda | 844 | unsigned t = Radio::radio.from_big_endian32(gnssAutonomous_buf); |
| Wayne Roberts |
9:295e37c38fb3 | 845 | pc.printf("%u", t); |
| Wayne Roberts |
9:295e37c38fb3 | 846 | } |
| Wayne Roberts |
9:295e37c38fb3 | 847 | |
| Wayne Roberts |
10:db4e11a55bda | 848 | bool gnssAutonomous_time_write(const char *txt) |
| Wayne Roberts |
10:db4e11a55bda | 849 | { |
| Wayne Roberts |
10:db4e11a55bda | 850 | unsigned t; |
| Wayne Roberts |
10:db4e11a55bda | 851 | if (sscanf(txt, "%u", &t) == 1) { |
| Wayne Roberts |
10:db4e11a55bda | 852 | Radio::radio.to_big_endian32(t, gnssAutonomous_buf); |
| Wayne Roberts |
10:db4e11a55bda | 853 | } |
| Wayne Roberts |
10:db4e11a55bda | 854 | return false; |
| Wayne Roberts |
10:db4e11a55bda | 855 | } |
| Wayne Roberts |
10:db4e11a55bda | 856 | |
| Wayne Roberts |
10:db4e11a55bda | 857 | |
| Wayne Roberts |
10:db4e11a55bda | 858 | bool gnssAutoResultTimeStamp_read() |
| Wayne Roberts |
10:db4e11a55bda | 859 | { |
| Wayne Roberts |
10:db4e11a55bda | 860 | return (gnssAutonomous_buf[5] & 0x01) == 0x01; |
| Wayne Roberts |
10:db4e11a55bda | 861 | } |
| Wayne Roberts |
10:db4e11a55bda | 862 | bool gnssAutoResultTimeStamp_push() |
| Wayne Roberts |
10:db4e11a55bda | 863 | { |
| Wayne Roberts |
10:db4e11a55bda | 864 | gnssAutonomous_buf[5] ^= 0x01; |
| Wayne Roberts |
10:db4e11a55bda | 865 | return (gnssAutonomous_buf[5] & 0x01) == 0x01; |
| Wayne Roberts |
10:db4e11a55bda | 866 | } |
| Wayne Roberts |
10:db4e11a55bda | 867 | const toggle_item_t gnssAutoResultTimeStamp_item = { _ITEM_TOGGLE, "timestamp", NULL, gnssAutoResultTimeStamp_read, gnssAutoResultTimeStamp_push}; |
| Wayne Roberts |
10:db4e11a55bda | 868 | |
| Wayne Roberts |
10:db4e11a55bda | 869 | bool gnssAutoResultDoppler_read() |
| Wayne Roberts |
10:db4e11a55bda | 870 | { |
| Wayne Roberts |
10:db4e11a55bda | 871 | return (gnssAutonomous_buf[5] & 0x02) == 0x02; |
| Wayne Roberts |
10:db4e11a55bda | 872 | } |
| Wayne Roberts |
10:db4e11a55bda | 873 | bool gnssAutoResultDoppler_push() |
| Wayne Roberts |
10:db4e11a55bda | 874 | { |
| Wayne Roberts |
10:db4e11a55bda | 875 | gnssAutonomous_buf[5] ^= 0x02; |
| Wayne Roberts |
10:db4e11a55bda | 876 | return (gnssAutonomous_buf[5] & 0x02) == 0x02; |
| Wayne Roberts |
10:db4e11a55bda | 877 | } |
| Wayne Roberts |
10:db4e11a55bda | 878 | const toggle_item_t gnssAutoResultDoppler_item = { _ITEM_TOGGLE, "doppler", NULL, gnssAutoResultDoppler_read, gnssAutoResultDoppler_push}; |
| Wayne Roberts |
10:db4e11a55bda | 879 | |
| Wayne Roberts |
10:db4e11a55bda | 880 | bool gnssAutoResultBitChange_read() |
| Wayne Roberts |
10:db4e11a55bda | 881 | { |
| Wayne Roberts |
10:db4e11a55bda | 882 | return (gnssAutonomous_buf[5] & 0x04) == 0x04; |
| Wayne Roberts |
10:db4e11a55bda | 883 | } |
| Wayne Roberts |
10:db4e11a55bda | 884 | bool gnssAutoResultBitChange_push() |
| Wayne Roberts |
10:db4e11a55bda | 885 | { |
| Wayne Roberts |
10:db4e11a55bda | 886 | gnssAutonomous_buf[5] ^= 0x04; |
| Wayne Roberts |
10:db4e11a55bda | 887 | return (gnssAutonomous_buf[5] & 0x04) == 0x04; |
| Wayne Roberts |
10:db4e11a55bda | 888 | } |
| Wayne Roberts |
10:db4e11a55bda | 889 | const toggle_item_t gnssAutoResultBitChange_item = { _ITEM_TOGGLE, "bit change", NULL, gnssAutoResultBitChange_read, gnssAutoResultBitChange_push}; |
| Wayne Roberts |
10:db4e11a55bda | 890 | |
| Wayne Roberts |
10:db4e11a55bda | 891 | void gnssAutoNbSvMax_print() |
| Wayne Roberts |
10:db4e11a55bda | 892 | { |
| Wayne Roberts |
10:db4e11a55bda | 893 | pc.printf("%u", gnssAutonomous_buf[6]); |
| Wayne Roberts |
10:db4e11a55bda | 894 | } |
| Wayne Roberts |
10:db4e11a55bda | 895 | |
| Wayne Roberts |
10:db4e11a55bda | 896 | bool gnssAutoNbSvMax_write(const char *txt) |
| Wayne Roberts |
10:db4e11a55bda | 897 | { |
| Wayne Roberts |
10:db4e11a55bda | 898 | unsigned n; |
| Wayne Roberts |
10:db4e11a55bda | 899 | sscanf(txt, "%u", &n); |
| Wayne Roberts |
10:db4e11a55bda | 900 | gnssAutonomous_buf[6] = n; |
| Wayne Roberts |
10:db4e11a55bda | 901 | return false; |
| Wayne Roberts |
10:db4e11a55bda | 902 | } |
| Wayne Roberts |
10:db4e11a55bda | 903 | |
| Wayne Roberts |
10:db4e11a55bda | 904 | const value_item_t gnssAutoNbSvMax_item = { _ITEM_VALUE, 3, gnssAutoNbSvMax_print, gnssAutoNbSvMax_write}; |
| Wayne Roberts |
10:db4e11a55bda | 905 | |
| Wayne Roberts |
10:db4e11a55bda | 906 | const value_item_t gnssAutonomous_time_item = { _ITEM_VALUE, 9, gnssAutonomous_time_print, gnssAutonomous_time_write}; |
| Wayne Roberts |
10:db4e11a55bda | 907 | |
| Wayne Roberts |
10:db4e11a55bda | 908 | void Radio::gnssAssisted_push() |
| Wayne Roberts |
10:db4e11a55bda | 909 | { |
| Wayne Roberts |
10:db4e11a55bda | 910 | gnssAssisted_buf[5] = 3; // ResultMask |
| Wayne Roberts |
10:db4e11a55bda | 911 | radio.xfer(OPCODE_GNSS_ASSISTED, 7, 0, gnssAssisted_buf); |
| Wayne Roberts |
10:db4e11a55bda | 912 | log_printf("gnssAssisted...\r\n"); |
| Wayne Roberts |
10:db4e11a55bda | 913 | } |
| Wayne Roberts |
10:db4e11a55bda | 914 | |
| Wayne Roberts |
10:db4e11a55bda | 915 | const button_item_t Radio::gnssAssisted_item = { _ITEM_BUTTON, "gnssAssisted", gnssAssisted_push}; |
| Wayne Roberts |
10:db4e11a55bda | 916 | |
| Wayne Roberts |
10:db4e11a55bda | 917 | void gnssAssisted_time_print() |
| Wayne Roberts |
10:db4e11a55bda | 918 | { |
| Wayne Roberts |
10:db4e11a55bda | 919 | unsigned t = Radio::radio.from_big_endian32(gnssAssisted_buf); |
| Wayne Roberts |
10:db4e11a55bda | 920 | pc.printf("%u", t); |
| Wayne Roberts |
10:db4e11a55bda | 921 | } |
| Wayne Roberts |
10:db4e11a55bda | 922 | |
| Wayne Roberts |
10:db4e11a55bda | 923 | bool gnssAssisted_time_write(const char *txt) |
| Wayne Roberts |
9:295e37c38fb3 | 924 | { |
| Wayne Roberts |
9:295e37c38fb3 | 925 | unsigned t; |
| Wayne Roberts |
9:295e37c38fb3 | 926 | if (sscanf(txt, "%u", &t) == 1) { |
| Wayne Roberts |
10:db4e11a55bda | 927 | Radio::radio.to_big_endian32(t, gnssAssisted_buf); |
| Wayne Roberts |
9:295e37c38fb3 | 928 | } |
| Wayne Roberts |
9:295e37c38fb3 | 929 | return false; |
| Wayne Roberts |
9:295e37c38fb3 | 930 | } |
| Wayne Roberts |
10:db4e11a55bda | 931 | const value_item_t gnssAssisted_time_item = { _ITEM_VALUE, 9, gnssAssisted_time_print, gnssAssisted_time_write}; |
| Wayne Roberts |
10:db4e11a55bda | 932 | |
| Wayne Roberts |
10:db4e11a55bda | 933 | bool gnssAssisted_effort_read() |
| Wayne Roberts |
10:db4e11a55bda | 934 | { |
| Wayne Roberts |
10:db4e11a55bda | 935 | return gnssAssisted_buf[4] == 0x01; |
| Wayne Roberts |
10:db4e11a55bda | 936 | } |
| Wayne Roberts |
10:db4e11a55bda | 937 | |
| Wayne Roberts |
10:db4e11a55bda | 938 | bool gnssAssisted_effort_push() |
| Wayne Roberts |
10:db4e11a55bda | 939 | { |
| Wayne Roberts |
10:db4e11a55bda | 940 | gnssAssisted_buf[4] ^= 0x01; |
| Wayne Roberts |
10:db4e11a55bda | 941 | return gnssAssisted_buf[4] == 0x01; |
| Wayne Roberts |
10:db4e11a55bda | 942 | } |
| Wayne Roberts |
10:db4e11a55bda | 943 | |
| Wayne Roberts |
10:db4e11a55bda | 944 | const toggle_item_t gnssAssisted_effort_item = { _ITEM_TOGGLE, |
| Wayne Roberts |
10:db4e11a55bda | 945 | "lowPower", |
| Wayne Roberts |
10:db4e11a55bda | 946 | "best ", |
| Wayne Roberts |
10:db4e11a55bda | 947 | gnssAssisted_effort_read, |
| Wayne Roberts |
10:db4e11a55bda | 948 | gnssAssisted_effort_push |
| Wayne Roberts |
10:db4e11a55bda | 949 | }; |
| Wayne Roberts |
10:db4e11a55bda | 950 | |
| Wayne Roberts |
10:db4e11a55bda | 951 | void gnssAssisted_nbsvmax_print() |
| Wayne Roberts |
10:db4e11a55bda | 952 | { |
| Wayne Roberts |
10:db4e11a55bda | 953 | pc.printf("%u", gnssAssisted_buf[6]); |
| Wayne Roberts |
10:db4e11a55bda | 954 | } |
| Wayne Roberts |
10:db4e11a55bda | 955 | |
| Wayne Roberts |
10:db4e11a55bda | 956 | bool gnssAssisted_nbsvmax_write(const char *txt) |
| Wayne Roberts |
10:db4e11a55bda | 957 | { |
| Wayne Roberts |
10:db4e11a55bda | 958 | unsigned n; |
| Wayne Roberts |
10:db4e11a55bda | 959 | sscanf(txt, "%u", &n); |
| Wayne Roberts |
10:db4e11a55bda | 960 | gnssAssisted_buf[6] = n; |
| Wayne Roberts |
10:db4e11a55bda | 961 | return false; |
| Wayne Roberts |
10:db4e11a55bda | 962 | } |
| Wayne Roberts |
10:db4e11a55bda | 963 | |
| Wayne Roberts |
10:db4e11a55bda | 964 | const value_item_t gnssAssisted_nbsvmax_item = { _ITEM_VALUE, 3, gnssAssisted_nbsvmax_print, gnssAssisted_nbsvmax_write}; |
| Wayne Roberts |
10:db4e11a55bda | 965 | |
| Wayne Roberts |
10:db4e11a55bda | 966 | bool gnss_const_gps_enable_read() |
| Wayne Roberts |
10:db4e11a55bda | 967 | { |
| Wayne Roberts |
10:db4e11a55bda | 968 | gnssConstellation_t gc; |
| Wayne Roberts |
10:db4e11a55bda | 969 | Radio::radio.memRegRead(REG_ADDR_GNSS_CONST, 1, &gc.dword); |
| Wayne Roberts |
10:db4e11a55bda | 970 | return gc.bits.gps; |
| Wayne Roberts |
10:db4e11a55bda | 971 | } |
| Wayne Roberts |
10:db4e11a55bda | 972 | |
| Wayne Roberts |
10:db4e11a55bda | 973 | bool gnss_const_gps_enable_push() |
| Wayne Roberts |
9:295e37c38fb3 | 974 | { |
| Wayne Roberts |
10:db4e11a55bda | 975 | uint8_t ConstellationBitMask = 0; |
| Wayne Roberts |
10:db4e11a55bda | 976 | gnssConstellation_t gc; |
| Wayne Roberts |
10:db4e11a55bda | 977 | Radio::radio.memRegRead(REG_ADDR_GNSS_CONST, 1, &gc.dword); |
| Wayne Roberts |
10:db4e11a55bda | 978 | if (gc.bits.gps) |
| Wayne Roberts |
10:db4e11a55bda | 979 | ConstellationBitMask &= ~1; |
| Wayne Roberts |
10:db4e11a55bda | 980 | else |
| Wayne Roberts |
10:db4e11a55bda | 981 | ConstellationBitMask |= 1; |
| Wayne Roberts |
10:db4e11a55bda | 982 | if (gc.bits.beidou) |
| Wayne Roberts |
10:db4e11a55bda | 983 | ConstellationBitMask |= 2; |
| Wayne Roberts |
10:db4e11a55bda | 984 | Radio::radio.xfer(OPCODE_GNSS_SET_CONSTELLATION, 1, 0, &ConstellationBitMask); |
| Wayne Roberts |
10:db4e11a55bda | 985 | return ConstellationBitMask & 1; |
| Wayne Roberts |
9:295e37c38fb3 | 986 | } |
| Wayne Roberts |
9:295e37c38fb3 | 987 | |
| Wayne Roberts |
10:db4e11a55bda | 988 | const toggle_item_t gnss_const_gps_enable_item = { _ITEM_TOGGLE, "GPS", NULL, gnss_const_gps_enable_read, gnss_const_gps_enable_push}; |
| Wayne Roberts |
10:db4e11a55bda | 989 | |
| Wayne Roberts |
10:db4e11a55bda | 990 | bool gnss_const_beidou_enable_read() |
| Wayne Roberts |
10:db4e11a55bda | 991 | { |
| Wayne Roberts |
10:db4e11a55bda | 992 | gnssConstellation_t gc; |
| Wayne Roberts |
10:db4e11a55bda | 993 | Radio::radio.memRegRead(REG_ADDR_GNSS_CONST, 1, &gc.dword); |
| Wayne Roberts |
10:db4e11a55bda | 994 | return gc.bits.beidou; |
| Wayne Roberts |
10:db4e11a55bda | 995 | } |
| Wayne Roberts |
10:db4e11a55bda | 996 | |
| Wayne Roberts |
10:db4e11a55bda | 997 | bool gnss_const_beidou_enable_push() |
| Wayne Roberts |
10:db4e11a55bda | 998 | { |
| Wayne Roberts |
10:db4e11a55bda | 999 | uint8_t ConstellationBitMask = 0; |
| Wayne Roberts |
10:db4e11a55bda | 1000 | gnssConstellation_t gc; |
| Wayne Roberts |
10:db4e11a55bda | 1001 | Radio::radio.memRegRead(REG_ADDR_GNSS_CONST, 1, &gc.dword); |
| Wayne Roberts |
10:db4e11a55bda | 1002 | if (gc.bits.beidou) |
| Wayne Roberts |
10:db4e11a55bda | 1003 | ConstellationBitMask &= ~2; |
| Wayne Roberts |
10:db4e11a55bda | 1004 | else |
| Wayne Roberts |
10:db4e11a55bda | 1005 | ConstellationBitMask |= 2; |
| Wayne Roberts |
10:db4e11a55bda | 1006 | if (gc.bits.gps) |
| Wayne Roberts |
10:db4e11a55bda | 1007 | ConstellationBitMask |= 1; |
| Wayne Roberts |
10:db4e11a55bda | 1008 | Radio::radio.xfer(OPCODE_GNSS_SET_CONSTELLATION, 1, 0, &ConstellationBitMask); |
| Wayne Roberts |
10:db4e11a55bda | 1009 | return ConstellationBitMask & 1; |
| Wayne Roberts |
10:db4e11a55bda | 1010 | } |
| Wayne Roberts |
10:db4e11a55bda | 1011 | |
| Wayne Roberts |
10:db4e11a55bda | 1012 | const toggle_item_t gnss_const_beidou_enable_item = { _ITEM_TOGGLE, "BEIDOU", NULL, gnss_const_beidou_enable_read, gnss_const_beidou_enable_push}; |
| Wayne Roberts |
10:db4e11a55bda | 1013 | |
| Wayne Roberts |
10:db4e11a55bda | 1014 | bool gnssmode_read() |
| Wayne Roberts |
10:db4e11a55bda | 1015 | { |
| Wayne Roberts |
10:db4e11a55bda | 1016 | gnssMode_t gm; |
| Wayne Roberts |
10:db4e11a55bda | 1017 | Radio::radio.memRegRead(REG_ADDR_GNSS_MODE, 1, &gm.dword); |
| Wayne Roberts |
10:db4e11a55bda | 1018 | return gm.bits.gnss_scan_single; |
| Wayne Roberts |
10:db4e11a55bda | 1019 | } |
| Wayne Roberts |
10:db4e11a55bda | 1020 | |
| Wayne Roberts |
10:db4e11a55bda | 1021 | bool gnssmode_push() |
| Wayne Roberts |
10:db4e11a55bda | 1022 | { |
| Wayne Roberts |
10:db4e11a55bda | 1023 | uint8_t buf = gnssmode_read(); // GnssSetMode takes 1 for dual-scan |
| Wayne Roberts |
10:db4e11a55bda | 1024 | Radio::radio.xfer(OPCODE_GNSS_SET_MODE, 1, 0, &buf); |
| Wayne Roberts |
10:db4e11a55bda | 1025 | return buf == 0; |
| Wayne Roberts |
10:db4e11a55bda | 1026 | } |
| Wayne Roberts |
10:db4e11a55bda | 1027 | |
| Wayne Roberts |
10:db4e11a55bda | 1028 | const toggle_item_t gnss_mode_item = { _ITEM_TOGGLE, |
| Wayne Roberts |
10:db4e11a55bda | 1029 | "dual ", |
| Wayne Roberts |
10:db4e11a55bda | 1030 | "single", |
| Wayne Roberts |
10:db4e11a55bda | 1031 | gnssmode_read, |
| Wayne Roberts |
10:db4e11a55bda | 1032 | gnssmode_push |
| Wayne Roberts |
10:db4e11a55bda | 1033 | }; |
| Wayne Roberts |
9:295e37c38fb3 | 1034 | |
| Wayne Roberts |
9:295e37c38fb3 | 1035 | const menu_t Radio::common_menu[] = { |
| Wayne Roberts |
9:295e37c38fb3 | 1036 | { {FIRST_CHIP_MENU_ROW, 1}, NULL, &PaSel_item, FLAG_MSGTYPE_ALL, &tx_dbm_item}, |
| Wayne Roberts |
9:295e37c38fb3 | 1037 | { {FIRST_CHIP_MENU_ROW, 10}, NULL, &RegPASupply_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
9:295e37c38fb3 | 1038 | { {FIRST_CHIP_MENU_ROW, 30}, "PaDutyCycle:", &PaDutyCycle_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
9:295e37c38fb3 | 1039 | { {FIRST_CHIP_MENU_ROW, 47}, "PaHPSel:", &PaHPSel_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
9:295e37c38fb3 | 1040 | |
| Wayne Roberts |
10:db4e11a55bda | 1041 | { {FIRST_CHIP_MENU_ROW+1, 1}, "regulator:", ®ulator_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 1042 | { {FIRST_CHIP_MENU_ROW+1, 18}, "tcxoVolts:", &tcxo_volts_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 1043 | { {FIRST_CHIP_MENU_ROW+1, 32}, "tcxoDelay(ms):", &tcxo_delay_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 1044 | { {FIRST_CHIP_MENU_ROW+1, 52}, "re-cal(hex):", &recalibrate_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 1045 | |
| Wayne Roberts |
10:db4e11a55bda | 1046 | //012345678901234567890 |
| Wayne Roberts |
10:db4e11a55bda | 1047 | |
| Wayne Roberts |
10:db4e11a55bda | 1048 | { {FIRST_CHIP_MENU_ROW+2, 1}, "txTimeout(sec):", &txTimeout_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 1049 | { {FIRST_CHIP_MENU_ROW+2, 24}, NULL, &rxBufferStatus_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 1050 | { {FIRST_CHIP_MENU_ROW+2, 35}, NULL, &getStats_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 1051 | |
| Wayne Roberts |
10:db4e11a55bda | 1052 | { {FIRST_CHIP_MENU_ROW+10, 1}, NULL, &wifiScan_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 1053 | { {FIRST_CHIP_MENU_ROW+10, 10}, NULL, &wifiType_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 1054 | { {FIRST_CHIP_MENU_ROW+10, 19}, NULL, &wifiAcqMode_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 1055 | { {FIRST_CHIP_MENU_ROW+10, 35}, "NbMaxRes:", &wifiNbMaxRes_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 1056 | { {FIRST_CHIP_MENU_ROW+10, 48}, "NbScanPerChan:", &wifiNbScanPerChan_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 1057 | |
| Wayne Roberts |
10:db4e11a55bda | 1058 | { {FIRST_CHIP_MENU_ROW+11, 1}, "timeout(ms):", &wifiTimeout_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 1059 | { {FIRST_CHIP_MENU_ROW+11, 20}, NULL, &wifiAbort_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 1060 | { {FIRST_CHIP_MENU_ROW+11, 45}, "resultFormat:", &wifiResultFormat_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 1061 | |
| Wayne Roberts |
10:db4e11a55bda | 1062 | |
| Wayne Roberts |
10:db4e11a55bda | 1063 | { {FIRST_CHIP_MENU_ROW+12, 1}, NULL, &wifi_ch14_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 1064 | { {FIRST_CHIP_MENU_ROW+12, 6}, NULL, &wifi_ch13_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 1065 | { {FIRST_CHIP_MENU_ROW+12, 11}, NULL, &wifi_ch12_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 1066 | { {FIRST_CHIP_MENU_ROW+12, 16}, NULL, &wifi_ch11_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 1067 | { {FIRST_CHIP_MENU_ROW+12, 21}, NULL, &wifi_ch10_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 1068 | { {FIRST_CHIP_MENU_ROW+12, 26}, NULL, &wifi_ch9_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 1069 | { {FIRST_CHIP_MENU_ROW+12, 31}, NULL, &wifi_ch8_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 1070 | { {FIRST_CHIP_MENU_ROW+12, 36}, NULL, &wifi_ch7_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 1071 | { {FIRST_CHIP_MENU_ROW+12, 41}, NULL, &wifi_ch6_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 1072 | { {FIRST_CHIP_MENU_ROW+12, 46}, NULL, &wifi_ch5_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 1073 | { {FIRST_CHIP_MENU_ROW+12, 51}, NULL, &wifi_ch4_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 1074 | { {FIRST_CHIP_MENU_ROW+12, 56}, NULL, &wifi_ch3_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 1075 | { {FIRST_CHIP_MENU_ROW+12, 61}, NULL, &wifi_ch2_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 1076 | { {FIRST_CHIP_MENU_ROW+12, 66}, NULL, &wifi_ch1_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 1077 | |
| Wayne Roberts |
10:db4e11a55bda | 1078 | { {FIRST_CHIP_MENU_ROW+13, 1}, NULL, &gnss_const_gps_enable_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 1079 | { {FIRST_CHIP_MENU_ROW+13, 5}, NULL, &gnss_const_beidou_enable_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 1080 | { {FIRST_CHIP_MENU_ROW+13, 12}, "scanning:", &gnss_mode_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 1081 | |
| Wayne Roberts |
10:db4e11a55bda | 1082 | { {FIRST_CHIP_MENU_ROW+14, 1}, NULL, &gnssAutonomous_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 1083 | { {FIRST_CHIP_MENU_ROW+14, 16}, "time:", &gnssAutonomous_time_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 1084 | { {FIRST_CHIP_MENU_ROW+14, 31}, NULL, &gnssAutoResultTimeStamp_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 1085 | { {FIRST_CHIP_MENU_ROW+14, 41}, NULL, &gnssAutoResultDoppler_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 1086 | { {FIRST_CHIP_MENU_ROW+14, 51}, NULL, &gnssAutoResultBitChange_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 1087 | { {FIRST_CHIP_MENU_ROW+14, 63}, "NbSvMax:", &gnssAutoNbSvMax_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 1088 | |
| Wayne Roberts |
10:db4e11a55bda | 1089 | { {FIRST_CHIP_MENU_ROW+15, 1}, NULL, &gnssAssisted_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 1090 | { {FIRST_CHIP_MENU_ROW+15, 16}, "time:", &gnssAssisted_time_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 1091 | { {FIRST_CHIP_MENU_ROW+15, 30}, "effort:", &gnssAssisted_effort_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 1092 | { {FIRST_CHIP_MENU_ROW+15, 50}, "NbSvMax::", &gnssAssisted_nbsvmax_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 1093 | |
| Wayne Roberts |
10:db4e11a55bda | 1094 | //0123456789012345 |
| Wayne Roberts |
9:295e37c38fb3 | 1095 | { {0, 0}, NULL, NULL } |
| Wayne Roberts |
9:295e37c38fb3 | 1096 | }; |
| Wayne Roberts |
9:295e37c38fb3 | 1097 | |
| Wayne Roberts |
9:295e37c38fb3 | 1098 | void Radio::gfsk_bitrate_print() |
| Wayne Roberts |
9:295e37c38fb3 | 1099 | { |
| Wayne Roberts |
10:db4e11a55bda | 1100 | uint32_t u32; |
| Wayne Roberts |
10:db4e11a55bda | 1101 | unsigned hz; |
| Wayne Roberts |
10:db4e11a55bda | 1102 | radio.memRegRead(REG_ADDR_GFSK_BITRATE, 1, &u32); |
| Wayne Roberts |
10:db4e11a55bda | 1103 | hz = GFSK_BITRATE_NUMERATOR / u32; |
| Wayne Roberts |
10:db4e11a55bda | 1104 | pc.printf("%u", hz); |
| Wayne Roberts |
10:db4e11a55bda | 1105 | radio.to_big_endian32(hz, gfsk_mp_buf); |
| Wayne Roberts |
9:295e37c38fb3 | 1106 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1107 | |
| Wayne Roberts |
9:295e37c38fb3 | 1108 | bool Radio::gfsk_bitrate_write(const char* txt) |
| Wayne Roberts |
9:295e37c38fb3 | 1109 | { |
| Wayne Roberts |
9:295e37c38fb3 | 1110 | unsigned bps; |
| Wayne Roberts |
9:295e37c38fb3 | 1111 | |
| Wayne Roberts |
9:295e37c38fb3 | 1112 | if (sscanf(txt, "%u", &bps) == 1) { |
| Wayne Roberts |
9:295e37c38fb3 | 1113 | radio.to_big_endian32(bps, gfsk_mp_buf); |
| Wayne Roberts |
9:295e37c38fb3 | 1114 | radio.xfer(OPCODE_SET_MODULATION, 10, 0, gfsk_mp_buf); |
| Wayne Roberts |
9:295e37c38fb3 | 1115 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1116 | return false; |
| Wayne Roberts |
9:295e37c38fb3 | 1117 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1118 | |
| Wayne Roberts |
9:295e37c38fb3 | 1119 | const value_item_t Radio::gfsk_bitrate_item = { _ITEM_VALUE, 8, gfsk_bitrate_print, gfsk_bitrate_write}; |
| Wayne Roberts |
9:295e37c38fb3 | 1120 | |
| Wayne Roberts |
9:295e37c38fb3 | 1121 | static const char* const gfsk_bts[] = { |
| Wayne Roberts |
9:295e37c38fb3 | 1122 | "off", // 0 |
| Wayne Roberts |
9:295e37c38fb3 | 1123 | "0.3", // 1 |
| Wayne Roberts |
9:295e37c38fb3 | 1124 | "0.5", // 2 |
| Wayne Roberts |
9:295e37c38fb3 | 1125 | "0.7", // 3 |
| Wayne Roberts |
9:295e37c38fb3 | 1126 | "1.0", // 4 |
| Wayne Roberts |
9:295e37c38fb3 | 1127 | NULL |
| Wayne Roberts |
9:295e37c38fb3 | 1128 | }; |
| Wayne Roberts |
9:295e37c38fb3 | 1129 | |
| Wayne Roberts |
9:295e37c38fb3 | 1130 | unsigned Radio::gfsk_bt_read(bool forWriting) |
| Wayne Roberts |
9:295e37c38fb3 | 1131 | { |
| Wayne Roberts |
9:295e37c38fb3 | 1132 | gfskConfig0_t cfg0; |
| Wayne Roberts |
10:db4e11a55bda | 1133 | radio.memRegRead(REG_ADDR_GFSK_CFG0, 1, &cfg0.dword); |
| Wayne Roberts |
9:295e37c38fb3 | 1134 | if (cfg0.bits.shaping_en) { |
| Wayne Roberts |
10:db4e11a55bda | 1135 | switch (cfg0.bits.bt) { |
| Wayne Roberts |
10:db4e11a55bda | 1136 | case 0: /* off */ gfsk_mp_buf[4] = GFSK_BT_OFF; break; |
| Wayne Roberts |
10:db4e11a55bda | 1137 | case 1: /* 0.3 */ gfsk_mp_buf[4] = GFSK_BT_0_3; break; |
| Wayne Roberts |
10:db4e11a55bda | 1138 | case 2: /* 0.5 */ gfsk_mp_buf[4] = GFSK_BT_0_5; break; |
| Wayne Roberts |
10:db4e11a55bda | 1139 | case 3: /* 0.7 */ gfsk_mp_buf[4] = GFSK_BT_0_7; break; |
| Wayne Roberts |
10:db4e11a55bda | 1140 | case 4: /* 1.0 */ gfsk_mp_buf[4] = GFSK_BT_1_0; break; |
| Wayne Roberts |
10:db4e11a55bda | 1141 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1142 | return cfg0.bits.bt + 1; |
| Wayne Roberts |
9:295e37c38fb3 | 1143 | } else |
| Wayne Roberts |
9:295e37c38fb3 | 1144 | return 0; |
| Wayne Roberts |
9:295e37c38fb3 | 1145 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1146 | |
| Wayne Roberts |
9:295e37c38fb3 | 1147 | menuMode_e Radio::gfsk_bt_write(unsigned sidx) |
| Wayne Roberts |
9:295e37c38fb3 | 1148 | { |
| Wayne Roberts |
9:295e37c38fb3 | 1149 | switch (sidx) { |
| Wayne Roberts |
9:295e37c38fb3 | 1150 | case 0: gfsk_mp_buf[4] = GFSK_BT_OFF; break; |
| Wayne Roberts |
9:295e37c38fb3 | 1151 | case 1: gfsk_mp_buf[4] = GFSK_BT_0_3; break; |
| Wayne Roberts |
9:295e37c38fb3 | 1152 | case 2: gfsk_mp_buf[4] = GFSK_BT_0_5; break; |
| Wayne Roberts |
9:295e37c38fb3 | 1153 | case 3: gfsk_mp_buf[4] = GFSK_BT_0_7; break; |
| Wayne Roberts |
9:295e37c38fb3 | 1154 | case 4: gfsk_mp_buf[4] = GFSK_BT_1_0; break; |
| Wayne Roberts |
9:295e37c38fb3 | 1155 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1156 | radio.xfer(OPCODE_SET_MODULATION, 10, 0, gfsk_mp_buf); |
| Wayne Roberts |
9:295e37c38fb3 | 1157 | return MENUMODE_REDRAW; |
| Wayne Roberts |
9:295e37c38fb3 | 1158 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1159 | |
| Wayne Roberts |
9:295e37c38fb3 | 1160 | const dropdown_item_t Radio::gfsk_bt_item = { _ITEM_DROPDOWN, gfsk_bts, gfsk_bts, gfsk_bt_read, gfsk_bt_write}; |
| Wayne Roberts |
9:295e37c38fb3 | 1161 | |
| Wayne Roberts |
9:295e37c38fb3 | 1162 | void Radio::gfsk_rxbw_print() |
| Wayne Roberts |
9:295e37c38fb3 | 1163 | { |
| Wayne Roberts |
9:295e37c38fb3 | 1164 | unsigned n; |
| Wayne Roberts |
10:db4e11a55bda | 1165 | uint8_t bwf; |
| Wayne Roberts |
9:295e37c38fb3 | 1166 | gfskBW_t bw_reg; |
| Wayne Roberts |
10:db4e11a55bda | 1167 | radio.memRegRead(REG_ADDR_GFSK_BWF, 1, &bw_reg.dword); |
| Wayne Roberts |
9:295e37c38fb3 | 1168 | bwf = bw_reg.bits.bwf_hi; |
| Wayne Roberts |
9:295e37c38fb3 | 1169 | bwf <<= 3; |
| Wayne Roberts |
9:295e37c38fb3 | 1170 | bwf |= bw_reg.bits.bwf_lo; |
| Wayne Roberts |
9:295e37c38fb3 | 1171 | gfsk_mp_buf[5] = bwf; |
| Wayne Roberts |
9:295e37c38fb3 | 1172 | |
| Wayne Roberts |
9:295e37c38fb3 | 1173 | for (n = 0; n < NB_RXBW; n++) { |
| Wayne Roberts |
9:295e37c38fb3 | 1174 | if (rxbws[n].bwf == bwf) { |
| Wayne Roberts |
9:295e37c38fb3 | 1175 | pc.printf("%u", rxbws[n].hz); |
| Wayne Roberts |
9:295e37c38fb3 | 1176 | break; |
| Wayne Roberts |
9:295e37c38fb3 | 1177 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1178 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1179 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1180 | |
| Wayne Roberts |
9:295e37c38fb3 | 1181 | rxbw_t Radio::rxbws[] = { |
| Wayne Roberts |
9:295e37c38fb3 | 1182 | /* 0 */ { 4800, GFSK_RX_BW_4800 }, |
| Wayne Roberts |
9:295e37c38fb3 | 1183 | /* 1 */ { 5800, GFSK_RX_BW_5800 }, |
| Wayne Roberts |
9:295e37c38fb3 | 1184 | /* 2 */ { 7300, GFSK_RX_BW_7300 }, |
| Wayne Roberts |
9:295e37c38fb3 | 1185 | /* 3 */ { 9700, GFSK_RX_BW_9700 }, |
| Wayne Roberts |
9:295e37c38fb3 | 1186 | /* 4 */ { 11700, GFSK_RX_BW_11700 }, |
| Wayne Roberts |
9:295e37c38fb3 | 1187 | /* 5 */ { 14600, GFSK_RX_BW_14600 }, |
| Wayne Roberts |
9:295e37c38fb3 | 1188 | /* 6 */ { 19500, GFSK_RX_BW_19500 }, |
| Wayne Roberts |
9:295e37c38fb3 | 1189 | /* 7 */ { 23400, GFSK_RX_BW_23400 }, |
| Wayne Roberts |
9:295e37c38fb3 | 1190 | /* 8 */ { 29300, GFSK_RX_BW_29300 }, |
| Wayne Roberts |
9:295e37c38fb3 | 1191 | /* 9 */ { 39000, GFSK_RX_BW_39000 }, |
| Wayne Roberts |
9:295e37c38fb3 | 1192 | /* 10 */ { 46900, GFSK_RX_BW_46900 }, |
| Wayne Roberts |
9:295e37c38fb3 | 1193 | /* 11 */ { 58600, GFSK_RX_BW_58600 }, |
| Wayne Roberts |
9:295e37c38fb3 | 1194 | /* 12 */ { 78200, GFSK_RX_BW_78200 }, |
| Wayne Roberts |
9:295e37c38fb3 | 1195 | /* 13 */ { 93800, GFSK_RX_BW_93800 }, |
| Wayne Roberts |
9:295e37c38fb3 | 1196 | /* 14 */ { 117300, GFSK_RX_BW_117300 }, |
| Wayne Roberts |
9:295e37c38fb3 | 1197 | /* 15 */ { 156200, GFSK_RX_BW_156200 }, |
| Wayne Roberts |
9:295e37c38fb3 | 1198 | /* 16 */ { 187200, GFSK_RX_BW_187200 }, |
| Wayne Roberts |
9:295e37c38fb3 | 1199 | /* 17 */ { 234300, GFSK_RX_BW_234300 }, |
| Wayne Roberts |
9:295e37c38fb3 | 1200 | /* 18 */ { 312000, GFSK_RX_BW_312000 }, |
| Wayne Roberts |
9:295e37c38fb3 | 1201 | /* 19 */ { 373600, GFSK_RX_BW_373600 }, |
| Wayne Roberts |
9:295e37c38fb3 | 1202 | /* 20 */ { 467000, GFSK_RX_BW_467000 } |
| Wayne Roberts |
9:295e37c38fb3 | 1203 | }; |
| Wayne Roberts |
9:295e37c38fb3 | 1204 | |
| Wayne Roberts |
9:295e37c38fb3 | 1205 | bool Radio::gfsk_rxbw_write(const char* txt) |
| Wayne Roberts |
9:295e37c38fb3 | 1206 | { |
| Wayne Roberts |
9:295e37c38fb3 | 1207 | unsigned n, rxbw; |
| Wayne Roberts |
9:295e37c38fb3 | 1208 | if (sscanf(txt, "%u", &rxbw) == 1) { |
| Wayne Roberts |
9:295e37c38fb3 | 1209 | for (n = 1; n < NB_RXBW; n++) { |
| Wayne Roberts |
9:295e37c38fb3 | 1210 | log_printf("%u) %u > %u\r\n", n, rxbw, rxbws[n].hz); |
| Wayne Roberts |
9:295e37c38fb3 | 1211 | if (rxbw >= rxbws[n-1].hz && rxbw < rxbws[n].hz) { |
| Wayne Roberts |
9:295e37c38fb3 | 1212 | gfsk_mp_buf[5] = rxbws[n-1].bwf; |
| Wayne Roberts |
9:295e37c38fb3 | 1213 | log_printf("RXBWset %u<-%u %02x\r\n", rxbws[n-1].hz, rxbw, gfsk_mp_buf[5]); |
| Wayne Roberts |
9:295e37c38fb3 | 1214 | break; |
| Wayne Roberts |
9:295e37c38fb3 | 1215 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1216 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1217 | radio.xfer(OPCODE_SET_MODULATION, 10, 0, gfsk_mp_buf); |
| Wayne Roberts |
9:295e37c38fb3 | 1218 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1219 | return false; |
| Wayne Roberts |
9:295e37c38fb3 | 1220 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1221 | |
| Wayne Roberts |
9:295e37c38fb3 | 1222 | const value_item_t Radio::gfsk_rxbw_item = { _ITEM_VALUE, 8, gfsk_rxbw_print, gfsk_rxbw_write}; |
| Wayne Roberts |
9:295e37c38fb3 | 1223 | |
| Wayne Roberts |
9:295e37c38fb3 | 1224 | void Radio::gfsk_fdev_print() |
| Wayne Roberts |
9:295e37c38fb3 | 1225 | { |
| Wayne Roberts |
10:db4e11a55bda | 1226 | unsigned hz; |
| Wayne Roberts |
10:db4e11a55bda | 1227 | uint32_t u32; |
| Wayne Roberts |
10:db4e11a55bda | 1228 | radio.memRegRead(REG_ADDR_GFSK_FDEV, 1, &u32); |
| Wayne Roberts |
10:db4e11a55bda | 1229 | hz = my_round(u32 * FREQ_STEP); |
| Wayne Roberts |
10:db4e11a55bda | 1230 | pc.printf("%u", hz); |
| Wayne Roberts |
10:db4e11a55bda | 1231 | radio.to_big_endian32(hz, gfsk_mp_buf+6); |
| Wayne Roberts |
9:295e37c38fb3 | 1232 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1233 | |
| Wayne Roberts |
9:295e37c38fb3 | 1234 | bool Radio::gfsk_fdev_write(const char* txt) |
| Wayne Roberts |
9:295e37c38fb3 | 1235 | { |
| Wayne Roberts |
9:295e37c38fb3 | 1236 | unsigned hz; |
| Wayne Roberts |
9:295e37c38fb3 | 1237 | if (sscanf(txt, "%u", &hz) == 1) { |
| Wayne Roberts |
9:295e37c38fb3 | 1238 | radio.to_big_endian32(hz, gfsk_mp_buf+6); |
| Wayne Roberts |
9:295e37c38fb3 | 1239 | radio.xfer(OPCODE_SET_MODULATION, 10, 0, gfsk_mp_buf); |
| Wayne Roberts |
9:295e37c38fb3 | 1240 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1241 | return false; |
| Wayne Roberts |
9:295e37c38fb3 | 1242 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1243 | |
| Wayne Roberts |
9:295e37c38fb3 | 1244 | const value_item_t Radio::gfsk_fdev_item = { _ITEM_VALUE, 8, gfsk_fdev_print, gfsk_fdev_write}; |
| Wayne Roberts |
9:295e37c38fb3 | 1245 | |
| Wayne Roberts |
9:295e37c38fb3 | 1246 | void Radio::gfsk_pblLen_print() |
| Wayne Roberts |
9:295e37c38fb3 | 1247 | { |
| Wayne Roberts |
9:295e37c38fb3 | 1248 | unsigned n; |
| Wayne Roberts |
10:db4e11a55bda | 1249 | gfskConfig1_t cfg1; |
| Wayne Roberts |
10:db4e11a55bda | 1250 | radio.memRegRead(REG_ADDR_GFSK_CFG1, 1, &cfg1.dword); |
| Wayne Roberts |
10:db4e11a55bda | 1251 | pc.printf("%u", cfg1.bits.preamble_length); |
| Wayne Roberts |
10:db4e11a55bda | 1252 | n = cfg1.bits.preamble_length; |
| Wayne Roberts |
9:295e37c38fb3 | 1253 | gfsk_pp_buf[1] = n; |
| Wayne Roberts |
9:295e37c38fb3 | 1254 | n >>= 8; |
| Wayne Roberts |
9:295e37c38fb3 | 1255 | gfsk_pp_buf[0] = n; |
| Wayne Roberts |
9:295e37c38fb3 | 1256 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1257 | |
| Wayne Roberts |
9:295e37c38fb3 | 1258 | bool Radio::gfsk_pblLen_write(const char* txt) |
| Wayne Roberts |
9:295e37c38fb3 | 1259 | { |
| Wayne Roberts |
9:295e37c38fb3 | 1260 | unsigned n; |
| Wayne Roberts |
9:295e37c38fb3 | 1261 | if (sscanf(txt, "%u", &n) == 1) { |
| Wayne Roberts |
10:db4e11a55bda | 1262 | radio.to_big_endian16(n, gfsk_pp_buf); |
| Wayne Roberts |
9:295e37c38fb3 | 1263 | radio.xfer(OPCODE_SET_PACKET_PARAM, 9, 0, gfsk_pp_buf); |
| Wayne Roberts |
9:295e37c38fb3 | 1264 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1265 | return false; |
| Wayne Roberts |
9:295e37c38fb3 | 1266 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1267 | |
| Wayne Roberts |
9:295e37c38fb3 | 1268 | const value_item_t Radio::gfsk_pblLen_item = { _ITEM_VALUE, 5, gfsk_pblLen_print, gfsk_pblLen_write}; |
| Wayne Roberts |
9:295e37c38fb3 | 1269 | |
| Wayne Roberts |
9:295e37c38fb3 | 1270 | static const char* const fsk_detlens[] = { |
| Wayne Roberts |
9:295e37c38fb3 | 1271 | " off ", // GFSK_PBLDET_LENGTH_OFF 0x00 |
| Wayne Roberts |
9:295e37c38fb3 | 1272 | " 8bits", // GFSK_PBLDET_LENGTH_8 0x04 |
| Wayne Roberts |
9:295e37c38fb3 | 1273 | "16bits", // GFSK_PBLDET_LENGTH_16 0x05 |
| Wayne Roberts |
9:295e37c38fb3 | 1274 | "24bits", // GFSK_PBLDET_LENGTH_24 0x06 |
| Wayne Roberts |
9:295e37c38fb3 | 1275 | "32bits", // GFSK_PBLDET_LENGTH_32 0x07 |
| Wayne Roberts |
9:295e37c38fb3 | 1276 | NULL |
| Wayne Roberts |
9:295e37c38fb3 | 1277 | }; |
| Wayne Roberts |
9:295e37c38fb3 | 1278 | |
| Wayne Roberts |
9:295e37c38fb3 | 1279 | unsigned Radio::gfsk_pblDetLen_read(bool forWriting) |
| Wayne Roberts |
9:295e37c38fb3 | 1280 | { |
| Wayne Roberts |
10:db4e11a55bda | 1281 | gfskConfig1_t cfg1; |
| Wayne Roberts |
10:db4e11a55bda | 1282 | radio.memRegRead(REG_ADDR_GFSK_CFG1, 1, &cfg1.dword); |
| Wayne Roberts |
10:db4e11a55bda | 1283 | if (cfg1.bits.preamble_det_enable) { |
| Wayne Roberts |
10:db4e11a55bda | 1284 | gfsk_pp_buf[2] = cfg1.bits.preamble_det_len + 4; |
| Wayne Roberts |
10:db4e11a55bda | 1285 | return cfg1.bits.preamble_det_len + 1; |
| Wayne Roberts |
9:295e37c38fb3 | 1286 | } else { |
| Wayne Roberts |
9:295e37c38fb3 | 1287 | gfsk_pp_buf[2] = 0; |
| Wayne Roberts |
9:295e37c38fb3 | 1288 | return 0; |
| Wayne Roberts |
9:295e37c38fb3 | 1289 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1290 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1291 | |
| Wayne Roberts |
9:295e37c38fb3 | 1292 | menuMode_e Radio::gfsk_pblDetLen_write(unsigned sidx) |
| Wayne Roberts |
9:295e37c38fb3 | 1293 | { |
| Wayne Roberts |
9:295e37c38fb3 | 1294 | if (sidx == 0) |
| Wayne Roberts |
9:295e37c38fb3 | 1295 | gfsk_pp_buf[2] = 0; |
| Wayne Roberts |
9:295e37c38fb3 | 1296 | else |
| Wayne Roberts |
9:295e37c38fb3 | 1297 | gfsk_pp_buf[2] = sidx + 4; |
| Wayne Roberts |
9:295e37c38fb3 | 1298 | |
| Wayne Roberts |
9:295e37c38fb3 | 1299 | radio.xfer(OPCODE_SET_PACKET_PARAM, 9, 0, gfsk_pp_buf); |
| Wayne Roberts |
9:295e37c38fb3 | 1300 | return MENUMODE_REDRAW; |
| Wayne Roberts |
9:295e37c38fb3 | 1301 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1302 | |
| Wayne Roberts |
9:295e37c38fb3 | 1303 | const dropdown_item_t Radio::gfsk_pblDetLen_item = { _ITEM_DROPDOWN, fsk_detlens, fsk_detlens, gfsk_pblDetLen_read, gfsk_pblDetLen_write}; |
| Wayne Roberts |
9:295e37c38fb3 | 1304 | |
| Wayne Roberts |
9:295e37c38fb3 | 1305 | void Radio::gfsk_syncWord_print(void) |
| Wayne Roberts |
9:295e37c38fb3 | 1306 | { |
| Wayne Roberts |
10:db4e11a55bda | 1307 | uint32_t dword[2]; |
| Wayne Roberts |
10:db4e11a55bda | 1308 | radio.memRegRead(REG_ADDR_GFSK_SYNC_LO, 2, dword); |
| Wayne Roberts |
10:db4e11a55bda | 1309 | pc.printf("%08lx", dword[1]); |
| Wayne Roberts |
10:db4e11a55bda | 1310 | pc.printf("%08lx", dword[0]); |
| Wayne Roberts |
9:295e37c38fb3 | 1311 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1312 | |
| Wayne Roberts |
9:295e37c38fb3 | 1313 | bool Radio::gfsk_syncWord_write(const char* txt) |
| Wayne Roberts |
9:295e37c38fb3 | 1314 | { |
| Wayne Roberts |
9:295e37c38fb3 | 1315 | uint8_t buf[8]; |
| Wayne Roberts |
9:295e37c38fb3 | 1316 | const char* ptr; |
| Wayne Roberts |
9:295e37c38fb3 | 1317 | const char* endPtr; |
| Wayne Roberts |
9:295e37c38fb3 | 1318 | unsigned o, n = 0; |
| Wayne Roberts |
9:295e37c38fb3 | 1319 | |
| Wayne Roberts |
9:295e37c38fb3 | 1320 | endPtr = txt + strlen(txt); |
| Wayne Roberts |
9:295e37c38fb3 | 1321 | for (ptr = txt; sscanf(ptr, "%02x", &o) == 1; ) { |
| Wayne Roberts |
9:295e37c38fb3 | 1322 | buf[n++] = o; |
| Wayne Roberts |
9:295e37c38fb3 | 1323 | ptr += 2; |
| Wayne Roberts |
9:295e37c38fb3 | 1324 | if (ptr >= endPtr) |
| Wayne Roberts |
9:295e37c38fb3 | 1325 | break; |
| Wayne Roberts |
9:295e37c38fb3 | 1326 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1327 | |
| Wayne Roberts |
9:295e37c38fb3 | 1328 | radio.xfer(OPCODE_SET_GFSK_SYNC_WORD, 8, 0, buf); |
| Wayne Roberts |
9:295e37c38fb3 | 1329 | return false; |
| Wayne Roberts |
9:295e37c38fb3 | 1330 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1331 | |
| Wayne Roberts |
9:295e37c38fb3 | 1332 | const value_item_t Radio::gfsk_syncWord_item = { _ITEM_VALUE, 17, gfsk_syncWord_print, gfsk_syncWord_write}; |
| Wayne Roberts |
9:295e37c38fb3 | 1333 | |
| Wayne Roberts |
9:295e37c38fb3 | 1334 | static const char* const addrcomps[] = { |
| Wayne Roberts |
9:295e37c38fb3 | 1335 | " off ", |
| Wayne Roberts |
9:295e37c38fb3 | 1336 | "NodeAddress ", |
| Wayne Roberts |
9:295e37c38fb3 | 1337 | "NodeAddress+broadcast", |
| Wayne Roberts |
9:295e37c38fb3 | 1338 | NULL |
| Wayne Roberts |
9:295e37c38fb3 | 1339 | }; |
| Wayne Roberts |
9:295e37c38fb3 | 1340 | |
| Wayne Roberts |
9:295e37c38fb3 | 1341 | unsigned Radio::gfsk_addrcomp_read(bool forWriting) |
| Wayne Roberts |
9:295e37c38fb3 | 1342 | { |
| Wayne Roberts |
9:295e37c38fb3 | 1343 | gfskConfig4_t cfg4; |
| Wayne Roberts |
10:db4e11a55bda | 1344 | radio.memRegRead(REG_ADDR_GFSK_PAYLOAD_LENGTH_B, 1, &cfg4.dword); |
| Wayne Roberts |
9:295e37c38fb3 | 1345 | gfsk_pp_buf[4] = cfg4.bits.addr_comp; |
| Wayne Roberts |
9:295e37c38fb3 | 1346 | return cfg4.bits.addr_comp; |
| Wayne Roberts |
9:295e37c38fb3 | 1347 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1348 | |
| Wayne Roberts |
9:295e37c38fb3 | 1349 | menuMode_e Radio::gfsk_addrcomp_write(unsigned sidx) |
| Wayne Roberts |
9:295e37c38fb3 | 1350 | { |
| Wayne Roberts |
9:295e37c38fb3 | 1351 | gfsk_pp_buf[4] = sidx; |
| Wayne Roberts |
9:295e37c38fb3 | 1352 | radio.xfer(OPCODE_SET_PACKET_PARAM, 9, 0, gfsk_pp_buf); |
| Wayne Roberts |
9:295e37c38fb3 | 1353 | return MENUMODE_REDRAW; |
| Wayne Roberts |
9:295e37c38fb3 | 1354 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1355 | |
| Wayne Roberts |
9:295e37c38fb3 | 1356 | const dropdown_item_t Radio::gfsk_addrcomp_item = { _ITEM_DROPDOWN, addrcomps, addrcomps, gfsk_addrcomp_read, gfsk_addrcomp_write}; |
| Wayne Roberts |
9:295e37c38fb3 | 1357 | |
| Wayne Roberts |
9:295e37c38fb3 | 1358 | bool Radio::gfsk_varlen_read() |
| Wayne Roberts |
9:295e37c38fb3 | 1359 | { |
| Wayne Roberts |
9:295e37c38fb3 | 1360 | gfskConfig3_t cfg3; |
| Wayne Roberts |
10:db4e11a55bda | 1361 | radio.memRegRead(REG_ADDR_GFSK_CFG3, 1, &cfg3.dword); |
| Wayne Roberts |
9:295e37c38fb3 | 1362 | gfsk_pp_buf[5] = cfg3.bits.variable_length; |
| Wayne Roberts |
9:295e37c38fb3 | 1363 | return cfg3.bits.variable_length; |
| Wayne Roberts |
9:295e37c38fb3 | 1364 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1365 | |
| Wayne Roberts |
9:295e37c38fb3 | 1366 | bool Radio::gfsk_varlen_push() |
| Wayne Roberts |
9:295e37c38fb3 | 1367 | { |
| Wayne Roberts |
9:295e37c38fb3 | 1368 | gfsk_pp_buf[5] ^= 1; |
| Wayne Roberts |
9:295e37c38fb3 | 1369 | radio.xfer(OPCODE_SET_PACKET_PARAM, 9, 0, gfsk_pp_buf); |
| Wayne Roberts |
9:295e37c38fb3 | 1370 | return gfsk_pp_buf[5]; |
| Wayne Roberts |
9:295e37c38fb3 | 1371 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1372 | |
| Wayne Roberts |
9:295e37c38fb3 | 1373 | const toggle_item_t Radio::gfsk_varlen_item = { _ITEM_TOGGLE, "fixLen", "varLen", gfsk_varlen_read, gfsk_varlen_push}; |
| Wayne Roberts |
9:295e37c38fb3 | 1374 | |
| Wayne Roberts |
9:295e37c38fb3 | 1375 | void Radio::gfsk_syncLen_print() |
| Wayne Roberts |
9:295e37c38fb3 | 1376 | { |
| Wayne Roberts |
9:295e37c38fb3 | 1377 | gfskConfig2_t cfg2; |
| Wayne Roberts |
10:db4e11a55bda | 1378 | radio.memRegRead(REG_ADDR_GFSK_CFG2, 1, &cfg2.dword); |
| Wayne Roberts |
9:295e37c38fb3 | 1379 | gfsk_pp_buf[3] = cfg2.bits.sync_word_length; |
| Wayne Roberts |
9:295e37c38fb3 | 1380 | pc.printf("%u", cfg2.bits.sync_word_length); |
| Wayne Roberts |
9:295e37c38fb3 | 1381 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1382 | |
| Wayne Roberts |
9:295e37c38fb3 | 1383 | bool Radio::gfsk_syncLen_write(const char *txt) |
| Wayne Roberts |
9:295e37c38fb3 | 1384 | { |
| Wayne Roberts |
9:295e37c38fb3 | 1385 | unsigned n; |
| Wayne Roberts |
9:295e37c38fb3 | 1386 | if (sscanf(txt, "%u", &n) == 1) { |
| Wayne Roberts |
9:295e37c38fb3 | 1387 | gfsk_pp_buf[3] = n; |
| Wayne Roberts |
9:295e37c38fb3 | 1388 | radio.xfer(OPCODE_SET_PACKET_PARAM, 9, 0, gfsk_pp_buf); |
| Wayne Roberts |
9:295e37c38fb3 | 1389 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1390 | return false; |
| Wayne Roberts |
9:295e37c38fb3 | 1391 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1392 | |
| Wayne Roberts |
9:295e37c38fb3 | 1393 | const value_item_t Radio::gfsk_syncLen_item = { _ITEM_VALUE, 4, gfsk_syncLen_print, gfsk_syncLen_write}; |
| Wayne Roberts |
9:295e37c38fb3 | 1394 | |
| Wayne Roberts |
9:295e37c38fb3 | 1395 | const char* const Radio::gfsk_crcType_strs[] = |
| Wayne Roberts |
9:295e37c38fb3 | 1396 | { |
| Wayne Roberts |
9:295e37c38fb3 | 1397 | /* 0 */ " OFF ", |
| Wayne Roberts |
9:295e37c38fb3 | 1398 | /* 1 */ "1_BYTE ", |
| Wayne Roberts |
9:295e37c38fb3 | 1399 | /* 2 */ "2_BYTE ", |
| Wayne Roberts |
9:295e37c38fb3 | 1400 | /* 3 */ "1_BYTE_INV", |
| Wayne Roberts |
9:295e37c38fb3 | 1401 | /* 4 */ "2_BYTE_INV", |
| Wayne Roberts |
9:295e37c38fb3 | 1402 | /* 5 */ NULL |
| Wayne Roberts |
9:295e37c38fb3 | 1403 | }; |
| Wayne Roberts |
9:295e37c38fb3 | 1404 | |
| Wayne Roberts |
9:295e37c38fb3 | 1405 | unsigned Radio::gfsk_crcType_read(bool for_writing) |
| Wayne Roberts |
9:295e37c38fb3 | 1406 | { |
| Wayne Roberts |
9:295e37c38fb3 | 1407 | unsigned ret; |
| Wayne Roberts |
9:295e37c38fb3 | 1408 | gfskConfig5_t cfg5; |
| Wayne Roberts |
10:db4e11a55bda | 1409 | radio.memRegRead(REG_ADDR_GFSK_CFG5, 1, &cfg5.dword); |
| Wayne Roberts |
9:295e37c38fb3 | 1410 | // gfsk_pp_buf[7]: bit2:inv bit1:twobyte bit0:disabled |
| Wayne Roberts |
9:295e37c38fb3 | 1411 | if (cfg5.bits.crc_off) |
| Wayne Roberts |
9:295e37c38fb3 | 1412 | gfsk_pp_buf[7] |= 1; |
| Wayne Roberts |
9:295e37c38fb3 | 1413 | else |
| Wayne Roberts |
9:295e37c38fb3 | 1414 | gfsk_pp_buf[7] &= ~1; |
| Wayne Roberts |
9:295e37c38fb3 | 1415 | |
| Wayne Roberts |
9:295e37c38fb3 | 1416 | if (cfg5.bits.crc_size) |
| Wayne Roberts |
9:295e37c38fb3 | 1417 | gfsk_pp_buf[7] |= 2; |
| Wayne Roberts |
9:295e37c38fb3 | 1418 | else |
| Wayne Roberts |
9:295e37c38fb3 | 1419 | gfsk_pp_buf[7] &= ~2; |
| Wayne Roberts |
9:295e37c38fb3 | 1420 | |
| Wayne Roberts |
9:295e37c38fb3 | 1421 | if (cfg5.bits.crc_invert) |
| Wayne Roberts |
9:295e37c38fb3 | 1422 | gfsk_pp_buf[7] |= 4; |
| Wayne Roberts |
9:295e37c38fb3 | 1423 | else |
| Wayne Roberts |
9:295e37c38fb3 | 1424 | gfsk_pp_buf[7] &= ~4; |
| Wayne Roberts |
9:295e37c38fb3 | 1425 | |
| Wayne Roberts |
9:295e37c38fb3 | 1426 | switch (gfsk_pp_buf[7]) { |
| Wayne Roberts |
9:295e37c38fb3 | 1427 | case GFSK_CRC_OFF: ret = 0; break; |
| Wayne Roberts |
9:295e37c38fb3 | 1428 | case GFSK_CRC_1_BYTE: ret = 1; break; |
| Wayne Roberts |
9:295e37c38fb3 | 1429 | case GFSK_CRC_2_BYTE: ret = 2; break; |
| Wayne Roberts |
9:295e37c38fb3 | 1430 | case GFSK_CRC_1_BYTE_INV: ret = 3; break; |
| Wayne Roberts |
9:295e37c38fb3 | 1431 | case GFSK_CRC_2_BYTE_INV: ret = 4; break; |
| Wayne Roberts |
9:295e37c38fb3 | 1432 | default: ret = 5; break; |
| Wayne Roberts |
9:295e37c38fb3 | 1433 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1434 | return ret; |
| Wayne Roberts |
9:295e37c38fb3 | 1435 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1436 | |
| Wayne Roberts |
9:295e37c38fb3 | 1437 | menuMode_e Radio::gfsk_crcType_write(unsigned sidx) |
| Wayne Roberts |
9:295e37c38fb3 | 1438 | { |
| Wayne Roberts |
9:295e37c38fb3 | 1439 | switch (sidx) { |
| Wayne Roberts |
9:295e37c38fb3 | 1440 | case 0: gfsk_pp_buf[7] = GFSK_CRC_OFF; break; |
| Wayne Roberts |
9:295e37c38fb3 | 1441 | case 1: gfsk_pp_buf[7] = GFSK_CRC_1_BYTE; break; |
| Wayne Roberts |
9:295e37c38fb3 | 1442 | case 2: gfsk_pp_buf[7] = GFSK_CRC_2_BYTE; break; |
| Wayne Roberts |
9:295e37c38fb3 | 1443 | case 3: gfsk_pp_buf[7] = GFSK_CRC_1_BYTE_INV; break; |
| Wayne Roberts |
9:295e37c38fb3 | 1444 | case 4: gfsk_pp_buf[7] = GFSK_CRC_2_BYTE_INV; break; |
| Wayne Roberts |
9:295e37c38fb3 | 1445 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1446 | radio.xfer(OPCODE_SET_PACKET_PARAM, 9, 0, gfsk_pp_buf); |
| Wayne Roberts |
9:295e37c38fb3 | 1447 | return MENUMODE_REDRAW; |
| Wayne Roberts |
9:295e37c38fb3 | 1448 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1449 | |
| Wayne Roberts |
9:295e37c38fb3 | 1450 | const dropdown_item_t Radio::gfsk_crcType_item = { _ITEM_DROPDOWN, gfsk_crcType_strs, gfsk_crcType_strs, gfsk_crcType_read, gfsk_crcType_write }; |
| Wayne Roberts |
9:295e37c38fb3 | 1451 | |
| Wayne Roberts |
9:295e37c38fb3 | 1452 | bool Radio::gfsk_dcfree_read(void) |
| Wayne Roberts |
9:295e37c38fb3 | 1453 | { |
| Wayne Roberts |
9:295e37c38fb3 | 1454 | gfskConfig5_t cfg5; |
| Wayne Roberts |
10:db4e11a55bda | 1455 | radio.memRegRead(REG_ADDR_GFSK_CFG5, 1, &cfg5.dword); |
| Wayne Roberts |
9:295e37c38fb3 | 1456 | gfsk_pp_buf[8] = cfg5.bits.whitening_enable; |
| Wayne Roberts |
9:295e37c38fb3 | 1457 | return cfg5.bits.whitening_enable; |
| Wayne Roberts |
9:295e37c38fb3 | 1458 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1459 | |
| Wayne Roberts |
9:295e37c38fb3 | 1460 | bool Radio::gfsk_dcfree_push(void) |
| Wayne Roberts |
9:295e37c38fb3 | 1461 | { |
| Wayne Roberts |
9:295e37c38fb3 | 1462 | gfsk_pp_buf[8] ^= 1; |
| Wayne Roberts |
9:295e37c38fb3 | 1463 | radio.xfer(OPCODE_SET_PACKET_PARAM, 9, 0, gfsk_pp_buf); |
| Wayne Roberts |
9:295e37c38fb3 | 1464 | return gfsk_pp_buf[8] == 1; |
| Wayne Roberts |
9:295e37c38fb3 | 1465 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1466 | |
| Wayne Roberts |
9:295e37c38fb3 | 1467 | const toggle_item_t Radio::gfsk_dcfree_item = { _ITEM_TOGGLE, "off", "on ", gfsk_dcfree_read, gfsk_dcfree_push}; |
| Wayne Roberts |
9:295e37c38fb3 | 1468 | |
| Wayne Roberts |
9:295e37c38fb3 | 1469 | void Radio::gfsk_crcinit_print() |
| Wayne Roberts |
9:295e37c38fb3 | 1470 | { |
| Wayne Roberts |
10:db4e11a55bda | 1471 | radio.memRegRead(REG_ADDR_GFSK_CRC_INIT, 1, &gfsk_crc_Poly); |
| Wayne Roberts |
10:db4e11a55bda | 1472 | pc.printf("%04x", (unsigned)gfsk_crc_Poly); |
| Wayne Roberts |
9:295e37c38fb3 | 1473 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1474 | |
| Wayne Roberts |
9:295e37c38fb3 | 1475 | bool Radio::gfsk_crcinit_write(const char *txt) |
| Wayne Roberts |
9:295e37c38fb3 | 1476 | { |
| Wayne Roberts |
10:db4e11a55bda | 1477 | uint8_t buf[8]; |
| Wayne Roberts |
9:295e37c38fb3 | 1478 | unsigned crcInit; |
| Wayne Roberts |
9:295e37c38fb3 | 1479 | sscanf(txt, "%x", &crcInit); |
| Wayne Roberts |
10:db4e11a55bda | 1480 | gfsk_crc_initValue = crcInit; |
| Wayne Roberts |
10:db4e11a55bda | 1481 | radio.to_big_endian32(gfsk_crc_initValue, buf); |
| Wayne Roberts |
10:db4e11a55bda | 1482 | radio.to_big_endian32(gfsk_crc_Poly, buf+4); |
| Wayne Roberts |
10:db4e11a55bda | 1483 | radio.xfer(OPCODE_SET_GFSK_CRC_PARAMS, 8, 0, buf); |
| Wayne Roberts |
9:295e37c38fb3 | 1484 | return false; |
| Wayne Roberts |
9:295e37c38fb3 | 1485 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1486 | |
| Wayne Roberts |
9:295e37c38fb3 | 1487 | const value_item_t Radio::gfsk_crcinit_item = { _ITEM_VALUE, 4, gfsk_crcinit_print, gfsk_crcinit_write}; |
| Wayne Roberts |
9:295e37c38fb3 | 1488 | |
| Wayne Roberts |
10:db4e11a55bda | 1489 | void Radio::gfsk_crcpoly_print() |
| Wayne Roberts |
10:db4e11a55bda | 1490 | { |
| Wayne Roberts |
10:db4e11a55bda | 1491 | radio.memRegRead(REG_ADDR_GFSK_CRC_POLY, 1, &gfsk_crc_Poly); |
| Wayne Roberts |
10:db4e11a55bda | 1492 | pc.printf("%04x", (unsigned)gfsk_crc_Poly); |
| Wayne Roberts |
10:db4e11a55bda | 1493 | } |
| Wayne Roberts |
10:db4e11a55bda | 1494 | |
| Wayne Roberts |
10:db4e11a55bda | 1495 | bool Radio::gfsk_crcpoly_write(const char *txt) |
| Wayne Roberts |
10:db4e11a55bda | 1496 | { |
| Wayne Roberts |
10:db4e11a55bda | 1497 | uint8_t buf[8]; |
| Wayne Roberts |
10:db4e11a55bda | 1498 | unsigned crcPoly; |
| Wayne Roberts |
10:db4e11a55bda | 1499 | sscanf(txt, "%x", &crcPoly); |
| Wayne Roberts |
10:db4e11a55bda | 1500 | gfsk_crc_Poly = crcPoly; |
| Wayne Roberts |
10:db4e11a55bda | 1501 | radio.to_big_endian32(gfsk_crc_initValue, buf); |
| Wayne Roberts |
10:db4e11a55bda | 1502 | radio.to_big_endian32(gfsk_crc_Poly, buf+4); |
| Wayne Roberts |
10:db4e11a55bda | 1503 | radio.xfer(OPCODE_SET_GFSK_CRC_PARAMS, 8, 0, buf); |
| Wayne Roberts |
10:db4e11a55bda | 1504 | return false; |
| Wayne Roberts |
10:db4e11a55bda | 1505 | } |
| Wayne Roberts |
10:db4e11a55bda | 1506 | |
| Wayne Roberts |
10:db4e11a55bda | 1507 | const value_item_t Radio::gfsk_crcpoly_item = { _ITEM_VALUE, 4, gfsk_crcpoly_print, gfsk_crcpoly_write}; |
| Wayne Roberts |
10:db4e11a55bda | 1508 | |
| Wayne Roberts |
9:295e37c38fb3 | 1509 | const menu_t Radio::gfsk_menu[] = { |
| Wayne Roberts |
9:295e37c38fb3 | 1510 | { {FIRST_CHIP_MENU_ROW+2, 1}, "bps:", &gfsk_bitrate_item, FLAG_MSGTYPE_ALL }, |
| Wayne Roberts |
9:295e37c38fb3 | 1511 | { {FIRST_CHIP_MENU_ROW+2, 15}, "bt:", &gfsk_bt_item, FLAG_MSGTYPE_ALL }, |
| Wayne Roberts |
9:295e37c38fb3 | 1512 | { {FIRST_CHIP_MENU_ROW+2, 23}, "rxbw:", &gfsk_rxbw_item, FLAG_MSGTYPE_ALL }, |
| Wayne Roberts |
9:295e37c38fb3 | 1513 | { {FIRST_CHIP_MENU_ROW+2, 39}, "fdev:", &gfsk_fdev_item, FLAG_MSGTYPE_ALL }, |
| Wayne Roberts |
9:295e37c38fb3 | 1514 | |
| Wayne Roberts |
9:295e37c38fb3 | 1515 | { {FIRST_CHIP_MENU_ROW+3, 1}, "PreambleLength:", &gfsk_pblLen_item, FLAG_MSGTYPE_ALL }, |
| Wayne Roberts |
9:295e37c38fb3 | 1516 | { {FIRST_CHIP_MENU_ROW+3, 21}, "PreambleDetectorLength:", &gfsk_pblDetLen_item, FLAG_MSGTYPE_ALL }, |
| Wayne Roberts |
9:295e37c38fb3 | 1517 | { {FIRST_CHIP_MENU_ROW+4, 1}, "syncWord:", &gfsk_syncWord_item, FLAG_MSGTYPE_ALL }, |
| Wayne Roberts |
9:295e37c38fb3 | 1518 | { {FIRST_CHIP_MENU_ROW+4, 29}, "bits:", &gfsk_syncLen_item, FLAG_MSGTYPE_ALL }, |
| Wayne Roberts |
9:295e37c38fb3 | 1519 | { {FIRST_CHIP_MENU_ROW+4, 38}, "CRC:", &gfsk_crcType_item, FLAG_MSGTYPE_ALL }, |
| Wayne Roberts |
9:295e37c38fb3 | 1520 | { {FIRST_CHIP_MENU_ROW+4, 55}, "AddrComp:", &gfsk_addrcomp_item, FLAG_MSGTYPE_ALL }, |
| Wayne Roberts |
9:295e37c38fb3 | 1521 | |
| Wayne Roberts |
9:295e37c38fb3 | 1522 | { {FIRST_CHIP_MENU_ROW+5, 1}, NULL, &gfsk_varlen_item, FLAG_MSGTYPE_ALL }, |
| Wayne Roberts |
9:295e37c38fb3 | 1523 | { {FIRST_CHIP_MENU_ROW+5, 10}, "whiten:", &gfsk_dcfree_item, FLAG_MSGTYPE_ALL }, |
| Wayne Roberts |
9:295e37c38fb3 | 1524 | { {FIRST_CHIP_MENU_ROW+5, 23}, "crcInit:", &gfsk_crcinit_item, FLAG_MSGTYPE_ALL }, |
| Wayne Roberts |
10:db4e11a55bda | 1525 | { {FIRST_CHIP_MENU_ROW+5, 36}, "crcPoly:", &gfsk_crcpoly_item, FLAG_MSGTYPE_ALL }, |
| Wayne Roberts |
9:295e37c38fb3 | 1526 | |
| Wayne Roberts |
9:295e37c38fb3 | 1527 | { {FIRST_CHIP_MENU_ROW+6, 1}, NULL, &dbg_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
9:295e37c38fb3 | 1528 | { {0, 0}, NULL, NULL } |
| Wayne Roberts |
9:295e37c38fb3 | 1529 | }; |
| Wayne Roberts |
9:295e37c38fb3 | 1530 | |
| Wayne Roberts |
9:295e37c38fb3 | 1531 | static const char* const lora_bwstrs[] = { |
| Wayne Roberts |
10:db4e11a55bda | 1532 | /* 0 */ " 7.8KHz", |
| Wayne Roberts |
10:db4e11a55bda | 1533 | /* 1 */ " 15.6KHz", |
| Wayne Roberts |
10:db4e11a55bda | 1534 | /* 2 */ "31,25KHz", |
| Wayne Roberts |
10:db4e11a55bda | 1535 | /* 3 */ " 62.5KHz", |
| Wayne Roberts |
10:db4e11a55bda | 1536 | /* 4 */ " 125KHz", |
| Wayne Roberts |
10:db4e11a55bda | 1537 | /* 5 */ " 250KHz", |
| Wayne Roberts |
10:db4e11a55bda | 1538 | /* 6 */ " 500KHz", |
| Wayne Roberts |
10:db4e11a55bda | 1539 | /* 7 */ " 1000KHz", |
| Wayne Roberts |
10:db4e11a55bda | 1540 | /* 0 */ NULL |
| Wayne Roberts |
9:295e37c38fb3 | 1541 | }; |
| Wayne Roberts |
9:295e37c38fb3 | 1542 | |
| Wayne Roberts |
9:295e37c38fb3 | 1543 | unsigned Radio::lora_bw_read(bool forWriting) |
| Wayne Roberts |
9:295e37c38fb3 | 1544 | { |
| Wayne Roberts |
9:295e37c38fb3 | 1545 | loraConfig0_t cfg0; |
| Wayne Roberts |
10:db4e11a55bda | 1546 | radio.memRegRead(REG_ADDR_LORA_CONFIG0, 1, &cfg0.dword); |
| Wayne Roberts |
10:db4e11a55bda | 1547 | return cfg0.bits.modem_bw; |
| Wayne Roberts |
9:295e37c38fb3 | 1548 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1549 | |
| Wayne Roberts |
9:295e37c38fb3 | 1550 | menuMode_e Radio::lora_bw_write(unsigned sidx) |
| Wayne Roberts |
9:295e37c38fb3 | 1551 | { |
| Wayne Roberts |
10:db4e11a55bda | 1552 | lora_mp_buf[1] = sidx; |
| Wayne Roberts |
9:295e37c38fb3 | 1553 | radio.xfer(OPCODE_SET_MODULATION, 4, 0, lora_mp_buf); |
| Wayne Roberts |
9:295e37c38fb3 | 1554 | return MENUMODE_REDRAW; |
| Wayne Roberts |
9:295e37c38fb3 | 1555 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1556 | |
| Wayne Roberts |
9:295e37c38fb3 | 1557 | const dropdown_item_t Radio::lora_bw_item = { _ITEM_DROPDOWN, lora_bwstrs, lora_bwstrs, lora_bw_read, lora_bw_write}; |
| Wayne Roberts |
9:295e37c38fb3 | 1558 | |
| Wayne Roberts |
9:295e37c38fb3 | 1559 | void Radio::lora_sf_print() |
| Wayne Roberts |
9:295e37c38fb3 | 1560 | { |
| Wayne Roberts |
9:295e37c38fb3 | 1561 | loraConfig0_t cfg0; |
| Wayne Roberts |
10:db4e11a55bda | 1562 | radio.memRegRead(REG_ADDR_LORA_CONFIG0, 1, &cfg0.dword); |
| Wayne Roberts |
9:295e37c38fb3 | 1563 | lora_mp_buf[0] = cfg0.bits.modem_sf; |
| Wayne Roberts |
9:295e37c38fb3 | 1564 | pc.printf("%u", cfg0.bits.modem_sf); |
| Wayne Roberts |
9:295e37c38fb3 | 1565 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1566 | |
| Wayne Roberts |
9:295e37c38fb3 | 1567 | bool Radio::lora_sf_write(const char* str) |
| Wayne Roberts |
9:295e37c38fb3 | 1568 | { |
| Wayne Roberts |
9:295e37c38fb3 | 1569 | unsigned sf; |
| Wayne Roberts |
9:295e37c38fb3 | 1570 | if (sscanf(str, "%u", &sf) == 1) { |
| Wayne Roberts |
9:295e37c38fb3 | 1571 | lora_mp_buf[0] = sf; |
| Wayne Roberts |
9:295e37c38fb3 | 1572 | radio.xfer(OPCODE_SET_MODULATION, 4, 0, lora_mp_buf); |
| Wayne Roberts |
9:295e37c38fb3 | 1573 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1574 | return false; |
| Wayne Roberts |
9:295e37c38fb3 | 1575 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1576 | |
| Wayne Roberts |
9:295e37c38fb3 | 1577 | const value_item_t Radio::lora_sf_item = { _ITEM_VALUE, 3, lora_sf_print, lora_sf_write }; |
| Wayne Roberts |
9:295e37c38fb3 | 1578 | |
| Wayne Roberts |
9:295e37c38fb3 | 1579 | void Radio::lora_pblLen_print() |
| Wayne Roberts |
9:295e37c38fb3 | 1580 | { |
| Wayne Roberts |
9:295e37c38fb3 | 1581 | unsigned pl; |
| Wayne Roberts |
9:295e37c38fb3 | 1582 | loraConfigC_t cfgc; |
| Wayne Roberts |
10:db4e11a55bda | 1583 | radio.memRegRead(REG_ADDR_LORA_CONFIGC, 1, &cfgc.dword); |
| Wayne Roberts |
9:295e37c38fb3 | 1584 | pc.printf("%u", cfgc.bits.preamble_length); |
| Wayne Roberts |
9:295e37c38fb3 | 1585 | pl = cfgc.bits.preamble_length; |
| Wayne Roberts |
9:295e37c38fb3 | 1586 | lora_pp_buf[1] = pl & 0xff; |
| Wayne Roberts |
9:295e37c38fb3 | 1587 | pl >>= 8; |
| Wayne Roberts |
9:295e37c38fb3 | 1588 | lora_pp_buf[0] = pl; |
| Wayne Roberts |
9:295e37c38fb3 | 1589 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1590 | |
| Wayne Roberts |
9:295e37c38fb3 | 1591 | bool Radio::lora_pblLen_write(const char* txt) |
| Wayne Roberts |
9:295e37c38fb3 | 1592 | { |
| Wayne Roberts |
9:295e37c38fb3 | 1593 | unsigned n; |
| Wayne Roberts |
9:295e37c38fb3 | 1594 | if (sscanf(txt, "%u", &n) == 1) { |
| Wayne Roberts |
10:db4e11a55bda | 1595 | radio.to_big_endian16(n, lora_pp_buf); |
| Wayne Roberts |
9:295e37c38fb3 | 1596 | radio.xfer(OPCODE_SET_PACKET_PARAM, 6, 0, lora_pp_buf); |
| Wayne Roberts |
9:295e37c38fb3 | 1597 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1598 | return false; |
| Wayne Roberts |
9:295e37c38fb3 | 1599 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1600 | |
| Wayne Roberts |
9:295e37c38fb3 | 1601 | const value_item_t Radio::lora_pblLen_item = { _ITEM_VALUE, 5, lora_pblLen_print, lora_pblLen_write}; |
| Wayne Roberts |
9:295e37c38fb3 | 1602 | |
| Wayne Roberts |
9:295e37c38fb3 | 1603 | bool Radio::lora_headerType_read() |
| Wayne Roberts |
9:295e37c38fb3 | 1604 | { |
| Wayne Roberts |
9:295e37c38fb3 | 1605 | loraConfig0_t cfg0; |
| Wayne Roberts |
10:db4e11a55bda | 1606 | radio.memRegRead(REG_ADDR_LORA_CONFIG0, 1, &cfg0.dword); |
| Wayne Roberts |
9:295e37c38fb3 | 1607 | lora_pp_buf[2] = cfg0.bits.implicit_header; |
| Wayne Roberts |
9:295e37c38fb3 | 1608 | return cfg0.bits.implicit_header; |
| Wayne Roberts |
9:295e37c38fb3 | 1609 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1610 | |
| Wayne Roberts |
9:295e37c38fb3 | 1611 | bool Radio::lora_headerType_push() |
| Wayne Roberts |
9:295e37c38fb3 | 1612 | { |
| Wayne Roberts |
9:295e37c38fb3 | 1613 | bool ret; |
| Wayne Roberts |
9:295e37c38fb3 | 1614 | if (lora_pp_buf[2]) { |
| Wayne Roberts |
9:295e37c38fb3 | 1615 | lora_pp_buf[2] = 0; |
| Wayne Roberts |
9:295e37c38fb3 | 1616 | ret = false; |
| Wayne Roberts |
9:295e37c38fb3 | 1617 | } else { |
| Wayne Roberts |
9:295e37c38fb3 | 1618 | lora_pp_buf[2] = 1; |
| Wayne Roberts |
9:295e37c38fb3 | 1619 | ret = true; |
| Wayne Roberts |
9:295e37c38fb3 | 1620 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1621 | radio.xfer(OPCODE_SET_PACKET_PARAM, 6, 0, lora_pp_buf); |
| Wayne Roberts |
9:295e37c38fb3 | 1622 | return ret; |
| Wayne Roberts |
9:295e37c38fb3 | 1623 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1624 | |
| Wayne Roberts |
9:295e37c38fb3 | 1625 | const toggle_item_t Radio::lora_headerType_item = { _ITEM_TOGGLE, "EXPLICIT", "IMPLICIT", lora_headerType_read, lora_headerType_push}; |
| Wayne Roberts |
9:295e37c38fb3 | 1626 | |
| Wayne Roberts |
9:295e37c38fb3 | 1627 | static const char* const lora_crs[] = { |
| Wayne Roberts |
9:295e37c38fb3 | 1628 | "short 4/5 ", |
| Wayne Roberts |
9:295e37c38fb3 | 1629 | "short 4/6 ", |
| Wayne Roberts |
9:295e37c38fb3 | 1630 | "short 4/7 ", |
| Wayne Roberts |
9:295e37c38fb3 | 1631 | "short 4/8 ", |
| Wayne Roberts |
9:295e37c38fb3 | 1632 | " long 4/5 ", |
| Wayne Roberts |
9:295e37c38fb3 | 1633 | " long 4/6 ", |
| Wayne Roberts |
9:295e37c38fb3 | 1634 | " long 4/8 ", |
| Wayne Roberts |
9:295e37c38fb3 | 1635 | NULL |
| Wayne Roberts |
9:295e37c38fb3 | 1636 | }; |
| Wayne Roberts |
9:295e37c38fb3 | 1637 | |
| Wayne Roberts |
9:295e37c38fb3 | 1638 | unsigned Radio::lora_cr_read(bool forWriting) |
| Wayne Roberts |
9:295e37c38fb3 | 1639 | { |
| Wayne Roberts |
9:295e37c38fb3 | 1640 | loraConfig0_t cfg0; |
| Wayne Roberts |
10:db4e11a55bda | 1641 | radio.memRegRead(REG_ADDR_LORA_CONFIG0, 1, &cfg0.dword); |
| Wayne Roberts |
9:295e37c38fb3 | 1642 | lora_mp_buf[2] = cfg0.bits.coding_rate; |
| Wayne Roberts |
9:295e37c38fb3 | 1643 | if (lora_mp_buf[2] > 7) |
| Wayne Roberts |
9:295e37c38fb3 | 1644 | return 7; |
| Wayne Roberts |
9:295e37c38fb3 | 1645 | else |
| Wayne Roberts |
9:295e37c38fb3 | 1646 | return lora_mp_buf[2]; |
| Wayne Roberts |
9:295e37c38fb3 | 1647 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1648 | |
| Wayne Roberts |
9:295e37c38fb3 | 1649 | menuMode_e Radio::lora_cr_write(unsigned sidx) |
| Wayne Roberts |
9:295e37c38fb3 | 1650 | { |
| Wayne Roberts |
9:295e37c38fb3 | 1651 | lora_mp_buf[2] = sidx + 1; |
| Wayne Roberts |
9:295e37c38fb3 | 1652 | radio.xfer(OPCODE_SET_MODULATION, 4, 0, lora_mp_buf); |
| Wayne Roberts |
9:295e37c38fb3 | 1653 | return MENUMODE_REDRAW; |
| Wayne Roberts |
9:295e37c38fb3 | 1654 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1655 | |
| Wayne Roberts |
9:295e37c38fb3 | 1656 | const dropdown_item_t Radio::lora_cr_item = { _ITEM_DROPDOWN, lora_crs, lora_crs, lora_cr_read, lora_cr_write}; |
| Wayne Roberts |
9:295e37c38fb3 | 1657 | |
| Wayne Roberts |
9:295e37c38fb3 | 1658 | bool Radio::ppmOffset_read() |
| Wayne Roberts |
9:295e37c38fb3 | 1659 | { |
| Wayne Roberts |
9:295e37c38fb3 | 1660 | loraConfig0_t cfg0; |
| Wayne Roberts |
10:db4e11a55bda | 1661 | radio.memRegRead(REG_ADDR_LORA_CONFIG0, 1, &cfg0.dword); |
| Wayne Roberts |
9:295e37c38fb3 | 1662 | lora_mp_buf[3] = cfg0.bits.ppm_offset; |
| Wayne Roberts |
9:295e37c38fb3 | 1663 | return lora_mp_buf[3]; |
| Wayne Roberts |
9:295e37c38fb3 | 1664 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1665 | |
| Wayne Roberts |
9:295e37c38fb3 | 1666 | bool Radio::ppmOffset_push() |
| Wayne Roberts |
9:295e37c38fb3 | 1667 | { |
| Wayne Roberts |
9:295e37c38fb3 | 1668 | bool ret; |
| Wayne Roberts |
9:295e37c38fb3 | 1669 | if (lora_mp_buf[3]) { |
| Wayne Roberts |
9:295e37c38fb3 | 1670 | lora_mp_buf[3] = 0; |
| Wayne Roberts |
9:295e37c38fb3 | 1671 | ret = false; |
| Wayne Roberts |
9:295e37c38fb3 | 1672 | } else { |
| Wayne Roberts |
9:295e37c38fb3 | 1673 | lora_mp_buf[3] = 1; |
| Wayne Roberts |
9:295e37c38fb3 | 1674 | ret = true; |
| Wayne Roberts |
9:295e37c38fb3 | 1675 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1676 | radio.xfer(OPCODE_SET_MODULATION, 4, 0, lora_mp_buf); |
| Wayne Roberts |
9:295e37c38fb3 | 1677 | return ret; |
| Wayne Roberts |
9:295e37c38fb3 | 1678 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1679 | |
| Wayne Roberts |
9:295e37c38fb3 | 1680 | const toggle_item_t Radio::lora_ppmOffset_item = { _ITEM_TOGGLE, "LowDatarateOptimize", NULL, ppmOffset_read, ppmOffset_push}; |
| Wayne Roberts |
9:295e37c38fb3 | 1681 | |
| Wayne Roberts |
9:295e37c38fb3 | 1682 | bool Radio::lora_crcon_read() |
| Wayne Roberts |
9:295e37c38fb3 | 1683 | { |
| Wayne Roberts |
9:295e37c38fb3 | 1684 | loraConfig0_t cfg0; |
| Wayne Roberts |
10:db4e11a55bda | 1685 | radio.memRegRead(REG_ADDR_LORA_CONFIG0, 1, &cfg0.dword); |
| Wayne Roberts |
9:295e37c38fb3 | 1686 | lora_pp_buf[4] = cfg0.bits.crc_on; |
| Wayne Roberts |
9:295e37c38fb3 | 1687 | return cfg0.bits.crc_on; |
| Wayne Roberts |
9:295e37c38fb3 | 1688 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1689 | |
| Wayne Roberts |
9:295e37c38fb3 | 1690 | bool Radio::lora_crcon_push() |
| Wayne Roberts |
9:295e37c38fb3 | 1691 | { |
| Wayne Roberts |
9:295e37c38fb3 | 1692 | bool ret; |
| Wayne Roberts |
9:295e37c38fb3 | 1693 | if (lora_pp_buf[4]) { |
| Wayne Roberts |
9:295e37c38fb3 | 1694 | lora_pp_buf[4] = 0; |
| Wayne Roberts |
9:295e37c38fb3 | 1695 | ret = false; |
| Wayne Roberts |
9:295e37c38fb3 | 1696 | } else { |
| Wayne Roberts |
9:295e37c38fb3 | 1697 | lora_pp_buf[4] = 1; |
| Wayne Roberts |
9:295e37c38fb3 | 1698 | ret = true; |
| Wayne Roberts |
9:295e37c38fb3 | 1699 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1700 | radio.xfer(OPCODE_SET_PACKET_PARAM, 6, 0, lora_pp_buf); |
| Wayne Roberts |
9:295e37c38fb3 | 1701 | return ret; |
| Wayne Roberts |
9:295e37c38fb3 | 1702 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1703 | |
| Wayne Roberts |
9:295e37c38fb3 | 1704 | const toggle_item_t Radio::lora_crcon_item = { _ITEM_TOGGLE, |
| Wayne Roberts |
9:295e37c38fb3 | 1705 | "crc-off", |
| Wayne Roberts |
9:295e37c38fb3 | 1706 | " CrcOn ", |
| Wayne Roberts |
9:295e37c38fb3 | 1707 | lora_crcon_read, |
| Wayne Roberts |
9:295e37c38fb3 | 1708 | lora_crcon_push |
| Wayne Roberts |
9:295e37c38fb3 | 1709 | }; |
| Wayne Roberts |
9:295e37c38fb3 | 1710 | |
| Wayne Roberts |
9:295e37c38fb3 | 1711 | bool Radio::lora_inviq_read() |
| Wayne Roberts |
9:295e37c38fb3 | 1712 | { |
| Wayne Roberts |
9:295e37c38fb3 | 1713 | loraConfigA_t cfgA; |
| Wayne Roberts |
9:295e37c38fb3 | 1714 | //loraConfigB_t cfgB; |
| Wayne Roberts |
10:db4e11a55bda | 1715 | radio.memRegRead(REG_ADDR_LORA_CONFIGA, 1, &cfgA.dword); |
| Wayne Roberts |
9:295e37c38fb3 | 1716 | /*radio.memRegRead(REG_ADDR_LORA_CONFIGB, 1, buf); |
| Wayne Roberts |
9:295e37c38fb3 | 1717 | cfgB.dword = radio.from_big_endian32(buf);*/ |
| Wayne Roberts |
9:295e37c38fb3 | 1718 | //TODO which one is RX vs TX: cfgA.bits.invertIQ, cfgB.bits.invertIQ |
| Wayne Roberts |
9:295e37c38fb3 | 1719 | lora_pp_buf[5] = cfgA.bits.invertIQ; |
| Wayne Roberts |
9:295e37c38fb3 | 1720 | /*if (cfgA.bits.invertIQ != cfgB.bits.invertIQ) |
| Wayne Roberts |
9:295e37c38fb3 | 1721 | log_printf("invIQ %u %u\r\n", cfgA.bits.invertIQ, cfgB.bits.invertIQ);*/ |
| Wayne Roberts |
9:295e37c38fb3 | 1722 | return lora_pp_buf[5]; |
| Wayne Roberts |
9:295e37c38fb3 | 1723 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1724 | |
| Wayne Roberts |
9:295e37c38fb3 | 1725 | bool Radio::lora_inviq_push() |
| Wayne Roberts |
9:295e37c38fb3 | 1726 | { |
| Wayne Roberts |
10:db4e11a55bda | 1727 | lora_pp_buf[5] ^= 1; |
| Wayne Roberts |
9:295e37c38fb3 | 1728 | radio.xfer(OPCODE_SET_PACKET_PARAM, 6, 0, lora_pp_buf); |
| Wayne Roberts |
10:db4e11a55bda | 1729 | return lora_pp_buf[5] == 1; |
| Wayne Roberts |
9:295e37c38fb3 | 1730 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1731 | |
| Wayne Roberts |
9:295e37c38fb3 | 1732 | const toggle_item_t Radio::lora_inviq_item = { _ITEM_TOGGLE, |
| Wayne Roberts |
9:295e37c38fb3 | 1733 | " IQ ", |
| Wayne Roberts |
9:295e37c38fb3 | 1734 | "invertedIQ", |
| Wayne Roberts |
9:295e37c38fb3 | 1735 | lora_inviq_read, lora_inviq_push |
| Wayne Roberts |
9:295e37c38fb3 | 1736 | }; |
| Wayne Roberts |
9:295e37c38fb3 | 1737 | |
| Wayne Roberts |
9:295e37c38fb3 | 1738 | bool Radio::lora_sync_read() |
| Wayne Roberts |
9:295e37c38fb3 | 1739 | { |
| Wayne Roberts |
9:295e37c38fb3 | 1740 | loraSync_t sync; |
| Wayne Roberts |
10:db4e11a55bda | 1741 | radio.memRegRead(REG_ADDR_LORA_SYNC, 1, &sync.dword); |
| Wayne Roberts |
9:295e37c38fb3 | 1742 | if (sync.bits.ppg_a == 2 && sync.bits.ppg_b == 4) |
| Wayne Roberts |
9:295e37c38fb3 | 1743 | return false; // private |
| Wayne Roberts |
9:295e37c38fb3 | 1744 | else if (sync.bits.ppg_a == 6 && sync.bits.ppg_b == 8) |
| Wayne Roberts |
9:295e37c38fb3 | 1745 | return true; // public |
| Wayne Roberts |
9:295e37c38fb3 | 1746 | else |
| Wayne Roberts |
9:295e37c38fb3 | 1747 | return false; // unknown |
| Wayne Roberts |
9:295e37c38fb3 | 1748 | |
| Wayne Roberts |
9:295e37c38fb3 | 1749 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1750 | |
| Wayne Roberts |
9:295e37c38fb3 | 1751 | bool Radio::lora_sync_push() |
| Wayne Roberts |
9:295e37c38fb3 | 1752 | { |
| Wayne Roberts |
9:295e37c38fb3 | 1753 | uint8_t buf; |
| Wayne Roberts |
9:295e37c38fb3 | 1754 | if (lora_sync_read()) |
| Wayne Roberts |
9:295e37c38fb3 | 1755 | buf = 0; |
| Wayne Roberts |
9:295e37c38fb3 | 1756 | else |
| Wayne Roberts |
9:295e37c38fb3 | 1757 | buf = 1; |
| Wayne Roberts |
9:295e37c38fb3 | 1758 | |
| Wayne Roberts |
9:295e37c38fb3 | 1759 | radio.xfer(OPCODE_SET_LORA_PUBLIC_NETWORK, 1, 0, &buf); |
| Wayne Roberts |
9:295e37c38fb3 | 1760 | return buf; |
| Wayne Roberts |
9:295e37c38fb3 | 1761 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1762 | |
| Wayne Roberts |
9:295e37c38fb3 | 1763 | const toggle_item_t Radio::lora_sync_item = { _ITEM_TOGGLE, |
| Wayne Roberts |
9:295e37c38fb3 | 1764 | "private", |
| Wayne Roberts |
9:295e37c38fb3 | 1765 | "public ", |
| Wayne Roberts |
9:295e37c38fb3 | 1766 | lora_sync_read, |
| Wayne Roberts |
9:295e37c38fb3 | 1767 | lora_sync_push |
| Wayne Roberts |
9:295e37c38fb3 | 1768 | }; |
| Wayne Roberts |
9:295e37c38fb3 | 1769 | |
| Wayne Roberts |
9:295e37c38fb3 | 1770 | const menu_t Radio::lora_menu[] = { |
| Wayne Roberts |
9:295e37c38fb3 | 1771 | { {FIRST_CHIP_MENU_ROW+2, 1}, NULL, &lora_bw_item, FLAG_MSGTYPE_ALL }, |
| Wayne Roberts |
9:295e37c38fb3 | 1772 | { {FIRST_CHIP_MENU_ROW+2, 12}, "sf:", &lora_sf_item, FLAG_MSGTYPE_ALL }, |
| Wayne Roberts |
9:295e37c38fb3 | 1773 | { {FIRST_CHIP_MENU_ROW+2, 19}, "cr:", &lora_cr_item, FLAG_MSGTYPE_ALL }, |
| Wayne Roberts |
9:295e37c38fb3 | 1774 | { {FIRST_CHIP_MENU_ROW+2, 37}, NULL, &lora_ppmOffset_item, FLAG_MSGTYPE_ALL }, |
| Wayne Roberts |
9:295e37c38fb3 | 1775 | |
| Wayne Roberts |
9:295e37c38fb3 | 1776 | { {FIRST_CHIP_MENU_ROW+3, 1}, "PreambleLength:", &lora_pblLen_item, FLAG_MSGTYPE_ALL }, |
| Wayne Roberts |
9:295e37c38fb3 | 1777 | { {FIRST_CHIP_MENU_ROW+3, 23}, NULL, &lora_headerType_item, FLAG_MSGTYPE_ALL }, |
| Wayne Roberts |
9:295e37c38fb3 | 1778 | { {FIRST_CHIP_MENU_ROW+3, 33}, NULL, &lora_crcon_item, FLAG_MSGTYPE_ALL }, |
| Wayne Roberts |
9:295e37c38fb3 | 1779 | { {FIRST_CHIP_MENU_ROW+3, 43}, NULL, &lora_inviq_item, FLAG_MSGTYPE_ALL }, |
| Wayne Roberts |
9:295e37c38fb3 | 1780 | { {FIRST_CHIP_MENU_ROW+3, 55}, "sync:", &lora_sync_item, FLAG_MSGTYPE_ALL }, |
| Wayne Roberts |
9:295e37c38fb3 | 1781 | |
| Wayne Roberts |
9:295e37c38fb3 | 1782 | { {0, 0}, NULL, NULL } |
| Wayne Roberts |
9:295e37c38fb3 | 1783 | }; |
| Wayne Roberts |
9:295e37c38fb3 | 1784 | |
| Wayne Roberts |
9:295e37c38fb3 | 1785 | void Radio::dbg_push() |
| Wayne Roberts |
9:295e37c38fb3 | 1786 | { |
| Wayne Roberts |
10:db4e11a55bda | 1787 | log_printf("dbg\r\n"); |
| Wayne Roberts |
9:295e37c38fb3 | 1788 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1789 | |
| Wayne Roberts |
9:295e37c38fb3 | 1790 | const button_item_t Radio::dbg_item = { _ITEM_BUTTON, "DBG", dbg_push }; |
| Wayne Roberts |
9:295e37c38fb3 | 1791 | |
| Wayne Roberts |
9:295e37c38fb3 | 1792 | const button_item_t rfswEn_item = { _ITEM_BUTTON, " RfSwEnable:", NULL}; |
| Wayne Roberts |
9:295e37c38fb3 | 1793 | const button_item_t rfswStbyCfg_item = { _ITEM_BUTTON, "rfswStbyCfg:", NULL}; |
| Wayne Roberts |
9:295e37c38fb3 | 1794 | const button_item_t rfswRxCfg_item = { _ITEM_BUTTON, " rfswRxCfg:", NULL}; |
| Wayne Roberts |
9:295e37c38fb3 | 1795 | const button_item_t rfswTxCfg_item = { _ITEM_BUTTON, " rfswTxCfg:", NULL}; |
| Wayne Roberts |
9:295e37c38fb3 | 1796 | const button_item_t rfswTxHPCfg_item = { _ITEM_BUTTON, "rfswTxHPCfg:", NULL}; |
| Wayne Roberts |
9:295e37c38fb3 | 1797 | const button_item_t rfswGnssCfg_item = { _ITEM_BUTTON, "rfswGnssCfg:", NULL}; |
| Wayne Roberts |
9:295e37c38fb3 | 1798 | const button_item_t rfswWifiCfg_item = { _ITEM_BUTTON, "rfswWifiCfg:", NULL}; |
| Wayne Roberts |
9:295e37c38fb3 | 1799 | |
| Wayne Roberts |
9:295e37c38fb3 | 1800 | |
| Wayne Roberts |
9:295e37c38fb3 | 1801 | bool Radio::DIO10en_read() |
| Wayne Roberts |
9:295e37c38fb3 | 1802 | { |
| Wayne Roberts |
9:295e37c38fb3 | 1803 | dioEnable_t dio; |
| Wayne Roberts |
10:db4e11a55bda | 1804 | radio.memRegRead(REG_ADDR_DIO10, 1, &dio.dword); |
| Wayne Roberts |
9:295e37c38fb3 | 1805 | if (dio.bits.enable) |
| Wayne Roberts |
9:295e37c38fb3 | 1806 | dioBuf[DIO_en_IDX] |= DIO10_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 1807 | else |
| Wayne Roberts |
9:295e37c38fb3 | 1808 | dioBuf[DIO_en_IDX] &= ~DIO10_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 1809 | return dio.bits.enable; |
| Wayne Roberts |
9:295e37c38fb3 | 1810 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1811 | |
| Wayne Roberts |
9:295e37c38fb3 | 1812 | bool Radio::DIO8en_read() |
| Wayne Roberts |
9:295e37c38fb3 | 1813 | { |
| Wayne Roberts |
9:295e37c38fb3 | 1814 | dioEnable_t dio; |
| Wayne Roberts |
10:db4e11a55bda | 1815 | radio.memRegRead(REG_ADDR_DIO8, 1, &dio.dword); |
| Wayne Roberts |
9:295e37c38fb3 | 1816 | if (dio.bits.enable) |
| Wayne Roberts |
9:295e37c38fb3 | 1817 | dioBuf[DIO_en_IDX] |= DIO8_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 1818 | else |
| Wayne Roberts |
9:295e37c38fb3 | 1819 | dioBuf[DIO_en_IDX] &= ~DIO8_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 1820 | return dio.bits.enable; |
| Wayne Roberts |
9:295e37c38fb3 | 1821 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1822 | |
| Wayne Roberts |
9:295e37c38fb3 | 1823 | bool Radio::DIO7en_read() |
| Wayne Roberts |
9:295e37c38fb3 | 1824 | { |
| Wayne Roberts |
9:295e37c38fb3 | 1825 | dioEnable_t dio; |
| Wayne Roberts |
10:db4e11a55bda | 1826 | radio.memRegRead(REG_ADDR_DIO7, 1, &dio.dword); |
| Wayne Roberts |
9:295e37c38fb3 | 1827 | if (dio.bits.enable) |
| Wayne Roberts |
9:295e37c38fb3 | 1828 | dioBuf[DIO_en_IDX] |= DIO7_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 1829 | else |
| Wayne Roberts |
9:295e37c38fb3 | 1830 | dioBuf[DIO_en_IDX] &= ~DIO7_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 1831 | return dio.bits.enable; |
| Wayne Roberts |
9:295e37c38fb3 | 1832 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1833 | |
| Wayne Roberts |
9:295e37c38fb3 | 1834 | bool Radio::DIO6en_read() |
| Wayne Roberts |
9:295e37c38fb3 | 1835 | { |
| Wayne Roberts |
9:295e37c38fb3 | 1836 | dioEnable_t dio; |
| Wayne Roberts |
10:db4e11a55bda | 1837 | radio.memRegRead(REG_ADDR_DIO6, 1, &dio.dword); |
| Wayne Roberts |
9:295e37c38fb3 | 1838 | if (dio.bits.enable) |
| Wayne Roberts |
9:295e37c38fb3 | 1839 | dioBuf[DIO_en_IDX] |= DIO6_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 1840 | else |
| Wayne Roberts |
9:295e37c38fb3 | 1841 | dioBuf[DIO_en_IDX] &= ~DIO6_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 1842 | return dio.bits.enable; |
| Wayne Roberts |
9:295e37c38fb3 | 1843 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1844 | |
| Wayne Roberts |
9:295e37c38fb3 | 1845 | bool Radio::DIO5en_read() |
| Wayne Roberts |
9:295e37c38fb3 | 1846 | { |
| Wayne Roberts |
9:295e37c38fb3 | 1847 | dioEnable_t dio; |
| Wayne Roberts |
10:db4e11a55bda | 1848 | radio.memRegRead(REG_ADDR_DIO5, 1, &dio.dword); |
| Wayne Roberts |
9:295e37c38fb3 | 1849 | if (dio.bits.enable) |
| Wayne Roberts |
9:295e37c38fb3 | 1850 | dioBuf[DIO_en_IDX] |= DIO5_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 1851 | else |
| Wayne Roberts |
9:295e37c38fb3 | 1852 | dioBuf[DIO_en_IDX] &= ~DIO5_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 1853 | return dio.bits.enable; |
| Wayne Roberts |
9:295e37c38fb3 | 1854 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1855 | |
| Wayne Roberts |
9:295e37c38fb3 | 1856 | bool Radio::DIO10en_push() |
| Wayne Roberts |
9:295e37c38fb3 | 1857 | { |
| Wayne Roberts |
9:295e37c38fb3 | 1858 | dioBuf[DIO_en_IDX] ^= DIO10_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 1859 | radio.xfer(OPCODE_SET_DIO_AS_RFSWITCH, 8, 0, dioBuf); |
| Wayne Roberts |
9:295e37c38fb3 | 1860 | return dioBuf[DIO_en_IDX] == DIO10_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 1861 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1862 | |
| Wayne Roberts |
9:295e37c38fb3 | 1863 | bool Radio::DIO8en_push() |
| Wayne Roberts |
9:295e37c38fb3 | 1864 | { |
| Wayne Roberts |
9:295e37c38fb3 | 1865 | dioBuf[DIO_en_IDX] ^= DIO8_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 1866 | radio.xfer(OPCODE_SET_DIO_AS_RFSWITCH, 8, 0, dioBuf); |
| Wayne Roberts |
9:295e37c38fb3 | 1867 | return dioBuf[DIO_en_IDX] == DIO8_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 1868 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1869 | |
| Wayne Roberts |
9:295e37c38fb3 | 1870 | bool Radio::DIO7en_push() |
| Wayne Roberts |
9:295e37c38fb3 | 1871 | { |
| Wayne Roberts |
9:295e37c38fb3 | 1872 | dioBuf[DIO_en_IDX] ^= DIO7_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 1873 | radio.xfer(OPCODE_SET_DIO_AS_RFSWITCH, 8, 0, dioBuf); |
| Wayne Roberts |
9:295e37c38fb3 | 1874 | return dioBuf[DIO_en_IDX] == DIO7_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 1875 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1876 | |
| Wayne Roberts |
9:295e37c38fb3 | 1877 | bool Radio::DIO6en_push() |
| Wayne Roberts |
9:295e37c38fb3 | 1878 | { |
| Wayne Roberts |
9:295e37c38fb3 | 1879 | dioBuf[DIO_en_IDX] ^= DIO6_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 1880 | radio.xfer(OPCODE_SET_DIO_AS_RFSWITCH, 8, 0, dioBuf); |
| Wayne Roberts |
9:295e37c38fb3 | 1881 | return dioBuf[DIO_en_IDX] == DIO6_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 1882 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1883 | |
| Wayne Roberts |
9:295e37c38fb3 | 1884 | bool Radio::DIO5en_push() |
| Wayne Roberts |
9:295e37c38fb3 | 1885 | { |
| Wayne Roberts |
9:295e37c38fb3 | 1886 | dioBuf[DIO_en_IDX] ^= DIO5_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 1887 | radio.xfer(OPCODE_SET_DIO_AS_RFSWITCH, 8, 0, dioBuf); |
| Wayne Roberts |
9:295e37c38fb3 | 1888 | return dioBuf[DIO_en_IDX] == DIO5_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 1889 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1890 | |
| Wayne Roberts |
9:295e37c38fb3 | 1891 | const toggle_item_t Radio::DIO5en_item = { _ITEM_TOGGLE, "DIO5", NULL, DIO5en_read, DIO5en_push}; |
| Wayne Roberts |
9:295e37c38fb3 | 1892 | const toggle_item_t Radio::DIO6en_item = { _ITEM_TOGGLE, "DIO6", NULL, DIO6en_read, DIO6en_push}; |
| Wayne Roberts |
9:295e37c38fb3 | 1893 | const toggle_item_t Radio::DIO7en_item = { _ITEM_TOGGLE, "DIO7", NULL, DIO7en_read, DIO7en_push}; |
| Wayne Roberts |
9:295e37c38fb3 | 1894 | const toggle_item_t Radio::DIO8en_item = { _ITEM_TOGGLE, "DIO8", NULL, DIO8en_read, DIO8en_push}; |
| Wayne Roberts |
9:295e37c38fb3 | 1895 | const toggle_item_t Radio::DIO10en_item = { _ITEM_TOGGLE, "DIO10", NULL, DIO10en_read, DIO10en_push}; |
| Wayne Roberts |
9:295e37c38fb3 | 1896 | |
| Wayne Roberts |
9:295e37c38fb3 | 1897 | bool Radio::DIO10stby_read() |
| Wayne Roberts |
9:295e37c38fb3 | 1898 | { |
| Wayne Roberts |
9:295e37c38fb3 | 1899 | return dioBuf[DIO_stby_IDX] == DIO10_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 1900 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1901 | |
| Wayne Roberts |
9:295e37c38fb3 | 1902 | bool Radio::DIO10stby_push() |
| Wayne Roberts |
9:295e37c38fb3 | 1903 | { |
| Wayne Roberts |
9:295e37c38fb3 | 1904 | dioBuf[DIO_stby_IDX] ^= DIO10_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 1905 | radio.xfer(OPCODE_SET_DIO_AS_RFSWITCH, 8, 0, dioBuf); |
| Wayne Roberts |
9:295e37c38fb3 | 1906 | return DIO10stby_read(); |
| Wayne Roberts |
9:295e37c38fb3 | 1907 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1908 | |
| Wayne Roberts |
9:295e37c38fb3 | 1909 | bool Radio::DIO8stby_read() |
| Wayne Roberts |
9:295e37c38fb3 | 1910 | { |
| Wayne Roberts |
9:295e37c38fb3 | 1911 | return dioBuf[DIO_stby_IDX] == DIO8_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 1912 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1913 | |
| Wayne Roberts |
9:295e37c38fb3 | 1914 | bool Radio::DIO8stby_push() |
| Wayne Roberts |
9:295e37c38fb3 | 1915 | { |
| Wayne Roberts |
9:295e37c38fb3 | 1916 | dioBuf[DIO_stby_IDX] ^= DIO8_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 1917 | radio.xfer(OPCODE_SET_DIO_AS_RFSWITCH, 8, 0, dioBuf); |
| Wayne Roberts |
9:295e37c38fb3 | 1918 | return DIO8stby_read(); |
| Wayne Roberts |
9:295e37c38fb3 | 1919 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1920 | |
| Wayne Roberts |
9:295e37c38fb3 | 1921 | bool Radio::DIO7stby_read() |
| Wayne Roberts |
9:295e37c38fb3 | 1922 | { |
| Wayne Roberts |
9:295e37c38fb3 | 1923 | return dioBuf[DIO_stby_IDX] == DIO7_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 1924 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1925 | |
| Wayne Roberts |
9:295e37c38fb3 | 1926 | bool Radio::DIO7stby_push() |
| Wayne Roberts |
9:295e37c38fb3 | 1927 | { |
| Wayne Roberts |
9:295e37c38fb3 | 1928 | dioBuf[DIO_stby_IDX] ^= DIO7_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 1929 | radio.xfer(OPCODE_SET_DIO_AS_RFSWITCH, 8, 0, dioBuf); |
| Wayne Roberts |
9:295e37c38fb3 | 1930 | return DIO7stby_read(); |
| Wayne Roberts |
9:295e37c38fb3 | 1931 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1932 | |
| Wayne Roberts |
9:295e37c38fb3 | 1933 | bool Radio::DIO6stby_read() |
| Wayne Roberts |
9:295e37c38fb3 | 1934 | { |
| Wayne Roberts |
9:295e37c38fb3 | 1935 | return dioBuf[DIO_stby_IDX] == DIO6_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 1936 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1937 | |
| Wayne Roberts |
9:295e37c38fb3 | 1938 | bool Radio::DIO6stby_push() |
| Wayne Roberts |
9:295e37c38fb3 | 1939 | { |
| Wayne Roberts |
9:295e37c38fb3 | 1940 | dioBuf[DIO_stby_IDX] ^= DIO6_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 1941 | radio.xfer(OPCODE_SET_DIO_AS_RFSWITCH, 8, 0, dioBuf); |
| Wayne Roberts |
9:295e37c38fb3 | 1942 | return DIO6stby_read(); |
| Wayne Roberts |
9:295e37c38fb3 | 1943 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1944 | |
| Wayne Roberts |
9:295e37c38fb3 | 1945 | bool Radio::DIO5stby_read() |
| Wayne Roberts |
9:295e37c38fb3 | 1946 | { |
| Wayne Roberts |
9:295e37c38fb3 | 1947 | return dioBuf[DIO_stby_IDX] == DIO5_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 1948 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1949 | |
| Wayne Roberts |
9:295e37c38fb3 | 1950 | bool Radio::DIO5stby_push() |
| Wayne Roberts |
9:295e37c38fb3 | 1951 | { |
| Wayne Roberts |
9:295e37c38fb3 | 1952 | dioBuf[DIO_stby_IDX] ^= DIO5_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 1953 | radio.xfer(OPCODE_SET_DIO_AS_RFSWITCH, 8, 0, dioBuf); |
| Wayne Roberts |
9:295e37c38fb3 | 1954 | return DIO5stby_read(); |
| Wayne Roberts |
9:295e37c38fb3 | 1955 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1956 | |
| Wayne Roberts |
9:295e37c38fb3 | 1957 | const toggle_item_t Radio::DIO5stby_item = { _ITEM_TOGGLE, "DIO5", NULL, DIO5stby_read, DIO5stby_push}; |
| Wayne Roberts |
9:295e37c38fb3 | 1958 | const toggle_item_t Radio::DIO6stby_item = { _ITEM_TOGGLE, "DIO6", NULL, DIO6stby_read, DIO6stby_push}; |
| Wayne Roberts |
9:295e37c38fb3 | 1959 | const toggle_item_t Radio::DIO7stby_item = { _ITEM_TOGGLE, "DIO7", NULL, DIO7stby_read, DIO7stby_push}; |
| Wayne Roberts |
9:295e37c38fb3 | 1960 | const toggle_item_t Radio::DIO8stby_item = { _ITEM_TOGGLE, "DIO8", NULL, DIO8stby_read, DIO8stby_push}; |
| Wayne Roberts |
9:295e37c38fb3 | 1961 | const toggle_item_t Radio::DIO10stby_item = { _ITEM_TOGGLE, "DIO10", NULL, DIO10stby_read, DIO10stby_push}; |
| Wayne Roberts |
9:295e37c38fb3 | 1962 | |
| Wayne Roberts |
9:295e37c38fb3 | 1963 | bool Radio::DIO10rx_read() |
| Wayne Roberts |
9:295e37c38fb3 | 1964 | { |
| Wayne Roberts |
9:295e37c38fb3 | 1965 | return dioBuf[DIO_rx_IDX] == DIO10_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 1966 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1967 | |
| Wayne Roberts |
9:295e37c38fb3 | 1968 | bool Radio::DIO10rx_push() |
| Wayne Roberts |
9:295e37c38fb3 | 1969 | { |
| Wayne Roberts |
9:295e37c38fb3 | 1970 | dioBuf[DIO_rx_IDX] ^= DIO10_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 1971 | radio.xfer(OPCODE_SET_DIO_AS_RFSWITCH, 8, 0, dioBuf); |
| Wayne Roberts |
9:295e37c38fb3 | 1972 | return DIO10rx_read(); |
| Wayne Roberts |
9:295e37c38fb3 | 1973 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1974 | |
| Wayne Roberts |
9:295e37c38fb3 | 1975 | bool Radio::DIO8rx_read() |
| Wayne Roberts |
9:295e37c38fb3 | 1976 | { |
| Wayne Roberts |
9:295e37c38fb3 | 1977 | return dioBuf[DIO_rx_IDX] == DIO8_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 1978 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1979 | |
| Wayne Roberts |
9:295e37c38fb3 | 1980 | bool Radio::DIO8rx_push() |
| Wayne Roberts |
9:295e37c38fb3 | 1981 | { |
| Wayne Roberts |
9:295e37c38fb3 | 1982 | dioBuf[DIO_rx_IDX] ^= DIO8_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 1983 | radio.xfer(OPCODE_SET_DIO_AS_RFSWITCH, 8, 0, dioBuf); |
| Wayne Roberts |
9:295e37c38fb3 | 1984 | return DIO8rx_read(); |
| Wayne Roberts |
9:295e37c38fb3 | 1985 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1986 | |
| Wayne Roberts |
9:295e37c38fb3 | 1987 | bool Radio::DIO7rx_read() |
| Wayne Roberts |
9:295e37c38fb3 | 1988 | { |
| Wayne Roberts |
9:295e37c38fb3 | 1989 | return dioBuf[DIO_rx_IDX] == DIO7_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 1990 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1991 | |
| Wayne Roberts |
9:295e37c38fb3 | 1992 | bool Radio::DIO7rx_push() |
| Wayne Roberts |
9:295e37c38fb3 | 1993 | { |
| Wayne Roberts |
9:295e37c38fb3 | 1994 | dioBuf[DIO_rx_IDX] ^= DIO7_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 1995 | radio.xfer(OPCODE_SET_DIO_AS_RFSWITCH, 8, 0, dioBuf); |
| Wayne Roberts |
9:295e37c38fb3 | 1996 | return DIO7rx_read(); |
| Wayne Roberts |
9:295e37c38fb3 | 1997 | } |
| Wayne Roberts |
9:295e37c38fb3 | 1998 | |
| Wayne Roberts |
9:295e37c38fb3 | 1999 | bool Radio::DIO6rx_read() |
| Wayne Roberts |
9:295e37c38fb3 | 2000 | { |
| Wayne Roberts |
9:295e37c38fb3 | 2001 | return dioBuf[DIO_rx_IDX] == DIO6_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 2002 | } |
| Wayne Roberts |
9:295e37c38fb3 | 2003 | |
| Wayne Roberts |
9:295e37c38fb3 | 2004 | bool Radio::DIO6rx_push() |
| Wayne Roberts |
9:295e37c38fb3 | 2005 | { |
| Wayne Roberts |
9:295e37c38fb3 | 2006 | dioBuf[DIO_rx_IDX] ^= DIO6_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 2007 | radio.xfer(OPCODE_SET_DIO_AS_RFSWITCH, 8, 0, dioBuf); |
| Wayne Roberts |
9:295e37c38fb3 | 2008 | return DIO6rx_read(); |
| Wayne Roberts |
9:295e37c38fb3 | 2009 | } |
| Wayne Roberts |
9:295e37c38fb3 | 2010 | |
| Wayne Roberts |
9:295e37c38fb3 | 2011 | bool Radio::DIO5rx_read() |
| Wayne Roberts |
9:295e37c38fb3 | 2012 | { |
| Wayne Roberts |
9:295e37c38fb3 | 2013 | return dioBuf[DIO_rx_IDX] == DIO5_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 2014 | } |
| Wayne Roberts |
9:295e37c38fb3 | 2015 | |
| Wayne Roberts |
9:295e37c38fb3 | 2016 | bool Radio::DIO5rx_push() |
| Wayne Roberts |
9:295e37c38fb3 | 2017 | { |
| Wayne Roberts |
9:295e37c38fb3 | 2018 | dioBuf[DIO_rx_IDX] ^= DIO5_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 2019 | radio.xfer(OPCODE_SET_DIO_AS_RFSWITCH, 8, 0, dioBuf); |
| Wayne Roberts |
9:295e37c38fb3 | 2020 | return DIO5rx_read(); |
| Wayne Roberts |
9:295e37c38fb3 | 2021 | } |
| Wayne Roberts |
9:295e37c38fb3 | 2022 | |
| Wayne Roberts |
9:295e37c38fb3 | 2023 | const toggle_item_t Radio::DIO5rx_item = { _ITEM_TOGGLE, "DIO5", NULL, DIO5rx_read, DIO5rx_push}; |
| Wayne Roberts |
9:295e37c38fb3 | 2024 | const toggle_item_t Radio::DIO6rx_item = { _ITEM_TOGGLE, "DIO6", NULL, DIO6rx_read, DIO6rx_push}; |
| Wayne Roberts |
9:295e37c38fb3 | 2025 | const toggle_item_t Radio::DIO7rx_item = { _ITEM_TOGGLE, "DIO7", NULL, DIO7rx_read, DIO7rx_push}; |
| Wayne Roberts |
9:295e37c38fb3 | 2026 | const toggle_item_t Radio::DIO8rx_item = { _ITEM_TOGGLE, "DIO8", NULL, DIO8rx_read, DIO8rx_push}; |
| Wayne Roberts |
9:295e37c38fb3 | 2027 | const toggle_item_t Radio::DIO10rx_item = { _ITEM_TOGGLE, "DIO10", NULL, DIO10rx_read, DIO10rx_push}; |
| Wayne Roberts |
9:295e37c38fb3 | 2028 | |
| Wayne Roberts |
9:295e37c38fb3 | 2029 | bool Radio::DIO10tx_read() |
| Wayne Roberts |
9:295e37c38fb3 | 2030 | { |
| Wayne Roberts |
9:295e37c38fb3 | 2031 | return dioBuf[DIO_tx_IDX] == DIO10_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 2032 | } |
| Wayne Roberts |
9:295e37c38fb3 | 2033 | |
| Wayne Roberts |
9:295e37c38fb3 | 2034 | bool Radio::DIO10tx_push() |
| Wayne Roberts |
9:295e37c38fb3 | 2035 | { |
| Wayne Roberts |
9:295e37c38fb3 | 2036 | dioBuf[DIO_tx_IDX] ^= DIO10_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 2037 | radio.xfer(OPCODE_SET_DIO_AS_RFSWITCH, 8, 0, dioBuf); |
| Wayne Roberts |
9:295e37c38fb3 | 2038 | return DIO10tx_read(); |
| Wayne Roberts |
9:295e37c38fb3 | 2039 | } |
| Wayne Roberts |
9:295e37c38fb3 | 2040 | |
| Wayne Roberts |
9:295e37c38fb3 | 2041 | bool Radio::DIO8tx_read() |
| Wayne Roberts |
9:295e37c38fb3 | 2042 | { |
| Wayne Roberts |
9:295e37c38fb3 | 2043 | return dioBuf[DIO_tx_IDX] == DIO8_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 2044 | } |
| Wayne Roberts |
9:295e37c38fb3 | 2045 | |
| Wayne Roberts |
9:295e37c38fb3 | 2046 | bool Radio::DIO8tx_push() |
| Wayne Roberts |
9:295e37c38fb3 | 2047 | { |
| Wayne Roberts |
9:295e37c38fb3 | 2048 | dioBuf[DIO_tx_IDX] ^= DIO8_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 2049 | radio.xfer(OPCODE_SET_DIO_AS_RFSWITCH, 8, 0, dioBuf); |
| Wayne Roberts |
9:295e37c38fb3 | 2050 | return DIO8tx_read(); |
| Wayne Roberts |
9:295e37c38fb3 | 2051 | } |
| Wayne Roberts |
9:295e37c38fb3 | 2052 | |
| Wayne Roberts |
9:295e37c38fb3 | 2053 | bool Radio::DIO7tx_read() |
| Wayne Roberts |
9:295e37c38fb3 | 2054 | { |
| Wayne Roberts |
9:295e37c38fb3 | 2055 | return dioBuf[DIO_tx_IDX] == DIO7_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 2056 | } |
| Wayne Roberts |
9:295e37c38fb3 | 2057 | |
| Wayne Roberts |
9:295e37c38fb3 | 2058 | bool Radio::DIO7tx_push() |
| Wayne Roberts |
9:295e37c38fb3 | 2059 | { |
| Wayne Roberts |
9:295e37c38fb3 | 2060 | dioBuf[DIO_tx_IDX] ^= DIO7_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 2061 | radio.xfer(OPCODE_SET_DIO_AS_RFSWITCH, 8, 0, dioBuf); |
| Wayne Roberts |
9:295e37c38fb3 | 2062 | return DIO7tx_read(); |
| Wayne Roberts |
9:295e37c38fb3 | 2063 | } |
| Wayne Roberts |
9:295e37c38fb3 | 2064 | |
| Wayne Roberts |
9:295e37c38fb3 | 2065 | bool Radio::DIO6tx_read() |
| Wayne Roberts |
9:295e37c38fb3 | 2066 | { |
| Wayne Roberts |
9:295e37c38fb3 | 2067 | return dioBuf[DIO_tx_IDX] == DIO6_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 2068 | } |
| Wayne Roberts |
9:295e37c38fb3 | 2069 | |
| Wayne Roberts |
9:295e37c38fb3 | 2070 | bool Radio::DIO6tx_push() |
| Wayne Roberts |
9:295e37c38fb3 | 2071 | { |
| Wayne Roberts |
9:295e37c38fb3 | 2072 | dioBuf[DIO_tx_IDX] ^= DIO6_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 2073 | radio.xfer(OPCODE_SET_DIO_AS_RFSWITCH, 8, 0, dioBuf); |
| Wayne Roberts |
9:295e37c38fb3 | 2074 | return DIO6tx_read(); |
| Wayne Roberts |
9:295e37c38fb3 | 2075 | } |
| Wayne Roberts |
9:295e37c38fb3 | 2076 | |
| Wayne Roberts |
9:295e37c38fb3 | 2077 | bool Radio::DIO5tx_read() |
| Wayne Roberts |
9:295e37c38fb3 | 2078 | { |
| Wayne Roberts |
9:295e37c38fb3 | 2079 | return dioBuf[DIO_tx_IDX] == DIO5_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 2080 | } |
| Wayne Roberts |
9:295e37c38fb3 | 2081 | |
| Wayne Roberts |
9:295e37c38fb3 | 2082 | bool Radio::DIO5tx_push() |
| Wayne Roberts |
9:295e37c38fb3 | 2083 | { |
| Wayne Roberts |
9:295e37c38fb3 | 2084 | dioBuf[DIO_tx_IDX] ^= DIO5_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 2085 | radio.xfer(OPCODE_SET_DIO_AS_RFSWITCH, 8, 0, dioBuf); |
| Wayne Roberts |
9:295e37c38fb3 | 2086 | return DIO5tx_read(); |
| Wayne Roberts |
9:295e37c38fb3 | 2087 | } |
| Wayne Roberts |
9:295e37c38fb3 | 2088 | |
| Wayne Roberts |
9:295e37c38fb3 | 2089 | const toggle_item_t Radio::DIO5tx_item = { _ITEM_TOGGLE, "DIO5", NULL, DIO5tx_read, DIO5tx_push}; |
| Wayne Roberts |
9:295e37c38fb3 | 2090 | const toggle_item_t Radio::DIO6tx_item = { _ITEM_TOGGLE, "DIO6", NULL, DIO6tx_read, DIO6tx_push}; |
| Wayne Roberts |
9:295e37c38fb3 | 2091 | const toggle_item_t Radio::DIO7tx_item = { _ITEM_TOGGLE, "DIO7", NULL, DIO7tx_read, DIO7tx_push}; |
| Wayne Roberts |
9:295e37c38fb3 | 2092 | const toggle_item_t Radio::DIO8tx_item = { _ITEM_TOGGLE, "DIO8", NULL, DIO8tx_read, DIO8tx_push}; |
| Wayne Roberts |
9:295e37c38fb3 | 2093 | const toggle_item_t Radio::DIO10tx_item = { _ITEM_TOGGLE, "DIO10", NULL, DIO10tx_read, DIO10tx_push}; |
| Wayne Roberts |
9:295e37c38fb3 | 2094 | |
| Wayne Roberts |
9:295e37c38fb3 | 2095 | bool Radio::DIO10txhp_read() |
| Wayne Roberts |
9:295e37c38fb3 | 2096 | { |
| Wayne Roberts |
9:295e37c38fb3 | 2097 | return dioBuf[DIO_txhp_IDX] == DIO10_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 2098 | } |
| Wayne Roberts |
9:295e37c38fb3 | 2099 | |
| Wayne Roberts |
9:295e37c38fb3 | 2100 | bool Radio::DIO10txhp_push() |
| Wayne Roberts |
9:295e37c38fb3 | 2101 | { |
| Wayne Roberts |
9:295e37c38fb3 | 2102 | dioBuf[DIO_txhp_IDX] ^= DIO10_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 2103 | radio.xfer(OPCODE_SET_DIO_AS_RFSWITCH, 8, 0, dioBuf); |
| Wayne Roberts |
9:295e37c38fb3 | 2104 | return DIO10txhp_read(); |
| Wayne Roberts |
9:295e37c38fb3 | 2105 | } |
| Wayne Roberts |
9:295e37c38fb3 | 2106 | |
| Wayne Roberts |
9:295e37c38fb3 | 2107 | bool Radio::DIO8txhp_read() |
| Wayne Roberts |
9:295e37c38fb3 | 2108 | { |
| Wayne Roberts |
9:295e37c38fb3 | 2109 | return dioBuf[DIO_txhp_IDX] == DIO8_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 2110 | } |
| Wayne Roberts |
9:295e37c38fb3 | 2111 | |
| Wayne Roberts |
9:295e37c38fb3 | 2112 | bool Radio::DIO8txhp_push() |
| Wayne Roberts |
9:295e37c38fb3 | 2113 | { |
| Wayne Roberts |
9:295e37c38fb3 | 2114 | dioBuf[DIO_txhp_IDX] ^= DIO8_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 2115 | radio.xfer(OPCODE_SET_DIO_AS_RFSWITCH, 8, 0, dioBuf); |
| Wayne Roberts |
9:295e37c38fb3 | 2116 | return DIO8txhp_read(); |
| Wayne Roberts |
9:295e37c38fb3 | 2117 | } |
| Wayne Roberts |
9:295e37c38fb3 | 2118 | |
| Wayne Roberts |
9:295e37c38fb3 | 2119 | bool Radio::DIO7txhp_read() |
| Wayne Roberts |
9:295e37c38fb3 | 2120 | { |
| Wayne Roberts |
9:295e37c38fb3 | 2121 | return dioBuf[DIO_txhp_IDX] == DIO7_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 2122 | } |
| Wayne Roberts |
9:295e37c38fb3 | 2123 | |
| Wayne Roberts |
9:295e37c38fb3 | 2124 | bool Radio::DIO7txhp_push() |
| Wayne Roberts |
9:295e37c38fb3 | 2125 | { |
| Wayne Roberts |
9:295e37c38fb3 | 2126 | dioBuf[DIO_txhp_IDX] ^= DIO7_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 2127 | radio.xfer(OPCODE_SET_DIO_AS_RFSWITCH, 8, 0, dioBuf); |
| Wayne Roberts |
9:295e37c38fb3 | 2128 | return DIO7txhp_read(); |
| Wayne Roberts |
9:295e37c38fb3 | 2129 | } |
| Wayne Roberts |
9:295e37c38fb3 | 2130 | |
| Wayne Roberts |
9:295e37c38fb3 | 2131 | bool Radio::DIO6txhp_read() |
| Wayne Roberts |
9:295e37c38fb3 | 2132 | { |
| Wayne Roberts |
9:295e37c38fb3 | 2133 | return dioBuf[DIO_txhp_IDX] == DIO6_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 2134 | } |
| Wayne Roberts |
9:295e37c38fb3 | 2135 | |
| Wayne Roberts |
9:295e37c38fb3 | 2136 | bool Radio::DIO6txhp_push() |
| Wayne Roberts |
9:295e37c38fb3 | 2137 | { |
| Wayne Roberts |
9:295e37c38fb3 | 2138 | dioBuf[DIO_txhp_IDX] ^= DIO6_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 2139 | radio.xfer(OPCODE_SET_DIO_AS_RFSWITCH, 8, 0, dioBuf); |
| Wayne Roberts |
9:295e37c38fb3 | 2140 | return DIO6txhp_read(); |
| Wayne Roberts |
9:295e37c38fb3 | 2141 | } |
| Wayne Roberts |
9:295e37c38fb3 | 2142 | |
| Wayne Roberts |
9:295e37c38fb3 | 2143 | bool Radio::DIO5txhp_read() |
| Wayne Roberts |
9:295e37c38fb3 | 2144 | { |
| Wayne Roberts |
9:295e37c38fb3 | 2145 | return dioBuf[DIO_txhp_IDX] == DIO5_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 2146 | } |
| Wayne Roberts |
9:295e37c38fb3 | 2147 | |
| Wayne Roberts |
9:295e37c38fb3 | 2148 | bool Radio::DIO5txhp_push() |
| Wayne Roberts |
9:295e37c38fb3 | 2149 | { |
| Wayne Roberts |
9:295e37c38fb3 | 2150 | dioBuf[DIO_txhp_IDX] ^= DIO5_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 2151 | radio.xfer(OPCODE_SET_DIO_AS_RFSWITCH, 8, 0, dioBuf); |
| Wayne Roberts |
9:295e37c38fb3 | 2152 | return DIO5txhp_read(); |
| Wayne Roberts |
9:295e37c38fb3 | 2153 | } |
| Wayne Roberts |
9:295e37c38fb3 | 2154 | |
| Wayne Roberts |
9:295e37c38fb3 | 2155 | const toggle_item_t Radio::DIO5txhp_item = { _ITEM_TOGGLE, "DIO5", NULL, DIO5txhp_read, DIO5txhp_push}; |
| Wayne Roberts |
9:295e37c38fb3 | 2156 | const toggle_item_t Radio::DIO6txhp_item = { _ITEM_TOGGLE, "DIO6", NULL, DIO6txhp_read, DIO6txhp_push}; |
| Wayne Roberts |
9:295e37c38fb3 | 2157 | const toggle_item_t Radio::DIO7txhp_item = { _ITEM_TOGGLE, "DIO7", NULL, DIO7txhp_read, DIO7txhp_push}; |
| Wayne Roberts |
9:295e37c38fb3 | 2158 | const toggle_item_t Radio::DIO8txhp_item = { _ITEM_TOGGLE, "DIO8", NULL, DIO8txhp_read, DIO8txhp_push}; |
| Wayne Roberts |
9:295e37c38fb3 | 2159 | const toggle_item_t Radio::DIO10txhp_item = { _ITEM_TOGGLE, "DIO10", NULL, DIO10txhp_read, DIO10txhp_push}; |
| Wayne Roberts |
9:295e37c38fb3 | 2160 | |
| Wayne Roberts |
9:295e37c38fb3 | 2161 | bool Radio::DIO10gnss_read() |
| Wayne Roberts |
9:295e37c38fb3 | 2162 | { |
| Wayne Roberts |
9:295e37c38fb3 | 2163 | return dioBuf[DIO_gnss_IDX] == DIO10_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 2164 | } |
| Wayne Roberts |
9:295e37c38fb3 | 2165 | |
| Wayne Roberts |
9:295e37c38fb3 | 2166 | bool Radio::DIO10gnss_push() |
| Wayne Roberts |
9:295e37c38fb3 | 2167 | { |
| Wayne Roberts |
9:295e37c38fb3 | 2168 | dioBuf[DIO_gnss_IDX] ^= DIO10_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 2169 | radio.xfer(OPCODE_SET_DIO_AS_RFSWITCH, 8, 0, dioBuf); |
| Wayne Roberts |
9:295e37c38fb3 | 2170 | return DIO10gnss_read(); |
| Wayne Roberts |
9:295e37c38fb3 | 2171 | } |
| Wayne Roberts |
9:295e37c38fb3 | 2172 | |
| Wayne Roberts |
9:295e37c38fb3 | 2173 | bool Radio::DIO8gnss_read() |
| Wayne Roberts |
9:295e37c38fb3 | 2174 | { |
| Wayne Roberts |
9:295e37c38fb3 | 2175 | return dioBuf[DIO_gnss_IDX] == DIO8_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 2176 | } |
| Wayne Roberts |
9:295e37c38fb3 | 2177 | |
| Wayne Roberts |
9:295e37c38fb3 | 2178 | bool Radio::DIO8gnss_push() |
| Wayne Roberts |
9:295e37c38fb3 | 2179 | { |
| Wayne Roberts |
9:295e37c38fb3 | 2180 | dioBuf[DIO_gnss_IDX] ^= DIO8_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 2181 | radio.xfer(OPCODE_SET_DIO_AS_RFSWITCH, 8, 0, dioBuf); |
| Wayne Roberts |
9:295e37c38fb3 | 2182 | return DIO8gnss_read(); |
| Wayne Roberts |
9:295e37c38fb3 | 2183 | } |
| Wayne Roberts |
9:295e37c38fb3 | 2184 | |
| Wayne Roberts |
9:295e37c38fb3 | 2185 | bool Radio::DIO7gnss_read() |
| Wayne Roberts |
9:295e37c38fb3 | 2186 | { |
| Wayne Roberts |
9:295e37c38fb3 | 2187 | return dioBuf[DIO_gnss_IDX] == DIO7_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 2188 | } |
| Wayne Roberts |
9:295e37c38fb3 | 2189 | |
| Wayne Roberts |
9:295e37c38fb3 | 2190 | bool Radio::DIO7gnss_push() |
| Wayne Roberts |
9:295e37c38fb3 | 2191 | { |
| Wayne Roberts |
9:295e37c38fb3 | 2192 | dioBuf[DIO_gnss_IDX] ^= DIO7_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 2193 | radio.xfer(OPCODE_SET_DIO_AS_RFSWITCH, 8, 0, dioBuf); |
| Wayne Roberts |
9:295e37c38fb3 | 2194 | return DIO7gnss_read(); |
| Wayne Roberts |
9:295e37c38fb3 | 2195 | } |
| Wayne Roberts |
9:295e37c38fb3 | 2196 | |
| Wayne Roberts |
9:295e37c38fb3 | 2197 | bool Radio::DIO6gnss_read() |
| Wayne Roberts |
9:295e37c38fb3 | 2198 | { |
| Wayne Roberts |
9:295e37c38fb3 | 2199 | return dioBuf[DIO_gnss_IDX] == DIO6_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 2200 | } |
| Wayne Roberts |
9:295e37c38fb3 | 2201 | |
| Wayne Roberts |
9:295e37c38fb3 | 2202 | bool Radio::DIO6gnss_push() |
| Wayne Roberts |
9:295e37c38fb3 | 2203 | { |
| Wayne Roberts |
9:295e37c38fb3 | 2204 | dioBuf[DIO_gnss_IDX] ^= DIO6_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 2205 | radio.xfer(OPCODE_SET_DIO_AS_RFSWITCH, 8, 0, dioBuf); |
| Wayne Roberts |
9:295e37c38fb3 | 2206 | return DIO6gnss_read(); |
| Wayne Roberts |
9:295e37c38fb3 | 2207 | } |
| Wayne Roberts |
9:295e37c38fb3 | 2208 | |
| Wayne Roberts |
9:295e37c38fb3 | 2209 | bool Radio::DIO5gnss_read() |
| Wayne Roberts |
9:295e37c38fb3 | 2210 | { |
| Wayne Roberts |
9:295e37c38fb3 | 2211 | return dioBuf[DIO_gnss_IDX] == DIO5_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 2212 | } |
| Wayne Roberts |
9:295e37c38fb3 | 2213 | |
| Wayne Roberts |
9:295e37c38fb3 | 2214 | bool Radio::DIO5gnss_push() |
| Wayne Roberts |
9:295e37c38fb3 | 2215 | { |
| Wayne Roberts |
9:295e37c38fb3 | 2216 | dioBuf[DIO_gnss_IDX] ^= DIO5_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 2217 | radio.xfer(OPCODE_SET_DIO_AS_RFSWITCH, 8, 0, dioBuf); |
| Wayne Roberts |
9:295e37c38fb3 | 2218 | return DIO5gnss_read(); |
| Wayne Roberts |
9:295e37c38fb3 | 2219 | } |
| Wayne Roberts |
9:295e37c38fb3 | 2220 | |
| Wayne Roberts |
9:295e37c38fb3 | 2221 | const toggle_item_t Radio::DIO5gnss_item = { _ITEM_TOGGLE, "DIO5", NULL, DIO5gnss_read, DIO5gnss_push}; |
| Wayne Roberts |
9:295e37c38fb3 | 2222 | const toggle_item_t Radio::DIO6gnss_item = { _ITEM_TOGGLE, "DIO6", NULL, DIO6gnss_read, DIO6gnss_push}; |
| Wayne Roberts |
9:295e37c38fb3 | 2223 | const toggle_item_t Radio::DIO7gnss_item = { _ITEM_TOGGLE, "DIO7", NULL, DIO7gnss_read, DIO7gnss_push}; |
| Wayne Roberts |
9:295e37c38fb3 | 2224 | const toggle_item_t Radio::DIO8gnss_item = { _ITEM_TOGGLE, "DIO8", NULL, DIO8gnss_read, DIO8gnss_push}; |
| Wayne Roberts |
9:295e37c38fb3 | 2225 | const toggle_item_t Radio::DIO10gnss_item = { _ITEM_TOGGLE, "DIO10", NULL, DIO10gnss_read, DIO10gnss_push}; |
| Wayne Roberts |
9:295e37c38fb3 | 2226 | |
| Wayne Roberts |
9:295e37c38fb3 | 2227 | bool Radio::DIO10wifi_read() |
| Wayne Roberts |
9:295e37c38fb3 | 2228 | { |
| Wayne Roberts |
9:295e37c38fb3 | 2229 | return dioBuf[DIO_wifi_IDX] == DIO10_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 2230 | } |
| Wayne Roberts |
9:295e37c38fb3 | 2231 | |
| Wayne Roberts |
9:295e37c38fb3 | 2232 | bool Radio::DIO10wifi_push() |
| Wayne Roberts |
9:295e37c38fb3 | 2233 | { |
| Wayne Roberts |
9:295e37c38fb3 | 2234 | dioBuf[DIO_wifi_IDX] ^= DIO10_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 2235 | radio.xfer(OPCODE_SET_DIO_AS_RFSWITCH, 8, 0, dioBuf); |
| Wayne Roberts |
9:295e37c38fb3 | 2236 | return DIO10wifi_read(); |
| Wayne Roberts |
9:295e37c38fb3 | 2237 | } |
| Wayne Roberts |
9:295e37c38fb3 | 2238 | |
| Wayne Roberts |
9:295e37c38fb3 | 2239 | bool Radio::DIO8wifi_read() |
| Wayne Roberts |
9:295e37c38fb3 | 2240 | { |
| Wayne Roberts |
9:295e37c38fb3 | 2241 | return dioBuf[DIO_wifi_IDX] == DIO8_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 2242 | } |
| Wayne Roberts |
9:295e37c38fb3 | 2243 | |
| Wayne Roberts |
9:295e37c38fb3 | 2244 | bool Radio::DIO8wifi_push() |
| Wayne Roberts |
9:295e37c38fb3 | 2245 | { |
| Wayne Roberts |
9:295e37c38fb3 | 2246 | dioBuf[DIO_wifi_IDX] ^= DIO8_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 2247 | radio.xfer(OPCODE_SET_DIO_AS_RFSWITCH, 8, 0, dioBuf); |
| Wayne Roberts |
9:295e37c38fb3 | 2248 | return DIO8wifi_read(); |
| Wayne Roberts |
9:295e37c38fb3 | 2249 | } |
| Wayne Roberts |
9:295e37c38fb3 | 2250 | |
| Wayne Roberts |
9:295e37c38fb3 | 2251 | bool Radio::DIO7wifi_read() |
| Wayne Roberts |
9:295e37c38fb3 | 2252 | { |
| Wayne Roberts |
9:295e37c38fb3 | 2253 | return dioBuf[DIO_wifi_IDX] == DIO7_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 2254 | } |
| Wayne Roberts |
9:295e37c38fb3 | 2255 | |
| Wayne Roberts |
9:295e37c38fb3 | 2256 | bool Radio::DIO7wifi_push() |
| Wayne Roberts |
9:295e37c38fb3 | 2257 | { |
| Wayne Roberts |
9:295e37c38fb3 | 2258 | dioBuf[DIO_wifi_IDX] ^= DIO7_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 2259 | radio.xfer(OPCODE_SET_DIO_AS_RFSWITCH, 8, 0, dioBuf); |
| Wayne Roberts |
9:295e37c38fb3 | 2260 | return DIO7wifi_read(); |
| Wayne Roberts |
9:295e37c38fb3 | 2261 | } |
| Wayne Roberts |
9:295e37c38fb3 | 2262 | |
| Wayne Roberts |
9:295e37c38fb3 | 2263 | bool Radio::DIO6wifi_read() |
| Wayne Roberts |
9:295e37c38fb3 | 2264 | { |
| Wayne Roberts |
9:295e37c38fb3 | 2265 | return dioBuf[DIO_wifi_IDX] == DIO6_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 2266 | } |
| Wayne Roberts |
9:295e37c38fb3 | 2267 | |
| Wayne Roberts |
9:295e37c38fb3 | 2268 | bool Radio::DIO6wifi_push() |
| Wayne Roberts |
9:295e37c38fb3 | 2269 | { |
| Wayne Roberts |
9:295e37c38fb3 | 2270 | dioBuf[DIO_wifi_IDX] ^= DIO6_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 2271 | radio.xfer(OPCODE_SET_DIO_AS_RFSWITCH, 8, 0, dioBuf); |
| Wayne Roberts |
9:295e37c38fb3 | 2272 | return DIO6wifi_read(); |
| Wayne Roberts |
9:295e37c38fb3 | 2273 | } |
| Wayne Roberts |
9:295e37c38fb3 | 2274 | |
| Wayne Roberts |
9:295e37c38fb3 | 2275 | bool Radio::DIO5wifi_read() |
| Wayne Roberts |
9:295e37c38fb3 | 2276 | { |
| Wayne Roberts |
9:295e37c38fb3 | 2277 | return dioBuf[DIO_wifi_IDX] == DIO5_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 2278 | } |
| Wayne Roberts |
9:295e37c38fb3 | 2279 | |
| Wayne Roberts |
9:295e37c38fb3 | 2280 | bool Radio::DIO5wifi_push() |
| Wayne Roberts |
9:295e37c38fb3 | 2281 | { |
| Wayne Roberts |
9:295e37c38fb3 | 2282 | dioBuf[DIO_wifi_IDX] ^= DIO5_BIT; |
| Wayne Roberts |
9:295e37c38fb3 | 2283 | radio.xfer(OPCODE_SET_DIO_AS_RFSWITCH, 8, 0, dioBuf); |
| Wayne Roberts |
9:295e37c38fb3 | 2284 | return DIO5wifi_read(); |
| Wayne Roberts |
9:295e37c38fb3 | 2285 | } |
| Wayne Roberts |
9:295e37c38fb3 | 2286 | |
| Wayne Roberts |
9:295e37c38fb3 | 2287 | const toggle_item_t Radio::DIO5wifi_item = { _ITEM_TOGGLE, "DIO5", NULL, DIO5wifi_read, DIO5wifi_push}; |
| Wayne Roberts |
9:295e37c38fb3 | 2288 | const toggle_item_t Radio::DIO6wifi_item = { _ITEM_TOGGLE, "DIO6", NULL, DIO6wifi_read, DIO6wifi_push}; |
| Wayne Roberts |
9:295e37c38fb3 | 2289 | const toggle_item_t Radio::DIO7wifi_item = { _ITEM_TOGGLE, "DIO7", NULL, DIO7wifi_read, DIO7wifi_push}; |
| Wayne Roberts |
9:295e37c38fb3 | 2290 | const toggle_item_t Radio::DIO8wifi_item = { _ITEM_TOGGLE, "DIO8", NULL, DIO8wifi_read, DIO8wifi_push}; |
| Wayne Roberts |
9:295e37c38fb3 | 2291 | const toggle_item_t Radio::DIO10wifi_item = { _ITEM_TOGGLE, "DIO10", NULL, DIO10wifi_read, DIO10wifi_push}; |
| Wayne Roberts |
9:295e37c38fb3 | 2292 | |
| Wayne Roberts |
9:295e37c38fb3 | 2293 | const menu_t Radio::none_menu[] = { |
| Wayne Roberts |
10:db4e11a55bda | 2294 | { {FIRST_CHIP_MENU_ROW+3, 1}, NULL, &rfswEn_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 2295 | { {FIRST_CHIP_MENU_ROW+3, 14}, NULL, &DIO10en_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 2296 | { {FIRST_CHIP_MENU_ROW+3, 21}, NULL, &DIO8en_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 2297 | { {FIRST_CHIP_MENU_ROW+3, 26}, NULL, &DIO7en_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 2298 | { {FIRST_CHIP_MENU_ROW+3, 32}, NULL, &DIO6en_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 2299 | { {FIRST_CHIP_MENU_ROW+3, 38}, NULL, &DIO5en_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 2300 | |
| Wayne Roberts |
10:db4e11a55bda | 2301 | { {FIRST_CHIP_MENU_ROW+4, 1}, NULL, &rfswStbyCfg_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 2302 | { {FIRST_CHIP_MENU_ROW+4, 14}, NULL, &DIO10stby_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 2303 | { {FIRST_CHIP_MENU_ROW+4, 21}, NULL, &DIO8stby_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 2304 | { {FIRST_CHIP_MENU_ROW+4, 26}, NULL, &DIO7stby_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 2305 | { {FIRST_CHIP_MENU_ROW+4, 32}, NULL, &DIO6stby_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 2306 | { {FIRST_CHIP_MENU_ROW+4, 38}, NULL, &DIO5stby_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 2307 | |
| Wayne Roberts |
10:db4e11a55bda | 2308 | { {FIRST_CHIP_MENU_ROW+5, 1}, NULL, &rfswRxCfg_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 2309 | { {FIRST_CHIP_MENU_ROW+5, 14}, NULL, &DIO10rx_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 2310 | { {FIRST_CHIP_MENU_ROW+5, 21}, NULL, &DIO8rx_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 2311 | { {FIRST_CHIP_MENU_ROW+5, 26}, NULL, &DIO7rx_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 2312 | { {FIRST_CHIP_MENU_ROW+5, 32}, NULL, &DIO6rx_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 2313 | { {FIRST_CHIP_MENU_ROW+5, 38}, NULL, &DIO5rx_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 2314 | |
| Wayne Roberts |
10:db4e11a55bda | 2315 | { {FIRST_CHIP_MENU_ROW+6, 1}, NULL, &rfswTxCfg_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 2316 | { {FIRST_CHIP_MENU_ROW+6, 14}, NULL, &DIO10tx_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 2317 | { {FIRST_CHIP_MENU_ROW+6, 21}, NULL, &DIO8tx_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 2318 | { {FIRST_CHIP_MENU_ROW+6, 26}, NULL, &DIO7tx_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 2319 | { {FIRST_CHIP_MENU_ROW+6, 32}, NULL, &DIO6tx_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 2320 | { {FIRST_CHIP_MENU_ROW+6, 38}, NULL, &DIO5tx_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 2321 | |
| Wayne Roberts |
10:db4e11a55bda | 2322 | { {FIRST_CHIP_MENU_ROW+7, 1}, NULL, &rfswTxHPCfg_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 2323 | { {FIRST_CHIP_MENU_ROW+7, 14}, NULL, &DIO10txhp_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 2324 | { {FIRST_CHIP_MENU_ROW+7, 21}, NULL, &DIO8txhp_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 2325 | { {FIRST_CHIP_MENU_ROW+7, 26}, NULL, &DIO7txhp_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 2326 | { {FIRST_CHIP_MENU_ROW+7, 32}, NULL, &DIO6txhp_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 2327 | { {FIRST_CHIP_MENU_ROW+7, 38}, NULL, &DIO5txhp_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 2328 | |
| Wayne Roberts |
10:db4e11a55bda | 2329 | { {FIRST_CHIP_MENU_ROW+8, 1}, NULL, &rfswGnssCfg_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 2330 | { {FIRST_CHIP_MENU_ROW+8, 14}, NULL, &DIO10gnss_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 2331 | { {FIRST_CHIP_MENU_ROW+8, 21}, NULL, &DIO8gnss_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 2332 | { {FIRST_CHIP_MENU_ROW+8, 26}, NULL, &DIO7gnss_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 2333 | { {FIRST_CHIP_MENU_ROW+8, 32}, NULL, &DIO6gnss_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 2334 | { {FIRST_CHIP_MENU_ROW+8, 38}, NULL, &DIO5gnss_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 2335 | |
| Wayne Roberts |
10:db4e11a55bda | 2336 | { {FIRST_CHIP_MENU_ROW+9, 1}, NULL, &rfswWifiCfg_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 2337 | { {FIRST_CHIP_MENU_ROW+9, 14}, NULL, &DIO10wifi_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 2338 | { {FIRST_CHIP_MENU_ROW+9, 21}, NULL, &DIO8wifi_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 2339 | { {FIRST_CHIP_MENU_ROW+9, 26}, NULL, &DIO7wifi_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 2340 | { {FIRST_CHIP_MENU_ROW+9, 32}, NULL, &DIO6wifi_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 2341 | { {FIRST_CHIP_MENU_ROW+9, 38}, NULL, &DIO5wifi_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
10:db4e11a55bda | 2342 | |
| Wayne Roberts |
10:db4e11a55bda | 2343 | { {LAST_CHIP_MENU_ROW, 1}, NULL, &dbg_item, FLAG_MSGTYPE_ALL}, |
| Wayne Roberts |
9:295e37c38fb3 | 2344 | { {0, 0}, NULL, NULL } |
| Wayne Roberts |
9:295e37c38fb3 | 2345 | }; |
| Wayne Roberts |
9:295e37c38fb3 | 2346 | |
| Wayne Roberts |
9:295e37c38fb3 | 2347 | const menu_t* Radio::get_modem_sub_menu() { return NULL; } |
| Wayne Roberts |
9:295e37c38fb3 | 2348 | |
| Wayne Roberts |
9:295e37c38fb3 | 2349 | const menu_t* Radio::get_modem_menu() |
| Wayne Roberts |
9:295e37c38fb3 | 2350 | { |
| Wayne Roberts |
9:295e37c38fb3 | 2351 | pktType = radio.getPacketType(); |
| Wayne Roberts |
9:295e37c38fb3 | 2352 | |
| Wayne Roberts |
9:295e37c38fb3 | 2353 | if (pktType == PACKET_TYPE_LORA) |
| Wayne Roberts |
9:295e37c38fb3 | 2354 | return lora_menu; |
| Wayne Roberts |
9:295e37c38fb3 | 2355 | else if (pktType == PACKET_TYPE_GFSK) |
| Wayne Roberts |
9:295e37c38fb3 | 2356 | return gfsk_menu; |
| Wayne Roberts |
9:295e37c38fb3 | 2357 | else |
| Wayne Roberts |
9:295e37c38fb3 | 2358 | return none_menu; |
| Wayne Roberts |
9:295e37c38fb3 | 2359 | |
| Wayne Roberts |
9:295e37c38fb3 | 2360 | return NULL; |
| Wayne Roberts |
9:295e37c38fb3 | 2361 | } |
| Wayne Roberts |
9:295e37c38fb3 | 2362 | |
| Wayne Roberts |
9:295e37c38fb3 | 2363 | void Radio::setFS() |
| Wayne Roberts |
9:295e37c38fb3 | 2364 | { |
| Wayne Roberts |
9:295e37c38fb3 | 2365 | radio.xfer(OPCODE_SET_FS, 0, 0, NULL); |
| Wayne Roberts |
9:295e37c38fb3 | 2366 | } |
| Wayne Roberts |
9:295e37c38fb3 | 2367 | |
| Wayne Roberts |
9:295e37c38fb3 | 2368 | void Radio::test() |
| Wayne Roberts |
9:295e37c38fb3 | 2369 | { |
| Wayne Roberts |
9:295e37c38fb3 | 2370 | } |
| Wayne Roberts |
9:295e37c38fb3 | 2371 | |
| Wayne Roberts |
9:295e37c38fb3 | 2372 | void Radio::rxDone(uint8_t size, float rssi, float snr) |
| Wayne Roberts |
9:295e37c38fb3 | 2373 | { |
| Wayne Roberts |
9:295e37c38fb3 | 2374 | RadioEvents->RxDone(size, rssi, snr); |
| Wayne Roberts |
9:295e37c38fb3 | 2375 | } |
| Wayne Roberts |
9:295e37c38fb3 | 2376 | |
| Wayne Roberts |
9:295e37c38fb3 | 2377 | void Radio::txDoneBottom() |
| Wayne Roberts |
9:295e37c38fb3 | 2378 | { |
| Wayne Roberts |
9:295e37c38fb3 | 2379 | if (RadioEvents->TxDone_botHalf) |
| Wayne Roberts |
9:295e37c38fb3 | 2380 | RadioEvents->TxDone_botHalf(); |
| Wayne Roberts |
9:295e37c38fb3 | 2381 | } |
| Wayne Roberts |
9:295e37c38fb3 | 2382 | |
| Wayne Roberts |
9:295e37c38fb3 | 2383 | void Radio::boardInit(const RadioEvents_t* e) |
| Wayne Roberts |
9:295e37c38fb3 | 2384 | { |
| Wayne Roberts |
9:295e37c38fb3 | 2385 | uint8_t buf[4]; |
| Wayne Roberts |
10:db4e11a55bda | 2386 | |
| Wayne Roberts |
10:db4e11a55bda | 2387 | { |
| Wayne Roberts |
10:db4e11a55bda | 2388 | float default_ms = 62.5; |
| Wayne Roberts |
10:db4e11a55bda | 2389 | unsigned ticks = default_ms * 32.768; |
| Wayne Roberts |
10:db4e11a55bda | 2390 | radio.to_big_endian24(ticks, tcxo_buf+1); |
| Wayne Roberts |
10:db4e11a55bda | 2391 | } |
| Wayne Roberts |
10:db4e11a55bda | 2392 | |
| Wayne Roberts |
9:295e37c38fb3 | 2393 | radio.txDone = txDoneBottom; |
| Wayne Roberts |
9:295e37c38fb3 | 2394 | radio.rxDone = rxDone; |
| Wayne Roberts |
9:295e37c38fb3 | 2395 | radio.cadDone = cadDone; |
| Wayne Roberts |
9:295e37c38fb3 | 2396 | |
| Wayne Roberts |
9:295e37c38fb3 | 2397 | //radio.chipModeChange = chipModeChange; |
| Wayne Roberts |
9:295e37c38fb3 | 2398 | RadioEvents = e; |
| Wayne Roberts |
9:295e37c38fb3 | 2399 | stat_t stat; |
| Wayne Roberts |
9:295e37c38fb3 | 2400 | stat.word = radio.xfer(OPCODE_GET_VERSION, 0, 0, NULL); |
| Wayne Roberts |
9:295e37c38fb3 | 2401 | stat.word = radio.xfer(0x0000, 0, 4, buf); |
| Wayne Roberts |
9:295e37c38fb3 | 2402 | if (stat.bits.cmdStatus == CMD_DAT) { |
| Wayne Roberts |
9:295e37c38fb3 | 2403 | sprintf(chip_ver, "LR1110 %02x %02x %u.%u", |
| Wayne Roberts |
9:295e37c38fb3 | 2404 | buf[0], /* silicon rev */ |
| Wayne Roberts |
9:295e37c38fb3 | 2405 | buf[1], /* use case */ |
| Wayne Roberts |
9:295e37c38fb3 | 2406 | buf[2], /* firmware major */ |
| Wayne Roberts |
9:295e37c38fb3 | 2407 | buf[3] /* firmware minor */ |
| Wayne Roberts |
9:295e37c38fb3 | 2408 | ); |
| Wayne Roberts |
9:295e37c38fb3 | 2409 | } |
| Wayne Roberts |
9:295e37c38fb3 | 2410 | |
| Wayne Roberts |
9:295e37c38fb3 | 2411 | initRfSwDIO(); |
| Wayne Roberts |
9:295e37c38fb3 | 2412 | readChip(); |
| Wayne Roberts |
9:295e37c38fb3 | 2413 | } |
| Wayne Roberts |
9:295e37c38fb3 | 2414 | |
| Wayne Roberts |
10:db4e11a55bda | 2415 | const char* const navToHostStr[] = { |
| Wayne Roberts |
10:db4e11a55bda | 2416 | /* 0 */ "ok", |
| Wayne Roberts |
10:db4e11a55bda | 2417 | /* 1 */ "cmd unexpected", |
| Wayne Roberts |
10:db4e11a55bda | 2418 | /* 2 */ "cmd not implemented", |
| Wayne Roberts |
10:db4e11a55bda | 2419 | /* 3 */ "cmd paramters invalid", |
| Wayne Roberts |
10:db4e11a55bda | 2420 | /* 4 */ "message sanity check", |
| Wayne Roberts |
10:db4e11a55bda | 2421 | /* 5 */ "scanning failed", |
| Wayne Roberts |
10:db4e11a55bda | 2422 | /* 6 */ "no time", |
| Wayne Roberts |
10:db4e11a55bda | 2423 | /* 7 */ "no satellite detected", |
| Wayne Roberts |
10:db4e11a55bda | 2424 | /* 8 */ "almanac too old", |
| Wayne Roberts |
10:db4e11a55bda | 2425 | /* 9 */ "alamanac update fail: crc", |
| Wayne Roberts |
10:db4e11a55bda | 2426 | /* 10 */ "alamanac update fail: flash integrity", |
| Wayne Roberts |
10:db4e11a55bda | 2427 | /* 11 */ "alamanac update fail: date too old", |
| Wayne Roberts |
10:db4e11a55bda | 2428 | /* 12 */ "alamanac update fail: not allowed", |
| Wayne Roberts |
10:db4e11a55bda | 2429 | /* 13 */ "global almanac crc error", |
| Wayne Roberts |
10:db4e11a55bda | 2430 | /* 14 */ "almanac version not supported", |
| Wayne Roberts |
10:db4e11a55bda | 2431 | /* 15 */ "" |
| Wayne Roberts |
10:db4e11a55bda | 2432 | }; |
| Wayne Roberts |
10:db4e11a55bda | 2433 | |
| Wayne Roberts |
10:db4e11a55bda | 2434 | struct wifidr { |
| Wayne Roberts |
10:db4e11a55bda | 2435 | const char *txt; |
| Wayne Roberts |
10:db4e11a55bda | 2436 | float Mbps; |
| Wayne Roberts |
10:db4e11a55bda | 2437 | }; |
| Wayne Roberts |
10:db4e11a55bda | 2438 | |
| Wayne Roberts |
10:db4e11a55bda | 2439 | const struct wifidr wifiDatarates[] = { |
| Wayne Roberts |
10:db4e11a55bda | 2440 | /* 0 */ { NULL, 0}, |
| Wayne Roberts |
10:db4e11a55bda | 2441 | /* 1 */ { "DBPSK", 1}, |
| Wayne Roberts |
10:db4e11a55bda | 2442 | /* 2 */ { "DQPSK", 2}, |
| Wayne Roberts |
10:db4e11a55bda | 2443 | /* 3 */ { "BPSK", 6}, |
| Wayne Roberts |
10:db4e11a55bda | 2444 | /* 4 */ { "BPSK", 9}, |
| Wayne Roberts |
10:db4e11a55bda | 2445 | /* 5 */ { "QPSK", 12}, |
| Wayne Roberts |
10:db4e11a55bda | 2446 | /* 6 */ { "QPSK", 18}, |
| Wayne Roberts |
10:db4e11a55bda | 2447 | /* 7 */ { "16-QAM", 24}, |
| Wayne Roberts |
10:db4e11a55bda | 2448 | /* 8 */ { "16-QAM", 36}, |
| Wayne Roberts |
10:db4e11a55bda | 2449 | /* 9 */ { "(9)", 0}, |
| Wayne Roberts |
10:db4e11a55bda | 2450 | /* 10 */ { "(10)", 0}, |
| Wayne Roberts |
10:db4e11a55bda | 2451 | /* 11 */ { "BPSK", 6.5}, |
| Wayne Roberts |
10:db4e11a55bda | 2452 | /* 12 */ { "QPSK", 13}, |
| Wayne Roberts |
10:db4e11a55bda | 2453 | /* 13 */ { "QPSK", 19.5}, |
| Wayne Roberts |
10:db4e11a55bda | 2454 | /* 14 */ { "16-QAM", 26}, |
| Wayne Roberts |
10:db4e11a55bda | 2455 | /* 15 */ { "16-QAM", 39}, |
| Wayne Roberts |
10:db4e11a55bda | 2456 | /* 16 */ { "(16)", 0}, |
| Wayne Roberts |
10:db4e11a55bda | 2457 | /* 17 */ { "(17)", 0}, |
| Wayne Roberts |
10:db4e11a55bda | 2458 | /* 18 */ { "(18)", 0}, |
| Wayne Roberts |
10:db4e11a55bda | 2459 | /* 19 */ { "BPSK", 7.2}, |
| Wayne Roberts |
10:db4e11a55bda | 2460 | /* 20 */ { "QPSK", 14.4}, |
| Wayne Roberts |
10:db4e11a55bda | 2461 | /* 21 */ { "QPSK", 21.7}, |
| Wayne Roberts |
10:db4e11a55bda | 2462 | /* 22 */ { "16-QAM", 28.9}, |
| Wayne Roberts |
10:db4e11a55bda | 2463 | /* 23 */ { "16-QAM", 43.3}, |
| Wayne Roberts |
10:db4e11a55bda | 2464 | }; |
| Wayne Roberts |
10:db4e11a55bda | 2465 | |
| Wayne Roberts |
10:db4e11a55bda | 2466 | |
| Wayne Roberts |
10:db4e11a55bda | 2467 | void print_wifi_result(const uint8_t *result) |
| Wayne Roberts |
10:db4e11a55bda | 2468 | { |
| Wayne Roberts |
10:db4e11a55bda | 2469 | char out[96]; |
| Wayne Roberts |
10:db4e11a55bda | 2470 | char str[24]; |
| Wayne Roberts |
10:db4e11a55bda | 2471 | unsigned n, macStart; |
| Wayne Roberts |
10:db4e11a55bda | 2472 | wifiType_t wt; |
| Wayne Roberts |
10:db4e11a55bda | 2473 | wifiChanInfo_t ci; |
| Wayne Roberts |
10:db4e11a55bda | 2474 | wt.octet = result[0]; |
| Wayne Roberts |
10:db4e11a55bda | 2475 | ci.octet = result[1]; |
| Wayne Roberts |
10:db4e11a55bda | 2476 | out[0] = 0; |
| Wayne Roberts |
10:db4e11a55bda | 2477 | strcat(out, "802.11"); |
| Wayne Roberts |
10:db4e11a55bda | 2478 | switch (wt.bits.signal) { |
| Wayne Roberts |
10:db4e11a55bda | 2479 | case 1: strcat(out, "b"); break; |
| Wayne Roberts |
10:db4e11a55bda | 2480 | case 2: strcat(out, "g"); break; |
| Wayne Roberts |
10:db4e11a55bda | 2481 | case 3: strcat(out, "n"); break; |
| Wayne Roberts |
10:db4e11a55bda | 2482 | } |
| Wayne Roberts |
10:db4e11a55bda | 2483 | sprintf(str, " %s %.1fMbps", wifiDatarates[wt.bits.datarate].txt, wifiDatarates[wt.bits.datarate].Mbps); |
| Wayne Roberts |
10:db4e11a55bda | 2484 | strcat(out, str); |
| Wayne Roberts |
10:db4e11a55bda | 2485 | strcat(out, " "); |
| Wayne Roberts |
10:db4e11a55bda | 2486 | |
| Wayne Roberts |
10:db4e11a55bda | 2487 | sprintf(str, "ch%u ", ci.bits.channelID); |
| Wayne Roberts |
10:db4e11a55bda | 2488 | strcat(out, str); |
| Wayne Roberts |
10:db4e11a55bda | 2489 | switch (ci.bits.channelID) { |
| Wayne Roberts |
10:db4e11a55bda | 2490 | // table 10-5 |
| Wayne Roberts |
10:db4e11a55bda | 2491 | } |
| Wayne Roberts |
10:db4e11a55bda | 2492 | strcat(out, " "); |
| Wayne Roberts |
10:db4e11a55bda | 2493 | sprintf(str, "mv:%u ", ci.bits.macValidationID); |
| Wayne Roberts |
10:db4e11a55bda | 2494 | strcat(out, str); |
| Wayne Roberts |
10:db4e11a55bda | 2495 | switch (ci.bits.macValidationID) { |
| Wayne Roberts |
10:db4e11a55bda | 2496 | case 1: strcat(out, "gateway"); break; |
| Wayne Roberts |
10:db4e11a55bda | 2497 | case 2: strcat(out, "phone"); break; |
| Wayne Roberts |
10:db4e11a55bda | 2498 | case 3: strcat(out, "?"); break; |
| Wayne Roberts |
10:db4e11a55bda | 2499 | // table 10.8 |
| Wayne Roberts |
10:db4e11a55bda | 2500 | } |
| Wayne Roberts |
10:db4e11a55bda | 2501 | |
| Wayne Roberts |
10:db4e11a55bda | 2502 | sprintf(str, " rssi:%d ", (int8_t)result[2]); |
| Wayne Roberts |
10:db4e11a55bda | 2503 | strcat(out, str); |
| Wayne Roberts |
10:db4e11a55bda | 2504 | |
| Wayne Roberts |
10:db4e11a55bda | 2505 | if (wifiResultFormatBasic) { |
| Wayne Roberts |
10:db4e11a55bda | 2506 | macStart = 3; |
| Wayne Roberts |
10:db4e11a55bda | 2507 | } else { |
| Wayne Roberts |
10:db4e11a55bda | 2508 | macStart = 4; |
| Wayne Roberts |
10:db4e11a55bda | 2509 | } |
| Wayne Roberts |
10:db4e11a55bda | 2510 | for (n = 0; n < 6; n++) { |
| Wayne Roberts |
10:db4e11a55bda | 2511 | sprintf(str, "%02x", result[n+macStart]); |
| Wayne Roberts |
10:db4e11a55bda | 2512 | strcat(out, str); |
| Wayne Roberts |
10:db4e11a55bda | 2513 | if (n < 5) |
| Wayne Roberts |
10:db4e11a55bda | 2514 | strcat(out, ":"); |
| Wayne Roberts |
10:db4e11a55bda | 2515 | } |
| Wayne Roberts |
10:db4e11a55bda | 2516 | strcat(out, " "); |
| Wayne Roberts |
10:db4e11a55bda | 2517 | |
| Wayne Roberts |
10:db4e11a55bda | 2518 | |
| Wayne Roberts |
10:db4e11a55bda | 2519 | if (!wifiResultFormatBasic) { |
| Wayne Roberts |
10:db4e11a55bda | 2520 | sprintf(str, "frameCtrl:%02x ", result[3]); |
| Wayne Roberts |
10:db4e11a55bda | 2521 | strcat(out, str); |
| Wayne Roberts |
10:db4e11a55bda | 2522 | } |
| Wayne Roberts |
10:db4e11a55bda | 2523 | log_printf("%s\r\n", out); |
| Wayne Roberts |
10:db4e11a55bda | 2524 | } |
| Wayne Roberts |
10:db4e11a55bda | 2525 | |
| Wayne Roberts |
9:295e37c38fb3 | 2526 | bool Radio::service(int8_t statusRow) |
| Wayne Roberts |
9:295e37c38fb3 | 2527 | { |
| Wayne Roberts |
9:295e37c38fb3 | 2528 | irq_t irq; |
| Wayne Roberts |
9:295e37c38fb3 | 2529 | irq.dword = radio.service(); |
| Wayne Roberts |
9:295e37c38fb3 | 2530 | if (irq.dword != 0) { |
| Wayne Roberts |
9:295e37c38fb3 | 2531 | char str[94]; |
| Wayne Roberts |
9:295e37c38fb3 | 2532 | sprintf(str, "irq.dword:%06lx ", irq.dword); |
| Wayne Roberts |
9:295e37c38fb3 | 2533 | if (irq.bits.TxDone) |
| Wayne Roberts |
9:295e37c38fb3 | 2534 | strcat(str, "TxDone "); |
| Wayne Roberts |
9:295e37c38fb3 | 2535 | if (irq.bits.RxDone) |
| Wayne Roberts |
9:295e37c38fb3 | 2536 | strcat(str, "RxDone "); |
| Wayne Roberts |
9:295e37c38fb3 | 2537 | if (irq.bits.PreambleDetected) |
| Wayne Roberts |
9:295e37c38fb3 | 2538 | strcat(str, "PreambleDetected "); |
| Wayne Roberts |
9:295e37c38fb3 | 2539 | if (irq.bits.SyncHeaderValid) |
| Wayne Roberts |
9:295e37c38fb3 | 2540 | strcat(str, "SyncHeaderValid "); |
| Wayne Roberts |
9:295e37c38fb3 | 2541 | if (irq.bits.HeaderErr) |
| Wayne Roberts |
9:295e37c38fb3 | 2542 | strcat(str, "HeaderErr "); |
| Wayne Roberts |
9:295e37c38fb3 | 2543 | if (irq.bits.CadDone) |
| Wayne Roberts |
9:295e37c38fb3 | 2544 | strcat(str, "CadDone "); |
| Wayne Roberts |
9:295e37c38fb3 | 2545 | if (irq.bits.CadDetected) |
| Wayne Roberts |
9:295e37c38fb3 | 2546 | strcat(str, "CadDetected "); |
| Wayne Roberts |
9:295e37c38fb3 | 2547 | if (irq.bits.Timeout) |
| Wayne Roberts |
9:295e37c38fb3 | 2548 | strcat(str, "Timeout "); |
| Wayne Roberts |
9:295e37c38fb3 | 2549 | if (irq.bits.lowBat) |
| Wayne Roberts |
9:295e37c38fb3 | 2550 | strcat(str, "lowBat "); |
| Wayne Roberts |
9:295e37c38fb3 | 2551 | if (irq.bits.FskLenError) |
| Wayne Roberts |
9:295e37c38fb3 | 2552 | strcat(str, "FskLenError "); |
| Wayne Roberts |
9:295e37c38fb3 | 2553 | if (irq.bits.FskAddrError) |
| Wayne Roberts |
9:295e37c38fb3 | 2554 | strcat(str, "FskAddrError "); |
| Wayne Roberts |
9:295e37c38fb3 | 2555 | if (irq.bits.CmdErr) { |
| Wayne Roberts |
9:295e37c38fb3 | 2556 | char txt[23]; |
| Wayne Roberts |
9:295e37c38fb3 | 2557 | sprintf(txt, "\e[31mCmdErr_%04x\e[0m ", radio.err_opcode); |
| Wayne Roberts |
9:295e37c38fb3 | 2558 | strcat(str, txt); |
| Wayne Roberts |
9:295e37c38fb3 | 2559 | } |
| Wayne Roberts |
9:295e37c38fb3 | 2560 | if (irq.bits.Error) { |
| Wayne Roberts |
9:295e37c38fb3 | 2561 | strcat(str, "\e[31mError: "); |
| Wayne Roberts |
9:295e37c38fb3 | 2562 | if (radio.errorStat.bits.lf_rc_calib) |
| Wayne Roberts |
9:295e37c38fb3 | 2563 | strcat(str, "lf_rc_calib "); |
| Wayne Roberts |
9:295e37c38fb3 | 2564 | if (radio.errorStat.bits.hf_rc_calib) |
| Wayne Roberts |
9:295e37c38fb3 | 2565 | strcat(str, "hf_rc_calib "); |
| Wayne Roberts |
9:295e37c38fb3 | 2566 | if (radio.errorStat.bits.adc_calib) |
| Wayne Roberts |
9:295e37c38fb3 | 2567 | strcat(str, "adc_calib "); |
| Wayne Roberts |
9:295e37c38fb3 | 2568 | if (radio.errorStat.bits.pll_calib) |
| Wayne Roberts |
9:295e37c38fb3 | 2569 | strcat(str, "pll_calib "); |
| Wayne Roberts |
9:295e37c38fb3 | 2570 | if (radio.errorStat.bits.img_calib) |
| Wayne Roberts |
9:295e37c38fb3 | 2571 | strcat(str, "img_calib "); |
| Wayne Roberts |
10:db4e11a55bda | 2572 | if (radio.errorStat.bits.hf_xosc_start_) |
| Wayne Roberts |
9:295e37c38fb3 | 2573 | strcat(str, "hf_xosc_start "); |
| Wayne Roberts |
9:295e37c38fb3 | 2574 | if (radio.errorStat.bits.lf_xosc_start) |
| Wayne Roberts |
9:295e37c38fb3 | 2575 | strcat(str, "lf_xosc_start "); |
| Wayne Roberts |
9:295e37c38fb3 | 2576 | if (radio.errorStat.bits.pll_lock) |
| Wayne Roberts |
9:295e37c38fb3 | 2577 | strcat(str, "pll_lock "); |
| Wayne Roberts |
9:295e37c38fb3 | 2578 | if (radio.errorStat.bits.rx_adc_offset) |
| Wayne Roberts |
9:295e37c38fb3 | 2579 | strcat(str, "rx_adc_offset "); |
| Wayne Roberts |
9:295e37c38fb3 | 2580 | strcat(str, "\e[0m"); |
| Wayne Roberts |
9:295e37c38fb3 | 2581 | } |
| Wayne Roberts |
9:295e37c38fb3 | 2582 | |
| Wayne Roberts |
9:295e37c38fb3 | 2583 | if (irq.bits.WifiDone) { |
| Wayne Roberts |
9:295e37c38fb3 | 2584 | strcat(str, "WifiDone "); |
| Wayne Roberts |
9:295e37c38fb3 | 2585 | } |
| Wayne Roberts |
9:295e37c38fb3 | 2586 | if (irq.bits.GNSSDone) { |
| Wayne Roberts |
9:295e37c38fb3 | 2587 | strcat(str, "GNSSDone "); |
| Wayne Roberts |
9:295e37c38fb3 | 2588 | } |
| Wayne Roberts |
9:295e37c38fb3 | 2589 | log_printf("%s\r\n", str); |
| Wayne Roberts |
10:db4e11a55bda | 2590 | |
| Wayne Roberts |
10:db4e11a55bda | 2591 | /****************************/ |
| Wayne Roberts |
10:db4e11a55bda | 2592 | if (irq.bits.WifiDone) { |
| Wayne Roberts |
10:db4e11a55bda | 2593 | stat_t stat; |
| Wayne Roberts |
10:db4e11a55bda | 2594 | uint8_t nbResults; |
| Wayne Roberts |
10:db4e11a55bda | 2595 | stat.word = radio.xfer(OPCODE_GET_WIFI_NB_RESULTS, 0, 0, NULL); |
| Wayne Roberts |
10:db4e11a55bda | 2596 | stat.word = radio.xfer(0x0000, 0, 1, &nbResults); |
| Wayne Roberts |
10:db4e11a55bda | 2597 | if (stat.bits.cmdStatus == CMD_DAT) { |
| Wayne Roberts |
10:db4e11a55bda | 2598 | unsigned n; |
| Wayne Roberts |
10:db4e11a55bda | 2599 | log_printf("nbResults:%u\r\n", nbResults); |
| Wayne Roberts |
10:db4e11a55bda | 2600 | for (n = 0; n < nbResults; n++) { |
| Wayne Roberts |
10:db4e11a55bda | 2601 | uint8_t buf[3]; |
| Wayne Roberts |
10:db4e11a55bda | 2602 | uint8_t resultBuf[22]; |
| Wayne Roberts |
10:db4e11a55bda | 2603 | buf[0] = n; |
| Wayne Roberts |
10:db4e11a55bda | 2604 | buf[1] = 1; // number of results in this read |
| Wayne Roberts |
10:db4e11a55bda | 2605 | buf[2] = wifiResultFormatBasic ? 4 : 1; |
| Wayne Roberts |
10:db4e11a55bda | 2606 | stat.word = radio.xfer(OPCODE_WIFI_READ_RESULTS, 3, 0, buf); |
| Wayne Roberts |
10:db4e11a55bda | 2607 | // basic = 9byte length |
| Wayne Roberts |
10:db4e11a55bda | 2608 | // full = 22byte length |
| Wayne Roberts |
10:db4e11a55bda | 2609 | stat.word = radio.xfer(0x0000, 0, wifiResultFormatBasic ? 9 : 22, resultBuf); |
| Wayne Roberts |
10:db4e11a55bda | 2610 | if (stat.bits.cmdStatus == CMD_DAT) |
| Wayne Roberts |
10:db4e11a55bda | 2611 | print_wifi_result(resultBuf); |
| Wayne Roberts |
10:db4e11a55bda | 2612 | else |
| Wayne Roberts |
10:db4e11a55bda | 2613 | log_printf("readResult:%s\r\n", radio.cmdStatus_toString(stat.bits.cmdStatus)); |
| Wayne Roberts |
10:db4e11a55bda | 2614 | } |
| Wayne Roberts |
10:db4e11a55bda | 2615 | } else |
| Wayne Roberts |
10:db4e11a55bda | 2616 | log_printf("nbResults:%s\r\n", radio.cmdStatus_toString(stat.bits.cmdStatus)); |
| Wayne Roberts |
10:db4e11a55bda | 2617 | } // ..if (irq.bits.WifiDone) |
| Wayne Roberts |
10:db4e11a55bda | 2618 | |
| Wayne Roberts |
10:db4e11a55bda | 2619 | if (irq.bits.GNSSDone) { |
| Wayne Roberts |
10:db4e11a55bda | 2620 | uint8_t gnssResultBuf[512]; |
| Wayne Roberts |
10:db4e11a55bda | 2621 | uint8_t buf[2]; |
| Wayne Roberts |
10:db4e11a55bda | 2622 | stat_t stat; |
| Wayne Roberts |
10:db4e11a55bda | 2623 | unsigned resultSize; |
| Wayne Roberts |
10:db4e11a55bda | 2624 | stat.word = radio.xfer(OPCODE_GNSS_GET_RESULT_SIZE, 0, 0, NULL); |
| Wayne Roberts |
10:db4e11a55bda | 2625 | stat.word = radio.xfer(0x0000, 0, 2, buf); |
| Wayne Roberts |
10:db4e11a55bda | 2626 | if (stat.bits.cmdStatus == CMD_DAT) { |
| Wayne Roberts |
10:db4e11a55bda | 2627 | resultSize = buf[1]; |
| Wayne Roberts |
10:db4e11a55bda | 2628 | resultSize <<= 8; |
| Wayne Roberts |
10:db4e11a55bda | 2629 | resultSize |= buf[0]; |
| Wayne Roberts |
10:db4e11a55bda | 2630 | log_printf("resultSize:%u\r\n", resultSize); |
| Wayne Roberts |
10:db4e11a55bda | 2631 | stat.word = radio.xfer(OPCODE_GNSS_READ_RESULTS, 0, 0, NULL); |
| Wayne Roberts |
10:db4e11a55bda | 2632 | stat.word = radio.xfer(0x0000, 0, resultSize, gnssResultBuf); |
| Wayne Roberts |
10:db4e11a55bda | 2633 | if (stat.bits.cmdStatus == CMD_DAT) { |
| Wayne Roberts |
10:db4e11a55bda | 2634 | unsigned i = 0, n; |
| Wayne Roberts |
10:db4e11a55bda | 2635 | switch (gnssResultBuf[0]) { |
| Wayne Roberts |
10:db4e11a55bda | 2636 | case 0: log_printf("navToHost:%s\r\n", navToHostStr[gnssResultBuf[0]]); break; |
| Wayne Roberts |
10:db4e11a55bda | 2637 | case 1: log_printf("navToSolver\r\n"); break; |
| Wayne Roberts |
10:db4e11a55bda | 2638 | case 2: log_printf("navToDMC\r\n"); break; |
| Wayne Roberts |
10:db4e11a55bda | 2639 | default: log_printf("nav:%u\r\n", gnssResultBuf[0]); break; |
| Wayne Roberts |
10:db4e11a55bda | 2640 | } |
| Wayne Roberts |
10:db4e11a55bda | 2641 | for (i = 0; i < resultSize; ) { |
| Wayne Roberts |
10:db4e11a55bda | 2642 | printf("%03x:", i); |
| Wayne Roberts |
10:db4e11a55bda | 2643 | for (n = 0; n < 16; n++) { |
| Wayne Roberts |
10:db4e11a55bda | 2644 | printf("%02x ", gnssResultBuf[i+n]); |
| Wayne Roberts |
10:db4e11a55bda | 2645 | if (n == 7) |
| Wayne Roberts |
10:db4e11a55bda | 2646 | printf(" "); |
| Wayne Roberts |
10:db4e11a55bda | 2647 | } |
| Wayne Roberts |
10:db4e11a55bda | 2648 | for (n = 0; n < 16; n++) { |
| Wayne Roberts |
10:db4e11a55bda | 2649 | if (n > ' ' && n < 0x7f) |
| Wayne Roberts |
10:db4e11a55bda | 2650 | printf("%c", gnssResultBuf[i+n]); |
| Wayne Roberts |
10:db4e11a55bda | 2651 | else |
| Wayne Roberts |
10:db4e11a55bda | 2652 | printf("."); |
| Wayne Roberts |
10:db4e11a55bda | 2653 | if (n == 7) |
| Wayne Roberts |
10:db4e11a55bda | 2654 | printf(" "); |
| Wayne Roberts |
10:db4e11a55bda | 2655 | } |
| Wayne Roberts |
10:db4e11a55bda | 2656 | printf("\r\n"); |
| Wayne Roberts |
10:db4e11a55bda | 2657 | i += 16; |
| Wayne Roberts |
10:db4e11a55bda | 2658 | } |
| Wayne Roberts |
10:db4e11a55bda | 2659 | } else |
| Wayne Roberts |
10:db4e11a55bda | 2660 | log_printf("resultBuf:%s\r\n", radio.cmdStatus_toString(stat.bits.cmdStatus)); |
| Wayne Roberts |
10:db4e11a55bda | 2661 | } else |
| Wayne Roberts |
10:db4e11a55bda | 2662 | log_printf("resultSize:%s\r\n", radio.cmdStatus_toString(stat.bits.cmdStatus)); |
| Wayne Roberts |
10:db4e11a55bda | 2663 | } // ..if (irq.bits.GNSSDone) |
| Wayne Roberts |
10:db4e11a55bda | 2664 | |
| Wayne Roberts |
10:db4e11a55bda | 2665 | } // ..if (irq.dword != 0) |
| Wayne Roberts |
9:295e37c38fb3 | 2666 | return false; |
| Wayne Roberts |
9:295e37c38fb3 | 2667 | } |
| Wayne Roberts |
9:295e37c38fb3 | 2668 | |
| Wayne Roberts |
9:295e37c38fb3 | 2669 | char Radio::chip_ver[24]; |
| Wayne Roberts |
9:295e37c38fb3 | 2670 | const char* const Radio::chipNum_str = chip_ver; |
| Wayne Roberts |
9:295e37c38fb3 | 2671 | |
| Wayne Roberts |
9:295e37c38fb3 | 2672 | const char* const Radio::opmode_select_strs[] = { |
| Wayne Roberts |
9:295e37c38fb3 | 2673 | "SLEEP ", // 0 |
| Wayne Roberts |
9:295e37c38fb3 | 2674 | "STDBY-RC ", // 1 |
| Wayne Roberts |
9:295e37c38fb3 | 2675 | "STDBY-XOSC", // 2 |
| Wayne Roberts |
9:295e37c38fb3 | 2676 | "FS ", // 3 |
| Wayne Roberts |
9:295e37c38fb3 | 2677 | "RX ", // 4 |
| Wayne Roberts |
9:295e37c38fb3 | 2678 | "TX ", // 5 |
| Wayne Roberts |
9:295e37c38fb3 | 2679 | NULL |
| Wayne Roberts |
9:295e37c38fb3 | 2680 | }; |
| Wayne Roberts |
9:295e37c38fb3 | 2681 | |
| Wayne Roberts |
9:295e37c38fb3 | 2682 | menuMode_e Radio::opmode_write(unsigned sel) |
| Wayne Roberts |
9:295e37c38fb3 | 2683 | { |
| Wayne Roberts |
9:295e37c38fb3 | 2684 | //stat_t stat; |
| Wayne Roberts |
9:295e37c38fb3 | 2685 | uint8_t buf[5]; |
| Wayne Roberts |
9:295e37c38fb3 | 2686 | |
| Wayne Roberts |
9:295e37c38fb3 | 2687 | switch (sel) { |
| Wayne Roberts |
9:295e37c38fb3 | 2688 | case 0: //sleep |
| Wayne Roberts |
9:295e37c38fb3 | 2689 | { |
| Wayne Roberts |
9:295e37c38fb3 | 2690 | unsigned ticks = 0; |
| Wayne Roberts |
9:295e37c38fb3 | 2691 | buf[0] = 1; // sleep config: dont wakeup, retain chip state |
| Wayne Roberts |
9:295e37c38fb3 | 2692 | radio.to_big_endian24(ticks, buf+1); |
| Wayne Roberts |
9:295e37c38fb3 | 2693 | /*stat.word =*/ radio.xfer(OPCODE_SET_SLEEP, 5, 0, buf); |
| Wayne Roberts |
9:295e37c38fb3 | 2694 | } |
| Wayne Roberts |
9:295e37c38fb3 | 2695 | break; |
| Wayne Roberts |
9:295e37c38fb3 | 2696 | case 1: // stby-rc |
| Wayne Roberts |
9:295e37c38fb3 | 2697 | buf[0] = 0; |
| Wayne Roberts |
9:295e37c38fb3 | 2698 | /*stat.word =*/ radio.xfer(OPCODE_SET_STANDBY, 1, 0, buf); |
| Wayne Roberts |
9:295e37c38fb3 | 2699 | break; |
| Wayne Roberts |
9:295e37c38fb3 | 2700 | case 2: // stby-xosc |
| Wayne Roberts |
9:295e37c38fb3 | 2701 | buf[0] = 1; |
| Wayne Roberts |
9:295e37c38fb3 | 2702 | /*stat.word =*/ radio.xfer(OPCODE_SET_STANDBY, 1, 0, buf); |
| Wayne Roberts |
9:295e37c38fb3 | 2703 | break; |
| Wayne Roberts |
9:295e37c38fb3 | 2704 | case 3: // fs |
| Wayne Roberts |
9:295e37c38fb3 | 2705 | setFS(); |
| Wayne Roberts |
9:295e37c38fb3 | 2706 | break; |
| Wayne Roberts |
9:295e37c38fb3 | 2707 | case 4: // rx |
| Wayne Roberts |
9:295e37c38fb3 | 2708 | { |
| Wayne Roberts |
9:295e37c38fb3 | 2709 | unsigned ticks = 0xffffff; // all 1's: receive until commanded to stop |
| Wayne Roberts |
9:295e37c38fb3 | 2710 | radio.to_big_endian24(ticks, buf); |
| Wayne Roberts |
9:295e37c38fb3 | 2711 | log_printf("setRx %02x %02x %02x\r\n", buf[0], buf[1], buf[2]); |
| Wayne Roberts |
9:295e37c38fb3 | 2712 | /*stat.word =*/ radio.xfer(OPCODE_SET_RX, 3, 0, buf); |
| Wayne Roberts |
9:295e37c38fb3 | 2713 | } |
| Wayne Roberts |
9:295e37c38fb3 | 2714 | break; |
| Wayne Roberts |
9:295e37c38fb3 | 2715 | case 5: // tx |
| Wayne Roberts |
9:295e37c38fb3 | 2716 | { |
| Wayne Roberts |
9:295e37c38fb3 | 2717 | unsigned ticks = 0; // 0 = disable-tx-timeout |
| Wayne Roberts |
9:295e37c38fb3 | 2718 | radio.to_big_endian24(ticks, buf); |
| Wayne Roberts |
9:295e37c38fb3 | 2719 | log_printf("setTx %02x %02x %02x\r\n", buf[0], buf[1], buf[2]); |
| Wayne Roberts |
9:295e37c38fb3 | 2720 | /*stat.word =*/ radio.xfer(OPCODE_SET_TX, 3, 0, buf); |
| Wayne Roberts |
9:295e37c38fb3 | 2721 | } |
| Wayne Roberts |
9:295e37c38fb3 | 2722 | |
| Wayne Roberts |
9:295e37c38fb3 | 2723 | break; |
| Wayne Roberts |
9:295e37c38fb3 | 2724 | } |
| Wayne Roberts |
9:295e37c38fb3 | 2725 | return MENUMODE_REDRAW; |
| Wayne Roberts |
9:295e37c38fb3 | 2726 | } |
| Wayne Roberts |
9:295e37c38fb3 | 2727 | |
| Wayne Roberts |
9:295e37c38fb3 | 2728 | const char* const Radio::opmode_status_strs[] = { |
| Wayne Roberts |
9:295e37c38fb3 | 2729 | "SLEEP ", // 0 |
| Wayne Roberts |
9:295e37c38fb3 | 2730 | "STDBY-RC ", // 1 |
| Wayne Roberts |
9:295e37c38fb3 | 2731 | "STDBY-XOSC", // 2 |
| Wayne Roberts |
9:295e37c38fb3 | 2732 | "FS ", // 3 |
| Wayne Roberts |
9:295e37c38fb3 | 2733 | "RX ", // 4 |
| Wayne Roberts |
9:295e37c38fb3 | 2734 | "TX ", // 5 |
| Wayne Roberts |
9:295e37c38fb3 | 2735 | "wifi/gnss ", // 6 |
| Wayne Roberts |
9:295e37c38fb3 | 2736 | NULL |
| Wayne Roberts |
9:295e37c38fb3 | 2737 | }; |
| Wayne Roberts |
9:295e37c38fb3 | 2738 | |
| Wayne Roberts |
9:295e37c38fb3 | 2739 | |
| Wayne Roberts |
9:295e37c38fb3 | 2740 | unsigned Radio::opmode_read(bool forWriting) |
| Wayne Roberts |
9:295e37c38fb3 | 2741 | { |
| Wayne Roberts |
9:295e37c38fb3 | 2742 | uint8_t buf[4]; |
| Wayne Roberts |
9:295e37c38fb3 | 2743 | stat_t stat; |
| Wayne Roberts |
9:295e37c38fb3 | 2744 | stat.word = radio.xfer(OPCODE_GET_STATUS, 4, 0, buf); |
| Wayne Roberts |
9:295e37c38fb3 | 2745 | return stat.bits.chipMode; |
| Wayne Roberts |
9:295e37c38fb3 | 2746 | } |
| Wayne Roberts |
9:295e37c38fb3 | 2747 | |
| Wayne Roberts |
9:295e37c38fb3 | 2748 | const char* const Radio::pktType_strs[] = { |
| Wayne Roberts |
9:295e37c38fb3 | 2749 | "NONE ", |
| Wayne Roberts |
9:295e37c38fb3 | 2750 | "GFSK ", |
| Wayne Roberts |
9:295e37c38fb3 | 2751 | "LORA ", |
| Wayne Roberts |
9:295e37c38fb3 | 2752 | NULL |
| Wayne Roberts |
9:295e37c38fb3 | 2753 | }; |
| Wayne Roberts |
9:295e37c38fb3 | 2754 | |
| Wayne Roberts |
9:295e37c38fb3 | 2755 | unsigned Radio::pktType_read(bool fw) |
| Wayne Roberts |
9:295e37c38fb3 | 2756 | { |
| Wayne Roberts |
9:295e37c38fb3 | 2757 | return radio.getPacketType(); |
| Wayne Roberts |
9:295e37c38fb3 | 2758 | } |
| Wayne Roberts |
9:295e37c38fb3 | 2759 | |
| Wayne Roberts |
9:295e37c38fb3 | 2760 | menuMode_e Radio::pktType_write(unsigned idx) |
| Wayne Roberts |
9:295e37c38fb3 | 2761 | { |
| Wayne Roberts |
9:295e37c38fb3 | 2762 | //stat_t stat; |
| Wayne Roberts |
9:295e37c38fb3 | 2763 | uint8_t buf = idx; |
| Wayne Roberts |
9:295e37c38fb3 | 2764 | /*stat.word =*/ radio.xfer(OPCODE_SET_PACKET_TYPE, 1, 0, &buf); |
| Wayne Roberts |
9:295e37c38fb3 | 2765 | return MENUMODE_REINIT_MENU; |
| Wayne Roberts |
9:295e37c38fb3 | 2766 | } |
| Wayne Roberts |
9:295e37c38fb3 | 2767 | |
| Wayne Roberts |
9:295e37c38fb3 | 2768 | bool Radio::tx_dbm_write(const char* str) |
| Wayne Roberts |
9:295e37c38fb3 | 2769 | { |
| Wayne Roberts |
9:295e37c38fb3 | 2770 | int dbm; |
| Wayne Roberts |
9:295e37c38fb3 | 2771 | sscanf(str, "%d", &dbm); |
| Wayne Roberts |
9:295e37c38fb3 | 2772 | tx_param_buf[0] = dbm; |
| Wayne Roberts |
9:295e37c38fb3 | 2773 | radio.xfer(OPCODE_SET_TXPARAMS, 2, 0, tx_param_buf); |
| Wayne Roberts |
9:295e37c38fb3 | 2774 | return false; |
| Wayne Roberts |
9:295e37c38fb3 | 2775 | } |
| Wayne Roberts |
9:295e37c38fb3 | 2776 | |
| Wayne Roberts |
9:295e37c38fb3 | 2777 | void Radio::tx_dbm_print() |
| Wayne Roberts |
9:295e37c38fb3 | 2778 | { |
| Wayne Roberts |
9:295e37c38fb3 | 2779 | txParamsB_t txpb; // txpb.bits.PaSel |
| Wayne Roberts |
9:295e37c38fb3 | 2780 | txParamsC_t txpc; |
| Wayne Roberts |
10:db4e11a55bda | 2781 | radio.memRegRead(REG_ADDR_TX_PARAMS_C, 1, &txpc.dword); |
| Wayne Roberts |
10:db4e11a55bda | 2782 | radio.memRegRead(REG_ADDR_TX_PARAMS_B, 1, &txpb.dword); |
| Wayne Roberts |
9:295e37c38fb3 | 2783 | if (txpb.bits.PaSel) |
| Wayne Roberts |
9:295e37c38fb3 | 2784 | pc.printf("%d", txpc.bits.tx_dbm - 9); |
| Wayne Roberts |
9:295e37c38fb3 | 2785 | else |
| Wayne Roberts |
9:295e37c38fb3 | 2786 | pc.printf("%d", txpc.bits.tx_dbm - 17); |
| Wayne Roberts |
9:295e37c38fb3 | 2787 | } |
| Wayne Roberts |
9:295e37c38fb3 | 2788 | |
| Wayne Roberts |
9:295e37c38fb3 | 2789 | const char* Radio::tx_ramp_strs[] = { |
| Wayne Roberts |
9:295e37c38fb3 | 2790 | "10 ", // 0 |
| Wayne Roberts |
9:295e37c38fb3 | 2791 | "20 ", // 1 |
| Wayne Roberts |
9:295e37c38fb3 | 2792 | "40 ", // 2 |
| Wayne Roberts |
9:295e37c38fb3 | 2793 | "80 ", // 3 |
| Wayne Roberts |
9:295e37c38fb3 | 2794 | "200 ", // 4 |
| Wayne Roberts |
9:295e37c38fb3 | 2795 | "800 ", // 5 |
| Wayne Roberts |
9:295e37c38fb3 | 2796 | "1700", // 6 |
| Wayne Roberts |
9:295e37c38fb3 | 2797 | "3400", // 7 |
| Wayne Roberts |
9:295e37c38fb3 | 2798 | NULL |
| Wayne Roberts |
9:295e37c38fb3 | 2799 | }; |
| Wayne Roberts |
9:295e37c38fb3 | 2800 | |
| Wayne Roberts |
9:295e37c38fb3 | 2801 | unsigned Radio::tx_ramp_read(bool fw) |
| Wayne Roberts |
9:295e37c38fb3 | 2802 | { |
| Wayne Roberts |
9:295e37c38fb3 | 2803 | txParamsC_t txpc; |
| Wayne Roberts |
10:db4e11a55bda | 2804 | radio.memRegRead(REG_ADDR_TX_PARAMS_C, 1, &txpc.dword); |
| Wayne Roberts |
9:295e37c38fb3 | 2805 | return txpc.bits.pa_ramp_time; |
| Wayne Roberts |
9:295e37c38fb3 | 2806 | } |
| Wayne Roberts |
9:295e37c38fb3 | 2807 | |
| Wayne Roberts |
9:295e37c38fb3 | 2808 | menuMode_e Radio::tx_ramp_write(unsigned sidx) |
| Wayne Roberts |
9:295e37c38fb3 | 2809 | { |
| Wayne Roberts |
9:295e37c38fb3 | 2810 | tx_param_buf[1] = sidx; |
| Wayne Roberts |
9:295e37c38fb3 | 2811 | radio.xfer(OPCODE_SET_TXPARAMS, 2, 0, tx_param_buf); |
| Wayne Roberts |
9:295e37c38fb3 | 2812 | return MENUMODE_REDRAW; |
| Wayne Roberts |
9:295e37c38fb3 | 2813 | } |
| Wayne Roberts |
9:295e37c38fb3 | 2814 | |
| Wayne Roberts |
9:295e37c38fb3 | 2815 | void Radio::tx_payload_length_print() |
| Wayne Roberts |
9:295e37c38fb3 | 2816 | { |
| Wayne Roberts |
9:295e37c38fb3 | 2817 | pc.printf("%u", get_payload_length()); |
| Wayne Roberts |
9:295e37c38fb3 | 2818 | } |
| Wayne Roberts |
9:295e37c38fb3 | 2819 | |
| Wayne Roberts |
9:295e37c38fb3 | 2820 | |
| Wayne Roberts |
9:295e37c38fb3 | 2821 | #endif /* ..SX1265_H */ |