kamilsss655/radio.h

185 lines
5.0 KiB
C
Raw Permalink Normal View History

2024-02-04 12:32:49 +00:00
/* Original work Copyright 2023 Dual Tachyon
2023-09-09 07:03:56 +00:00
* https://github.com/DualTachyon
*
2024-02-04 12:32:49 +00:00
* Modified work Copyright 2024 kamilsss655
* https://github.com/kamilsss655
*
2023-09-09 07:03:56 +00:00
* 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"
#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 {
2024-01-01 17:00:12 +00:00
BANDWIDTH_WIDE = 0U,
BANDWIDTH_NARROW = 1U,
BANDWIDTH_NARROWAVIATION = 2U,
BANDWIDTH_NARROWER = 3U,
BANDWIDTH_NARROWEST = 4U
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
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 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;
typedef enum {
MODULATION_FM,
MODULATION_AM,
MODULATION_USB,
#ifdef ENABLE_BYP_RAW_DEMODULATORS
MODULATION_BYP,
MODULATION_RAW,
#endif
MODULATION_UKNOWN
} ModulationMode_t;
extern const char gModulationStr[MODULATION_UKNOWN][4];
2024-01-01 17:00:12 +00:00
extern const char *bwNames[5];
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;
#ifdef ENABLE_DTMF_CALLING
2023-09-09 07:03:56 +00:00
uint8_t DTMF_DECODING_ENABLE;
#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
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];
2024-01-31 12:41:03 +00:00
// determines whether mic should be muted during TX (i.e during FSK modem TX)
extern bool gMuteMic;
2024-02-04 11:46:04 +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);
void RADIO_InitInfo(VFO_Info_t *pInfo, const uint8_t ChannelSave, const uint32_t Frequency);
void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure);
void RADIO_ConfigureSquelchAndOutputPower(VFO_Info_t *pInfo);
void RADIO_ApplyTxOffset(VFO_Info_t *pInfo);
void RADIO_SelectVfos(void);
void RADIO_SetupRegisters(bool bSwitchToFunction0);
2023-09-14 08:56:30 +00:00
#ifdef ENABLE_NOAA
2024-02-04 11:46:04 +00:00
void RADIO_ConfigureNOAA(void);
2023-09-09 07:03:56 +00:00
#endif
2024-02-04 11:46:04 +00:00
void RADIO_SetTxParameters(void);
void RADIO_SetModulation(ModulationMode_t modulation);
void RADIO_SetVfoState(VfoState_t State);
VfoState_t RADIO_GetVfoState();
void RADIO_PrepareTX(void);
void RADIO_EnableCxCSS(void);
void RADIO_PrepareCssTX(void);
void RADIO_SendEndOfTransmission(bool playRoger);
2023-12-25 01:52:12 +00:00
#endif
2023-09-09 07:03:56 +00:00
2023-12-25 01:52:12 +00:00
#ifdef ENABLE_SPECTRUM_CHANNEL_SCAN
uint8_t RADIO_ValidMemoryChannelsCount(bool bCheckScanList, uint8_t VFO);
2023-09-09 07:03:56 +00:00
#endif