diff --git a/openrtx/include/interfaces/radio.h b/openrtx/include/interfaces/radio.h index d24f8397..91ebfb93 100644 --- a/openrtx/include/interfaces/radio.h +++ b/openrtx/include/interfaces/radio.h @@ -84,6 +84,16 @@ void radio_setOpmode(const enum opmode mode); */ bool radio_checkRxDigitalSquelch(); +/** + * Enable AF output towards the speakers. + */ +void radio_enableAfOutput(); + +/** + * Disable AF output towards the speakers. + */ +void radio_disableAfOutput(); + /** * Enable the RX stage. */ diff --git a/platform/drivers/baseband/AT1846S.h b/platform/drivers/baseband/AT1846S.h index 1936f5a8..734f8d61 100644 --- a/platform/drivers/baseband/AT1846S.h +++ b/platform/drivers/baseband/AT1846S.h @@ -318,6 +318,24 @@ public: i2c_writeReg16(0x49, static_cast< uint16_t >(thresh)); } + /** + * Mute the RX audio output while keeping the chip in RX mode. + */ + inline void muteRxOutput() + { + // Setting bit 7 of register 0x30 mutes the RX audio output + maskSetRegister(0x30, 0x0080, 0x0080); + } + + /** + * Unmute the RX audio output. + */ + inline void unmuteRxOutput() + { + // Clearing bit 7 of register 0x30 unmutes the RX audio output + maskSetRegister(0x30, 0x0080, 0x0000); + } + private: /** diff --git a/platform/drivers/baseband/HR_C6000_UV3x0.cpp b/platform/drivers/baseband/HR_C6000_UV3x0.cpp index e313709a..2bfacb09 100644 --- a/platform/drivers/baseband/HR_C6000_UV3x0.cpp +++ b/platform/drivers/baseband/HR_C6000_UV3x0.cpp @@ -171,7 +171,6 @@ void HR_Cx000< M >::fmMode() 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 - writeReg(M::CONFIG, 0x36, 0x02); // Enable voice channel in FM mode writeReg(M::CONFIG, 0xE4, 0x27); // Lineout gain, first and second stage mic gain writeReg(M::CONFIG, 0xE2, 0x06); // Mic preamp disabled, anti-pop enabled writeReg(M::CONFIG, 0x34, 0x98); // FM bpf enabled, 25kHz bandwidth diff --git a/platform/drivers/baseband/radio_GDx.cpp b/platform/drivers/baseband/radio_GDx.cpp index ee133b18..412438a3 100644 --- a/platform/drivers/baseband/radio_GDx.cpp +++ b/platform/drivers/baseband/radio_GDx.cpp @@ -79,10 +79,12 @@ void radio_init(const rtxStatus_t *rtxState) | DAC_C0_DACEN_MASK; // Enable DAC /* - * Enable and configure both AT1846S and HR_C6000 + * Enable and configure both AT1846S and HR_C6000, keep AF output disabled + * at power on. */ at1846s.init(); C6000.init(); + radio_disableAfOutput(); } void radio_terminate() @@ -132,6 +134,17 @@ bool radio_checkRxDigitalSquelch() return at1846s.rxCtcssDetected(); } +void radio_enableAfOutput() +{ + // TODO: AF output management for DMR mode + at1846s.unmuteRxOutput(); +} + +void radio_disableAfOutput() +{ + at1846s.muteRxOutput(); +} + void radio_enableRx() { gpio_clearPin(VHF_LNA_EN); diff --git a/platform/drivers/baseband/radio_MD3x0.cpp b/platform/drivers/baseband/radio_MD3x0.cpp index 1612ee32..15697fee 100644 --- a/platform/drivers/baseband/radio_MD3x0.cpp +++ b/platform/drivers/baseband/radio_MD3x0.cpp @@ -110,15 +110,14 @@ void radio_init(const rtxStatus_t *rtxState) gpio_setMode(RF_APC_SW, OUTPUT); gpio_setMode(TX_STG_EN, OUTPUT); gpio_setMode(RX_STG_EN, OUTPUT); - - gpio_setMode(FM_MUTE, OUTPUT); - gpio_clearPin(FM_MUTE); + gpio_setMode(FM_MUTE, OUTPUT); gpio_clearPin(PLL_PWR); // PLL off gpio_setPin(VCOVCC_SW); // VCOVCC high enables RX VCO, TX VCO if low #ifndef MDx_ENABLE_SWD gpio_setPin(WN_SW); // 25kHz bandwidth #endif + gpio_clearPin(FM_MUTE); // Mute FM AF output gpio_clearPin(DMR_SW); // Disconnect HR_C5000 input IF signal and audio out gpio_clearPin(FM_SW); // Disconnect analog FM audio path gpio_clearPin(RF_APC_SW); // Disable TX power control @@ -229,6 +228,17 @@ bool radio_checkRxDigitalSquelch() return false; } +void radio_enableAfOutput() +{ + // TODO: AF output management for DMR mode + gpio_setPin(FM_MUTE); +} + +void radio_disableAfOutput() +{ + gpio_clearPin(FM_MUTE); +} + void radio_enableRx() { gpio_clearPin(TX_STG_EN); // Disable TX PA @@ -252,12 +262,6 @@ void radio_enableRx() DAC->DHR12L1 = vtune_rx * 0xFF; gpio_setPin(RX_STG_EN); // Enable RX LNA - - if(config->opMode == OPMODE_FM) - { - gpio_setPin(FM_MUTE); // In FM mode, unmute audio path towards speaker - } - radioStatus = RX; } diff --git a/platform/drivers/baseband/radio_MD9600.cpp b/platform/drivers/baseband/radio_MD9600.cpp index 36753625..58b5ed3d 100644 --- a/platform/drivers/baseband/radio_MD9600.cpp +++ b/platform/drivers/baseband/radio_MD9600.cpp @@ -46,6 +46,16 @@ bool radio_checkRxDigitalSquelch() return false; } +void radio_enableAfOutput() +{ + +} + +void radio_disableAfOutput() +{ + +} + void radio_enableRx() { diff --git a/platform/drivers/baseband/radio_Mod17.cpp b/platform/drivers/baseband/radio_Mod17.cpp index c2ff7e7c..257ca262 100644 --- a/platform/drivers/baseband/radio_Mod17.cpp +++ b/platform/drivers/baseband/radio_Mod17.cpp @@ -52,6 +52,16 @@ bool radio_checkRxDigitalSquelch() return false; } +void radio_enableAfOutput() +{ + +} + +void radio_disableAfOutput() +{ + +} + void radio_enableRx() { radioStatus = RX; diff --git a/platform/drivers/baseband/radio_UV3x0.cpp b/platform/drivers/baseband/radio_UV3x0.cpp index 28f5dd2f..6c28532e 100644 --- a/platform/drivers/baseband/radio_UV3x0.cpp +++ b/platform/drivers/baseband/radio_UV3x0.cpp @@ -84,10 +84,11 @@ void radio_init(const rtxStatus_t *rtxState) DAC->DHR12R1 = 0; /* - * Configure AT1846S and HR_C6000 + * Configure AT1846S and HR_C6000, keep AF output disabled at power on. */ at1846s.init(); C6000.init(); + radio_disableAfOutput(); } void radio_terminate() @@ -141,6 +142,18 @@ bool radio_checkRxDigitalSquelch() return at1846s.rxCtcssDetected(); } +void radio_enableAfOutput() +{ + // Bit 2 of register 0x36: enable voice channel in FM mode + // TODO: AF output management for DMR mode + C6000.writeCfgRegister(0x36, 0x02); +} + +void radio_disableAfOutput() +{ + C6000.writeCfgRegister(0x36, 0x00); +} + void radio_enableRx() { gpio_clearPin(PA_EN_1);