opencom_xl_firmware/Config.h

157 lines
4.1 KiB
C
Raw Normal View History

// Copyright (C) 2024, Mark Qvist
2023-01-14 00:11:02 +01:00
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#include "ROM.h"
2024-02-09 15:29:54 +01:00
#include "Boards.h"
2018-04-05 18:10:42 +02:00
#ifndef CONFIG_H
#define CONFIG_H
#define MAJ_VERS 0x01
2024-10-22 12:56:24 +02:00
#define MIN_VERS 0x4a
2022-01-09 23:40:30 +01:00
2018-06-20 17:45:22 +02:00
#define MODE_HOST 0x11
#define MODE_TNC 0x12
2022-10-30 18:58:12 +01:00
#define CABLE_STATE_DISCONNECTED 0x00
#define CABLE_STATE_CONNECTED 0x01
uint8_t cable_state = CABLE_STATE_DISCONNECTED;
#define MAX_INTERFACES 12
2022-10-30 18:58:12 +01:00
#define BT_STATE_NA 0xff
#define BT_STATE_OFF 0x00
#define BT_STATE_ON 0x01
#define BT_STATE_PAIRING 0x02
#define BT_STATE_CONNECTED 0x03
uint8_t bt_state = BT_STATE_NA;
uint32_t bt_ssp_pin = 0;
bool bt_ready = false;
bool bt_enabled = false;
bool bt_allow_pairing = false;
2023-01-07 16:35:07 +01:00
#define M_FRQ_S 27388122
#define M_FRQ_R 27388061
bool console_active = false;
2024-06-10 14:05:21 +02:00
bool modems_installed = false;
2023-01-07 16:35:07 +01:00
#define MTU 508
2018-04-05 18:10:42 +02:00
#define SINGLE_MTU 255
#define HEADER_L 1
2020-05-28 22:18:19 +02:00
#define MIN_L 1
#define CMD_L 64
2018-04-05 18:10:42 +02:00
#define eeprom_addr(a) (a+EEPROM_OFFSET)
2024-06-10 14:05:21 +02:00
#define PA_OUTPUT_RFO_PIN 0
#define PA_OUTPUT_PA_BOOST_PIN 1
2024-01-19 11:08:55 +01:00
2018-04-05 18:10:42 +02:00
// MCU independent configuration parameters
2022-01-10 22:14:30 +01:00
const long serial_baudrate = 115200;
2018-04-05 18:10:42 +02:00
// SX1276 RSSI offset to get dBm value from
// packet RSSI register
2022-01-09 23:40:30 +01:00
const int rssi_offset = 157;
2024-06-10 14:05:21 +02:00
// Default LoRa settings
const int lora_rx_turnaround_ms = 66;
const int lora_post_tx_yield_slots = 6;
#define LORA_CAD_SYMBOLS 3
2018-04-05 18:10:42 +02:00
// Operational variables
2023-09-14 22:32:26 +02:00
bool community_fw = true;
2021-03-12 18:48:50 +01:00
bool hw_ready = false;
2023-09-14 22:32:26 +02:00
bool disp_ready = false;
bool pmu_ready = false;
2021-03-12 18:48:50 +01:00
bool promisc = false;
bool implicit = false;
bool memory_low = false;
2021-03-12 18:48:50 +01:00
uint8_t implicit_l = 0;
2018-06-27 11:42:48 +02:00
2024-10-15 18:34:16 +02:00
uint8_t packet_interface = 0xFF;
2024-09-11 22:49:27 +02:00
2018-06-20 17:45:22 +02:00
uint8_t op_mode = MODE_HOST;
uint8_t model = 0x00;
uint8_t hwrev = 0x00;
2021-12-14 01:50:37 +01:00
2018-06-27 14:08:16 +02:00
int last_rssi = -292;
uint8_t last_rssi_raw = 0x00;
uint8_t last_snr_raw = 0x80;
uint8_t seq[INTERFACE_COUNT];
uint16_t read_len[INTERFACE_COUNT];
2021-12-14 01:50:37 +01:00
bool serial_in_frame = false;
FIFOBuffer packet_rdy_interfaces;
uint8_t packet_rdy_interfaces_buf[MAX_INTERFACES];
2020-05-28 22:18:19 +02:00
// Incoming packet buffer
2018-04-05 18:10:42 +02:00
uint8_t pbuf[MTU];
2020-05-28 22:18:19 +02:00
// KISS command buffer
uint8_t cmdbuf[CMD_L];
2018-04-05 18:10:42 +02:00
2020-05-28 22:18:19 +02:00
// LoRa transmit buffer
uint8_t tbuf[MTU];
2018-06-27 10:22:44 +02:00
2018-04-05 18:10:42 +02:00
uint32_t stat_rx = 0;
uint32_t stat_tx = 0;
unsigned long last_tx = 0;
unsigned long last_rx = 0;
// Power management
#define BATTERY_STATE_UNKNOWN 0x00
#define BATTERY_STATE_DISCHARGING 0x01
#define BATTERY_STATE_CHARGING 0x02
#define BATTERY_STATE_CHARGED 0x03
2022-10-30 22:27:30 +01:00
bool battery_installed = false;
bool battery_indeterminate = false;
2022-10-30 22:27:30 +01:00
bool external_power = false;
bool battery_ready = false;
float battery_voltage = 0.0;
float battery_percent = 0.0;
uint8_t battery_state = 0x00;
uint8_t display_intensity = 0xFF;
uint8_t display_addr = 0xFF;
bool display_blanking_enabled = false;
2023-09-14 22:32:26 +02:00
bool display_diagnostics = true;
bool device_init_done = false;
bool eeprom_ok = false;
bool firmware_update_mode = false;
2021-12-26 11:27:32 +01:00
// Boot flags
#define START_FROM_BOOTLOADER 0x01
#define START_FROM_POWERON 0x02
#define START_FROM_BROWNOUT 0x03
#define START_FROM_JTAG 0x04
2021-12-26 11:27:32 +01:00
2024-06-10 14:05:21 +02:00
// Subinterfaces
// select interface 0 by default
uint8_t interface = 0;
RadioInterface* selected_radio;
RadioInterface* interface_obj[INTERFACE_COUNT];
RadioInterface* interface_obj_sorted[INTERFACE_COUNT];
#if HAS_BUZZER
// Buzzer
bool buzzer_enabled = true;
unsigned long last_tone_toggle = 0;
uint16_t buzzer_delay = 0;
uint16_t last_buzzer_tone = 0;
#endif
2022-01-24 19:30:00 +01:00
#endif