0
mirror of https://github.com/OneOfEleven/uv-k5-firmware-custom.git synced 2025-05-18 16:01:18 +03:00

fix mdc side beeps

This commit is contained in:
OneOfEleven 2023-11-06 00:47:22 +00:00
parent 32394cc558
commit b8e7d11bfc
8 changed files with 30 additions and 42 deletions

View File

@ -1562,7 +1562,7 @@ void APP_process_flash_light_10ms(void)
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT);
#ifdef ENABLE_FLASH_LIGHT_SOS_TONE
if (!g_squelch_open && !g_monitor_enabled && !GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER))
BK4819_StartTone1(880, 50, g_current_function == FUNCTION_TRANSMIT);
BK4819_StartTone1(880, 50, g_current_function == FUNCTION_TRANSMIT, true);
#endif
}
}

View File

@ -173,8 +173,7 @@ void AUDIO_PlayBeep(beep_type_t Beep)
break;
}
// BK4819_PlayTone(ToneFrequency, true);
BK4819_StartTone1(ToneFrequency, 96, false);
BK4819_StartTone1(ToneFrequency, 96, false, false);
SYSTEM_DelayMs(2);
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);

View File

@ -814,7 +814,7 @@ void BK4819_EnableDTMF(void)
(15u << BK4819_REG_24_SHIFT_MAX_SYMBOLS)); // 0 ~ 15
}
void BK4819_StartTone1(const uint16_t frequency, const unsigned int level, const bool tx)
void BK4819_StartTone1(const uint16_t frequency, const unsigned int level, const bool tx, const bool tx_unmute)
{
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
SYSTEM_DelayMs(2);
@ -825,7 +825,10 @@ void BK4819_StartTone1(const uint16_t frequency, const unsigned int level, const
BK4819_EnterTxMute();
BK4819_write_reg(0x70, BK4819_REG_70_ENABLE_TONE1 | ((level & 0x7f) << BK4819_REG_70_SHIFT_TONE1_TUNING_GAIN));
if (level > 0)
BK4819_write_reg(0x70, BK4819_REG_70_ENABLE_TONE1 | ((level & 0x7f) << BK4819_REG_70_SHIFT_TONE1_TUNING_GAIN));
else
BK4819_write_reg(0x70, 0);
BK4819_write_reg(0x30, 0);
@ -862,10 +865,12 @@ void BK4819_StartTone1(const uint16_t frequency, const unsigned int level, const
BK4819_write_reg(0x71, scale_freq(frequency));
BK4819_ExitTxMute();
if (tx_unmute)
BK4819_ExitTxMute();
SYSTEM_DelayMs(2);
if (!tx)
if (!tx && level > 0)
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
}
@ -918,7 +923,7 @@ void BK4819_StopTones(const bool tx)
void BK4819_PlayTone(const unsigned int tone_Hz, const unsigned int delay, const unsigned int level)
{
const uint16_t prev_af = BK4819_read_reg(0x47);
BK4819_StartTone1(tone_Hz, level, g_current_function == FUNCTION_TRANSMIT);
BK4819_StartTone1(tone_Hz, level, g_current_function == FUNCTION_TRANSMIT, true);
SYSTEM_DelayMs(delay - 2);
BK4819_StopTones(g_current_function == FUNCTION_TRANSMIT);
BK4819_write_reg(0x47, prev_af);
@ -936,9 +941,9 @@ void BK4819_PlayRoger(void)
#endif
const uint16_t prev_af = BK4819_read_reg(0x47);
BK4819_StartTone1(tone1_Hz, 96, true);
BK4819_StartTone1(tone1_Hz, 96, true, true);
SYSTEM_DelayMs(80 - 2);
BK4819_StartTone1(tone2_Hz, 96, true);
BK4819_StartTone1(tone2_Hz, 96, true, true);
SYSTEM_DelayMs(80);
BK4819_StopTones(true);
BK4819_write_reg(0x47, prev_af);
@ -2128,7 +2133,7 @@ void BK4819_reset_fsk(void)
}
}
void BK4819_send_MDC1200(const uint8_t op, const uint8_t arg, const uint16_t id)
void BK4819_send_MDC1200(const uint8_t op, const uint8_t arg, const uint16_t id, const bool long_preamble)
{
uint16_t fsk_reg59;
uint8_t packet[42];
@ -2320,10 +2325,11 @@ void BK4819_reset_fsk(void)
(0u << 10) | // 0/1 1 = invert data when RX
(0u << 9) | // 0/1 1 = invert data when TX
(0u << 8) | // 0/1 ???
(3u << 4) | // 0 ~ 15 preamble length .. bit toggling
(0u << 4) | // 0 ~ 15 preamble length .. bit toggling
(1u << 3) | // 0/1 sync length
(0u << 0); // 0 ~ 7 ???
fsk_reg59 |= long_preamble ? 15u << 4 : 3u << 4;
// Set packet length (not including pre-amble and sync bytes that we can't seem to disable)
BK4819_write_reg(0x5D, ((size - 1) << 8));

View File

@ -106,7 +106,7 @@ void BK4819_SetCompander(const unsigned int mode);
void BK4819_DisableVox(void);
void BK4819_DisableDTMF(void);
void BK4819_EnableDTMF(void);
void BK4819_StartTone1(const uint16_t frequency, const unsigned int level, const bool tx);
void BK4819_StartTone1(const uint16_t frequency, const unsigned int level, const bool tx, const bool tx_unmute);
void BK4819_StopTones(const bool tx);
void BK4819_PlayTone(const unsigned int tone_Hz, const unsigned int delay, const unsigned int level);
void BK4819_EnterTxMute(void);
@ -165,7 +165,7 @@ void BK4819_PlayRoger(void);
#ifdef ENABLE_MDC1200
void BK4819_enable_mdc1200_rx(const bool enable);
void BK4819_send_MDC1200(const uint8_t op, const uint8_t arg, const uint16_t id);
void BK4819_send_MDC1200(const uint8_t op, const uint8_t arg, const uint16_t id, const bool long_preamble);
#endif
void BK4819_Enable_AfDac_DiscMode_TxDsp(void);

Binary file not shown.

Binary file not shown.

View File

@ -220,7 +220,7 @@ void FUNCTION_Select(function_type_t Function)
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
SYSTEM_DelayMs(2);
BK4819_StartTone1(500, 28, g_current_function == FUNCTION_TRANSMIT);
BK4819_StartTone1(500, 28, g_current_function == FUNCTION_TRANSMIT, true);
SYSTEM_DelayMs(2);
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
@ -267,15 +267,16 @@ void FUNCTION_Select(function_type_t Function)
if (g_current_vfo->channel.mdc1200_mode == MDC1200_MODE_BOT || g_current_vfo->channel.mdc1200_mode == MDC1200_MODE_BOTH)
{
#ifdef ENABLE_MDC1200_SIDE_BEEP
BK4819_StartTone1(880, 20, false);
SYSTEM_DelayMs(120);
BK4819_StopTones(true);
// BK4819_StartTone1(880, 20, true, false);
// SYSTEM_DelayMs(120);
// BK4819_StopTones(true);
#endif
SYSTEM_DelayMs(30);
BK4819_send_MDC1200(MDC1200_OP_CODE_PTT_ID, 0x80, g_eeprom.config.setting.mdc1200_id);
BK4819_send_MDC1200(MDC1200_OP_CODE_PTT_ID, 0x80, g_eeprom.config.setting.mdc1200_id, true);
#ifdef ENABLE_MDC1200_SIDE_BEEP
BK4819_StartTone1(880, 20, false);
BK4819_StartTone1(880, 20, true, false);
SYSTEM_DelayMs(120);
BK4819_StopTones(true);
#endif
@ -287,19 +288,7 @@ void FUNCTION_Select(function_type_t Function)
BK4819_PlayTone(APOLLO_TONE1_HZ, APOLLO_TONE_MS, 0);
}
}
/*
BK4819_write_reg(0x30,
(1u << 15) | // enable VCO calibration
(1u << 14) | // enable something or other
(0u << 10) | // diable RX link
(1u << 9) | // enable AF DAC
(1u << 8) | // enable DISC mode, what's DISC mode ?
(15u << 4) | // enable PLL/VCO
(1u << 3) | // enable PA gain
(1u << 2) | // enable MIC ADC
(1u << 1) | // enable TX DSP
(0u << 0)); // disable RX DSP
*/
if (g_eeprom.config.setting.enable_scrambler)
BK4819_set_scrambler(g_current_vfo->channel.scrambler);

10
radio.c
View File

@ -1212,16 +1212,10 @@ void RADIO_tx_eot(void)
// if (g_eeprom.config.setting.roger_mode == ROGER_MODE_MDC)
if (g_current_vfo->channel.mdc1200_mode == MDC1200_MODE_EOT || g_current_vfo->channel.mdc1200_mode == MDC1200_MODE_BOTH)
{
#ifdef ENABLE_MDC1200_SIDE_BEEP
//BK4819_StartTone1(880, 20, false);
//SYSTEM_DelayMs(120);
//BK4819_StopTones(true);
#endif
BK4819_send_MDC1200(MDC1200_OP_CODE_POST_ID, 0x00, g_eeprom.config.setting.mdc1200_id);
BK4819_send_MDC1200(MDC1200_OP_CODE_POST_ID, 0x00, g_eeprom.config.setting.mdc1200_id, false);
#ifdef ENABLE_MDC1200_SIDE_BEEP
BK4819_StartTone1(880, 20, false);
BK4819_StartTone1(880, 30, true, false);
SYSTEM_DelayMs(120);
BK4819_StopTones(true);
#endif