2023-09-09 07:03:56 +00: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 08:01:52 +00:00
|
|
|
|
2023-09-09 07:03:56 +00:00
|
|
|
#include "dcs.h"
|
2023-10-02 09:05:15 +00:00
|
|
|
#include "frequencies.h"
|
2023-09-09 07:03:56 +00:00
|
|
|
|
|
|
|
enum {
|
2023-09-15 11:31:30 +00:00
|
|
|
RADIO_CHANNEL_UP = 0x01u,
|
|
|
|
RADIO_CHANNEL_DOWN = 0xFFu,
|
2023-09-09 07:03:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
2023-09-09 08:01:52 +00:00
|
|
|
BANDWIDTH_WIDE = 0,
|
|
|
|
BANDWIDTH_NARROW
|
2023-09-09 07:03:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum PTT_ID_t {
|
2023-10-02 18:23:37 +00:00
|
|
|
PTT_ID_OFF = 0, // OFF
|
2023-10-02 19:52:18 +00:00
|
|
|
PTT_ID_TX_UP, // BEGIN OF TX
|
|
|
|
PTT_ID_TX_DOWN, // END OF TX
|
2023-10-06 06:48:45 +00:00
|
|
|
PTT_ID_BOTH, // BOTH
|
|
|
|
PTT_ID_APOLLO // Apolo quindar tones
|
2023-09-09 07:03:56 +00:00
|
|
|
};
|
|
|
|
typedef enum PTT_ID_t PTT_ID_t;
|
|
|
|
|
2023-09-10 12:52:41 +00:00
|
|
|
enum VfoState_t
|
|
|
|
{
|
2023-09-09 08:01:52 +00: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 10:01:34 +00:00
|
|
|
VFO_STATE_VOLTAGE_HIGH
|
2023-09-09 07:03:56 +00:00
|
|
|
};
|
|
|
|
typedef enum VfoState_t VfoState_t;
|
|
|
|
|
2023-10-31 16:23:10 +00:00
|
|
|
typedef enum {
|
|
|
|
MODULATION_FM,
|
|
|
|
MODULATION_AM,
|
|
|
|
MODULATION_USB,
|
2023-11-03 11:51:06 +00:00
|
|
|
|
|
|
|
#ifdef ENABLE_BYP_RAW_DEMODULATORS
|
2023-10-31 16:23:10 +00:00
|
|
|
MODULATION_BYP,
|
|
|
|
MODULATION_RAW,
|
2023-11-03 11:51:06 +00:00
|
|
|
#endif
|
|
|
|
|
2023-10-31 16:23:10 +00:00
|
|
|
MODULATION_UKNOWN
|
|
|
|
} ModulationMode_t;
|
|
|
|
|
2023-11-03 11:51:06 +00:00
|
|
|
extern const char gModulationStr[MODULATION_UKNOWN][4];
|
2023-10-31 16:23:10 +00:00
|
|
|
|
2023-09-09 07:03:56 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
uint32_t Frequency;
|
|
|
|
DCS_CodeType_t CodeType;
|
|
|
|
uint8_t Code;
|
|
|
|
uint8_t Padding[2];
|
|
|
|
} FREQ_Config_t;
|
|
|
|
|
|
|
|
typedef struct VFO_Info_t
|
|
|
|
{
|
2023-09-25 17:08:21 +00:00
|
|
|
FREQ_Config_t freq_config_RX;
|
|
|
|
FREQ_Config_t freq_config_TX;
|
2023-10-24 16:35:27 +00:00
|
|
|
|
|
|
|
// this is for a purpose of the FrequencyReverse function
|
|
|
|
// it points to freq_config_RX normally and to freq_config_TX if reverse function is active
|
|
|
|
//
|
2023-09-09 07:03:56 +00:00
|
|
|
FREQ_Config_t *pRX;
|
2023-10-24 16:35:27 +00:00
|
|
|
|
|
|
|
// this is for a purpose of the FrequencyReverse function
|
|
|
|
// it points to freq_config_TX normally and to freq_config_RX if reverse function is active
|
2023-09-09 07:03:56 +00:00
|
|
|
FREQ_Config_t *pTX;
|
2023-09-25 17:08:21 +00:00
|
|
|
|
2023-09-15 11:31:30 +00:00
|
|
|
uint32_t TX_OFFSET_FREQUENCY;
|
2023-09-09 07:03:56 +00:00
|
|
|
uint16_t StepFrequency;
|
2023-09-25 17:08:21 +00:00
|
|
|
|
2023-09-09 07:03:56 +00:00
|
|
|
uint8_t CHANNEL_SAVE;
|
2023-09-25 17:08:21 +00:00
|
|
|
|
2023-09-15 11:31:30 +00:00
|
|
|
uint8_t TX_OFFSET_FREQUENCY_DIRECTION;
|
2023-09-25 17:08:21 +00:00
|
|
|
|
2023-09-09 07:03:56 +00:00
|
|
|
uint8_t SquelchOpenRSSIThresh;
|
|
|
|
uint8_t SquelchOpenNoiseThresh;
|
|
|
|
uint8_t SquelchCloseGlitchThresh;
|
|
|
|
uint8_t SquelchCloseRSSIThresh;
|
|
|
|
uint8_t SquelchCloseNoiseThresh;
|
|
|
|
uint8_t SquelchOpenGlitchThresh;
|
2023-09-25 17:08:21 +00:00
|
|
|
|
2023-09-09 07:03:56 +00:00
|
|
|
STEP_Setting_t STEP_SETTING;
|
|
|
|
uint8_t OUTPUT_POWER;
|
|
|
|
uint8_t TXP_CalculatedSetting;
|
|
|
|
bool FrequencyReverse;
|
2023-09-25 17:08:21 +00:00
|
|
|
|
2023-09-09 07:03:56 +00:00
|
|
|
uint8_t SCRAMBLING_TYPE;
|
|
|
|
uint8_t CHANNEL_BANDWIDTH;
|
2023-09-25 17:08:21 +00:00
|
|
|
|
2023-09-09 07:03:56 +00:00
|
|
|
uint8_t SCANLIST1_PARTICIPATION;
|
|
|
|
uint8_t SCANLIST2_PARTICIPATION;
|
2023-09-25 17:08:21 +00:00
|
|
|
|
2023-09-09 07:03:56 +00:00
|
|
|
uint8_t Band;
|
2023-11-28 19:11:03 +00:00
|
|
|
#ifdef ENABLE_DTMF_CALLING
|
2023-09-09 07:03:56 +00:00
|
|
|
uint8_t DTMF_DECODING_ENABLE;
|
2023-11-28 19:11:03 +00:00
|
|
|
#endif
|
2023-09-09 07:03:56 +00:00
|
|
|
PTT_ID_t DTMF_PTT_ID_TX_MODE;
|
2023-09-25 17:08:21 +00:00
|
|
|
|
2023-09-09 07:03:56 +00:00
|
|
|
uint8_t BUSY_CHANNEL_LOCK;
|
2023-09-25 17:08:21 +00:00
|
|
|
|
2023-10-31 16:23:10 +00:00
|
|
|
ModulationMode_t Modulation;
|
2023-09-25 17:08:21 +00:00
|
|
|
|
2023-10-04 15:37:11 +00:00
|
|
|
uint8_t Compander;
|
2023-09-25 17:08:21 +00:00
|
|
|
|
|
|
|
char Name[16];
|
2023-09-09 07:03:56 +00:00
|
|
|
} VFO_Info_t;
|
|
|
|
|
2023-10-19 12:26:27 +00:00
|
|
|
// Settings of the main VFO that is selected by the user
|
2023-11-27 21:51:36 +00:00
|
|
|
// The pointer follows gEeprom.TX_VFO index
|
2023-09-09 07:03:56 +00:00
|
|
|
extern VFO_Info_t *gTxVfo;
|
2023-10-19 12:26:27 +00:00
|
|
|
|
|
|
|
// Settings of the actual VFO that is now used for RX,
|
|
|
|
// It is being alternated by dual watch, and flipped by crossband
|
|
|
|
// The pointer follows gEeprom.RX_VFO
|
2023-09-09 07:03:56 +00:00
|
|
|
extern VFO_Info_t *gRxVfo;
|
2023-10-19 12:26:27 +00:00
|
|
|
|
|
|
|
// Equal to gTxVfo unless dual watch changes it on incomming transmition (this can only happen when XB off and DW on)
|
2023-09-09 07:03:56 +00:00
|
|
|
extern VFO_Info_t *gCurrentVfo;
|
|
|
|
|
|
|
|
extern DCS_CodeType_t gCurrentCodeType;
|
|
|
|
|
|
|
|
extern VfoState_t VfoState[2];
|
|
|
|
|
2023-09-09 08:01:52 +00: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 16:19:38 +00:00
|
|
|
void RADIO_InitInfo(VFO_Info_t *pInfo, const uint8_t ChannelSave, const uint32_t Frequency);
|
2023-09-28 21:42:52 +00:00
|
|
|
void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure);
|
2023-09-09 08:01:52 +00:00
|
|
|
void RADIO_ConfigureSquelchAndOutputPower(VFO_Info_t *pInfo);
|
2023-12-05 11:49:33 +00:00
|
|
|
void RADIO_ApplyTxOffset(VFO_Info_t *pInfo);
|
2023-09-09 08:01:52 +00:00
|
|
|
void RADIO_SelectVfos(void);
|
|
|
|
void RADIO_SetupRegisters(bool bSwitchToFunction0);
|
2023-09-14 08:56:30 +00:00
|
|
|
#ifdef ENABLE_NOAA
|
2023-09-09 07:03:56 +00:00
|
|
|
void RADIO_ConfigureNOAA(void);
|
|
|
|
#endif
|
2023-09-09 08:01:52 +00:00
|
|
|
void RADIO_SetTxParameters(void);
|
2023-10-31 16:23:10 +00:00
|
|
|
void RADIO_SetModulation(ModulationMode_t modulation);
|
2023-09-09 08:01:52 +00: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 07:03:56 +00:00
|
|
|
|
2023-10-31 16:23:10 +00:00
|
|
|
|
2023-09-09 07:03:56 +00:00
|
|
|
#endif
|