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