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
|
|
|
|
2023-09-09 08:03:56 +01:00
|
|
|
#include "dcs.h"
|
2023-10-02 10:05:15 +01:00
|
|
|
#include "frequencies.h"
|
2023-09-09 08:03:56 +01:00
|
|
|
|
|
|
|
enum {
|
2023-10-08 17:14:13 +01:00
|
|
|
USER_CH_BAND_MASK = 0x0F << 0,
|
|
|
|
USER_CH_COMPAND = 3u << 4, // new
|
|
|
|
USER_CH_SCANLIST2 = 1u << 6,
|
|
|
|
USER_CH_SCANLIST1 = 1u << 7
|
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
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
2023-09-09 09:01:52 +01:00
|
|
|
BANDWIDTH_WIDE = 0,
|
|
|
|
BANDWIDTH_NARROW
|
2023-09-09 08:03:56 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
enum PTT_ID_t {
|
2023-10-02 19:23:37 +01:00
|
|
|
PTT_ID_OFF = 0, // OFF
|
2023-10-02 20:52:18 +01:00
|
|
|
PTT_ID_TX_UP, // BEGIN OF TX
|
|
|
|
PTT_ID_TX_DOWN, // END OF TX
|
2023-10-06 07:48:45 +01:00
|
|
|
PTT_ID_BOTH, // BOTH
|
|
|
|
PTT_ID_APOLLO // Apolo quindar tones
|
2023-09-09 08:03:56 +01:00
|
|
|
};
|
|
|
|
typedef enum PTT_ID_t PTT_ID_t;
|
|
|
|
|
2023-09-10 13:52:41 +01:00
|
|
|
enum VfoState_t
|
|
|
|
{
|
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
|
|
|
};
|
|
|
|
typedef enum VfoState_t VfoState_t;
|
|
|
|
|
|
|
|
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-09-09 08:03:56 +01:00
|
|
|
} FREQ_Config_t;
|
|
|
|
|
|
|
|
typedef struct VFO_Info_t
|
|
|
|
{
|
2023-10-08 17:14:13 +01:00
|
|
|
FREQ_Config_t freq_config_rx;
|
|
|
|
FREQ_Config_t freq_config_tx;
|
2023-09-09 08:03:56 +01:00
|
|
|
FREQ_Config_t *pRX;
|
|
|
|
FREQ_Config_t *pTX;
|
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
|
|
|
|
2023-10-08 17:14:13 +01:00
|
|
|
uint8_t squelch_open_RSSI_thresh;
|
|
|
|
uint8_t squelch_open_noise_thresh;
|
|
|
|
uint8_t squelch_close_glitch_thresh;
|
|
|
|
uint8_t squelch_close_RSSI_thresh;
|
|
|
|
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 17:14:13 +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-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-08 17:14:13 +01:00
|
|
|
uint8_t compander;
|
2023-09-25 18:08:21 +01:00
|
|
|
|
2023-10-08 17:14:13 +01:00
|
|
|
char name[16];
|
2023-09-09 08:03:56 +01:00
|
|
|
} VFO_Info_t;
|
|
|
|
|
|
|
|
extern VFO_Info_t *gTxVfo;
|
|
|
|
extern VFO_Info_t *gRxVfo;
|
|
|
|
extern VFO_Info_t *gCurrentVfo;
|
|
|
|
|
2023-10-08 17:14:13 +01:00
|
|
|
extern dcs_code_type_t gSelectedcode_type;
|
|
|
|
extern dcs_code_type_t gCurrentcode_type;
|
2023-09-09 08:03:56 +01:00
|
|
|
extern uint8_t gSelectedCode;
|
|
|
|
|
2023-10-08 17:14:13 +01:00
|
|
|
extern step_setting_t gStepSetting;
|
2023-09-09 08:03:56 +01:00
|
|
|
|
|
|
|
extern VfoState_t VfoState[2];
|
|
|
|
|
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, int8_t Direction, bool bCheckScanList, uint8_t RadioNum);
|
2023-10-01 17:19:38 +01:00
|
|
|
void RADIO_InitInfo(VFO_Info_t *pInfo, const uint8_t ChannelSave, const uint32_t Frequency);
|
2023-09-28 22:42:52 +01:00
|
|
|
void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure);
|
2023-09-09 09:01:52 +01:00
|
|
|
void RADIO_ConfigureSquelchAndOutputPower(VFO_Info_t *pInfo);
|
|
|
|
void RADIO_ApplyOffset(VFO_Info_t *pInfo);
|
|
|
|
void RADIO_SelectVfos(void);
|
|
|
|
void RADIO_SetupRegisters(bool bSwitchToFunction0);
|
2023-09-14 09:56:30 +01:00
|
|
|
#ifdef ENABLE_NOAA
|
2023-09-09 08:03:56 +01:00
|
|
|
void RADIO_ConfigureNOAA(void);
|
|
|
|
#endif
|
2023-09-09 09:01:52 +01:00
|
|
|
void RADIO_SetTxParameters(void);
|
2023-09-09 08:03:56 +01:00
|
|
|
|
2023-09-09 09:01:52 +01:00
|
|
|
void RADIO_SetVfoState(VfoState_t State);
|
|
|
|
void RADIO_PrepareTX(void);
|
|
|
|
void RADIO_EnableCxCSS(void);
|
|
|
|
void RADIO_PrepareCssTX(void);
|
|
|
|
void RADIO_SendEndOfTransmission(void);
|
2023-09-09 08:03:56 +01:00
|
|
|
|
|
|
|
#endif
|