custom-uv-k5-firmware/radio.h

143 lines
3.4 KiB
C
Raw Permalink Normal View History

/* 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-08-15 00:30:30 +08:00
#include "dcs.h"
enum {
MR_CH_SCANLIST1 = (1U << 7),
MR_CH_SCANLIST2 = (1U << 6),
MR_CH_BAND_MASK = 0x0FU,
};
enum {
RADIO_CHANNEL_UP = 0x01U,
RADIO_CHANNEL_DOWN = 0xFFU,
};
enum {
BANDWIDTH_WIDE = 0U,
BANDWIDTH_NARROW = 1U,
};
2023-08-27 22:37:52 +08:00
enum PTT_ID_t {
PTT_ID_OFF = 0U,
PTT_ID_BOT = 1U,
PTT_ID_EOT = 2U,
PTT_ID_BOTH = 3U,
};
typedef enum PTT_ID_t PTT_ID_t;
2023-08-29 23:02:35 +08:00
enum STEP_Setting_t {
STEP_2_5kHz,
STEP_5_0kHz,
STEP_6_25kHz,
STEP_10_0kHz,
STEP_12_5kHz,
STEP_25_0kHz,
STEP_8_33kHz,
};
typedef enum STEP_Setting_t STEP_Setting_t;
2023-09-03 05:11:03 +08:00
enum VfoState_t {
VFO_STATE_NORMAL = 0U,
VFO_STATE_BUSY = 1U,
VFO_STATE_BAT_LOW = 2U,
VFO_STATE_TX_DISABLE = 3U,
VFO_STATE_TIMEOUT = 4U,
VFO_STATE_ALARM = 5U,
VFO_STATE_VOL_HIGH = 6U,
};
typedef enum VfoState_t VfoState_t;
typedef struct {
uint32_t Frequency;
2023-08-15 00:30:30 +08:00
DCS_CodeType_t CodeType;
2023-08-31 00:59:16 +08:00
uint8_t Code;
uint8_t Padding[2];
2023-08-30 17:35:41 +08:00
} FREQ_Config_t;
2023-08-20 22:28:17 +08:00
typedef struct VFO_Info_t {
2023-08-30 17:35:41 +08:00
FREQ_Config_t ConfigRX;
FREQ_Config_t ConfigTX;
2023-09-08 01:40:33 +08:00
FREQ_Config_t *pRX;
FREQ_Config_t *pTX;
uint32_t FREQUENCY_OF_DEVIATION;
uint16_t StepFrequency;
uint8_t CHANNEL_SAVE;
uint8_t FREQUENCY_DEVIATION_SETTING;
2023-10-15 02:48:36 +08:00
uint8_t SquelchOpenRSSI;
uint8_t SquelchOpenNoise;
uint8_t SquelchCloseGlitch;
uint8_t SquelchCloseRSSI;
uint8_t SquelchCloseNoise;
uint8_t SquelchOpenGlitch;
2023-08-29 23:02:35 +08:00
STEP_Setting_t STEP_SETTING;
uint8_t OUTPUT_POWER;
uint8_t TXP_CalculatedSetting;
bool FrequencyReverse;
uint8_t SCRAMBLING_TYPE;
uint8_t CHANNEL_BANDWIDTH;
uint8_t SCANLIST1_PARTICIPATION;
uint8_t SCANLIST2_PARTICIPATION;
uint8_t Band;
uint8_t DTMF_DECODING_ENABLE;
2023-08-27 22:37:52 +08:00
PTT_ID_t DTMF_PTT_ID_TX_MODE;
uint8_t BUSY_CHANNEL_LOCK;
uint8_t AM_CHANNEL_MODE;
2023-08-22 06:37:36 +08:00
bool IsAM;
char Name[16];
2023-08-20 22:28:17 +08:00
} VFO_Info_t;
2023-09-03 22:56:49 +08:00
extern VFO_Info_t *gTxVfo;
extern VFO_Info_t *gRxVfo;
extern VFO_Info_t *gCurrentVfo;
2023-09-08 02:57:40 +08:00
extern DCS_CodeType_t gCurrentCodeType;
extern DCS_CodeType_t gSelectedCodeType;
extern uint8_t gSelectedCode;
2023-08-15 00:30:30 +08:00
2023-08-29 23:02:35 +08:00
extern STEP_Setting_t gStepSetting;
2023-09-03 05:11:03 +08:00
extern VfoState_t VfoState[2];
bool RADIO_CheckValidChannel(uint16_t ChNum, bool bCheckScanList, uint8_t RadioNum);
2023-08-28 20:37:16 +08:00
uint8_t RADIO_FindNextChannel(uint8_t ChNum, int8_t Direction, bool bCheckScanList, uint8_t RadioNum);
2023-08-20 22:28:17 +08:00
void RADIO_InitInfo(VFO_Info_t *pInfo, uint8_t ChannelSave, uint8_t ChIndex, uint32_t Frequency);
void RADIO_ConfigureChannel(uint8_t RadioNum, uint32_t Arg);
2023-08-20 22:28:17 +08:00
void RADIO_ConfigureSquelchAndOutputPower(VFO_Info_t *pInfo);
void RADIO_ApplyOffset(VFO_Info_t *pInfo);
2023-09-03 22:56:49 +08:00
void RADIO_SelectVfos(void);
void RADIO_SetupRegisters(bool bSwitchToFunction0);
2023-08-14 07:39:49 +08:00
void RADIO_ConfigureNOAA(void);
2023-09-03 22:56:49 +08:00
void RADIO_SetTxParameters(void);
2023-09-03 05:11:03 +08:00
void RADIO_SetVfoState(VfoState_t State);
2023-09-03 22:56:49 +08:00
void RADIO_PrepareTX(void);
void RADIO_EnableCxCSS(void);
2023-09-03 22:56:49 +08:00
void RADIO_PrepareCssTX(void);
2023-08-27 22:37:52 +08:00
void RADIO_SendEndOfTransmission(void);
#endif