0
mirror of https://github.com/OneOfEleven/uv-k5-firmware-custom.git synced 2025-06-18 14:19:49 +03:00

fix tx tones

This commit is contained in:
OneOfEleven
2023-11-03 18:41:54 +00:00
parent 474317c149
commit e2e030aed4
16 changed files with 470 additions and 460 deletions

View File

@ -881,7 +881,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)
void BK4819_StartTone1(const uint16_t frequency, const unsigned int level, const bool tx)
{
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
SYSTEM_DelayMs(2);
@ -895,32 +895,37 @@ void BK4819_StartTone1(const uint16_t frequency, const unsigned int level)
BK4819_WriteRegister(0x70, BK4819_REG_70_ENABLE_TONE1 | ((level & 0x7f) << BK4819_REG_70_SHIFT_TONE1_TUNING_GAIN));
BK4819_WriteRegister(0x30, 0);
#if 1
BK4819_WriteRegister(0x30,
BK4819_REG_30_ENABLE_AF_DAC |
BK4819_REG_30_ENABLE_DISC_MODE |
BK4819_REG_30_ENABLE_TX_DSP);
#else
BK4819_WriteRegister(0x30,
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);
#endif
if (!tx)
{
BK4819_WriteRegister(0x30,
BK4819_REG_30_ENABLE_AF_DAC |
BK4819_REG_30_ENABLE_DISC_MODE |
BK4819_REG_30_ENABLE_TX_DSP);
}
else
{
BK4819_WriteRegister(0x30,
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);
}
BK4819_WriteRegister(0x71, scale_freq(frequency));
BK4819_ExitTxMute();
SYSTEM_DelayMs(2);
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
if (!tx)
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
}
void BK4819_StopTones(const bool tx)
@ -978,7 +983,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_ReadRegister(0x47);
BK4819_StartTone1(tone_Hz, level);
BK4819_StartTone1(tone_Hz, level, g_current_function == FUNCTION_TRANSMIT);
SYSTEM_DelayMs(delay - 2);
BK4819_StopTones(g_current_function == FUNCTION_TRANSMIT);
BK4819_WriteRegister(0x47, prev_af);
@ -996,9 +1001,9 @@ void BK4819_PlayRoger(void)
#endif
const uint16_t prev_af = BK4819_ReadRegister(0x47);
BK4819_StartTone1(tone1_Hz, 96);
BK4819_StartTone1(tone1_Hz, 96, true);
SYSTEM_DelayMs(80 - 2);
BK4819_StartTone1(tone2_Hz, 96);
BK4819_StartTone1(tone2_Hz, 96, true);
SYSTEM_DelayMs(80);
BK4819_StopTones(true);
BK4819_WriteRegister(0x47, prev_af);
@ -1553,12 +1558,12 @@ uint16_t BK4819_GetRSSI(void)
return BK4819_ReadRegister(0x67) & 0x01FF;
}
uint8_t BK4819_GetGlitchIndicator(void)
uint8_t BK4819_GetGlitchIndicator(void)
{
return BK4819_ReadRegister(0x63) & 0x00FF;
}
uint8_t BK4819_GetExNoiceIndicator(void)
uint8_t BK4819_GetExNoiceIndicator(void)
{
return BK4819_ReadRegister(0x65) & 0x007F;
}

View File

@ -103,7 +103,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);
void BK4819_StartTone1(const uint16_t frequency, const unsigned int level, const bool tx);
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);