0
mirror of https://github.com/OneOfEleven/uv-k5-firmware-custom.git synced 2025-04-28 06:11:24 +03:00

161 lines
4.1 KiB
C
Raw Normal View History

2023-09-09 08:03:56 +01:00
/* Copyright 2023 Dual Tachyon
* https://github.com/DualTachyon
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef RADIO_H
#define RADIO_H
#include <stdbool.h>
#include <stdint.h>
2023-09-09 09:01:52 +01:00
#include "misc.h"
2023-09-09 08:03:56 +01:00
#include "dcs.h"
#include "frequencies.h"
2023-09-09 08:03:56 +01:00
/*
2023-09-09 08:03:56 +01:00
enum {
2023-09-15 12:31:30 +01:00
RADIO_CHANNEL_UP = 0x01u,
RADIO_CHANNEL_DOWN = 0xFFu,
2023-09-09 08:03:56 +01:00
};
*/
2023-09-09 08:03:56 +01:00
enum {
2023-09-09 09:01:52 +01:00
BANDWIDTH_WIDE = 0,
BANDWIDTH_NARROW
2023-09-09 08:03:56 +01:00
};
2023-10-08 20:23:37 +01:00
enum ptt_id_e {
2023-10-02 19:23:37 +01:00
PTT_ID_OFF = 0, // OFF
PTT_ID_TX_UP, // BEGIN OF TX
PTT_ID_TX_DOWN, // END OF TX
PTT_ID_BOTH, // BOTH
PTT_ID_APOLLO // Apolo quindar tones
2023-09-09 08:03:56 +01:00
};
2023-10-08 20:23:37 +01:00
typedef enum ptt_id_e ptt_id_t;
2023-09-09 08:03:56 +01:00
2023-10-25 19:26:22 +01:00
enum mdc1200_mode_e {
MDC1200_MODE_OFF = 0, // OFF
MDC1200_MODE_BOT, // BEGIN OF TX
MDC1200_MODE_EOT, // END OF TX
MDC1200_MODE_BOTH // BOTH
};
typedef enum mdc1200_mode_e mdc1200_mode_t;
2023-10-08 20:23:37 +01:00
enum vfo_state_e
2023-09-10 13:52:41 +01:00
{
2023-09-09 09:01:52 +01:00
VFO_STATE_NORMAL = 0,
VFO_STATE_BUSY,
VFO_STATE_BAT_LOW,
VFO_STATE_TX_DISABLE,
VFO_STATE_TIMEOUT,
VFO_STATE_ALARM,
2023-09-12 11:01:34 +01:00
VFO_STATE_VOLTAGE_HIGH
2023-09-09 08:03:56 +01:00
};
2023-10-08 20:23:37 +01:00
typedef enum vfo_state_e vfo_state_t;
2023-09-09 08:03:56 +01:00
typedef struct
{
2023-10-08 17:14:13 +01:00
uint32_t frequency;
dcs_code_type_t code_type;
uint8_t code;
uint8_t padding[2];
2023-10-08 20:23:37 +01:00
} freq_config_t;
2023-09-09 08:03:56 +01:00
2023-10-08 20:23:37 +01:00
typedef struct vfo_info_t
2023-09-09 08:03:56 +01:00
{
2023-10-08 20:23:37 +01:00
freq_config_t freq_config_rx;
freq_config_t freq_config_tx;
freq_config_t *p_rx;
freq_config_t *p_tx;
2023-09-25 18:08:21 +01:00
2023-10-08 17:14:13 +01:00
uint32_t tx_offset_freq;
uint16_t step_freq;
2023-09-25 18:08:21 +01:00
2023-10-08 17:14:13 +01:00
uint8_t channel_save;
2023-09-25 18:08:21 +01:00
2023-10-08 17:14:13 +01:00
uint8_t tx_offset_freq_dir;
2023-09-25 18:08:21 +01:00
uint8_t squelch_level; // per channel squelch level
2023-10-08 20:23:37 +01:00
uint8_t squelch_open_rssi_thresh;
2023-10-08 17:14:13 +01:00
uint8_t squelch_open_noise_thresh;
uint8_t squelch_close_glitch_thresh;
2023-10-08 20:23:37 +01:00
uint8_t squelch_close_rssi_thresh;
2023-10-08 17:14:13 +01:00
uint8_t squelch_close_noise_thresh;
uint8_t squelch_open_glitch_thresh;
2023-09-25 18:08:21 +01:00
2023-10-08 17:14:13 +01:00
step_setting_t step_setting;
uint8_t output_power;
uint8_t txp_calculated_setting;
bool frequency_reverse;
2023-09-25 18:08:21 +01:00
2023-10-08 17:14:13 +01:00
uint8_t scrambling_type;
uint8_t channel_bandwidth;
2023-09-25 18:08:21 +01:00
2023-10-08 17:14:13 +01:00
uint8_t scanlist_1_participation;
uint8_t scanlist_2_participation;
2023-09-25 18:08:21 +01:00
2023-10-08 17:14:13 +01:00
uint8_t band;
2023-09-25 18:08:21 +01:00
2023-10-08 20:23:37 +01:00
uint8_t dtmf_decoding_enable;
ptt_id_t dtmf_ptt_id_tx_mode;
2023-09-25 18:08:21 +01:00
2023-10-25 19:26:22 +01:00
#ifdef ENABLE_MDC1200
mdc1200_mode_t mdc1200_mode;
#endif
2023-10-08 17:14:13 +01:00
uint8_t busy_channel_lock;
2023-09-25 18:08:21 +01:00
2023-10-08 17:14:13 +01:00
uint8_t am_mode;
2023-09-25 18:08:21 +01:00
2023-10-17 21:22:40 +01:00
uint8_t compand;
2023-09-25 18:08:21 +01:00
2023-10-22 14:22:53 +01:00
uint8_t freq_in_channel; // channel number if the VFO's frequency is found stored in a channel
2023-10-19 14:21:37 +01:00
2023-10-08 17:14:13 +01:00
char name[16];
2023-10-08 20:23:37 +01:00
} vfo_info_t;
2023-09-09 08:03:56 +01:00
2023-11-02 10:00:51 +00:00
extern vfo_info_t g_vfo_info[2];
2023-10-08 20:23:37 +01:00
extern vfo_info_t *g_tx_vfo;
extern vfo_info_t *g_rx_vfo;
extern vfo_info_t *g_current_vfo;
2023-09-09 08:03:56 +01:00
2023-10-08 20:23:37 +01:00
extern dcs_code_type_t g_selected_code_type;
extern dcs_code_type_t g_current_code_type;
extern uint8_t g_selected_code;
2023-09-09 08:03:56 +01:00
2023-10-08 20:23:37 +01:00
extern vfo_state_t g_vfo_state[2];
2023-09-09 08:03:56 +01:00
2023-09-09 09:01:52 +01:00
bool RADIO_CheckValidChannel(uint16_t ChNum, bool bCheckScanList, uint8_t RadioNum);
uint8_t RADIO_FindNextChannel(uint8_t ChNum, scan_state_dir_t Direction, bool bCheckScanList, uint8_t RadioNum);
void RADIO_InitInfo(vfo_info_t *p_vfo, const uint8_t ChannelSave, const uint32_t Frequency);
void RADIO_configure_channel(const unsigned int VFO, const unsigned int configure);
void RADIO_ConfigureSquelchAndOutputPower(vfo_info_t *p_vfo);
2023-10-28 08:46:27 +01:00
void RADIO_ApplyOffset(vfo_info_t *p_vfo, const bool set_pees);
void RADIO_select_vfos(void);
void RADIO_setup_registers(bool switch_to_function_foreground);
2023-09-14 09:56:30 +01:00
#ifdef ENABLE_NOAA
2023-09-09 08:03:56 +01:00
void RADIO_ConfigureNOAA(void);
#endif
void RADIO_enableTX(const bool fsk_tx);
2023-09-09 08:03:56 +01:00
void RADIO_set_vfo_state(vfo_state_t State);
2023-09-09 09:01:52 +01:00
void RADIO_PrepareTX(void);
void RADIO_enable_CxCSS_tail(void);
2023-09-09 09:01:52 +01:00
void RADIO_PrepareCssTX(void);
2023-10-18 11:31:30 +01:00
void RADIO_tx_eot(void);
2023-09-09 08:03:56 +01:00
#endif