From 66552be403d00c3cdbe2642b843d139c27d133ed Mon Sep 17 00:00:00 2001 From: Silvano Seva Date: Thu, 3 Jun 2021 14:50:47 +0200 Subject: [PATCH] Added function to radio API allowing to fine tune the radio's VCXO polarisation voltage. Currently, this functionality is effective only on MD-3x0 devices. (TG-195 #ready-for-test) --- openrtx/include/input.h | 6 ++++-- openrtx/include/interfaces/radio.h | 13 ++++++++++++ platform/drivers/baseband/radio_GDx.cpp | 8 ++++++++ platform/drivers/baseband/radio_MD3x0.cpp | 23 ++++++++++++++++++++++ platform/drivers/baseband/radio_MD9600.cpp | 8 +++++++- platform/drivers/baseband/radio_UV3x0.cpp | 8 ++++++++ platform/drivers/baseband/radio_linux.cpp | 7 +++++++ 7 files changed, 70 insertions(+), 3 deletions(-) diff --git a/openrtx/include/input.h b/openrtx/include/input.h index 585c56b3..1c4603fc 100644 --- a/openrtx/include/input.h +++ b/openrtx/include/input.h @@ -23,14 +23,16 @@ #include #include -/* This function returns true if at least one number is pressed on the +/** + * This function returns true if at least one number is pressed on the * keyboard. * @param msg: the keyboard queue message * @return true if at least a number is pressed on the keyboard */ bool input_isNumberPressed(kbd_msg_t msg); -/* This function returns the smallest number that is pressed on the keyboard, +/** + * This function returns the smallest number that is pressed on the keyboard, * 0 if none is pressed. * @param msg: the keyboard queue message * @return the smalled pressed number on the keyboard diff --git a/openrtx/include/interfaces/radio.h b/openrtx/include/interfaces/radio.h index 6a78cf86..63938d57 100644 --- a/openrtx/include/interfaces/radio.h +++ b/openrtx/include/interfaces/radio.h @@ -55,6 +55,19 @@ void radio_init(const rtxStatus_t *rtxState); */ void radio_terminate(); +/** + * This function allows to fine tune the VCXO frequency by acting on the + * polarisation voltage. + * The offset parameters allowed range of ±32768 and they are algebraically + * added to the tuning value provided by the manufacturer's calibration data. + * Not calling this function results in leaving the VCXO tuning as provided by + * the manufacturer's calibration data. + * + * @param vhfOffset: VCXO tuning offset for VHF band. + * @param uhfOffset: VCXO tuning offset for UHF band. + */ +void radio_tuneVcxo(const int16_t vhfOffset, const int16_t uhfOffset); + /** * Set current operating mode. * diff --git a/platform/drivers/baseband/radio_GDx.cpp b/platform/drivers/baseband/radio_GDx.cpp index 9f1e3d94..b02825f1 100644 --- a/platform/drivers/baseband/radio_GDx.cpp +++ b/platform/drivers/baseband/radio_GDx.cpp @@ -96,6 +96,14 @@ void radio_terminate() SIM->SCGC6 &= ~SIM_SCGC6_DAC0_MASK; } +void radio_tuneVcxo(const int16_t vhfOffset, const int16_t uhfOffset) +{ + //TODO: this part will be implemented in the future, when proved to be + // necessary. + (void) vhfOffset; + (void) uhfOffset; +} + void radio_setOpmode(const enum opmode mode) { switch(mode) diff --git a/platform/drivers/baseband/radio_MD3x0.cpp b/platform/drivers/baseband/radio_MD3x0.cpp index f95b3d77..3455f3e2 100644 --- a/platform/drivers/baseband/radio_MD3x0.cpp +++ b/platform/drivers/baseband/radio_MD3x0.cpp @@ -160,6 +160,29 @@ void radio_terminate() RCC->APB1ENR &= ~RCC_APB1ENR_DACEN; } +void radio_tuneVcxo(const int16_t vhfOffset, const int16_t uhfOffset) +{ + (void) vhfOffset; + + /* + * Adjust VCXO bias voltage acting on the value stored in MCU's DAC. + * Data from calibration is first converted to int16_t, then the value for + * the DAC register is computed according to which is done inside TYT's + * firmware. + * The signed offset is then added to this value, the result is constrained + * in the range [0 4095], converted to uint16_t and written into the DAC + * register. + * + * NOTE: we deliberately chose not to update the HR_C5000 modulation offset + * register, as we still have to deeply understand how TYT computes + * the values written there. + */ + int16_t calValue = static_cast< int16_t >(calData->freqAdjustMid); + int16_t oscTune = (calValue*4 + 0x600) + uhfOffset; + oscTune = std::max(std::min(oscTune, int16_t(4095)), int16_t(0)); + DAC->DHR12R2 = static_cast< uint16_t >(oscTune); +} + void radio_setOpmode(const enum opmode mode) { switch(mode) diff --git a/platform/drivers/baseband/radio_MD9600.cpp b/platform/drivers/baseband/radio_MD9600.cpp index 51376474..4d811786 100644 --- a/platform/drivers/baseband/radio_MD9600.cpp +++ b/platform/drivers/baseband/radio_MD9600.cpp @@ -30,6 +30,12 @@ void radio_terminate() } +void radio_tuneVcxo(const int16_t vhfOffset, const int16_t uhfOffset) +{ + (void) vhfOffset; + (void) uhfOffset; +} + void radio_setOpmode(const enum opmode mode) { (void) mode; @@ -37,7 +43,7 @@ void radio_setOpmode(const enum opmode mode) bool radio_checkRxDigitalSquelch() { - return true; + return false; } void radio_enableRx() diff --git a/platform/drivers/baseband/radio_UV3x0.cpp b/platform/drivers/baseband/radio_UV3x0.cpp index ca4da1f9..110197f2 100644 --- a/platform/drivers/baseband/radio_UV3x0.cpp +++ b/platform/drivers/baseband/radio_UV3x0.cpp @@ -100,6 +100,14 @@ void radio_terminate() RCC->APB1ENR &= ~RCC_APB1ENR_DACEN; } +void radio_tuneVcxo(const int16_t vhfOffset, const int16_t uhfOffset) +{ + //TODO: this part will be implemented in the future, when proved to be + // necessary. + (void) vhfOffset; + (void) uhfOffset; +} + void radio_setOpmode(const enum opmode mode) { switch(mode) diff --git a/platform/drivers/baseband/radio_linux.cpp b/platform/drivers/baseband/radio_linux.cpp index aeb001e6..1f159af1 100644 --- a/platform/drivers/baseband/radio_linux.cpp +++ b/platform/drivers/baseband/radio_linux.cpp @@ -33,6 +33,13 @@ void radio_terminate() puts("radio_linux: terminate() called"); } +void radio_tuneVcxo(const int16_t vhfOffset, const int16_t uhfOffset) +{ + (void) vhfOffset; + (void) uhfOffset; + puts("radio_linux: tuneVcxo() called"); +} + void radio_setOpmode(const enum opmode mode) { std::string mStr(" ");