mirror of
https://github.com/OneOfEleven/uv-k5-firmware-custom.git
synced 2025-06-20 15:08:37 +03:00
Try up/down butts with squelch off/monitor enabled
This commit is contained in:
147
radio.c
147
radio.c
@ -165,12 +165,9 @@ void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure
|
||||
if (Channel >= NOAA_CHANNEL_FIRST)
|
||||
{
|
||||
RADIO_InitInfo(pRadio, g_eeprom.screen_channel[VFO], NOAA_FREQUENCY_TABLE[Channel - NOAA_CHANNEL_FIRST]);
|
||||
|
||||
if (g_eeprom.cross_vfo_rx_tx == CROSS_BAND_OFF)
|
||||
return;
|
||||
|
||||
g_eeprom.cross_vfo_rx_tx = CROSS_BAND_OFF;
|
||||
|
||||
g_update_status = true;
|
||||
return;
|
||||
}
|
||||
@ -245,7 +242,7 @@ void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure
|
||||
uint8_t Tmp;
|
||||
uint8_t Data[8];
|
||||
// t_channel channel;
|
||||
|
||||
|
||||
// EEPROM_ReadBuffer(Base, channel, sizeof(channel));
|
||||
|
||||
// ***************
|
||||
@ -517,7 +514,7 @@ void RADIO_ConfigureSquelchAndOutputPower(vfo_info_t *pInfo)
|
||||
|
||||
// my calibration data
|
||||
//
|
||||
// 1ED0 32 32 32 64 64 64 8C 8C 8C FF FF FF FF FF FF FF .. 50 MHz
|
||||
// 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 .. 136 MHz
|
||||
// 1F00 32 32 32 64 64 64 8C 8C 8C FF FF FF FF FF FF FF .. 174 MHz
|
||||
@ -545,7 +542,7 @@ void RADIO_ConfigureSquelchAndOutputPower(vfo_info_t *pInfo)
|
||||
TX_power[2] /= 3;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
pInfo->txp_calculated_setting = FREQUENCY_CalculateOutputPower(
|
||||
TX_power[0],
|
||||
TX_power[1],
|
||||
@ -588,7 +585,7 @@ static void RADIO_SelectCurrentVfo(void)
|
||||
g_current_vfo = (g_eeprom.cross_vfo_rx_tx == CROSS_BAND_OFF) ? g_rx_vfo : &g_eeprom.vfo_info[g_eeprom.tx_vfo];
|
||||
}
|
||||
|
||||
void RADIO_SelectVfos(void)
|
||||
void RADIO_select_vfos(void)
|
||||
{
|
||||
g_eeprom.tx_vfo = get_TX_VFO();
|
||||
g_eeprom.rx_vfo = (g_eeprom.cross_vfo_rx_tx == CROSS_BAND_OFF) ? g_eeprom.tx_vfo : (g_eeprom.tx_vfo + 1) & 1u;
|
||||
@ -599,11 +596,11 @@ void RADIO_SelectVfos(void)
|
||||
RADIO_SelectCurrentVfo();
|
||||
}
|
||||
|
||||
void RADIO_SetupRegisters(bool bSwitchToFunction0)
|
||||
void RADIO_setup_registers(bool switch_to_function_0)
|
||||
{
|
||||
BK4819_filter_bandwidth_t Bandwidth = g_rx_vfo->channel_bandwidth;
|
||||
uint16_t InterruptMask;
|
||||
uint32_t Frequency;
|
||||
uint16_t interrupt_mask;
|
||||
uint32_t Frequency;
|
||||
|
||||
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH);
|
||||
|
||||
@ -636,7 +633,7 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0)
|
||||
BK4819_set_GPIO_pin(BK4819_GPIO5_PIN1, false); // ???
|
||||
|
||||
while (1)
|
||||
{ // wait for the interrupt to clear ???
|
||||
{ // wait for the interrupt to clear ?
|
||||
const uint16_t status_bits = BK4819_ReadRegister(BK4819_REG_0C);
|
||||
if ((status_bits & (1u << 0)) == 0)
|
||||
break;
|
||||
@ -644,20 +641,18 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0)
|
||||
SYSTEM_DelayMs(1);
|
||||
}
|
||||
|
||||
BK4819_WriteRegister(BK4819_REG_3F, 0);
|
||||
BK4819_WriteRegister(BK4819_REG_3F, 0); // disable interrupts
|
||||
|
||||
// mic gain 0.5dB/step 0 to 31
|
||||
BK4819_WriteRegister(BK4819_REG_7D, 0xE940 | (g_eeprom.mic_sensitivity_tuning & 0x1f));
|
||||
|
||||
#ifdef ENABLE_NOAA
|
||||
if (IS_NOT_NOAA_CHANNEL(g_rx_vfo->channel_save) || !g_is_noaa_mode)
|
||||
Frequency = g_rx_vfo->p_rx->frequency;
|
||||
else
|
||||
if (IS_NOAA_CHANNEL(g_rx_vfo->channel_save) && g_is_noaa_mode)
|
||||
Frequency = NOAA_FREQUENCY_TABLE[g_noaa_channel];
|
||||
#else
|
||||
Frequency = g_rx_vfo->p_rx->frequency;
|
||||
else
|
||||
#endif
|
||||
BK4819_SetFrequency(Frequency);
|
||||
Frequency = g_rx_vfo->p_rx->frequency;
|
||||
BK4819_set_rf_frequency(Frequency, false);
|
||||
|
||||
BK4819_SetupSquelch(
|
||||
g_rx_vfo->squelch_open_rssi_thresh, g_rx_vfo->squelch_close_rssi_thresh,
|
||||
@ -672,20 +667,19 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0)
|
||||
// AF RX Gain and DAC
|
||||
BK4819_WriteRegister(BK4819_REG_48, 0xB3A8); // 1011 00 111010 1000
|
||||
|
||||
InterruptMask = BK4819_REG_3F_SQUELCH_FOUND | BK4819_REG_3F_SQUELCH_LOST;
|
||||
interrupt_mask = BK4819_REG_3F_SQUELCH_FOUND | BK4819_REG_3F_SQUELCH_LOST;
|
||||
|
||||
#ifdef ENABLE_NOAA
|
||||
if (IS_NOT_NOAA_CHANNEL(g_rx_vfo->channel_save))
|
||||
#endif
|
||||
if (IS_NOT_NOAA_CHANNEL(g_rx_vfo->channel_save))
|
||||
{
|
||||
if (g_rx_vfo->am_mode == 0)
|
||||
{ // FM
|
||||
uint8_t code_type = g_selected_code_type;
|
||||
uint8_t Code = g_selected_code;
|
||||
uint8_t Code = g_selected_code;
|
||||
|
||||
if (g_css_scan_mode == CSS_SCAN_MODE_OFF)
|
||||
{
|
||||
code_type = g_rx_vfo->p_rx->code_type;
|
||||
Code = g_rx_vfo->p_rx->code;
|
||||
Code = g_rx_vfo->p_rx->code;
|
||||
}
|
||||
|
||||
switch (code_type)
|
||||
@ -700,7 +694,7 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0)
|
||||
// BK4819_SetTailDetection(670); // 67Hz
|
||||
//#endif
|
||||
|
||||
InterruptMask = BK4819_REG_3F_CxCSS_TAIL | BK4819_REG_3F_SQUELCH_FOUND | BK4819_REG_3F_SQUELCH_LOST;
|
||||
interrupt_mask = BK4819_REG_3F_CxCSS_TAIL | BK4819_REG_3F_SQUELCH_FOUND | BK4819_REG_3F_SQUELCH_LOST;
|
||||
break;
|
||||
|
||||
case CODE_TYPE_CONTINUOUS_TONE:
|
||||
@ -712,24 +706,24 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0)
|
||||
// BK4819_SetTailDetection(CTCSS_OPTIONS[Code]);
|
||||
//#endif
|
||||
|
||||
InterruptMask = 0
|
||||
| BK4819_REG_3F_CxCSS_TAIL
|
||||
| BK4819_REG_3F_CTCSS_FOUND
|
||||
| BK4819_REG_3F_CTCSS_LOST
|
||||
| BK4819_REG_3F_SQUELCH_FOUND
|
||||
| BK4819_REG_3F_SQUELCH_LOST;
|
||||
interrupt_mask =
|
||||
BK4819_REG_3F_CxCSS_TAIL |
|
||||
BK4819_REG_3F_CTCSS_FOUND |
|
||||
BK4819_REG_3F_CTCSS_LOST |
|
||||
BK4819_REG_3F_SQUELCH_FOUND |
|
||||
BK4819_REG_3F_SQUELCH_LOST;
|
||||
|
||||
break;
|
||||
|
||||
case CODE_TYPE_DIGITAL:
|
||||
case CODE_TYPE_REVERSE_DIGITAL:
|
||||
BK4819_SetCDCSSCodeWord(DCS_GetGolayCodeWord(code_type, Code));
|
||||
InterruptMask = 0
|
||||
| BK4819_REG_3F_CxCSS_TAIL
|
||||
| BK4819_REG_3F_CDCSS_FOUND
|
||||
| BK4819_REG_3F_CDCSS_LOST
|
||||
| BK4819_REG_3F_SQUELCH_FOUND
|
||||
| BK4819_REG_3F_SQUELCH_LOST;
|
||||
interrupt_mask =
|
||||
BK4819_REG_3F_CxCSS_TAIL |
|
||||
BK4819_REG_3F_CDCSS_FOUND |
|
||||
BK4819_REG_3F_CDCSS_LOST |
|
||||
BK4819_REG_3F_SQUELCH_FOUND |
|
||||
BK4819_REG_3F_SQUELCH_LOST;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -743,55 +737,50 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0)
|
||||
else
|
||||
{
|
||||
BK4819_SetCTCSSFrequency(2625);
|
||||
InterruptMask = 0
|
||||
| BK4819_REG_3F_CTCSS_FOUND
|
||||
| BK4819_REG_3F_CTCSS_LOST
|
||||
| BK4819_REG_3F_SQUELCH_FOUND
|
||||
| BK4819_REG_3F_SQUELCH_LOST;
|
||||
interrupt_mask =
|
||||
BK4819_REG_3F_CTCSS_FOUND |
|
||||
BK4819_REG_3F_CTCSS_LOST |
|
||||
BK4819_REG_3F_SQUELCH_FOUND |
|
||||
BK4819_REG_3F_SQUELCH_LOST;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_VOX
|
||||
#ifdef ENABLE_NOAA
|
||||
if (
|
||||
#ifdef ENABLE_FMRADIO
|
||||
if (g_eeprom.vox_switch && !g_fm_radio_mode && IS_NOT_NOAA_CHANNEL(g_current_vfo->channel_save) && g_current_vfo->am_mode == 0)
|
||||
#else
|
||||
if (g_eeprom.vox_switch && IS_NOT_NOAA_CHANNEL(g_current_vfo->channel_save) && g_current_vfo->am_mode == 0)
|
||||
!g_fm_radio_mode &&
|
||||
#endif
|
||||
#else
|
||||
#ifdef ENABLE_FMRADIO
|
||||
if (g_eeprom.vox_switch && !g_fm_radio_mode && g_current_vfo->am_mode == 0)
|
||||
#else
|
||||
if (g_eeprom.vox_switch && g_current_vfo->am_mode == 0)
|
||||
#endif
|
||||
#endif
|
||||
g_eeprom.vox_switch &&
|
||||
!g_fm_radio_mode &&
|
||||
IS_NOT_NOAA_CHANNEL(g_current_vfo->channel_save) &&
|
||||
g_current_vfo->am_mode == 0)
|
||||
{
|
||||
BK4819_EnableVox(g_eeprom.vox1_threshold, g_eeprom.vox0_threshold);
|
||||
InterruptMask |= BK4819_REG_3F_VOX_FOUND | BK4819_REG_3F_VOX_LOST;
|
||||
interrupt_mask |= BK4819_REG_3F_VOX_FOUND | BK4819_REG_3F_VOX_LOST;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
BK4819_DisableVox();
|
||||
BK4819_DisableVox();
|
||||
|
||||
// RX expander
|
||||
BK4819_SetCompander((g_rx_vfo->am_mode == 0 && g_rx_vfo->compander >= 2) ? g_rx_vfo->compander : 0);
|
||||
|
||||
#if 0
|
||||
if (!g_rx_vfo->dtmf_decoding_enable && !g_setting_killed)
|
||||
if (!g_rx_vfo->dtmf_decoding_enable && !g_setting_radio_disabled)
|
||||
{
|
||||
BK4819_DisableDTMF();
|
||||
}
|
||||
else
|
||||
{
|
||||
BK4819_EnableDTMF();
|
||||
InterruptMask |= BK4819_REG_3F_DTMF_5TONE_FOUND;
|
||||
interrupt_mask |= BK4819_REG_3F_DTMF_5TONE_FOUND;
|
||||
}
|
||||
#else
|
||||
if (g_current_function != FUNCTION_TRANSMIT)
|
||||
{
|
||||
BK4819_DisableDTMF();
|
||||
BK4819_EnableDTMF();
|
||||
InterruptMask |= BK4819_REG_3F_DTMF_5TONE_FOUND;
|
||||
interrupt_mask |= BK4819_REG_3F_DTMF_5TONE_FOUND;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -800,11 +789,11 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0)
|
||||
#endif
|
||||
|
||||
// enable/disable BK4819 selected interrupts
|
||||
BK4819_WriteRegister(BK4819_REG_3F, InterruptMask);
|
||||
BK4819_WriteRegister(BK4819_REG_3F, interrupt_mask);
|
||||
|
||||
FUNCTION_Init();
|
||||
|
||||
if (bSwitchToFunction0)
|
||||
if (switch_to_function_0)
|
||||
FUNCTION_Select(FUNCTION_FOREGROUND);
|
||||
}
|
||||
|
||||
@ -883,7 +872,7 @@ void RADIO_enableTX(const bool fsk_tx)
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
BK4819_SetFrequency(g_current_vfo->p_tx->frequency);
|
||||
BK4819_set_rf_frequency(g_current_vfo->p_tx->frequency, false);
|
||||
BK4819_SetCompander((!fsk_tx && g_rx_vfo->am_mode == 0 && (g_rx_vfo->compander == 1 || g_rx_vfo->compander >= 3)) ? g_rx_vfo->compander : 0);
|
||||
BK4819_PrepareTransmit();
|
||||
BK4819_PickRXFilterPathBasedOnFrequency(g_current_vfo->p_tx->frequency);
|
||||
@ -906,11 +895,11 @@ void RADIO_enableTX(const bool fsk_tx)
|
||||
case CODE_TYPE_NONE:
|
||||
BK4819_ExitSubAu();
|
||||
break;
|
||||
|
||||
|
||||
case CODE_TYPE_CONTINUOUS_TONE:
|
||||
BK4819_SetCTCSSFrequency(CTCSS_OPTIONS[g_current_vfo->p_tx->code]);
|
||||
break;
|
||||
|
||||
|
||||
case CODE_TYPE_DIGITAL:
|
||||
case CODE_TYPE_REVERSE_DIGITAL:
|
||||
BK4819_SetCDCSSCodeWord(DCS_GetGolayCodeWord(g_current_vfo->p_tx->code_type, g_current_vfo->p_tx->code));
|
||||
@ -959,29 +948,27 @@ void RADIO_PrepareTX(void)
|
||||
{ // dual-RX is enabled
|
||||
|
||||
g_dual_watch_count_down_10ms = dual_watch_count_after_tx_10ms;
|
||||
g_schedule_dual_watch = false;
|
||||
g_schedule_dual_watch = false;
|
||||
|
||||
#if 0
|
||||
if (g_rx_vfo_is_active)
|
||||
{ // use the TX vfo
|
||||
g_eeprom.rx_vfo = g_eeprom.tx_vfo;
|
||||
g_rx_vfo = &g_eeprom.vfo_info[g_eeprom.tx_vfo];
|
||||
g_eeprom.rx_vfo = g_eeprom.tx_vfo;
|
||||
g_rx_vfo = &g_eeprom.vfo_info[g_eeprom.tx_vfo];
|
||||
g_rx_vfo_is_active = false;
|
||||
}
|
||||
g_current_vfo = g_rx_vfo;
|
||||
#else
|
||||
if (!g_rx_vfo_is_active)
|
||||
{ // use the current RX vfo
|
||||
g_eeprom.rx_vfo = g_eeprom.tx_vfo;
|
||||
g_rx_vfo = &g_eeprom.vfo_info[g_eeprom.tx_vfo];
|
||||
g_eeprom.rx_vfo = g_eeprom.tx_vfo;
|
||||
g_rx_vfo = &g_eeprom.vfo_info[g_eeprom.tx_vfo];
|
||||
g_rx_vfo_is_active = true;
|
||||
}
|
||||
g_current_vfo = g_rx_vfo;
|
||||
#endif
|
||||
|
||||
// let the user see that DW is not active '><' symbol
|
||||
g_dual_watch_active = false;
|
||||
g_update_status = true;
|
||||
|
||||
g_update_status = true;
|
||||
}
|
||||
|
||||
RADIO_SelectCurrentVfo();
|
||||
@ -1033,8 +1020,8 @@ void RADIO_PrepareTX(void)
|
||||
{
|
||||
if (g_dtmf_call_mode == DTMF_CALL_MODE_DTMF)
|
||||
{
|
||||
g_dtmf_is_tx = true;
|
||||
g_dtmf_call_state = DTMF_CALL_STATE_NONE;
|
||||
g_dtmf_is_tx = true;
|
||||
g_dtmf_call_state = DTMF_CALL_STATE_NONE;
|
||||
g_dtmf_tx_stop_count_down_500ms = dtmf_txstop_countdown_500ms;
|
||||
}
|
||||
else
|
||||
@ -1046,7 +1033,7 @@ void RADIO_PrepareTX(void)
|
||||
|
||||
FUNCTION_Select(FUNCTION_TRANSMIT);
|
||||
|
||||
g_tx_timer_count_down_500ms = 0; // no timeout
|
||||
g_tx_timer_count_down_500ms = 0; // no timeout
|
||||
|
||||
#if defined(ENABLE_ALARM) || defined(ENABLE_TX1750)
|
||||
if (g_alarm_state == ALARM_STATE_OFF)
|
||||
@ -1060,11 +1047,11 @@ void RADIO_PrepareTX(void)
|
||||
else
|
||||
g_tx_timer_count_down_500ms = 120 * 15; // 15 minutes
|
||||
}
|
||||
g_tx_timeout_reached = false;
|
||||
|
||||
g_flag_end_tx = false;
|
||||
g_rtte_count_down = 0;
|
||||
g_dtmf_reply_state = DTMF_REPLY_NONE;
|
||||
g_tx_timeout_reached = false;
|
||||
g_flag_end_tx = false;
|
||||
g_rtte_count_down = 0;
|
||||
g_dtmf_reply_state = DTMF_REPLY_NONE;
|
||||
}
|
||||
|
||||
void RADIO_EnableCxCSS(void)
|
||||
@ -1095,7 +1082,7 @@ void RADIO_PrepareCssTX(void)
|
||||
SYSTEM_DelayMs(200);
|
||||
|
||||
RADIO_EnableCxCSS();
|
||||
RADIO_SetupRegisters(true);
|
||||
RADIO_setup_registers(true);
|
||||
}
|
||||
|
||||
void RADIO_SendEndOfTransmission(void)
|
||||
|
Reference in New Issue
Block a user