From a5b925e76f98cbed2a019296d960d4a152e7a288 Mon Sep 17 00:00:00 2001 From: Silvano Seva Date: Fri, 14 Jul 2023 17:28:16 +0200 Subject: [PATCH] Small code cleanup in MD-UV3x0 HR_C6000 driver, temporary workaround to fix #129 --- platform/drivers/baseband/HR_C6000_UV3x0.cpp | 21 ++++++++++---------- platform/drivers/baseband/radio_UV3x0.cpp | 10 +++++++++- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/platform/drivers/baseband/HR_C6000_UV3x0.cpp b/platform/drivers/baseband/HR_C6000_UV3x0.cpp index d113a9ed..366d1ca1 100644 --- a/platform/drivers/baseband/HR_C6000_UV3x0.cpp +++ b/platform/drivers/baseband/HR_C6000_UV3x0.cpp @@ -167,7 +167,7 @@ void HR_Cx000< M >::dmrMode() template< class M > void HR_Cx000< M >::fmMode() { - writeReg(M::CONFIG, 0x10, 0xF3); // FM mode, Tier II, TimeSlot, 3rd layer mode, aligned (?) + writeReg(M::CONFIG, 0x10, 0x80); // FM mode, Tier II, TimeSlot, 3rd layer mode, aligned (?) writeReg(M::CONFIG, 0x01, 0xB0); // Swap TX IQ, two point mode for TX, IF mode for RX writeReg(M::CONFIG, 0x81, 0x04); // Interrupt mask writeReg(M::CONFIG, 0xE5, 0x1A); // Undocumented register @@ -203,24 +203,23 @@ void HR_Cx000< M >::startAnalogTx(const TxAudioSource source, const FmConfig cfg if(source == TxAudioSource::MIC) audioCfg |= 0x40; if(source == TxAudioSource::LINE_IN) audioCfg |= 0x02; - writeReg(M::CONFIG, 0xE2, 0x00); // Mic preamp disabled, anti-pop disabled -// writeReg(M::CONFIG, 0xE4, 0x23); // Lineout gain, first and second stage mic gain + // writeReg(M::CONFIG, 0xE2, 0x00); // Mic preamp disabled, anti-pop disabled + writeReg(M::CONFIG, 0xE0, audioCfg); writeReg(M::CONFIG, 0xC2, 0x00); // Codec AGC gain + writeReg(M::CONFIG, 0xE5, 0x1A); // Unknown (Default value = 0A) + writeReg(M::CONFIG, 0x25, 0x0E); // Undocumented Register + writeReg(M::CONFIG, 0x26, 0xFE); // Undocumented register Turns off FM receive + writeReg(M::CONFIG, 0x83, 0xFF); // Clear all Interrupts + writeReg(M::CONFIG, 0x87, 0x00); // Clear Int Masks writeReg(M::CONFIG, 0xA1, 0x80); // FM_mod, all modes cleared writeReg(M::CONFIG, 0x83, 0xFF); // Clear all interrupt flags writeReg(M::CONFIG, 0x87, 0x00); // Disable all interrupt sources -// writeReg(M::CONFIG, 0x04, 0x24); -// writeReg(M::CONFIG, 0x35, 0x40); -// writeReg(M::CONFIG, 0x3F, 0x04); writeReg(M::CONFIG, 0x34, static_cast< uint8_t >(cfg)); - writeReg(M::CONFIG, 0x3E, 0x08); // FM Modulation frequency deviation coefficient at the receiving end writeReg(M::AUX, 0x50, 0x00); writeReg(M::AUX, 0x51, 0x00); - writeReg(M::CONFIG, 0x60, 0x80); // Start analog transmission - writeReg(M::CONFIG, 0x10, 0xF3); // FM mode, Tier II, TimeSlot, 3rd layer mode, aligned (?) - - writeReg(M::CONFIG, 0xE0, audioCfg); + writeReg(M::CONFIG, 0x3E, 0x08); // FM Modulation frequency deviation coefficient at the receiving end writeReg(M::CONFIG, 0x37, 0x8C); // DAC gain + writeReg(M::CONFIG, 0x60, 0x80); // Start analog transmission } template< class M > diff --git a/platform/drivers/baseband/radio_UV3x0.cpp b/platform/drivers/baseband/radio_UV3x0.cpp index b364bde2..96f98dbb 100644 --- a/platform/drivers/baseband/radio_UV3x0.cpp +++ b/platform/drivers/baseband/radio_UV3x0.cpp @@ -18,6 +18,7 @@ * along with this program; if not, see * ***************************************************************************/ +#include #include #include #include @@ -234,9 +235,15 @@ void radio_enableTx() break; } + // + // FIXME: workaround to fix a small carrier-only gap which appears at the + // beginning of each transmission. This problem is particularly evident in + // M17 mode because it causes the truncation of the preamble sequence. + // + sleepFor(0, 50); + at1846s.setFuncMode(AT1846S_FuncMode::TX); - gpio_setPin(PA_EN_1); if(currTxBand == BND_VHF) { @@ -247,6 +254,7 @@ void radio_enableTx() gpio_setPin(PA_SEL_SW); } + gpio_setPin(PA_EN_1); gpio_setPin(PA_EN_2); if(config->txToneEn)