0
mirror of https://github.com/OneOfEleven/uv-k5-firmware-custom.git synced 2025-04-27 22:01:26 +03:00

1312 lines
37 KiB
C
Raw Permalink 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.
*/
#include "app/app.h"
2023-09-09 08:03:56 +01:00
#include "app/dtmf.h"
#ifdef ENABLE_FMRADIO
2023-09-14 09:56:30 +01:00
#include "app/fm.h"
#endif
2023-10-27 17:27:31 +01:00
#ifdef ENABLE_AM_FIX
#include "am_fix.h"
#endif
2023-09-09 08:03:56 +01:00
#include "audio.h"
2023-10-19 14:21:37 +01:00
#include "board.h"
2023-09-09 08:03:56 +01:00
#include "bsp/dp32g030/gpio.h"
#include "dcs.h"
#include "driver/bk4819.h"
#include "driver/eeprom.h"
#include "driver/gpio.h"
#include "driver/system.h"
2023-11-02 21:44:53 +00:00
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
#include "driver/uart.h"
#endif
2023-09-09 08:03:56 +01:00
#include "frequencies.h"
#include "functions.h"
#include "helper/battery.h"
2023-10-25 13:07:12 +01:00
#ifdef ENABLE_MDC1200
#include "mdc1200.h"
#endif
2023-09-09 08:03:56 +01:00
#include "misc.h"
2023-11-18 18:44:10 +00:00
#ifdef ENABLE_PANADAPTER
#include "panadapter.h"
#endif
2023-09-09 08:03:56 +01:00
#include "radio.h"
#include "settings.h"
2023-09-28 23:32:08 +01:00
#include "ui/menu.h"
#include "ui/ui.h"
2023-09-09 08:03:56 +01:00
2023-11-02 10:00:51 +00:00
vfo_info_t g_vfo_info[2];
2023-10-08 20:23:37 +01:00
vfo_info_t *g_tx_vfo;
vfo_info_t *g_rx_vfo;
vfo_info_t *g_current_vfo;
dcs_code_type_t g_selected_code_type;
dcs_code_type_t g_current_code_type;
uint8_t g_selected_code;
vfo_state_t g_vfo_state[2];
2023-09-09 08:03:56 +01:00
2023-11-06 18:52:18 +00:00
bool RADIO_channel_valid(uint16_t Channel, bool bCheckScanList, uint8_t VFO)
{ // return true if the channel appears valid
2023-11-02 10:00:51 +00:00
unsigned int i;
uint8_t priority_channel[2];
2023-09-09 08:03:56 +01:00
2023-10-08 17:14:13 +01:00
if (Channel > USER_CHANNEL_LAST)
2023-09-09 08:03:56 +01:00
return false;
2023-11-03 10:39:43 +00:00
if (g_eeprom.config.channel_attributes[Channel].band > BAND7_470MHz)
2023-09-09 08:03:56 +01:00
return false;
if (bCheckScanList)
{
switch (VFO)
{
case 0:
2023-11-03 10:39:43 +00:00
if (g_eeprom.config.channel_attributes[Channel].scanlist1 == 0)
2023-09-09 08:03:56 +01:00
return false;
2023-11-02 10:00:51 +00:00
for (i = 0; i < 2; i++)
priority_channel[i] = g_eeprom.config.setting.priority_scan_list[VFO].channel[i];
2023-09-09 08:03:56 +01:00
break;
case 1:
2023-11-03 10:39:43 +00:00
if (g_eeprom.config.channel_attributes[Channel].scanlist2 == 0)
2023-09-09 08:03:56 +01:00
return false;
2023-11-02 10:00:51 +00:00
for (i = 0; i < 2; i++)
priority_channel[i] = g_eeprom.config.setting.priority_scan_list[VFO].channel[i];
2023-09-09 08:03:56 +01:00
break;
default:
return true;
}
2023-11-02 10:00:51 +00:00
if (priority_channel[0] == Channel)
2023-09-09 08:03:56 +01:00
return false;
2023-11-02 10:00:51 +00:00
if (priority_channel[1] == Channel)
2023-09-09 08:03:56 +01:00
return false;
}
return true;
}
uint8_t RADIO_FindNextChannel(uint8_t Channel, scan_state_dir_t Direction, bool bCheckScanList, uint8_t VFO)
2023-09-09 08:03:56 +01:00
{
unsigned int i;
2023-09-09 08:03:56 +01:00
2023-10-08 17:14:13 +01:00
for (i = 0; i <= USER_CHANNEL_LAST; i++)
2023-09-09 08:03:56 +01:00
{
if (Channel == 0xFF)
2023-10-08 17:14:13 +01:00
Channel = USER_CHANNEL_LAST;
2023-09-09 08:03:56 +01:00
else
2023-10-08 17:14:13 +01:00
if (Channel > USER_CHANNEL_LAST)
Channel = USER_CHANNEL_FIRST;
2023-09-09 08:03:56 +01:00
2023-11-06 18:52:18 +00:00
if (RADIO_channel_valid(Channel, bCheckScanList, VFO))
2023-09-09 08:03:56 +01:00
return Channel;
Channel += Direction;
}
return 0xFF;
}
void RADIO_InitInfo(vfo_info_t *p_vfo, const uint8_t ChannelSave, const uint32_t Frequency)
2023-09-09 08:03:56 +01:00
{
if (p_vfo == NULL)
return;
2023-10-28 23:11:57 +01:00
memset(p_vfo, 0, sizeof(*p_vfo));
2023-11-02 21:44:53 +00:00
p_vfo->channel_attributes.band = FREQUENCY_GetBand(Frequency);
p_vfo->channel_attributes.scanlist1 = 1;
p_vfo->channel_attributes.scanlist2 = 1;
p_vfo->channel.step_setting = STEP_12_5kHz;
p_vfo->step_freq = STEP_FREQ_TABLE[p_vfo->channel.step_setting];
p_vfo->channel_save = ChannelSave;
p_vfo->channel.frequency_reverse = false;
p_vfo->channel.tx_power = OUTPUT_POWER_LOW;
p_vfo->freq_config_rx.frequency = Frequency;
p_vfo->freq_config_tx.frequency = Frequency;
p_vfo->p_rx = &p_vfo->freq_config_rx;
p_vfo->p_tx = &p_vfo->freq_config_tx;
2023-11-24 08:16:38 +00:00
p_vfo->channel.compand = COMPAND_OFF;
2023-11-02 21:44:53 +00:00
p_vfo->channel.squelch_level = 0; // use main squelch
p_vfo->freq_in_channel = 0xff;
2023-09-28 17:39:45 +01:00
2023-09-13 02:01:35 +01:00
if (ChannelSave == (FREQ_CHANNEL_FIRST + BAND2_108MHz))
2023-11-06 14:46:39 +00:00
p_vfo->channel.mod_mode = MOD_MODE_AM;
2023-09-13 02:01:35 +01:00
2023-11-09 05:59:50 +00:00
RADIO_ConfigureSquelch(p_vfo);
// RADIO_ConfigureTXPower(p_vfo);
2023-09-09 08:03:56 +01:00
}
void RADIO_configure_channel(const unsigned int VFO, const unsigned int configure)
2023-09-09 08:03:56 +01:00
{
2023-11-02 10:00:51 +00:00
unsigned int channel;
2023-11-02 21:44:53 +00:00
unsigned int chan;
2023-11-02 10:00:51 +00:00
t_channel_attrib attributes;
// uint16_t base;
uint32_t frequency;
vfo_info_t *p_vfo = &g_vfo_info[VFO];
if (!g_eeprom.config.setting.enable_350)
2023-09-09 08:03:56 +01:00
{
2023-11-02 10:00:51 +00:00
if (g_eeprom.config.setting.indices.vfo[VFO].frequency == (FREQ_CHANNEL_LAST - 2))
g_eeprom.config.setting.indices.vfo[VFO].frequency = FREQ_CHANNEL_LAST - 1;
2023-09-09 08:03:56 +01:00
2023-11-02 10:00:51 +00:00
if (g_eeprom.config.setting.indices.vfo[VFO].screen == (FREQ_CHANNEL_LAST - 2))
g_eeprom.config.setting.indices.vfo[VFO].screen = FREQ_CHANNEL_LAST - 1;
2023-09-09 08:03:56 +01:00
}
2023-11-02 10:00:51 +00:00
channel = g_eeprom.config.setting.indices.vfo[VFO].screen;
2023-09-09 08:03:56 +01:00
2023-10-22 14:22:53 +01:00
p_vfo->freq_in_channel = 0xff;
2023-10-19 14:21:37 +01:00
2023-11-02 10:00:51 +00:00
if (IS_VALID_CHANNEL(channel))
2023-09-09 08:03:56 +01:00
{
2023-09-14 09:56:30 +01:00
#ifdef ENABLE_NOAA
2023-11-02 10:00:51 +00:00
if (channel >= NOAA_CHANNEL_FIRST)
2023-09-09 08:03:56 +01:00
{
2023-11-02 10:00:51 +00:00
RADIO_InitInfo(p_vfo, g_eeprom.config.setting.indices.vfo[VFO].screen, NOAA_FREQUENCY_TABLE[channel - NOAA_CHANNEL_FIRST]);
if (g_eeprom.config.setting.cross_vfo == CROSS_BAND_OFF)
2023-09-09 08:03:56 +01:00
return;
2023-11-02 10:00:51 +00:00
g_eeprom.config.setting.cross_vfo = CROSS_BAND_OFF;
2023-10-08 20:23:37 +01:00
g_update_status = true;
2023-09-09 08:03:56 +01:00
return;
}
#endif
2023-09-12 21:08:51 +01:00
2023-11-02 10:00:51 +00:00
if (channel <= USER_CHANNEL_LAST)
2023-09-09 08:03:56 +01:00
{
2023-11-02 10:00:51 +00:00
channel = RADIO_FindNextChannel(channel, SCAN_STATE_DIR_FORWARD, false, VFO);
2023-11-02 21:44:53 +00:00
if (!IS_VALID_CHANNEL(channel))
2023-09-09 08:03:56 +01:00
{
2023-11-02 10:00:51 +00:00
channel = g_eeprom.config.setting.indices.vfo[VFO].frequency;
g_eeprom.config.setting.indices.vfo[VFO].screen = channel;
2023-09-09 08:03:56 +01:00
}
else
{
2023-11-02 10:00:51 +00:00
g_eeprom.config.setting.indices.vfo[VFO].screen = channel;
g_eeprom.config.setting.indices.vfo[VFO].user = channel;
2023-09-09 08:03:56 +01:00
}
}
}
else
2023-11-02 10:00:51 +00:00
{
channel = FREQ_CHANNEL_LAST - 1;
}
2023-11-02 21:44:53 +00:00
chan = CHANNEL_NUM(channel, VFO);
2023-11-03 10:39:43 +00:00
attributes = g_eeprom.config.channel_attributes[channel];
2023-09-09 08:03:56 +01:00
2023-11-02 21:44:53 +00:00
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
2023-11-02 22:39:50 +00:00
// UART_printf("config chan 1 %u %u %u %u %u\r\n", channel, chan, attributes.band, attributes.scanlist1, attributes.scanlist2);
2023-11-02 21:44:53 +00:00
#endif
if (attributes.attributes == 0xff)
{ // invalid/unused channel
2023-11-02 10:00:51 +00:00
unsigned int index;
2023-09-09 08:03:56 +01:00
2023-11-02 10:00:51 +00:00
if (channel <= USER_CHANNEL_LAST)
2023-09-09 08:03:56 +01:00
{
2023-11-02 10:00:51 +00:00
channel = g_eeprom.config.setting.indices.vfo[VFO].frequency;
g_eeprom.config.setting.indices.vfo[VFO].screen = channel;
2023-09-09 08:03:56 +01:00
}
2023-11-02 10:00:51 +00:00
index = channel - FREQ_CHANNEL_FIRST;
2023-09-09 08:03:56 +01:00
2023-11-02 10:00:51 +00:00
RADIO_InitInfo(p_vfo, channel, FREQ_BAND_TABLE[index].lower);
2023-09-09 08:03:56 +01:00
return;
}
2023-11-02 10:00:51 +00:00
if (attributes.band > BAND7_470MHz)
attributes.band = BAND6_400MHz;
2023-09-28 17:39:45 +01:00
2023-11-02 10:00:51 +00:00
if (channel <= USER_CHANNEL_LAST)
{ // USER channel
2023-11-02 21:44:53 +00:00
p_vfo->channel_attributes = attributes;
2023-09-09 08:03:56 +01:00
}
else
2023-11-02 10:00:51 +00:00
if (IS_FREQ_CHANNEL(channel))
2023-10-19 14:21:37 +01:00
{ // VFO channel
2023-11-02 21:44:53 +00:00
attributes.band = channel - FREQ_CHANNEL_FIRST;
p_vfo->channel_attributes = attributes;
2023-10-19 14:21:37 +01:00
#if 0
2023-11-02 21:44:53 +00:00
// don't allow the VFO's to change their scanlist bits
p_vfo->channel_attributes.scanlist2 = 1;
p_vfo->channel_attributes.scanlist1 = 1;
2023-10-19 14:21:37 +01:00
#endif
2023-09-09 08:03:56 +01:00
}
2023-11-02 10:00:51 +00:00
p_vfo->channel_save = channel;
2023-09-09 08:03:56 +01:00
2023-11-02 10:00:51 +00:00
// if (channel <= USER_CHANNEL_LAST)
// base = channel * 16;
// else
// base = 0x0C80 + ((channel - FREQ_CHANNEL_FIRST) * 16 * 2) + (VFO * 16); // VFO channel
2023-09-09 08:03:56 +01:00
2023-11-02 10:00:51 +00:00
if (configure == VFO_CONFIGURE_RELOAD || IS_FREQ_CHANNEL(channel))
2023-09-09 08:03:56 +01:00
{
2023-11-02 10:00:51 +00:00
// EEPROM_ReadBuffer(Base, &m_channel, sizeof(t_channel));
2023-10-27 14:34:52 +01:00
2023-11-02 21:44:53 +00:00
// EEPROM_ReadBuffer(Base, p_vfo->channel, sizeof(t_channel));
memcpy(&p_vfo->channel, &g_eeprom.config.channel[chan], sizeof(t_channel));
2023-10-27 14:34:52 +01:00
2023-11-02 21:44:53 +00:00
p_vfo->step_freq = STEP_FREQ_TABLE[p_vfo->channel.step_setting];
2023-10-27 14:34:52 +01:00
2023-11-02 21:44:53 +00:00
p_vfo->channel_attributes = g_eeprom.config.channel_attributes[channel];
2023-10-27 14:34:52 +01:00
2023-11-02 21:44:53 +00:00
p_vfo->freq_config_rx.frequency = p_vfo->channel.frequency;
2023-09-28 23:32:08 +01:00
2023-11-02 21:44:53 +00:00
p_vfo->freq_config_rx.code_type = p_vfo->channel.rx_ctcss_cdcss_type;
p_vfo->freq_config_rx.code = p_vfo->channel.rx_ctcss_cdcss_code;
2023-09-09 08:03:56 +01:00
2023-11-02 21:44:53 +00:00
p_vfo->freq_config_tx.code_type = p_vfo->channel.tx_ctcss_cdcss_type;
p_vfo->freq_config_tx.code = p_vfo->channel.tx_ctcss_cdcss_code;
2023-09-09 08:03:56 +01:00
2023-11-02 21:44:53 +00:00
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
2023-11-02 22:39:50 +00:00
// UART_printf("config chan 2 %u %u %u %u %u %uHz\r\n", channel, chan, p_vfo->channel_attributes.band, p_vfo->channel_attributes.scanlist1, p_vfo->channel_attributes.scanlist2, p_vfo->channel.frequency * 10);
2023-11-02 21:44:53 +00:00
#endif
}
else
{
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
2023-11-02 22:39:50 +00:00
// UART_printf("config chan 3 %u %u %u %u %uHz\r\n", channel, p_vfo->channel_attributes.band, p_vfo->channel_attributes.scanlist1, p_vfo->channel_attributes.scanlist2, p_vfo->channel.frequency * 10);
2023-10-25 19:26:22 +01:00
#endif
2023-09-09 08:03:56 +01:00
}
2023-11-02 10:00:51 +00:00
frequency = p_vfo->freq_config_rx.frequency;
2023-09-10 13:52:41 +01:00
2023-11-02 10:00:51 +00:00
if (frequency < FREQ_BAND_TABLE[attributes.band].lower)
frequency = FREQ_BAND_TABLE[attributes.band].lower;
2023-09-09 08:03:56 +01:00
else
2023-11-02 10:00:51 +00:00
if (frequency >= FREQ_BAND_TABLE[attributes.band].upper)
frequency = FREQUENCY_floor_to_step(frequency, p_vfo->step_freq, FREQ_BAND_TABLE[attributes.band].lower, FREQ_BAND_TABLE[attributes.band].upper);
// else
// if (channel >= FREQ_CHANNEL_FIRST)
// frequency = FREQUENCY_floor_to_step(frequency, p_vfo->step_freq, FREQ_BAND_TABLE[attributes.band].lower, FREQ_BAND_TABLE[attributes.band].upper);
2023-11-02 10:00:51 +00:00
if (!g_eeprom.config.setting.enable_350 && frequency >= 35000000 && frequency < 40000000)
{ // 350~400Mhz not allowed
2023-10-23 10:42:51 +01:00
// hop onto the next band up
2023-11-02 21:44:53 +00:00
frequency = 43350000;
p_vfo->freq_config_rx.frequency = frequency;
p_vfo->freq_config_tx.frequency = frequency;
attributes.band = FREQUENCY_GetBand(frequency);
p_vfo->channel_attributes.band = attributes.band;
p_vfo->channel.frequency_reverse = 0;
p_vfo->channel.tx_offset_dir = TX_OFFSET_FREQ_DIR_OFF;
p_vfo->channel.tx_offset = 0;
2023-10-28 23:11:57 +01:00
2023-10-23 10:42:51 +01:00
// TODO: also update other settings such as step size
2023-10-28 23:11:57 +01:00
}
2023-11-02 10:00:51 +00:00
p_vfo->freq_config_rx.frequency = frequency;
2023-09-09 08:03:56 +01:00
2023-11-02 10:00:51 +00:00
if (frequency >= AIR_BAND.lower && frequency < AIR_BAND.upper)
{ // air band
2023-11-02 21:44:53 +00:00
p_vfo->channel.tx_offset_dir = TX_OFFSET_FREQ_DIR_OFF;
p_vfo->channel.tx_offset = 0;
}
2023-09-09 08:03:56 +01:00
else
2023-11-02 10:00:51 +00:00
if (channel > USER_CHANNEL_LAST)
{
2023-11-02 21:44:53 +00:00
p_vfo->channel.tx_offset = FREQUENCY_floor_to_step(p_vfo->channel.tx_offset + (p_vfo->step_freq / 2), p_vfo->step_freq, 0, p_vfo->channel.tx_offset + p_vfo->step_freq);
}
2023-10-19 14:21:37 +01:00
2023-11-10 07:31:50 +00:00
RADIO_apply_offset(p_vfo, true);
2023-09-09 08:03:56 +01:00
// channel name
2023-11-02 22:39:50 +00:00
memset(&p_vfo->channel_name, 0, sizeof(p_vfo->channel_name));
2023-11-02 10:00:51 +00:00
if (channel <= USER_CHANNEL_LAST)
2023-11-02 21:44:53 +00:00
// EEPROM_ReadBuffer(0x0F50 + (channel * 16), p_vfo->channel_name, 10); // only 10 bytes used
2023-11-02 22:39:50 +00:00
memcpy(p_vfo->channel_name.name, &g_eeprom.config.channel_name[channel].name, sizeof(p_vfo->channel_name.name));
2023-09-09 08:03:56 +01:00
2023-11-06 14:46:39 +00:00
if (p_vfo->channel.mod_mode != MOD_MODE_FM)
2023-09-28 23:32:08 +01:00
{ // freq/chan is in AM mode
// disable stuff, even though it can all still be used with AM ???
2023-11-02 21:44:53 +00:00
p_vfo->channel.scrambler = 0;
// p_vfo->channel.dtmf_decoding_enable = 0;
p_vfo->freq_config_rx.code_type = CODE_TYPE_NONE;
p_vfo->freq_config_tx.code_type = CODE_TYPE_NONE;
2023-09-09 08:03:56 +01:00
}
2023-11-09 05:59:50 +00:00
RADIO_ConfigureSquelch(p_vfo);
// RADIO_ConfigureTXPower(p_vfo);
2023-10-29 22:33:38 +00:00
#ifdef ENABLE_AM_FIX
2023-11-05 05:09:01 +00:00
AM_fix_reset(VFO);
2023-11-18 18:44:10 +00:00
2023-11-06 14:46:39 +00:00
if (p_vfo->channel.mod_mode != MOD_MODE_FM && g_eeprom.config.setting.am_fix)
2023-10-29 22:33:38 +00:00
{
2023-11-18 18:44:10 +00:00
#ifdef ENABLE_PANADAPTER
2023-11-19 06:59:38 +00:00
if (!PAN_scanning())
2023-11-18 18:44:10 +00:00
{
AM_fix_10ms(VFO);
}
else
{ // don't do agc
BK4819_DisableAGC();
BK4819_write_reg(0x13, (g_orig_lnas << 8) | (g_orig_lna << 5) | (g_orig_mixer << 3) | (g_orig_pga << 0));
}
#else
AM_fix_10ms(VFO);
#endif
2023-10-29 22:33:38 +00:00
}
else
{ // don't do agc in FM mode
BK4819_DisableAGC();
2023-11-18 18:44:10 +00:00
BK4819_write_reg(0x13, (g_orig_lnas << 8) | (g_orig_lna << 5) | (g_orig_mixer << 3) | (g_orig_pga << 0));
2023-10-29 22:33:38 +00:00
}
#else
2023-11-06 14:46:39 +00:00
if (p_vfo->mod_mode != MOD_MODE_FM)
2023-10-29 22:33:38 +00:00
{
2023-11-18 18:44:10 +00:00
#ifdef ENABLE_PANADAPTER
2023-11-19 06:59:38 +00:00
if (!PAN_scanning())
2023-11-18 18:44:10 +00:00
{
BK4819_EnableAGC();
}
else
{ // don't do agc
BK4819_DisableAGC();
BK4819_write_reg(0x13, (g_orig_lnas << 8) | (g_orig_lna << 5) | (g_orig_mixer << 3) | (g_orig_pga << 0));
}
#else
BK4819_EnableAGC();
#endif
2023-10-29 22:33:38 +00:00
}
else
{ // don't do agc in FM mode
BK4819_DisableAGC();
2023-11-18 18:44:10 +00:00
BK4819_write_reg(0x13, (g_orig_lnas << 8) | (g_orig_lna << 5) | (g_orig_mixer << 3) | (g_orig_pga << 0));
2023-10-29 22:33:38 +00:00
}
#endif
2023-10-27 17:27:31 +01:00
2023-11-02 10:00:51 +00:00
// if (configure == VFO_CONFIGURE_RELOAD || IS_FREQ_CHANNEL(channel))
if (IS_FREQ_CHANNEL(channel))
p_vfo->freq_in_channel = SETTINGS_find_channel(frequency); // find channel that has this frequency
2023-09-09 08:03:56 +01:00
}
#ifdef ENABLE_VOX
void RADIO_enable_vox(unsigned int level)
{
uint16_t threshold_enable;
uint16_t threshold_disable;
2023-11-04 01:59:17 +00:00
if (level > (ARRAY_SIZE(g_eeprom.calib.vox_threshold_enable) - 1))
level = ARRAY_SIZE(g_eeprom.calib.vox_threshold_enable) - 1;
2023-11-04 01:59:17 +00:00
// my eeprom values ..
//
// vox threshold enable 30 50 70 90 110 130 150 170 200 230 FFFF FFFF
// vox threshold disable 20 40 60 80 100 120 140 160 190 220 FFFF FFFF
//
#ifdef ENABLE_VOX_MORE_SENSITIVE
// more sensitive
threshold_enable = g_eeprom.calib.vox_threshold_enable[level] / 3;
threshold_disable = (threshold_enable > 13) ? threshold_enable - 10 : 3;
#else
threshold_enable = g_eeprom.calib.vox_threshold_enable[level];
threshold_disable = g_eeprom.calib.vox_threshold_disable[level];
#endif
2023-11-04 01:59:17 +00:00
BK4819_EnableVox(threshold_enable, threshold_disable);
2023-11-04 01:59:17 +00:00
2023-11-05 23:16:19 +00:00
BK4819_write_reg(0x3F, BK4819_read_reg(0x3F) | BK4819_REG_3F_VOX_FOUND | BK4819_REG_3F_VOX_LOST);
}
#endif
2023-11-09 05:59:50 +00:00
void RADIO_ConfigureSquelch(vfo_info_t *p_vfo)
2023-09-09 08:03:56 +01:00
{
2024-01-08 13:39:43 +00:00
const unsigned int squelch_level = (p_vfo->channel.squelch_level > 0 && p_vfo->channel.squelch_level < 10) ? p_vfo->channel.squelch_level : g_eeprom.config.setting.squelch_level;
2023-10-28 23:11:57 +01:00
2023-10-16 18:19:28 +01:00
// note that 'noise' and 'glitch' values are inverted compared to 'rssi' values
2024-01-08 13:39:43 +00:00
// peters readings, all on 156.550
//
// no antenna no signal r 53 g 83 n 73
// signal generator -100dBm signal r 114 g 0 n 17
// signal generator -110dBm signal r 95 g 0 n 32
// signal generator -120dBm signal r 75 g 0 n 34
//
// ext antenna no signal r 93~133 g 150 n 78
// ext antenna strong signal r 123~160 g 0 n 16~18
if (squelch_level == 0)
{ // squelch == 0 (off)
p_vfo->squelch_open_rssi_thresh = 0; // 0 ~ 255
p_vfo->squelch_close_rssi_thresh = 0; // 0 ~ 255
2023-10-16 18:19:28 +01:00
p_vfo->squelch_open_noise_thresh = 127; // 127 ~ 0
p_vfo->squelch_close_noise_thresh = 127; // 127 ~ 0
2023-10-16 18:19:28 +01:00
p_vfo->squelch_open_glitch_thresh = 255; // 255 ~ 0
2023-11-02 10:00:51 +00:00
p_vfo->squelch_close_glitch_thresh = 255; // 255 ~ 0
2023-09-09 08:03:56 +01:00
}
else
{ // squelch >= 1
2023-11-05 23:16:19 +00:00
// my calibration data
//
// bands 4567
2024-01-08 13:39:43 +00:00
// 0A 4B 53 56 59 5C 5F 62 64 66 FF FF FF FF FF FF // open rssi
// 05 46 50 53 56 59 5C 5F 62 64 FF FF FF FF FF FF // close rssi
// 5A 2D 29 26 23 20 1D 1A 17 14 FF FF FF FF FF FF // open noise
// 64 30 2D 29 26 23 20 1D 1A 17 FF FF FF FF FF FF // close noise
// 5A 14 11 0E 0B 08 03 02 02 02 FF FF FF FF FF FF // open glitch
// 64 11 0E 0B 08 05 05 04 04 04 FF FF FF FF FF FF // close glitch
2023-11-11 13:09:24 +00:00
//
2023-11-05 23:16:19 +00:00
// bands 123
2024-01-08 13:39:43 +00:00
// 32 68 6B 6E 6F 72 75 77 79 7B FF FF FF FF FF FF // open rssi
// 28 64 67 6A 6C 6E 71 73 76 78 FF FF FF FF FF FF // close rssi
// 41 32 2D 28 24 21 1E 1A 17 16 FF FF FF FF FF FF // open noise
// 46 37 32 2D 28 25 22 1E 1B 19 FF FF FF FF FF FF // close noise
// 5A 19 0F 0A 09 08 07 06 05 04 FF FF FF FF FF FF // open glitch
// 64 1E 14 0F 0D 0C 0B 0A 09 08 FF FF FF FF FF FF // close glitch
2023-11-05 23:16:19 +00:00
2023-11-02 10:00:51 +00:00
unsigned int band = (unsigned int)FREQUENCY_GetBand(p_vfo->p_rx->frequency);
band = (band < BAND4_174MHz) ? 1 : 0;
p_vfo->squelch_open_rssi_thresh = g_eeprom.calib.squelch_band[band].open_rssi_thresh[squelch_level];
p_vfo->squelch_close_rssi_thresh = g_eeprom.calib.squelch_band[band].close_rssi_thresh[squelch_level];
p_vfo->squelch_open_noise_thresh = g_eeprom.calib.squelch_band[band].open_noise_thresh[squelch_level];
p_vfo->squelch_close_noise_thresh = g_eeprom.calib.squelch_band[band].close_noise_thresh[squelch_level];
2023-09-09 08:03:56 +01:00
2023-11-02 10:00:51 +00:00
p_vfo->squelch_open_glitch_thresh = g_eeprom.calib.squelch_band[band].open_glitch_thresh[squelch_level];
p_vfo->squelch_close_glitch_thresh = g_eeprom.calib.squelch_band[band].close_glitch_thresh[squelch_level];
2023-11-04 01:59:17 +00:00
2023-10-16 18:19:28 +01:00
// *********
int16_t rssi_open = p_vfo->squelch_open_rssi_thresh; // 0 ~ 255
int16_t rssi_close = p_vfo->squelch_close_rssi_thresh; // 0 ~ 255
2023-10-16 18:19:28 +01:00
int16_t noise_open = p_vfo->squelch_open_noise_thresh; // 127 ~ 0
int16_t noise_close = p_vfo->squelch_close_noise_thresh; // 127 ~ 0
2023-10-16 18:19:28 +01:00
int16_t glitch_open = p_vfo->squelch_open_glitch_thresh; // 255 ~ 0
int16_t glitch_close = p_vfo->squelch_close_glitch_thresh; // 255 ~ 0
2023-10-16 18:19:28 +01:00
// *********
2023-10-05 13:42:14 +01:00
#if ENABLE_SQUELCH_MORE_SENSITIVE
// make squelch a little more sensitive
//
2023-10-16 18:19:28 +01:00
// getting the best general settings here is experimental, bare with me
2023-10-01 00:30:13 +01:00
2023-10-05 13:42:14 +01:00
#if 0
2023-11-04 01:59:17 +00:00
rssi_open = (rssi_open * 8) / 9;
2023-10-05 22:44:44 +01:00
noise_open = (noise_open * 9) / 8;
glitch_open = (glitch_open * 9) / 8;
2023-10-05 13:42:14 +01:00
#else
// even more sensitive .. use when RX bandwidths are fixed (no weak signal auto adjust)
2023-11-04 01:59:17 +00:00
rssi_open = (rssi_open * 1) / 2;
2023-10-05 22:44:44 +01:00
noise_open = (noise_open * 2) / 1;
glitch_open = (glitch_open * 2) / 1;
2023-10-05 13:42:14 +01:00
#endif
2023-09-28 17:39:45 +01:00
2023-12-19 12:02:21 +00:00
// *********
// ensure the 'close' threshold is lower than the 'open' threshold
// ie, maintain a minimum level of hysteresis
2024-01-08 13:39:43 +00:00
2023-12-19 12:02:21 +00:00
rssi_close = (rssi_open * 4) / 6;
noise_close = (noise_open * 6) / 4;
glitch_close = (glitch_open * 6) / 4;
2024-01-08 13:39:43 +00:00
2023-12-19 12:02:21 +00:00
if (rssi_open < 8)
rssi_open = 8;
if (rssi_close > (rssi_open - 8))
rssi_close = rssi_open - 8;
2024-01-08 13:39:43 +00:00
2023-12-19 12:02:21 +00:00
if (noise_open > (127 - 4))
noise_open = 127 - 4;
if (noise_close < (noise_open + 4))
noise_close = noise_open + 4;
2024-01-08 13:39:43 +00:00
2023-12-19 12:02:21 +00:00
if (glitch_open > (255 - 8))
glitch_open = 255 - 8;
if (glitch_close < (glitch_open + 8))
glitch_close = glitch_open + 8;
2023-10-05 13:42:14 +01:00
#else
2024-01-09 00:13:39 +00:00
// a bit more sensitive
rssi_open = (rssi_open * 1) / 2;
noise_open = (noise_open * 2) / 1;
glitch_open = (glitch_open * 2) / 1;
2024-01-09 00:13:39 +00:00
rssi_close = (rssi_close * 1) / 2;
noise_close = (noise_close * 2) / 1;
glitch_close = (glitch_close * 2) / 1;
2024-01-09 00:13:39 +00:00
2023-12-19 12:02:21 +00:00
#endif
2023-10-16 18:19:28 +01:00
// *********
p_vfo->squelch_open_rssi_thresh = (rssi_open > 255) ? 255 : (rssi_open < 0) ? 0 : rssi_open;
p_vfo->squelch_close_rssi_thresh = (rssi_close > 255) ? 255 : (rssi_close < 0) ? 0 : rssi_close;
2023-10-16 18:19:28 +01:00
p_vfo->squelch_open_noise_thresh = (noise_open > 127) ? 127 : (noise_open < 0) ? 0 : noise_open;
p_vfo->squelch_close_noise_thresh = (noise_close > 127) ? 127 : (noise_close < 0) ? 0 : noise_close;
2023-10-16 18:19:28 +01:00
p_vfo->squelch_open_glitch_thresh = (glitch_open > 255) ? 255 : (glitch_open < 0) ? 0 : glitch_open;
p_vfo->squelch_close_glitch_thresh = (glitch_close > 255) ? 255 : (glitch_close < 0) ? 0 : glitch_close;
2023-09-09 08:03:56 +01:00
}
2023-11-09 05:59:50 +00:00
}
2023-09-09 08:03:56 +01:00
2023-11-09 05:59:50 +00:00
void RADIO_ConfigureTXPower(vfo_info_t *p_vfo)
{
// my eeprom calibration data
2023-11-09 05:59:50 +00:00
//
// 1ED0 32 32 32 64 64 64 8C 8C 8C FF FF FF FF FF FF FF .. 50 MHz
// 1EE0 32 32 32 64 64 64 8C 8C 8C FF FF FF FF FF FF FF .. 108 MHz
// 1EF0 5F 5F 5F 69 69 69 91 91 8F FF FF FF FF FF FF FF .. 137 MHz
// 1F00 32 32 32 64 64 64 8C 8C 8C FF FF FF FF FF FF FF .. 174 MHz
// 1F10 5A 5A 5A 64 64 64 82 82 82 FF FF FF FF FF FF FF .. 350 MHz
// 1F20 5A 5A 5A 64 64 64 8F 91 8A FF FF FF FF FF FF FF .. 400 MHz
// 1F30 32 32 32 64 64 64 8C 8C 8C FF FF FF FF FF FF FF .. 470 MHz
const unsigned int band = (unsigned int)FREQUENCY_GetBand(p_vfo->p_tx->frequency);
2023-11-23 20:43:13 +00:00
uint8_t tx_power[3];
2023-11-09 05:59:50 +00:00
2023-11-23 20:43:13 +00:00
memcpy(tx_power, g_eeprom.calib.tx_band_power[band].level[p_vfo->channel.tx_power], 3);
2023-11-09 05:59:50 +00:00
2023-11-24 08:16:38 +00:00
#ifndef ENABLE_TX_POWER_CAL_MENU
2023-11-23 20:43:13 +00:00
2023-11-24 08:16:38 +00:00
#ifdef ENABLE_TX_POWER_FIX
switch (p_vfo->channel.tx_power)
{
case OUTPUT_POWER_LOW: // ~ 10mW
// if (p_vfo->p_tx->frequency <= 26000000)
// { // 137 ~ 174
// tx_power[0] = 0x13;
// tx_power[1] = 0x13;
// tx_power[2] = 0x13;
// }
// else
// { // 400 ~ 470
tx_power[0] = 0x13;
tx_power[1] = 0x13;
tx_power[2] = 0x13;
// }
break;
default:
case OUTPUT_POWER_MID: // ~ 500mW
if (p_vfo->p_tx->frequency <= 26000000)
{ // 137 ~ 174
tx_power[0] = 0x29;
tx_power[1] = 0x29;
tx_power[2] = 0x29;
}
else
{ // 400 ~ 470
tx_power[0] = 0x37;
tx_power[1] = 0x37;
tx_power[2] = 0x37;
}
break;
case OUTPUT_POWER_HIGH: // ~ 4W
if (p_vfo->p_tx->frequency <= 26000000)
{ // 137 ~ 174
tx_power[0] = 0x7F;
tx_power[1] = 0x84;
tx_power[2] = 0x8C;
}
else
{ // 400 ~ 470
tx_power[0] = 0x96;
tx_power[1] = 0x96;
tx_power[2] = 0x8C;
}
break;
}
#endif
2023-11-23 20:43:13 +00:00
2023-11-09 05:59:50 +00:00
#endif
2023-10-05 22:44:44 +01:00
2023-11-24 11:52:11 +00:00
if (p_vfo->channel.tx_power == OUTPUT_POWER_USER)
2023-11-24 18:11:00 +00:00
p_vfo->txp_reg_value = 8 + (p_vfo->channel.tx_power_user * 1);
2023-11-24 08:16:38 +00:00
else
p_vfo->txp_reg_value = FREQUENCY_CalculateOutputPower(tx_power[0], tx_power[1], tx_power[2], p_vfo->p_tx->frequency);
2023-09-09 08:03:56 +01:00
}
2023-11-10 07:31:50 +00:00
void RADIO_apply_offset(vfo_info_t *p_vfo, const bool set_pees)
2023-09-09 08:03:56 +01:00
{
uint32_t Frequency = p_vfo->freq_config_rx.frequency;
2023-09-09 08:03:56 +01:00
2023-11-02 21:44:53 +00:00
switch (p_vfo->channel.tx_offset_dir)
2023-09-09 08:03:56 +01:00
{
2023-10-08 17:14:13 +01:00
case TX_OFFSET_FREQ_DIR_OFF:
2023-09-09 08:03:56 +01:00
break;
2023-10-08 17:14:13 +01:00
case TX_OFFSET_FREQ_DIR_SUB:
2023-11-02 21:44:53 +00:00
Frequency -= p_vfo->channel.tx_offset;
2023-09-09 08:03:56 +01:00
break;
2023-11-30 16:15:19 +00:00
case TX_OFFSET_FREQ_DIR_ADD:
Frequency += p_vfo->channel.tx_offset;
break;
2023-09-09 08:03:56 +01:00
}
2023-10-08 20:23:37 +01:00
if (Frequency < FREQ_BAND_TABLE[0].lower)
Frequency = FREQ_BAND_TABLE[0].lower;
2023-10-02 14:13:27 +01:00
else
2023-10-08 20:23:37 +01:00
if (Frequency > FREQ_BAND_TABLE[ARRAY_SIZE(FREQ_BAND_TABLE) - 1].upper)
Frequency = FREQ_BAND_TABLE[ARRAY_SIZE(FREQ_BAND_TABLE) - 1].upper;
2023-09-28 17:39:45 +01:00
p_vfo->freq_config_tx.frequency = Frequency;
2023-10-28 08:46:27 +01:00
if (set_pees)
{
2023-11-02 21:44:53 +00:00
if (!p_vfo->channel.frequency_reverse)
2023-10-28 08:46:27 +01:00
{
p_vfo->p_rx = &p_vfo->freq_config_rx;
p_vfo->p_tx = &p_vfo->freq_config_tx;
}
else
{
p_vfo->p_rx = &p_vfo->freq_config_tx;
p_vfo->p_tx = &p_vfo->freq_config_rx;
}
}
2023-09-09 08:03:56 +01:00
}
void RADIO_select_vfos(void)
2023-09-09 08:03:56 +01:00
{
2023-11-02 10:00:51 +00:00
g_eeprom.config.setting.tx_vfo_num = get_TX_VFO();
g_rx_vfo_num = (g_eeprom.config.setting.cross_vfo == CROSS_BAND_OFF) ? g_eeprom.config.setting.tx_vfo_num : (g_eeprom.config.setting.tx_vfo_num + 1) & 1u;
2023-09-09 08:03:56 +01:00
2023-11-02 10:00:51 +00:00
g_tx_vfo = &g_vfo_info[g_eeprom.config.setting.tx_vfo_num];
g_rx_vfo = &g_vfo_info[g_rx_vfo_num];
2023-09-09 08:03:56 +01:00
2023-11-06 12:21:52 +00:00
g_current_vfo = (g_eeprom.config.setting.cross_vfo == CROSS_BAND_OFF) ? g_rx_vfo : &g_vfo_info[g_eeprom.config.setting.tx_vfo_num];
2023-09-09 08:03:56 +01:00
}
2023-11-11 13:09:24 +00:00
BK4819_filter_bandwidth_t RADIO_set_bandwidth(BK4819_filter_bandwidth_t bandwidth, const int mode)
{
uint16_t deviation;
2023-11-11 13:09:24 +00:00
switch (bandwidth)
{
default:
bandwidth = BK4819_FILTER_BW_WIDE;
// Fallthrough
case BK4819_FILTER_BW_WIDE:
case BK4819_FILTER_BW_NARROW:
case BK4819_FILTER_BW_NARROWER:
break;
}
switch (mode)
{
case MOD_MODE_FM:
//BK4819_set_AFC(2);
BK4819_set_AFC(0);
break;
case MOD_MODE_AM:
//BK4819_set_AFC(2);
BK4819_set_AFC(0);
break;
case MOD_MODE_DSB:
bandwidth = BK4819_FILTER_BW_NARROWER;
BK4819_set_AFC(0);
break;
}
if (g_eeprom.calib.deviation < FM_DEV_LIMIT_LOWER || g_eeprom.calib.deviation > FM_DEV_LIMIT_UPPER)
deviation = FM_DEV_LIMIT_DEFAULT;
else
deviation = g_eeprom.calib.deviation;
BK4819_set_TX_deviation(deviation);
2023-11-11 13:09:24 +00:00
BK4819_SetFilterBandwidth(bandwidth);
return bandwidth;
}
void RADIO_setup_registers(bool switch_to_function_foreground)
2023-09-09 08:03:56 +01:00
{
2023-11-08 14:26:27 +00:00
BK4819_filter_bandwidth_t Bandwidth = g_rx_vfo->channel.channel_bandwidth;
uint16_t interrupt_mask;
uint32_t Frequency;
2023-09-09 08:03:56 +01:00
if (!g_monitor_enabled)
2023-11-03 16:41:05 +00:00
{
#ifdef ENABLE_FMRADIO
if (!g_fm_radio_mode && g_request_display_screen != DISPLAY_FM)
#endif
2023-11-26 11:28:19 +00:00
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER); // speaker off
2023-11-03 16:41:05 +00:00
}
2023-09-09 08:03:56 +01:00
2023-11-26 11:28:19 +00:00
// green LED off
2023-10-17 21:22:40 +01:00
BK4819_set_GPIO_pin(BK4819_GPIO6_PIN2_GREEN, false);
2023-09-09 08:03:56 +01:00
2023-11-11 13:09:24 +00:00
Bandwidth = RADIO_set_bandwidth(Bandwidth, g_rx_vfo->channel.mod_mode);
2023-09-28 17:39:45 +01:00
2023-11-05 23:16:19 +00:00
BK4819_write_reg(0x30, 0);
BK4819_write_reg(0x30,
2023-10-30 16:28:41 +00:00
BK4819_REG_30_ENABLE_VCO_CALIB |
// BK4819_REG_30_ENABLE_UNKNOWN |
BK4819_REG_30_ENABLE_RX_LINK |
BK4819_REG_30_ENABLE_AF_DAC |
BK4819_REG_30_ENABLE_DISC_MODE |
BK4819_REG_30_ENABLE_PLL_VCO |
// BK4819_REG_30_ENABLE_PA_GAIN |
// BK4819_REG_30_ENABLE_MIC_ADC |
// BK4819_REG_30_ENABLE_TX_DSP |
BK4819_REG_30_ENABLE_RX_DSP |
0);
2023-11-26 11:28:19 +00:00
BK4819_set_GPIO_pin(BK4819_GPIO5_PIN1_RED, false); // red LED off
BK4819_SetupPowerAmplifier(0, 0); //
2023-10-17 21:22:40 +01:00
BK4819_set_GPIO_pin(BK4819_GPIO1_PIN29_PA_ENABLE, false); // PA off
2023-09-09 08:03:56 +01:00
2023-11-26 11:28:19 +00:00
do { // wait for interrupts to clear
2023-11-05 23:16:19 +00:00
const uint16_t int_bits = BK4819_read_reg(0x0C);
2023-10-29 22:33:38 +00:00
if ((int_bits & (1u << 0)) == 0)
2023-09-09 08:03:56 +01:00
break;
2023-11-26 11:28:19 +00:00
BK4819_write_reg(0x02, 0); // clear the interrupt bits ?
2023-09-09 08:03:56 +01:00
SYSTEM_DelayMs(1);
2023-11-26 11:28:19 +00:00
} while (1);
2023-11-05 23:16:19 +00:00
BK4819_write_reg(0x3F, 0); // disable interrupts
2023-09-09 08:03:56 +01:00
2023-09-14 09:56:30 +01:00
#ifdef ENABLE_NOAA
2023-11-08 14:26:27 +00:00
if (IS_NOAA_CHANNEL(g_rx_vfo->channel_save) && g_noaa_mode)
Frequency = NOAA_FREQUENCY_TABLE[g_noaa_channel];
else
2023-09-09 08:03:56 +01:00
#endif
2023-11-08 14:26:27 +00:00
Frequency = g_rx_vfo->p_rx->frequency;
2023-10-17 21:22:40 +01:00
2023-11-26 11:28:19 +00:00
// set VCO/PLL frequency
BK4819_set_rf_frequency(Frequency, true);
2023-10-17 21:22:40 +01:00
BK4819_set_rf_filter_path(Frequency);
2023-09-09 08:03:56 +01:00
2023-11-26 11:28:19 +00:00
// set squelch level
2023-09-09 08:03:56 +01:00
BK4819_SetupSquelch(
2023-11-08 14:26:27 +00:00
g_rx_vfo->squelch_open_rssi_thresh, g_rx_vfo->squelch_close_rssi_thresh,
g_rx_vfo->squelch_open_noise_thresh, g_rx_vfo->squelch_close_noise_thresh,
g_rx_vfo->squelch_close_glitch_thresh, g_rx_vfo->squelch_open_glitch_thresh);
2023-09-10 13:52:41 +01:00
2023-10-29 22:33:38 +00:00
// enable the RX front end
2023-10-17 21:22:40 +01:00
BK4819_set_GPIO_pin(BK4819_GPIO0_PIN28_RX_ENABLE, true);
2023-09-10 13:52:41 +01:00
2023-09-17 11:06:42 +01:00
// AF RX Gain and DAC
2023-11-08 14:26:27 +00:00
// if (g_rx_vfo->channel.mod_mode != MOD_MODE_FM)
2023-10-30 00:14:38 +00:00
// {
2023-11-05 23:16:19 +00:00
// BK4819_write_reg(0x48, 0xB3A8); // 1011 0011 1010 1000
2023-10-30 00:14:38 +00:00
// }
// else
2023-10-29 22:33:38 +00:00
{
2023-11-05 23:16:19 +00:00
BK4819_write_reg(0x48,
2023-11-02 10:00:51 +00:00
(11u << 12) | // ??? .. 0 ~ 15, doesn't seem to make any difference
( 0u << 10) | // AF Rx Gain-1
(g_eeprom.calib.volume_gain << 4) | // AF Rx Gain-2
(g_eeprom.calib.dac_gain << 0)); // AF DAC Gain (after Gain-1 and Gain-2)
2023-10-29 22:33:38 +00:00
}
2023-09-09 08:03:56 +01:00
2023-11-03 16:41:05 +00:00
if (!g_monitor_enabled)
2023-11-26 11:28:19 +00:00
{ // set modulation mode FM, AM etc
2023-11-03 16:41:05 +00:00
#ifdef ENABLE_FMRADIO
if (!g_fm_radio_mode && g_request_display_screen != DISPLAY_FM)
2023-10-30 02:10:36 +00:00
#endif
2023-11-03 16:41:05 +00:00
{
#ifdef ENABLE_VOICE
#ifdef MUTE_AUDIO_FOR_VOICE
if (g_voice_write_index == 0)
2023-11-08 14:26:27 +00:00
AUDIO_set_mod_mode(g_rx_vfo->channel.mod_mode);
2023-11-03 16:41:05 +00:00
#else
2023-11-08 14:26:27 +00:00
AUDIO_set_mod_mode(g_rx_vfo->channel.mod_mode);
2023-11-03 16:41:05 +00:00
#endif
#else
2023-11-08 14:26:27 +00:00
AUDIO_set_mod_mode(g_rx_vfo->channel.mod_mode);
2023-11-03 16:41:05 +00:00
#endif
}
}
2023-10-30 02:10:36 +00:00
interrupt_mask = BK4819_REG_3F_SQUELCH_FOUND | BK4819_REG_3F_SQUELCH_LOST;
2023-09-09 08:03:56 +01:00
2023-11-08 14:26:27 +00:00
if (IS_NOT_NOAA_CHANNEL(g_rx_vfo->channel_save))
2023-09-09 08:03:56 +01:00
{
2023-11-08 14:26:27 +00:00
if (g_rx_vfo->channel.mod_mode == MOD_MODE_FM)
{ // FM
2023-10-08 20:23:37 +01:00
uint8_t code_type = g_selected_code_type;
uint8_t code = g_selected_code;
2023-10-08 20:23:37 +01:00
if (g_css_scan_mode == CSS_SCAN_MODE_OFF)
2023-09-09 08:03:56 +01:00
{
2023-11-08 14:26:27 +00:00
code_type = g_rx_vfo->p_rx->code_type;
code = g_rx_vfo->p_rx->code;
2023-09-09 08:03:56 +01:00
}
2023-10-08 17:14:13 +01:00
switch (code_type)
2023-09-09 08:03:56 +01:00
{
2023-09-12 11:01:34 +01:00
default:
case CODE_TYPE_NONE:
BK4819_set_CTCSS_freq(670);
BK4819_set_tail_detection(550); // QS's 55Hz tone method
2023-09-14 11:16:45 +01:00
2023-10-29 22:33:38 +00:00
interrupt_mask |= BK4819_REG_3F_CxCSS_TAIL;
2023-09-12 11:01:34 +01:00
break;
2023-09-12 21:08:51 +01:00
2023-09-14 11:16:45 +01:00
case CODE_TYPE_CONTINUOUS_TONE:
BK4819_set_CTCSS_freq(CTCSS_TONE_LIST[code]);
// #ifdef ENABLE_CTCSS_TAIL_PHASE_SHIFT
// BK4819_set_tail_detection(CTCSS_TONE_LIST[code]); // doesn't work in RX mode
// #else
// BK4819_set_tail_detection(550); // QS's 55Hz tone method
// #endif
2023-09-14 11:16:45 +01:00
interrupt_mask |=
BK4819_REG_3F_CxCSS_TAIL |
BK4819_REG_3F_CTCSS_FOUND |
BK4819_REG_3F_CTCSS_LOST;
2023-09-14 11:16:45 +01:00
2023-09-09 08:03:56 +01:00
break;
2023-09-14 11:16:45 +01:00
case CODE_TYPE_DIGITAL:
case CODE_TYPE_REVERSE_DIGITAL:
BK4819_set_CDCSS_code(DCS_GetGolayCodeWord(code_type, code));
interrupt_mask |=
BK4819_REG_3F_CxCSS_TAIL |
BK4819_REG_3F_CDCSS_FOUND |
BK4819_REG_3F_CDCSS_LOST;
2023-09-09 08:03:56 +01:00
break;
}
2023-11-04 02:33:04 +00:00
if (g_eeprom.config.setting.enable_scrambler)
2023-11-08 14:26:27 +00:00
BK4819_set_scrambler(g_rx_vfo->channel.scrambler);
2023-09-17 09:54:24 +01:00
else
2023-11-04 02:33:04 +00:00
BK4819_set_scrambler(0);
2023-09-09 08:03:56 +01:00
}
}
2023-09-14 09:56:30 +01:00
#ifdef ENABLE_NOAA
2023-09-09 08:03:56 +01:00
else
{
BK4819_set_CTCSS_freq(0); // NOAA 1050Hz stuff
2023-10-29 22:33:38 +00:00
interrupt_mask |= BK4819_REG_3F_CTCSS_FOUND | BK4819_REG_3F_CTCSS_LOST;
2023-09-09 08:03:56 +01:00
}
#endif
2023-09-12 21:08:51 +01:00
#ifdef ENABLE_VOX
if (
#ifdef ENABLE_FMRADIO
!g_fm_radio_mode &&
#endif
g_eeprom.config.setting.vox_enabled &&
2023-11-08 14:26:27 +00:00
IS_NOT_NOAA_CHANNEL(g_rx_vfo->channel_save) &&
g_rx_vfo->channel.mod_mode == MOD_MODE_FM)
{
RADIO_enable_vox(g_eeprom.config.setting.vox_level);
interrupt_mask |= BK4819_REG_3F_VOX_FOUND | BK4819_REG_3F_VOX_LOST;
}
else
2023-09-09 08:03:56 +01:00
#endif
BK4819_DisableVox();
2023-09-09 08:03:56 +01:00
2023-10-04 16:37:11 +01:00
// RX expander
2023-11-24 08:16:38 +00:00
BK4819_SetCompander((g_rx_vfo->channel.mod_mode == MOD_MODE_FM) ? g_rx_vfo->channel.compand : COMPAND_OFF);
2023-09-15 10:57:26 +01:00
2023-10-29 22:33:38 +00:00
BK4819_EnableDTMF();
interrupt_mask |= BK4819_REG_3F_DTMF_5TONE_FOUND;
2023-09-10 13:52:41 +01:00
2023-10-26 23:14:46 +01:00
#ifdef ENABLE_MDC1200
BK4819_enable_mdc1200_rx(true);
2023-10-29 22:33:38 +00:00
interrupt_mask |= BK4819_REG_3F_FSK_RX_SYNC | BK4819_REG_3F_FSK_RX_FINISHED | BK4819_REG_3F_FSK_FIFO_ALMOST_FULL;
2023-10-26 23:14:46 +01:00
#endif
2023-10-29 22:33:38 +00:00
// enable BK4819 interrupts
2023-11-05 23:16:19 +00:00
BK4819_write_reg(0x3F, interrupt_mask);
2023-09-09 08:03:56 +01:00
FUNCTION_Init();
if (switch_to_function_foreground)
2023-10-29 22:33:38 +00:00
FUNCTION_Select(FUNCTION_FOREGROUND);
// if (g_monitor_enabled)
// GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
2023-11-26 11:28:19 +00:00
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
// UART_printf("setup-reg %4u.%05u MHz, %u\r\n", Frequency / 100000, Frequency % 100000, Bandwidth);
#endif
2023-09-09 08:03:56 +01:00
}
2023-09-14 09:56:30 +01:00
#ifdef ENABLE_NOAA
2023-09-09 08:03:56 +01:00
void RADIO_ConfigureNOAA(void)
{
uint8_t ChanAB;
2023-09-12 21:08:51 +01:00
2023-10-08 20:23:37 +01:00
g_update_status = true;
2023-09-12 21:08:51 +01:00
2023-11-02 10:00:51 +00:00
if (g_eeprom.config.setting.noaa_auto_scan)
2023-09-09 08:03:56 +01:00
{
2023-11-02 10:00:51 +00:00
if (g_eeprom.config.setting.dual_watch != DUAL_WATCH_OFF)
2023-09-09 08:03:56 +01:00
{
2023-11-02 10:00:51 +00:00
if (IS_NOT_NOAA_CHANNEL(g_eeprom.config.setting.indices.vfo[0].screen))
2023-09-09 08:03:56 +01:00
{
2023-11-02 10:00:51 +00:00
if (IS_NOT_NOAA_CHANNEL(g_eeprom.config.setting.indices.vfo[1].screen))
2023-09-09 08:03:56 +01:00
{
2023-11-02 10:00:51 +00:00
g_noaa_mode = false;
2023-09-09 08:03:56 +01:00
return;
}
ChanAB = 1;
}
else
ChanAB = 0;
2023-09-12 21:08:51 +01:00
2023-11-02 10:00:51 +00:00
if (!g_noaa_mode)
g_noaa_channel = g_vfo_info[ChanAB].channel_save - NOAA_CHANNEL_FIRST;
2023-09-12 21:08:51 +01:00
2023-11-02 10:00:51 +00:00
g_noaa_mode = true;
2023-09-09 08:03:56 +01:00
return;
}
2023-09-12 21:08:51 +01:00
2023-10-08 20:23:37 +01:00
if (g_rx_vfo->channel_save >= NOAA_CHANNEL_FIRST)
2023-09-09 08:03:56 +01:00
{
2023-11-02 10:00:51 +00:00
g_noaa_mode = true;
2023-10-08 20:23:37 +01:00
g_noaa_channel = g_rx_vfo->channel_save - NOAA_CHANNEL_FIRST;
g_noaa_tick_10ms = noaa_tick_2_10ms;
2023-10-08 20:23:37 +01:00
g_schedule_noaa = false;
2023-09-09 08:03:56 +01:00
}
else
2023-11-02 10:00:51 +00:00
g_noaa_mode = false;
2023-09-09 08:03:56 +01:00
}
else
2023-11-02 10:00:51 +00:00
g_noaa_mode = false;
2023-09-09 08:03:56 +01:00
}
#endif
void RADIO_enableTX(const bool fsk_tx)
2023-09-09 08:03:56 +01:00
{
2023-11-02 21:44:53 +00:00
BK4819_filter_bandwidth_t Bandwidth = g_current_vfo->channel.channel_bandwidth;
2023-09-09 08:03:56 +01:00
2023-10-29 22:33:38 +00:00
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
2023-09-09 08:03:56 +01:00
2023-10-25 13:07:12 +01:00
BK4819_set_GPIO_pin(BK4819_GPIO0_PIN28_RX_ENABLE, false);
2023-09-09 08:03:56 +01:00
2023-11-11 13:09:24 +00:00
Bandwidth = RADIO_set_bandwidth(Bandwidth, g_current_vfo->channel.mod_mode);
2023-09-09 08:03:56 +01:00
// if DTMF is enabled when TX'ing, it changes the TX audio filtering ! .. 1of11
// so MAKE SURE that DTMF is disabled - until needed
BK4819_DisableDTMF();
2023-11-24 08:16:38 +00:00
BK4819_SetCompander((!fsk_tx && g_current_vfo->channel.mod_mode == MOD_MODE_FM) ? g_current_vfo->channel.compand : COMPAND_OFF);
2023-11-23 20:43:13 +00:00
// ******************
2023-11-09 05:59:50 +00:00
BK4819_set_rf_frequency(g_current_vfo->p_tx->frequency, true);
2023-10-17 21:22:40 +01:00
BK4819_set_rf_filter_path(g_current_vfo->p_tx->frequency);
2023-11-23 20:43:13 +00:00
2023-09-09 08:03:56 +01:00
BK4819_PrepareTransmit();
2023-11-23 20:43:13 +00:00
2023-11-09 05:59:50 +00:00
RADIO_ConfigureTXPower(g_current_vfo);
2023-11-23 20:43:13 +00:00
2023-10-17 21:22:40 +01:00
BK4819_set_GPIO_pin(BK4819_GPIO1_PIN29_PA_ENABLE, true); // PA on
2023-11-23 20:43:13 +00:00
if (g_current_display_screen != DISPLAY_AIRCOPY)
2023-11-24 08:16:38 +00:00
BK4819_SetupPowerAmplifier(g_current_vfo->txp_reg_value, g_current_vfo->p_tx->frequency);
else
2023-10-17 21:22:40 +01:00
BK4819_SetupPowerAmplifier(0, g_current_vfo->p_tx->frequency); // very low power when in AIRCOPY mode
2023-10-17 21:22:40 +01:00
BK4819_set_GPIO_pin(BK4819_GPIO5_PIN1_RED, true); // turn the RED LED on
2023-09-09 08:03:56 +01:00
2023-11-23 20:43:13 +00:00
// ******************
if (fsk_tx)
2023-09-09 08:03:56 +01:00
{
BK4819_disable_sub_audible();
}
else
{
switch (g_current_vfo->p_tx->code_type)
{
default:
case CODE_TYPE_NONE:
BK4819_disable_sub_audible();
break;
case CODE_TYPE_CONTINUOUS_TONE:
BK4819_gen_tail(4);
BK4819_set_CTCSS_freq(CTCSS_TONE_LIST[g_current_vfo->p_tx->code]);
break;
case CODE_TYPE_DIGITAL:
case CODE_TYPE_REVERSE_DIGITAL:
BK4819_gen_tail(4);
BK4819_set_CDCSS_code(DCS_GetGolayCodeWord(g_current_vfo->p_tx->code_type, g_current_vfo->p_tx->code));
break;
}
2023-09-09 08:03:56 +01:00
}
}
void RADIO_set_vfo_state(vfo_state_t State)
2023-09-09 08:03:56 +01:00
{
if (State == VFO_STATE_NORMAL)
{
2023-10-08 20:23:37 +01:00
g_vfo_state[0] = VFO_STATE_NORMAL;
g_vfo_state[1] = VFO_STATE_NORMAL;
2023-09-09 08:03:56 +01:00
}
else
{
2023-09-12 11:01:34 +01:00
if (State == VFO_STATE_VOLTAGE_HIGH)
2023-09-09 08:03:56 +01:00
{
2023-10-08 20:23:37 +01:00
g_vfo_state[0] = VFO_STATE_VOLTAGE_HIGH;
g_vfo_state[1] = VFO_STATE_TX_DISABLE;
2023-09-09 08:03:56 +01:00
}
else
{ // 1of11
2023-11-02 10:00:51 +00:00
const unsigned int vfo = (g_eeprom.config.setting.cross_vfo == CROSS_BAND_OFF) ? g_rx_vfo_num : g_eeprom.config.setting.tx_vfo_num;
2023-10-08 20:23:37 +01:00
g_vfo_state[vfo] = State;
2023-09-09 08:03:56 +01:00
}
2023-10-31 10:07:29 +00:00
// cause a display update to remove the message
g_update_screen_tick_500ms = 8; // 4 seconds
2023-09-09 08:03:56 +01:00
}
2023-10-08 20:23:37 +01:00
g_update_display = true;
2023-09-09 08:03:56 +01:00
}
void RADIO_PrepareTX(void)
{
vfo_state_t State = VFO_STATE_NORMAL; // default to OK for TX
2023-09-28 17:39:45 +01:00
2023-11-06 12:21:52 +00:00
#ifdef ENABLE_ALARM
2023-12-08 17:43:01 +00:00
if (g_alarm_state == ALARM_STATE_TX_ALARM && g_eeprom.config.setting.alarm_mode != ALARM_MODE_TONE)
2023-11-06 12:21:52 +00:00
{ // enable the alarm tone but not the TX
2023-11-11 13:09:24 +00:00
2023-11-06 12:21:52 +00:00
g_alarm_state = ALARM_STATE_ALARM;
GUI_DisplayScreen();
BK4819_start_tone(500, 28, g_current_function == FUNCTION_TRANSMIT, false);
SYSTEM_DelayMs(60);
BK4819_ExitTxMute();
g_alarm_tone_counter_10ms = 0;
return;
}
#endif
2023-11-02 10:00:51 +00:00
if (g_eeprom.config.setting.dual_watch != DUAL_WATCH_OFF)
2023-09-28 17:39:45 +01:00
{ // dual-RX is enabled
#if 0
2023-10-08 20:23:37 +01:00
if (g_rx_vfo_is_active)
{ // use the TX vfo
2023-11-02 10:00:51 +00:00
g_rx_vfo_num = g_eeprom.config.setting.tx_vfo_num;
g_rx_vfo = &g_vfo_info[g_eeprom.config.setting.tx_vfo_num];
2023-10-08 20:23:37 +01:00
g_rx_vfo_is_active = false;
2023-09-09 08:03:56 +01:00
}
2023-10-08 20:23:37 +01:00
g_current_vfo = g_rx_vfo;
#else
2023-10-08 20:23:37 +01:00
if (!g_rx_vfo_is_active)
{ // use the current RX vfo
2023-11-02 10:00:51 +00:00
g_rx_vfo_num = g_eeprom.config.setting.tx_vfo_num;
g_rx_vfo = &g_vfo_info[g_eeprom.config.setting.tx_vfo_num];
2023-10-08 20:23:37 +01:00
g_rx_vfo_is_active = true;
}
2023-10-08 20:23:37 +01:00
g_current_vfo = g_rx_vfo;
#endif
g_update_status = true;
2023-09-09 08:03:56 +01:00
}
2023-11-06 12:21:52 +00:00
g_current_vfo = (g_eeprom.config.setting.cross_vfo == CROSS_BAND_OFF) ? g_rx_vfo : &g_vfo_info[g_eeprom.config.setting.tx_vfo_num];
2023-09-09 08:03:56 +01:00
#ifndef ENABLE_TX_WHEN_AM
2023-11-06 14:46:39 +00:00
if (g_current_vfo->channel.mod_mode != MOD_MODE_FM)
2023-10-30 01:51:41 +00:00
{ // not allowed to TX if not in FM mode
2023-09-19 09:16:57 +01:00
State = VFO_STATE_TX_DISABLE;
}
2023-09-19 09:16:57 +01:00
else
#endif
#if defined(ENABLE_UART)
if (!g_eeprom.config.setting.tx_enable || g_serial_config_tick_500ms > 0)
#else
if (!g_eeprom.config.setting.tx_enable)
#endif
{ // TX is disabled or config upload/download in progress
State = VFO_STATE_TX_DISABLE;
}
else
if (FREQUENCY_tx_freq_check(g_current_vfo->p_tx->frequency) == 0)
{ // TX frequency is allowed
2023-11-02 21:44:53 +00:00
if (g_current_vfo->channel.busy_channel_lock && g_current_function == FUNCTION_RECEIVE)
State = VFO_STATE_BUSY; // busy RX'ing a station
2023-09-09 08:03:56 +01:00
else
2023-10-08 20:23:37 +01:00
if (g_battery_display_level == 0)
State = VFO_STATE_BAT_LOW; // charge your battery !
2023-11-19 22:47:50 +00:00
// else
// if (g_battery_display_level >= 6)
// State = VFO_STATE_VOLTAGE_HIGH; // over voltage (no doubt to protect the PA) .. this is being a pain
2023-09-28 17:39:45 +01:00
}
else
State = VFO_STATE_TX_DISABLE; // TX frequency not allowed
2023-09-09 08:03:56 +01:00
2023-09-28 17:39:45 +01:00
if (State != VFO_STATE_NORMAL)
{ // TX not allowed
RADIO_set_vfo_state(State);
2023-12-08 17:43:01 +00:00
#if defined(ENABLE_ALARM) || (ENABLE_TX_TONE_HZ > 0)
2023-10-08 20:23:37 +01:00
g_alarm_state = ALARM_STATE_OFF;
2023-09-09 09:01:52 +01:00
#endif
2023-10-08 20:23:37 +01:00
g_dtmf_reply_state = DTMF_REPLY_NONE;
2023-09-17 09:54:24 +01:00
AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL);
2023-09-09 08:03:56 +01:00
return;
}
2023-09-12 21:08:51 +01:00
2023-11-06 12:21:52 +00:00
// ******************************
2023-09-28 17:39:45 +01:00
// TX is allowed
2023-12-08 14:04:02 +00:00
#if defined(ENABLE_DTMF_CALLING) && defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
// UART_printf("radio prepare tx %u %s\r\n", g_dtmf_reply_state, g_dtmf_string);
2023-11-19 22:47:50 +00:00
#endif
2023-12-08 14:04:02 +00:00
#ifdef ENABLE_DTMF_CALLING
if (g_dtmf_reply_state == DTMF_REPLY_STR || g_dtmf_reply_state == DTMF_REPLY_ANI)
2023-09-09 08:03:56 +01:00
{
2023-12-08 14:04:02 +00:00
if (g_dtmf_call_mode == DTMF_CALL_MODE_DTMF)
{
g_dtmf_call_state = DTMF_CALL_STATE_NONE;
g_dtmf_tx_stop_tick_500ms = dtmf_txstop_500ms;
2023-12-08 14:21:41 +00:00
g_dtmf_is_tx = true;
2023-12-08 14:04:02 +00:00
}
else
{
g_dtmf_call_state = DTMF_CALL_STATE_CALL_OUT;
g_dtmf_is_tx = false;
}
2023-09-09 08:03:56 +01:00
}
2023-12-08 14:04:02 +00:00
#else
if (g_dtmf_reply_state == DTMF_REPLY_STR)
2023-12-08 14:21:41 +00:00
{
g_dtmf_tx_stop_tick_500ms = dtmf_txstop_500ms;
g_dtmf_is_tx = true;
}
2023-12-08 14:04:02 +00:00
#endif
2023-09-09 08:03:56 +01:00
FUNCTION_Select(FUNCTION_TRANSMIT);
}
void RADIO_enable_CxCSS_tail(void)
2023-09-09 08:03:56 +01:00
{
switch (g_current_vfo->p_tx->code_type)
2023-09-09 08:03:56 +01:00
{
default:
case CODE_TYPE_NONE:
2023-09-10 17:57:12 +01:00
break;
2023-09-12 21:08:51 +01:00
2023-09-10 17:57:12 +01:00
case CODE_TYPE_CONTINUOUS_TONE:
BK4819_enable_CTCSS_tail();
2023-09-10 17:57:12 +01:00
SYSTEM_DelayMs(200);
break;
2023-09-12 21:08:51 +01:00
2023-09-09 08:03:56 +01:00
case CODE_TYPE_DIGITAL:
case CODE_TYPE_REVERSE_DIGITAL:
BK4819_enable_CDCSS_tail();
2023-09-10 17:57:12 +01:00
SYSTEM_DelayMs(200);
2023-09-09 08:03:56 +01:00
break;
}
}
void RADIO_PrepareCssTX(void)
{
2023-10-29 22:33:38 +00:00
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
2023-09-09 08:03:56 +01:00
RADIO_PrepareTX();
2023-09-17 09:54:24 +01:00
2023-09-09 08:03:56 +01:00
SYSTEM_DelayMs(200);
2023-09-17 09:54:24 +01:00
RADIO_enable_CxCSS_tail();
RADIO_setup_registers(true);
2023-09-09 08:03:56 +01:00
}
2023-10-18 11:31:30 +01:00
void RADIO_tx_eot(void)
2023-09-09 08:03:56 +01:00
{
2023-12-08 17:43:01 +00:00
#if defined(ENABLE_ALARM) || (ENABLE_TX_TONE_HZ > 0)
2023-10-18 11:31:30 +01:00
if (g_alarm_state != ALARM_STATE_OFF)
{ // don't send EOT if TX'ing tone/alarm
BK4819_ExitDTMF_TX(true);
return;
}
2023-10-18 11:31:30 +01:00
#endif
2023-12-08 14:04:02 +00:00
if (
#ifdef ENABLE_DTMF_CALLING
g_dtmf_call_state == DTMF_CALL_STATE_NONE &&
#endif
2023-11-24 10:55:47 +00:00
(g_current_vfo->channel.dtmf_ptt_id_tx_mode == PTT_ID_EOT || g_current_vfo->channel.dtmf_ptt_id_tx_mode == PTT_ID_BOTH))
2023-10-01 21:50:05 +01:00
{ // end-of-tx
2023-11-02 10:00:51 +00:00
if (g_eeprom.config.setting.dtmf.side_tone)
2023-09-09 08:03:56 +01:00
{
2023-10-29 22:33:38 +00:00
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
2023-10-18 21:22:12 +01:00
SYSTEM_DelayMs(60);
2023-09-09 08:03:56 +01:00
}
2023-10-29 22:33:38 +00:00
2023-11-02 10:00:51 +00:00
BK4819_EnterDTMF_TX(g_eeprom.config.setting.dtmf.side_tone);
2023-09-09 08:03:56 +01:00
BK4819_PlayDTMFString(
2023-11-02 10:00:51 +00:00
g_eeprom.config.setting.dtmf.key_down_code,
0,
2023-11-02 10:00:51 +00:00
g_eeprom.config.setting.dtmf.first_code_persist_time * 10,
g_eeprom.config.setting.dtmf.hash_code_persist_time * 10,
g_eeprom.config.setting.dtmf.code_persist_time * 10,
g_eeprom.config.setting.dtmf.code_interval_time * 10);
2023-10-06 22:58:21 +01:00
2023-10-29 22:33:38 +00:00
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
2023-09-09 08:03:56 +01:00
}
2023-10-18 11:31:30 +01:00
else
2023-10-21 20:54:42 +01:00
#ifdef ENABLE_MDC1200
2023-11-02 21:44:53 +00:00
if (g_current_vfo->channel.mdc1200_mode == MDC1200_MODE_EOT || g_current_vfo->channel.mdc1200_mode == MDC1200_MODE_BOTH)
2023-10-25 13:07:12 +01:00
{
2023-11-06 00:47:22 +00:00
BK4819_send_MDC1200(MDC1200_OP_CODE_POST_ID, 0x00, g_eeprom.config.setting.mdc1200_id, false);
2023-11-05 23:16:19 +00:00
#ifdef ENABLE_MDC1200_SIDE_BEEP
2023-11-06 09:08:09 +00:00
BK4819_start_tone(880, 10, true, true);
SYSTEM_DelayMs(120);
2023-11-06 09:08:09 +00:00
BK4819_stop_tones(true);
#endif
2023-10-25 13:07:12 +01:00
}
2023-10-18 11:31:30 +01:00
else
2023-10-21 20:54:42 +01:00
#endif
2023-11-02 21:44:53 +00:00
if (g_current_vfo->channel.dtmf_ptt_id_tx_mode == PTT_ID_APOLLO)
2023-10-25 13:07:12 +01:00
{
2023-11-06 09:08:09 +00:00
BK4819_start_tone(APOLLO_TONE2_HZ, 28, true, false);
SYSTEM_DelayMs(APOLLO_TONE_MS);
BK4819_stop_tones(true);
}
else
if (g_eeprom.config.setting.roger_mode != ROGER_MODE_OFF)
{
BK4819_PlayRoger(g_eeprom.config.setting.roger_mode);
2023-10-25 13:07:12 +01:00
}
2023-10-28 23:11:57 +01:00
2023-09-09 08:03:56 +01:00
BK4819_ExitDTMF_TX(true);
}