From 1fa13d63d834b6b2c939d82999f53ea9611db43b Mon Sep 17 00:00:00 2001 From: Silvano Seva Date: Mon, 1 Aug 2022 18:29:20 +0200 Subject: [PATCH] Modified radio drivers so that bandwidth parameter in radio configuration is ignored for operating modes different from analog FM. Fixes #100 --- platform/drivers/baseband/radio_GDx.cpp | 29 ++++++++++++++++------- platform/drivers/baseband/radio_MD3x0.cpp | 12 ++++++---- platform/drivers/baseband/radio_UV3x0.cpp | 25 +++++++++++++------ 3 files changed, 46 insertions(+), 20 deletions(-) diff --git a/platform/drivers/baseband/radio_GDx.cpp b/platform/drivers/baseband/radio_GDx.cpp index 4ae15b49..ee133b18 100644 --- a/platform/drivers/baseband/radio_GDx.cpp +++ b/platform/drivers/baseband/radio_GDx.cpp @@ -118,6 +118,8 @@ void radio_setOpmode(const enum opmode mode) gpio_clearPin(RX_AUDIO_MUX); // Audio out to HR_C6000 gpio_setPin(TX_AUDIO_MUX); // Audio in from HR_C6000 at1846s.setOpMode(AT1846S_OpMode::DMR); + at1846s.setBandwidth(AT1846S_BW::_12P5); + at1846s.setTxDeviation(calData->data[currTxBand].mixGainNarrowband); break; default: @@ -316,16 +318,25 @@ void radio_updateConfiguration() float apc = pwrLo + (pwrHi - pwrLo)/4.0f*(power - 1.0f); apcVoltage = static_cast< uint16_t >(apc) * 16; - // Set bandwidth and TX deviation, force 12.5kHz for DMR mode - if((config->bandwidth == BW_12_5) || (config->opMode == OPMODE_DMR)) + // Set bandwidth, only for analog FM mode + if(config->opMode == OPMODE_FM) { - at1846s.setBandwidth(AT1846S_BW::_12P5); - at1846s.setTxDeviation(calData->data[currTxBand].mixGainNarrowband); - } - else - { - at1846s.setBandwidth(AT1846S_BW::_25); - at1846s.setTxDeviation(calData->data[currTxBand].mixGainWideband); + switch(config->bandwidth) + { + case BW_12_5: + at1846s.setBandwidth(AT1846S_BW::_12P5); + at1846s.setTxDeviation(calData->data[currTxBand].mixGainNarrowband); + break; + + case BW_20: + case BW_25: + at1846s.setBandwidth(AT1846S_BW::_25); + at1846s.setTxDeviation(calData->data[currTxBand].mixGainWideband); + break; + + default: + break; + } } /* diff --git a/platform/drivers/baseband/radio_MD3x0.cpp b/platform/drivers/baseband/radio_MD3x0.cpp index 536902c5..5375ab3e 100644 --- a/platform/drivers/baseband/radio_MD3x0.cpp +++ b/platform/drivers/baseband/radio_MD3x0.cpp @@ -207,12 +207,14 @@ void radio_setOpmode(const enum opmode mode) case OPMODE_DMR: gpio_clearPin(FM_SW); // Disable analog RX stage after superhet gpio_setPin(DMR_SW); // Enable analog paths for DMR + _setBandwidth(BW_12_5); // Set bandwidth to 12.5kHz //C5000_dmrMode(); break; case OPMODE_M17: gpio_clearPin(DMR_SW); // Disconnect analog paths for DMR gpio_setPin(FM_SW); // Enable analog RX stage after superhet + _setBandwidth(BW_25); // Set bandwidth to 25kHz for proper deviation C5000.fmMode(); // HR_C5000 in FM mode C5000.setInputGain(-3); // Input gain in dB, found experimentally break; @@ -352,10 +354,12 @@ void radio_updateConfiguration() C5000.setModAmplitude(I, Q); - // Set bandwidth, force 12.5kHz for DMR mode - enum bandwidth bandwidth = static_cast< enum bandwidth >(config->bandwidth); - if(config->opMode == OPMODE_DMR) bandwidth = BW_12_5; - _setBandwidth(bandwidth); + // Set bandwidth, only for analog FM mode + if(config->opMode == OPMODE_FM) + { + enum bandwidth bw = static_cast< enum bandwidth >(config->bandwidth); + _setBandwidth(bw); + } // Set CTCSS tone float tone = static_cast< float >(config->txTone) / 10.0f; diff --git a/platform/drivers/baseband/radio_UV3x0.cpp b/platform/drivers/baseband/radio_UV3x0.cpp index 7c251508..28f5dd2f 100644 --- a/platform/drivers/baseband/radio_UV3x0.cpp +++ b/platform/drivers/baseband/radio_UV3x0.cpp @@ -120,11 +120,13 @@ void radio_setOpmode(const enum opmode mode) case OPMODE_DMR: at1846s.setOpMode(AT1846S_OpMode::DMR); + at1846s.setBandwidth(AT1846S_BW::_12P5); // C6000.dmrMode(); break; case OPMODE_M17: at1846s.setOpMode(AT1846S_OpMode::DMR); // AT1846S in DMR mode, disables RX filter + at1846s.setBandwidth(AT1846S_BW::_25); // Set bandwidth to 25kHz for proper deviation C6000.fmMode(); // HR_C6000 in FM mode C6000.setInputGain(+6); // Input gain in dB, found experimentally break; @@ -312,14 +314,23 @@ void radio_updateConfiguration() calPoints); C6000.setModAmplitude(0, Q); - // Set bandwidth, force 12.5kHz for DMR mode - if((config->bandwidth == BW_12_5) || (config->opMode == OPMODE_DMR)) + // Set bandwidth, only for analog FM mode + if(config->opMode == OPMODE_FM) { - at1846s.setBandwidth(AT1846S_BW::_12P5); - } - else - { - at1846s.setBandwidth(AT1846S_BW::_25); + switch(config->bandwidth) + { + case BW_12_5: + at1846s.setBandwidth(AT1846S_BW::_12P5); + break; + + case BW_20: + case BW_25: + at1846s.setBandwidth(AT1846S_BW::_25); + break; + + default: + break; + } } /*