2018-06-20 02:45:11 -04:00
|
|
|
#include "ROM.h"
|
|
|
|
|
2018-04-05 12:10:42 -04:00
|
|
|
#ifndef CONFIG_H
|
|
|
|
#define CONFIG_H
|
|
|
|
|
2018-06-20 02:45:11 -04:00
|
|
|
#define MAJ_VERS 0x01
|
2021-12-26 05:27:32 -05:00
|
|
|
#define MIN_VERS 0x12
|
2018-06-20 02:45:11 -04:00
|
|
|
|
2018-04-05 12:10:42 -04:00
|
|
|
#define MCU_1284P 0x91
|
2021-12-13 19:50:37 -05:00
|
|
|
#define MCU_2560 0x92
|
2018-04-05 12:10:42 -04:00
|
|
|
|
2018-06-20 11:45:22 -04:00
|
|
|
#define MODE_HOST 0x11
|
|
|
|
#define MODE_TNC 0x12
|
|
|
|
|
2020-05-28 16:18:19 -04:00
|
|
|
#if defined(__AVR_ATmega1284P__)
|
2018-04-05 12:10:42 -04:00
|
|
|
#define MCU_VARIANT MCU_1284P
|
|
|
|
#warning "Firmware is being compiled for atmega1284p based boards"
|
2021-12-13 19:50:37 -05:00
|
|
|
#elif defined(__AVR_ATmega2560__)
|
|
|
|
#define MCU_VARIANT MCU_2560
|
|
|
|
#warning "Firmware is being compiled for atmega2560 based boards"
|
2018-04-05 12:10:42 -04:00
|
|
|
#else
|
|
|
|
#error "The firmware cannot be compiled for the selected MCU variant"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define MTU 500
|
|
|
|
#define SINGLE_MTU 255
|
|
|
|
#define HEADER_L 1
|
2020-05-28 16:18:19 -04:00
|
|
|
#define MIN_L 1
|
|
|
|
|
2018-04-05 12:10:42 -04:00
|
|
|
#define CMD_L 4
|
|
|
|
|
|
|
|
// MCU dependent configuration parameters
|
|
|
|
|
|
|
|
#if MCU_VARIANT == MCU_1284P
|
|
|
|
const int pin_cs = 4;
|
|
|
|
const int pin_reset = 3;
|
|
|
|
const int pin_dio = 2;
|
|
|
|
const int pin_led_rx = 12;
|
|
|
|
const int pin_led_tx = 13;
|
2018-04-26 04:34:39 -04:00
|
|
|
|
2020-06-01 06:43:59 -04:00
|
|
|
// TODO: Reset
|
2020-05-29 08:58:10 -04:00
|
|
|
#define CONFIG_UART_BUFFER_SIZE 6144
|
|
|
|
#define CONFIG_QUEUE_SIZE 6144
|
2020-06-01 06:43:59 -04:00
|
|
|
#define CONFIG_QUEUE_MAX_LENGTH 250
|
2018-06-20 02:45:11 -04:00
|
|
|
|
|
|
|
#define EEPROM_SIZE 4096
|
|
|
|
#define EEPROM_OFFSET EEPROM_SIZE-EEPROM_RESERVED
|
2018-04-05 12:10:42 -04:00
|
|
|
#endif
|
|
|
|
|
2021-12-13 19:50:37 -05:00
|
|
|
#if MCU_VARIANT == MCU_2560
|
|
|
|
const int pin_cs = 10;
|
|
|
|
const int pin_reset = 9;
|
|
|
|
const int pin_dio = 2;
|
|
|
|
const int pin_led_rx = 12;
|
|
|
|
const int pin_led_tx = 13;
|
|
|
|
|
|
|
|
// TODO: Reset
|
|
|
|
#define CONFIG_UART_BUFFER_SIZE 2048
|
|
|
|
#define CONFIG_QUEUE_SIZE 2048
|
|
|
|
#define CONFIG_QUEUE_MAX_LENGTH 250
|
|
|
|
|
|
|
|
#define EEPROM_SIZE 4096
|
|
|
|
#define EEPROM_OFFSET EEPROM_SIZE-EEPROM_RESERVED
|
|
|
|
#endif
|
|
|
|
|
2018-06-20 02:45:11 -04:00
|
|
|
#define eeprom_addr(a) (a+EEPROM_OFFSET)
|
|
|
|
|
2018-04-05 12:10:42 -04:00
|
|
|
// MCU independent configuration parameters
|
2018-04-26 09:52:43 -04:00
|
|
|
const long serial_baudrate = 115200;
|
2018-04-26 10:47:03 -04:00
|
|
|
const int lora_rx_turnaround_ms = 50;
|
2018-04-05 12:10:42 -04:00
|
|
|
|
2019-11-07 09:26:21 -05:00
|
|
|
// SX1276 RSSI offset to get dBm value from
|
|
|
|
// packet RSSI register
|
|
|
|
const int rssi_offset = 157;
|
|
|
|
|
2018-04-05 12:10:42 -04:00
|
|
|
// Default LoRa settings
|
2018-06-20 10:32:30 -04:00
|
|
|
int lora_sf = 0;
|
|
|
|
int lora_cr = 5;
|
|
|
|
int lora_txp = 0xFF;
|
2018-04-05 12:10:42 -04:00
|
|
|
uint32_t lora_bw = 0;
|
|
|
|
uint32_t lora_freq = 0;
|
|
|
|
|
|
|
|
// Operational variables
|
2021-03-12 12:48:50 -05:00
|
|
|
bool radio_locked = true;
|
|
|
|
bool radio_online = false;
|
|
|
|
bool hw_ready = false;
|
|
|
|
bool promisc = false;
|
|
|
|
bool implicit = false;
|
|
|
|
uint8_t implicit_l = 0;
|
2018-06-27 05:42:48 -04:00
|
|
|
|
2018-06-20 11:45:22 -04:00
|
|
|
uint8_t op_mode = MODE_HOST;
|
2018-06-20 02:45:11 -04:00
|
|
|
uint8_t model = 0x00;
|
|
|
|
uint8_t hwrev = 0x00;
|
2021-12-13 19:50:37 -05:00
|
|
|
|
2018-06-27 08:08:16 -04:00
|
|
|
int last_rssi = -292;
|
|
|
|
uint8_t last_rssi_raw = 0x00;
|
2020-05-21 06:41:39 -04:00
|
|
|
uint8_t last_snr_raw = 0x00;
|
2018-04-05 12:10:42 -04:00
|
|
|
size_t read_len = 0;
|
|
|
|
uint8_t seq = 0xFF;
|
2021-12-13 19:50:37 -05:00
|
|
|
|
2020-05-28 16:18:19 -04:00
|
|
|
// Incoming packet buffer
|
2018-04-05 12:10:42 -04:00
|
|
|
uint8_t pbuf[MTU];
|
2020-05-28 16:18:19 -04:00
|
|
|
|
|
|
|
// KISS command buffer
|
2018-04-05 12:10:42 -04:00
|
|
|
uint8_t cbuf[CMD_L];
|
|
|
|
|
2020-05-28 16:18:19 -04:00
|
|
|
// LoRa transmit buffer
|
|
|
|
uint8_t tbuf[MTU];
|
2018-06-27 04:22:44 -04:00
|
|
|
|
2018-04-05 12:10:42 -04:00
|
|
|
uint32_t stat_rx = 0;
|
|
|
|
uint32_t stat_tx = 0;
|
|
|
|
|
2018-04-26 09:52:43 -04:00
|
|
|
bool stat_signal_detected = false;
|
|
|
|
bool stat_signal_synced = false;
|
|
|
|
bool stat_rx_ongoing = false;
|
|
|
|
bool dcd = false;
|
|
|
|
bool dcd_led = false;
|
|
|
|
bool dcd_waiting = false;
|
|
|
|
uint16_t dcd_count = 0;
|
|
|
|
uint16_t dcd_threshold = 15;
|
|
|
|
|
|
|
|
uint32_t status_interval_ms = 3;
|
|
|
|
uint32_t last_status_update = 0;
|
|
|
|
|
|
|
|
// Status flags
|
|
|
|
const uint8_t SIG_DETECT = 0x01;
|
|
|
|
const uint8_t SIG_SYNCED = 0x02;
|
|
|
|
const uint8_t RX_ONGOING = 0x04;
|
|
|
|
|
2021-12-26 05:27:32 -05:00
|
|
|
// Boot flags
|
|
|
|
#define START_FROM_BOOTLOADER 0x01
|
|
|
|
#define START_FROM_POWERON 0x02
|
|
|
|
#define START_FROM_BROWNOUT 0x03
|
|
|
|
#define START_FROM_JTAG 0x04
|
|
|
|
|
2018-04-05 12:10:42 -04:00
|
|
|
#endif
|