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