Removed platform_getCalibrationData() function because of limited usefulness.
Given that each radio driver loads its calibration data when initializing and that the radio driver is strongly platform-specific, there is no strong need for an intermediate redirection layer through the platform API.
This commit is contained in:
parent
6d58230c8c
commit
313e9615a6
|
|
@ -149,15 +149,6 @@ void platform_beepStop();
|
||||||
*/
|
*/
|
||||||
void platform_setBacklightLevel(uint8_t level);
|
void platform_setBacklightLevel(uint8_t level);
|
||||||
|
|
||||||
/**
|
|
||||||
* This function returns a pointer to the device-specific calbration data,
|
|
||||||
* application code has to cast it to the correct data structure.
|
|
||||||
* WARNING: calling code must ensure that free() is never called on the returned
|
|
||||||
* pointer!
|
|
||||||
* @return pointer to device's calibration data.
|
|
||||||
*/
|
|
||||||
const void *platform_getCalibrationData();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function returns a pointer to a data structure containing all the
|
* This function returns a pointer to a data structure containing all the
|
||||||
* hardware information.
|
* hardware information.
|
||||||
|
|
|
||||||
|
|
@ -25,9 +25,12 @@
|
||||||
#include <OpMode_M17.hpp>
|
#include <OpMode_M17.hpp>
|
||||||
#include <audio_codec.h>
|
#include <audio_codec.h>
|
||||||
#include <rtx.h>
|
#include <rtx.h>
|
||||||
|
|
||||||
#ifdef PLATFORM_MOD17
|
#ifdef PLATFORM_MOD17
|
||||||
#include <calibInfo_Mod17.h>
|
#include <calibInfo_Mod17.h>
|
||||||
#include <interfaces/platform.h>
|
#include <interfaces/platform.h>
|
||||||
|
|
||||||
|
extern mod17Calib_t mod17CalData;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
@ -87,10 +90,8 @@ void OpMode_M17::update(rtxStatus_t *const status, const bool newCfg)
|
||||||
//
|
//
|
||||||
// Get phase inversion settings from calibration.
|
// Get phase inversion settings from calibration.
|
||||||
//
|
//
|
||||||
const mod17Calib_t *calData =
|
invertTxPhase = (mod17CalData.tx_invert == 1) ? true : false;
|
||||||
reinterpret_cast< const mod17Calib_t * >(platform_getCalibrationData());
|
invertRxPhase = (mod17CalData.rx_invert == 1) ? true : false;
|
||||||
invertTxPhase = (calData->tx_invert == 1) ? true : false;
|
|
||||||
invertRxPhase = (calData->rx_invert == 1) ? true : false;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Main FSM logic
|
// Main FSM logic
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ static const uint32_t MEM_MAGIC = 0x584E504F; // "OPNX"
|
||||||
static const uint32_t baseAddress = 0x080E0000;
|
static const uint32_t baseAddress = 0x080E0000;
|
||||||
memory_t *memory = ((memory_t *) baseAddress);
|
memory_t *memory = ((memory_t *) baseAddress);
|
||||||
|
|
||||||
extern mod17Calib_t mod17CalData; // Calibration data, to be saved and loaded
|
mod17Calib_t mod17CalData; // Calibration data, to be saved and loaded
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \internal
|
* \internal
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,8 @@
|
||||||
* along with this program; if not, see <http://www.gnu.org/licenses/> *
|
* along with this program; if not, see <http://www.gnu.org/licenses/> *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#include <interfaces/platform.h>
|
|
||||||
#include <interfaces/radio.h>
|
#include <interfaces/radio.h>
|
||||||
|
#include <interfaces/nvmem.h>
|
||||||
#include <interfaces/gpio.h>
|
#include <interfaces/gpio.h>
|
||||||
#include <calibInfo_GDx.h>
|
#include <calibInfo_GDx.h>
|
||||||
#include <hwconfig.h>
|
#include <hwconfig.h>
|
||||||
|
|
@ -29,9 +29,9 @@
|
||||||
#include "HR_C6000.h"
|
#include "HR_C6000.h"
|
||||||
#include "AT1846S.h"
|
#include "AT1846S.h"
|
||||||
|
|
||||||
const gdxCalibration_t *calData; // Pointer to calibration data
|
|
||||||
const rtxStatus_t *config; // Pointer to data structure with radio configuration
|
const rtxStatus_t *config; // Pointer to data structure with radio configuration
|
||||||
|
|
||||||
|
static gdxCalibration_t calData; // Calibration data
|
||||||
Band currRxBand = BND_NONE; // Current band for RX
|
Band currRxBand = BND_NONE; // Current band for RX
|
||||||
Band currTxBand = BND_NONE; // Current band for TX
|
Band currTxBand = BND_NONE; // Current band for TX
|
||||||
uint16_t apcVoltage = 0; // APC voltage for TX output power control
|
uint16_t apcVoltage = 0; // APC voltage for TX output power control
|
||||||
|
|
@ -43,11 +43,6 @@ AT1846S& at1846s = AT1846S::instance(); // AT1846S driver
|
||||||
|
|
||||||
void radio_init(const rtxStatus_t *rtxState)
|
void radio_init(const rtxStatus_t *rtxState)
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
* Load calibration data
|
|
||||||
*/
|
|
||||||
calData = reinterpret_cast< const gdxCalibration_t * >(platform_getCalibrationData());
|
|
||||||
|
|
||||||
config = rtxState;
|
config = rtxState;
|
||||||
radioStatus = OFF;
|
radioStatus = OFF;
|
||||||
|
|
||||||
|
|
@ -78,6 +73,11 @@ void radio_init(const rtxStatus_t *rtxState)
|
||||||
DAC0->C0 |= DAC_C0_DACRFS_MASK // Reference voltage is Vref2
|
DAC0->C0 |= DAC_C0_DACRFS_MASK // Reference voltage is Vref2
|
||||||
| DAC_C0_DACEN_MASK; // Enable DAC
|
| DAC_C0_DACEN_MASK; // Enable DAC
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Load calibration data
|
||||||
|
*/
|
||||||
|
nvm_readCalibData(&calData);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Enable and configure both AT1846S and HR_C6000, keep AF output disabled
|
* Enable and configure both AT1846S and HR_C6000, keep AF output disabled
|
||||||
* at power on.
|
* at power on.
|
||||||
|
|
@ -121,7 +121,7 @@ void radio_setOpmode(const enum opmode mode)
|
||||||
gpio_setPin(TX_AUDIO_MUX); // Audio in from HR_C6000
|
gpio_setPin(TX_AUDIO_MUX); // Audio in from HR_C6000
|
||||||
at1846s.setOpMode(AT1846S_OpMode::DMR);
|
at1846s.setOpMode(AT1846S_OpMode::DMR);
|
||||||
at1846s.setBandwidth(AT1846S_BW::_12P5);
|
at1846s.setBandwidth(AT1846S_BW::_12P5);
|
||||||
at1846s.setTxDeviation(calData->data[currTxBand].mixGainNarrowband);
|
at1846s.setTxDeviation(calData.data[currTxBand].mixGainNarrowband);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
@ -157,8 +157,8 @@ void radio_enableRx()
|
||||||
if(currRxBand == BND_NONE) return;
|
if(currRxBand == BND_NONE) return;
|
||||||
|
|
||||||
// Adjust reference oscillator bias and offset.
|
// Adjust reference oscillator bias and offset.
|
||||||
C6000.writeCfgRegister(0x04, calData->data[currRxBand].mod2Offset);
|
C6000.writeCfgRegister(0x04, calData.data[currRxBand].mod2Offset);
|
||||||
C6000.setModOffset(calData->data[currRxBand].modBias);
|
C6000.setModOffset(calData.data[currRxBand].modBias);
|
||||||
|
|
||||||
// Set frequency and enable AT1846S RX
|
// Set frequency and enable AT1846S RX
|
||||||
at1846s.setFrequency(config->rxFrequency);
|
at1846s.setFrequency(config->rxFrequency);
|
||||||
|
|
@ -194,8 +194,8 @@ void radio_enableTx()
|
||||||
if(currTxBand == BND_NONE) return;
|
if(currTxBand == BND_NONE) return;
|
||||||
|
|
||||||
// Adjust reference oscillator bias and offset.
|
// Adjust reference oscillator bias and offset.
|
||||||
C6000.writeCfgRegister(0x04, calData->data[currTxBand].mod2Offset);
|
C6000.writeCfgRegister(0x04, calData.data[currTxBand].mod2Offset);
|
||||||
C6000.setModOffset(calData->data[currTxBand].modBias);
|
C6000.setModOffset(calData.data[currTxBand].modBias);
|
||||||
|
|
||||||
// Set frequency and enable AT1846S TX
|
// Set frequency and enable AT1846S TX
|
||||||
at1846s.setFrequency(config->txFrequency);
|
at1846s.setFrequency(config->txFrequency);
|
||||||
|
|
@ -252,7 +252,7 @@ void radio_updateConfiguration()
|
||||||
/*
|
/*
|
||||||
* Parameters dependent on RX frequency only
|
* Parameters dependent on RX frequency only
|
||||||
*/
|
*/
|
||||||
const bandCalData_t *cal = &(calData->data[currRxBand]);
|
const bandCalData_t *cal = &(calData.data[currRxBand]);
|
||||||
|
|
||||||
at1846s.setRxAudioGain(cal->rxDacGain, cal->rxVoiceGain);
|
at1846s.setRxAudioGain(cal->rxDacGain, cal->rxVoiceGain);
|
||||||
|
|
||||||
|
|
@ -274,12 +274,12 @@ void radio_updateConfiguration()
|
||||||
uint8_t sqlTresh = 0;
|
uint8_t sqlTresh = 0;
|
||||||
if(currRxBand == BND_VHF)
|
if(currRxBand == BND_VHF)
|
||||||
{
|
{
|
||||||
sqlTresh = interpCalParameter(config->rxFrequency, calData->vhfCalPoints,
|
sqlTresh = interpCalParameter(config->rxFrequency, calData.vhfCalPoints,
|
||||||
cal->analogSqlThresh, 8);
|
cal->analogSqlThresh, 8);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sqlTresh = interpCalParameter(config->rxFrequency, calData->uhfCalPoints,
|
sqlTresh = interpCalParameter(config->rxFrequency, calData.uhfCalPoints,
|
||||||
cal->analogSqlThresh, 8);
|
cal->analogSqlThresh, 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -288,10 +288,10 @@ void radio_updateConfiguration()
|
||||||
/*
|
/*
|
||||||
* Parameters dependent on TX frequency only
|
* Parameters dependent on TX frequency only
|
||||||
*/
|
*/
|
||||||
at1846s.setPgaGain(calData->data[currTxBand].PGA_gain);
|
at1846s.setPgaGain(calData.data[currTxBand].PGA_gain);
|
||||||
at1846s.setMicGain(calData->data[currTxBand].analogMicGain);
|
at1846s.setMicGain(calData.data[currTxBand].analogMicGain);
|
||||||
at1846s.setAgcGain(calData->data[currTxBand].rxAGCgain);
|
at1846s.setAgcGain(calData.data[currTxBand].rxAGCgain);
|
||||||
at1846s.setPaDrive(calData->data[currTxBand].PA_drv);
|
at1846s.setPaDrive(calData.data[currTxBand].PA_drv);
|
||||||
|
|
||||||
uint8_t mod1Amp = 0;
|
uint8_t mod1Amp = 0;
|
||||||
uint8_t txpwr_lo = 0;
|
uint8_t txpwr_lo = 0;
|
||||||
|
|
@ -300,25 +300,25 @@ void radio_updateConfiguration()
|
||||||
if(currTxBand == BND_VHF)
|
if(currTxBand == BND_VHF)
|
||||||
{
|
{
|
||||||
/* VHF band */
|
/* VHF band */
|
||||||
txpwr_lo = interpCalParameter(config->txFrequency, calData->vhfCalPoints,
|
txpwr_lo = interpCalParameter(config->txFrequency, calData.vhfCalPoints,
|
||||||
calData->data[currTxBand].txLowPower, 8);
|
calData.data[currTxBand].txLowPower, 8);
|
||||||
|
|
||||||
txpwr_hi = interpCalParameter(config->txFrequency, calData->vhfCalPoints,
|
txpwr_hi = interpCalParameter(config->txFrequency, calData.vhfCalPoints,
|
||||||
calData->data[currTxBand].txHighPower, 8);
|
calData.data[currTxBand].txHighPower, 8);
|
||||||
|
|
||||||
mod1Amp = interpCalParameter(config->txFrequency, calData->vhfCalPoints,
|
mod1Amp = interpCalParameter(config->txFrequency, calData.vhfCalPoints,
|
||||||
cal->mod1Amplitude, 8);
|
cal->mod1Amplitude, 8);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* UHF band */
|
/* UHF band */
|
||||||
txpwr_lo = interpCalParameter(config->txFrequency, calData->uhfPwrCalPoints,
|
txpwr_lo = interpCalParameter(config->txFrequency, calData.uhfPwrCalPoints,
|
||||||
calData->data[currTxBand].txLowPower, 16);
|
calData.data[currTxBand].txLowPower, 16);
|
||||||
|
|
||||||
txpwr_hi = interpCalParameter(config->txFrequency, calData->uhfPwrCalPoints,
|
txpwr_hi = interpCalParameter(config->txFrequency, calData.uhfPwrCalPoints,
|
||||||
calData->data[currTxBand].txHighPower, 16);
|
calData.data[currTxBand].txHighPower, 16);
|
||||||
|
|
||||||
mod1Amp = interpCalParameter(config->txFrequency, calData->uhfCalPoints,
|
mod1Amp = interpCalParameter(config->txFrequency, calData.uhfCalPoints,
|
||||||
cal->mod1Amplitude, 8);
|
cal->mod1Amplitude, 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -338,13 +338,13 @@ void radio_updateConfiguration()
|
||||||
{
|
{
|
||||||
case BW_12_5:
|
case BW_12_5:
|
||||||
at1846s.setBandwidth(AT1846S_BW::_12P5);
|
at1846s.setBandwidth(AT1846S_BW::_12P5);
|
||||||
at1846s.setTxDeviation(calData->data[currTxBand].mixGainNarrowband);
|
at1846s.setTxDeviation(calData.data[currTxBand].mixGainNarrowband);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BW_20:
|
case BW_20:
|
||||||
case BW_25:
|
case BW_25:
|
||||||
at1846s.setBandwidth(AT1846S_BW::_25);
|
at1846s.setBandwidth(AT1846S_BW::_25);
|
||||||
at1846s.setTxDeviation(calData->data[currTxBand].mixGainWideband);
|
at1846s.setTxDeviation(calData.data[currTxBand].mixGainWideband);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,8 @@
|
||||||
* along with this program; if not, see <http://www.gnu.org/licenses/> *
|
* along with this program; if not, see <http://www.gnu.org/licenses/> *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#include <interfaces/platform.h>
|
|
||||||
#include <toneGenerator_MDx.h>
|
#include <toneGenerator_MDx.h>
|
||||||
|
#include <interfaces/nvmem.h>
|
||||||
#include <interfaces/radio.h>
|
#include <interfaces/radio.h>
|
||||||
#include <interfaces/gpio.h>
|
#include <interfaces/gpio.h>
|
||||||
#include <calibInfo_MDx.h>
|
#include <calibInfo_MDx.h>
|
||||||
|
|
@ -32,9 +32,9 @@
|
||||||
|
|
||||||
static const freq_t IF_FREQ = 49950000; // Intermediate frequency: 49.95MHz
|
static const freq_t IF_FREQ = 49950000; // Intermediate frequency: 49.95MHz
|
||||||
|
|
||||||
const md3x0Calib_t *calData; // Pointer to calibration data
|
|
||||||
const rtxStatus_t *config; // Pointer to data structure with radio configuration
|
const rtxStatus_t *config; // Pointer to data structure with radio configuration
|
||||||
|
|
||||||
|
static md3x0Calib_t calData; // Calibration data
|
||||||
bool isVhfBand = false; // True if rtx stage is for VHF band
|
bool isVhfBand = false; // True if rtx stage is for VHF band
|
||||||
uint8_t vtune_rx = 0; // Tuning voltage for RX input filter
|
uint8_t vtune_rx = 0; // Tuning voltage for RX input filter
|
||||||
uint8_t txpwr_lo = 0; // APC voltage for TX output power control, low power
|
uint8_t txpwr_lo = 0; // APC voltage for TX output power control, low power
|
||||||
|
|
@ -88,11 +88,6 @@ void _setBandwidth(const enum bandwidth bw)
|
||||||
|
|
||||||
void radio_init(const rtxStatus_t *rtxState)
|
void radio_init(const rtxStatus_t *rtxState)
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
* Load calibration data
|
|
||||||
*/
|
|
||||||
calData = reinterpret_cast< const md3x0Calib_t * >(platform_getCalibrationData());
|
|
||||||
|
|
||||||
config = rtxState;
|
config = rtxState;
|
||||||
radioStatus = OFF;
|
radioStatus = OFF;
|
||||||
isVhfBand = (platform_getHwInfo()->vhf_band == 1) ? true : false;
|
isVhfBand = (platform_getHwInfo()->vhf_band == 1) ? true : false;
|
||||||
|
|
@ -134,6 +129,11 @@ void radio_init(const rtxStatus_t *rtxState)
|
||||||
DAC->DHR12R2 = 0;
|
DAC->DHR12R2 = 0;
|
||||||
DAC->DHR12R1 = 0;
|
DAC->DHR12R1 = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Load calibration data
|
||||||
|
*/
|
||||||
|
nvm_readCalibData(&calData);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Enable and configure PLL
|
* Enable and configure PLL
|
||||||
*/
|
*/
|
||||||
|
|
@ -148,8 +148,8 @@ void radio_init(const rtxStatus_t *rtxState)
|
||||||
/*
|
/*
|
||||||
* Modulation bias settings, as per TYT firmware.
|
* Modulation bias settings, as per TYT firmware.
|
||||||
*/
|
*/
|
||||||
DAC->DHR12R2 = (calData->freqAdjustMid)*4 + 0x600;
|
DAC->DHR12R2 = (calData.freqAdjustMid)*4 + 0x600;
|
||||||
C5000.setModOffset(calData->freqAdjustMid);
|
C5000.setModOffset(calData.freqAdjustMid);
|
||||||
}
|
}
|
||||||
|
|
||||||
void radio_terminate()
|
void radio_terminate()
|
||||||
|
|
@ -186,7 +186,7 @@ void radio_tuneVcxo(const int16_t vhfOffset, const int16_t uhfOffset)
|
||||||
* register, as we still have to deeply understand how TYT computes
|
* register, as we still have to deeply understand how TYT computes
|
||||||
* the values written there.
|
* the values written there.
|
||||||
*/
|
*/
|
||||||
int16_t calValue = static_cast< int16_t >(calData->freqAdjustMid);
|
int16_t calValue = static_cast< int16_t >(calData.freqAdjustMid);
|
||||||
int16_t oscTune = (calValue*4 + 0x600) + uhfOffset;
|
int16_t oscTune = (calValue*4 + 0x600) + uhfOffset;
|
||||||
oscTune = std::max(std::min(oscTune, int16_t(4095)), int16_t(0));
|
oscTune = std::max(std::min(oscTune, int16_t(4095)), int16_t(0));
|
||||||
DAC->DHR12R2 = static_cast< uint16_t >(oscTune);
|
DAC->DHR12R2 = static_cast< uint16_t >(oscTune);
|
||||||
|
|
@ -333,28 +333,28 @@ void radio_disableRtx()
|
||||||
void radio_updateConfiguration()
|
void radio_updateConfiguration()
|
||||||
{
|
{
|
||||||
// Tuning voltage for RX input filter
|
// Tuning voltage for RX input filter
|
||||||
vtune_rx = interpCalParameter(config->rxFrequency, calData->rxFreq,
|
vtune_rx = interpCalParameter(config->rxFrequency, calData.rxFreq,
|
||||||
calData->rxSensitivity, 9);
|
calData.rxSensitivity, 9);
|
||||||
|
|
||||||
// APC voltage for TX output power control
|
// APC voltage for TX output power control
|
||||||
txpwr_lo = interpCalParameter(config->txFrequency, calData->txFreq,
|
txpwr_lo = interpCalParameter(config->txFrequency, calData.txFreq,
|
||||||
calData->txLowPower, 9);
|
calData.txLowPower, 9);
|
||||||
|
|
||||||
txpwr_hi = interpCalParameter(config->txFrequency, calData->txFreq,
|
txpwr_hi = interpCalParameter(config->txFrequency, calData.txFreq,
|
||||||
calData->txHighPower, 9);
|
calData.txHighPower, 9);
|
||||||
|
|
||||||
// HR_C5000 modulation amplitude
|
// HR_C5000 modulation amplitude
|
||||||
const uint8_t *Ical = calData->sendIrange;
|
const uint8_t *Ical = calData.sendIrange;
|
||||||
const uint8_t *Qcal = calData->sendQrange;
|
const uint8_t *Qcal = calData.sendQrange;
|
||||||
|
|
||||||
if(config->opMode == OPMODE_FM)
|
if(config->opMode == OPMODE_FM)
|
||||||
{
|
{
|
||||||
Ical = calData->analogSendIrange;
|
Ical = calData.analogSendIrange;
|
||||||
Qcal = calData->analogSendQrange;
|
Qcal = calData.analogSendQrange;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t I = interpCalParameter(config->txFrequency, calData->txFreq, Ical, 9);
|
uint8_t I = interpCalParameter(config->txFrequency, calData.txFreq, Ical, 9);
|
||||||
uint8_t Q = interpCalParameter(config->txFrequency, calData->txFreq, Qcal, 9);
|
uint8_t Q = interpCalParameter(config->txFrequency, calData.txFreq, Qcal, 9);
|
||||||
|
|
||||||
C5000.setModAmplitude(I, Q);
|
C5000.setModAmplitude(I, Q);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@
|
||||||
* along with this program; if not, see <http://www.gnu.org/licenses/> *
|
* along with this program; if not, see <http://www.gnu.org/licenses/> *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#include <interfaces/platform.h>
|
|
||||||
#include <interfaces/radio.h>
|
#include <interfaces/radio.h>
|
||||||
#include <interfaces/gpio.h>
|
#include <interfaces/gpio.h>
|
||||||
#include <calibInfo_Mod17.h>
|
#include <calibInfo_Mod17.h>
|
||||||
|
|
@ -27,7 +26,7 @@
|
||||||
#include "../audio/MAX9814.h"
|
#include "../audio/MAX9814.h"
|
||||||
|
|
||||||
enum opstatus radioStatus; // Current operating status
|
enum opstatus radioStatus; // Current operating status
|
||||||
const mod17Calib_t *calData; // Calibration data
|
extern mod17Calib_t mod17CalData; // Calibration data
|
||||||
|
|
||||||
|
|
||||||
void radio_init(const rtxStatus_t *rtxState)
|
void radio_init(const rtxStatus_t *rtxState)
|
||||||
|
|
@ -35,10 +34,9 @@ void radio_init(const rtxStatus_t *rtxState)
|
||||||
(void) rtxState;
|
(void) rtxState;
|
||||||
|
|
||||||
radioStatus = OFF;
|
radioStatus = OFF;
|
||||||
calData = reinterpret_cast< const mod17Calib_t * >(platform_getCalibrationData());
|
|
||||||
|
|
||||||
mcp4551_setWiper(SOFTPOT_TX, calData->tx_wiper);
|
mcp4551_setWiper(SOFTPOT_TX, mod17CalData.tx_wiper);
|
||||||
mcp4551_setWiper(SOFTPOT_RX, calData->rx_wiper);
|
mcp4551_setWiper(SOFTPOT_RX, mod17CalData.rx_wiper);
|
||||||
}
|
}
|
||||||
|
|
||||||
void radio_terminate()
|
void radio_terminate()
|
||||||
|
|
@ -77,8 +75,8 @@ void radio_enableRx()
|
||||||
radioStatus = RX;
|
radioStatus = RX;
|
||||||
gpio_clearPin(PTT_OUT);
|
gpio_clearPin(PTT_OUT);
|
||||||
|
|
||||||
mcp4551_setWiper(SOFTPOT_TX, calData->tx_wiper);
|
mcp4551_setWiper(SOFTPOT_TX, mod17CalData.tx_wiper);
|
||||||
mcp4551_setWiper(SOFTPOT_RX, calData->rx_wiper);
|
mcp4551_setWiper(SOFTPOT_RX, mod17CalData.rx_wiper);
|
||||||
}
|
}
|
||||||
|
|
||||||
void radio_enableTx()
|
void radio_enableTx()
|
||||||
|
|
@ -86,9 +84,9 @@ void radio_enableTx()
|
||||||
radioStatus = TX;
|
radioStatus = TX;
|
||||||
gpio_setPin(PTT_OUT);
|
gpio_setPin(PTT_OUT);
|
||||||
|
|
||||||
mcp4551_setWiper(SOFTPOT_TX, calData->tx_wiper);
|
mcp4551_setWiper(SOFTPOT_TX, mod17CalData.tx_wiper);
|
||||||
mcp4551_setWiper(SOFTPOT_RX, calData->rx_wiper);
|
mcp4551_setWiper(SOFTPOT_RX, mod17CalData.rx_wiper);
|
||||||
max9814_setGain(calData->mic_gain);
|
max9814_setGain(mod17CalData.mic_gain);
|
||||||
}
|
}
|
||||||
|
|
||||||
void radio_disableRtx()
|
void radio_disableRtx()
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
* along with this program; if not, see <http://www.gnu.org/licenses/> *
|
* along with this program; if not, see <http://www.gnu.org/licenses/> *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#include <interfaces/platform.h>
|
#include <interfaces/nvmem.h>
|
||||||
#include <interfaces/radio.h>
|
#include <interfaces/radio.h>
|
||||||
#include <interfaces/gpio.h>
|
#include <interfaces/gpio.h>
|
||||||
#include <calibInfo_MDx.h>
|
#include <calibInfo_MDx.h>
|
||||||
|
|
@ -30,9 +30,9 @@
|
||||||
#include "AT1846S.h"
|
#include "AT1846S.h"
|
||||||
|
|
||||||
|
|
||||||
const mduv3x0Calib_t *calData; // Pointer to calibration data
|
|
||||||
const rtxStatus_t *config; // Pointer to data structure with radio configuration
|
const rtxStatus_t *config; // Pointer to data structure with radio configuration
|
||||||
|
|
||||||
|
static mduv3x0Calib_t calData; // Calibration data
|
||||||
Band currRxBand = BND_NONE; // Current band for RX
|
Band currRxBand = BND_NONE; // Current band for RX
|
||||||
Band currTxBand = BND_NONE; // Current band for TX
|
Band currTxBand = BND_NONE; // Current band for TX
|
||||||
uint8_t txpwr_lo = 0; // APC voltage for TX output power control, low power
|
uint8_t txpwr_lo = 0; // APC voltage for TX output power control, low power
|
||||||
|
|
@ -47,11 +47,6 @@ AT1846S& at1846s = AT1846S::instance(); // AT1846S driver
|
||||||
|
|
||||||
void radio_init(const rtxStatus_t *rtxState)
|
void radio_init(const rtxStatus_t *rtxState)
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
* Load calibration data
|
|
||||||
*/
|
|
||||||
calData = reinterpret_cast< const mduv3x0Calib_t * >(platform_getCalibrationData());
|
|
||||||
|
|
||||||
config = rtxState;
|
config = rtxState;
|
||||||
radioStatus = OFF;
|
radioStatus = OFF;
|
||||||
|
|
||||||
|
|
@ -83,6 +78,11 @@ void radio_init(const rtxStatus_t *rtxState)
|
||||||
DAC->CR = DAC_CR_EN1;
|
DAC->CR = DAC_CR_EN1;
|
||||||
DAC->DHR12R1 = 0;
|
DAC->DHR12R1 = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Load calibration data
|
||||||
|
*/
|
||||||
|
nvm_readCalibData(&calData);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Configure AT1846S and HR_C6000, keep AF output disabled at power on.
|
* Configure AT1846S and HR_C6000, keep AF output disabled at power on.
|
||||||
*/
|
*/
|
||||||
|
|
@ -287,33 +287,28 @@ void radio_updateConfiguration()
|
||||||
* VCXO bias voltage, separated values for TX and RX to allow for cross-band
|
* VCXO bias voltage, separated values for TX and RX to allow for cross-band
|
||||||
* operation.
|
* operation.
|
||||||
*/
|
*/
|
||||||
txModBias = calData->vhfCal.freqAdjustMid;
|
txModBias = calData.vhfCal.freqAdjustMid;
|
||||||
rxModBias = calData->vhfCal.freqAdjustMid;
|
rxModBias = calData.vhfCal.freqAdjustMid;
|
||||||
if(currRxBand == BND_UHF) rxModBias = calData->uhfCal.freqAdjustMid;
|
if(currRxBand == BND_UHF) rxModBias = calData.uhfCal.freqAdjustMid;
|
||||||
if(currTxBand == BND_UHF) txModBias = calData->uhfCal.freqAdjustMid;
|
if(currTxBand == BND_UHF) txModBias = calData.uhfCal.freqAdjustMid;
|
||||||
|
|
||||||
/*
|
|
||||||
* Discarding "const" qualifier to suppress compiler warnings.
|
|
||||||
* This operation is safe anyway because calibration data is only read.
|
|
||||||
*/
|
|
||||||
mduv3x0Calib_t *cal = const_cast< mduv3x0Calib_t * >(calData);
|
|
||||||
uint8_t calPoints = 5;
|
uint8_t calPoints = 5;
|
||||||
freq_t *txCalPoints = cal->vhfCal.txFreq;
|
freq_t *txCalPoints = calData.vhfCal.txFreq;
|
||||||
uint8_t *loPwrCal = cal->vhfCal.txLowPower;
|
uint8_t *loPwrCal = calData.vhfCal.txLowPower;
|
||||||
uint8_t *hiPwrCal = cal->vhfCal.txHighPower;
|
uint8_t *hiPwrCal = calData.vhfCal.txHighPower;
|
||||||
uint8_t *qRangeCal = (config->opMode == OPMODE_FM)
|
uint8_t *qRangeCal = (config->opMode == OPMODE_FM)
|
||||||
? cal->vhfCal.analogSendQrange
|
? calData.vhfCal.analogSendQrange
|
||||||
: cal->vhfCal.sendQrange;
|
: calData.vhfCal.sendQrange;
|
||||||
|
|
||||||
if(currTxBand == BND_UHF)
|
if(currTxBand == BND_UHF)
|
||||||
{
|
{
|
||||||
calPoints = 9;
|
calPoints = 9;
|
||||||
txCalPoints = cal->uhfCal.txFreq;
|
txCalPoints = calData.uhfCal.txFreq;
|
||||||
loPwrCal = cal->uhfCal.txLowPower;
|
loPwrCal = calData.uhfCal.txLowPower;
|
||||||
hiPwrCal = cal->uhfCal.txHighPower;
|
hiPwrCal = calData.uhfCal.txHighPower;
|
||||||
qRangeCal = (config->opMode == OPMODE_FM)
|
qRangeCal = (config->opMode == OPMODE_FM)
|
||||||
? cal->uhfCal.analogSendQrange
|
? calData.uhfCal.analogSendQrange
|
||||||
: cal->uhfCal.sendQrange;
|
: calData.uhfCal.sendQrange;
|
||||||
}
|
}
|
||||||
|
|
||||||
// APC voltage for TX output power control
|
// APC voltage for TX output power control
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,7 @@ void platform_init()
|
||||||
backlight_init(); /* Initialise backlight driver */
|
backlight_init(); /* Initialise backlight driver */
|
||||||
audio_init(); /* Initialise audio management module */
|
audio_init(); /* Initialise audio management module */
|
||||||
adc0_init(); /* Initialise ADC */
|
adc0_init(); /* Initialise ADC */
|
||||||
|
nvm_init(); /* Initialise NVM manager */
|
||||||
pthread_mutex_init(&adc_mutex, NULL);
|
pthread_mutex_init(&adc_mutex, NULL);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -71,14 +72,6 @@ void platform_init()
|
||||||
gpio_setAlternateFunction(I2C_SDA, 3);
|
gpio_setAlternateFunction(I2C_SDA, 3);
|
||||||
gpio_setAlternateFunction(I2C_SCL, 3);
|
gpio_setAlternateFunction(I2C_SCL, 3);
|
||||||
i2c0_init();
|
i2c0_init();
|
||||||
|
|
||||||
/*
|
|
||||||
* Initialise non volatile memory manager and zero calibration data.
|
|
||||||
* Actual loading of calibration data is deferred to the first call of
|
|
||||||
* platform_getCalibrationData().
|
|
||||||
*/
|
|
||||||
nvm_init();
|
|
||||||
memset(&calibration, 0x00, sizeof(gdxCalibration_t));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void platform_terminate()
|
void platform_terminate()
|
||||||
|
|
@ -198,17 +191,6 @@ void platform_beepStop()
|
||||||
/* TODO */
|
/* TODO */
|
||||||
}
|
}
|
||||||
|
|
||||||
const void *platform_getCalibrationData()
|
|
||||||
{
|
|
||||||
/* The first time this function is called, load calibration data from flash */
|
|
||||||
if(calibration.vhfCalPoints[0] == 0)
|
|
||||||
{
|
|
||||||
nvm_readCalibData(&calibration);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ((const void *) &calibration);
|
|
||||||
}
|
|
||||||
|
|
||||||
const hwInfo_t *platform_getHwInfo()
|
const hwInfo_t *platform_getHwInfo()
|
||||||
{
|
{
|
||||||
return &hwInfo;
|
return &hwInfo;
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,7 @@ void platform_init()
|
||||||
backlight_init(); /* Initialise backlight driver */
|
backlight_init(); /* Initialise backlight driver */
|
||||||
audio_init(); /* Initialise audio management module */
|
audio_init(); /* Initialise audio management module */
|
||||||
adc0_init(); /* Initialise ADC */
|
adc0_init(); /* Initialise ADC */
|
||||||
|
nvm_init(); /* Initialise NVM manager */
|
||||||
pthread_mutex_init(&adc_mutex, NULL);
|
pthread_mutex_init(&adc_mutex, NULL);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -71,14 +72,6 @@ void platform_init()
|
||||||
gpio_setAlternateFunction(I2C_SDA, 3);
|
gpio_setAlternateFunction(I2C_SDA, 3);
|
||||||
gpio_setAlternateFunction(I2C_SCL, 3);
|
gpio_setAlternateFunction(I2C_SCL, 3);
|
||||||
i2c0_init();
|
i2c0_init();
|
||||||
|
|
||||||
/*
|
|
||||||
* Initialise non volatile memory manager and zero calibration data.
|
|
||||||
* Actual loading of calibration data is deferred to the first call of
|
|
||||||
* platform_getCalibrationData().
|
|
||||||
*/
|
|
||||||
nvm_init();
|
|
||||||
memset(&calibration, 0x00, sizeof(gdxCalibration_t));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void platform_terminate()
|
void platform_terminate()
|
||||||
|
|
@ -198,17 +191,6 @@ void platform_beepStop()
|
||||||
/* TODO */
|
/* TODO */
|
||||||
}
|
}
|
||||||
|
|
||||||
const void *platform_getCalibrationData()
|
|
||||||
{
|
|
||||||
/* The first time this function is called, load calibration data from flash */
|
|
||||||
if(calibration.vhfCalPoints[0] == 0)
|
|
||||||
{
|
|
||||||
nvm_readCalibData(&calibration);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ((const void *) &calibration);
|
|
||||||
}
|
|
||||||
|
|
||||||
const hwInfo_t *platform_getHwInfo()
|
const hwInfo_t *platform_getHwInfo()
|
||||||
{
|
{
|
||||||
return &hwInfo;
|
return &hwInfo;
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,6 @@
|
||||||
#include <interfaces/rtc.h>
|
#include <interfaces/rtc.h>
|
||||||
#include <interfaces/audio.h>
|
#include <interfaces/audio.h>
|
||||||
|
|
||||||
md3x0Calib_t calibration;
|
|
||||||
static hwInfo_t hwInfo;
|
static hwInfo_t hwInfo;
|
||||||
|
|
||||||
void platform_init()
|
void platform_init()
|
||||||
|
|
@ -61,7 +60,6 @@ void platform_init()
|
||||||
memset(&hwInfo, 0x00, sizeof(hwInfo));
|
memset(&hwInfo, 0x00, sizeof(hwInfo));
|
||||||
|
|
||||||
nvm_init(); /* Initialise non volatile memory manager */
|
nvm_init(); /* Initialise non volatile memory manager */
|
||||||
nvm_readCalibData(&calibration); /* Load calibration data */
|
|
||||||
nvm_readHwInfo(&hwInfo); /* Load hardware information data */
|
nvm_readHwInfo(&hwInfo); /* Load hardware information data */
|
||||||
toneGen_init(); /* Initialise tone generator */
|
toneGen_init(); /* Initialise tone generator */
|
||||||
rtc_init(); /* Initialise RTC */
|
rtc_init(); /* Initialise RTC */
|
||||||
|
|
@ -200,11 +198,6 @@ void platform_beepStop()
|
||||||
toneGen_beepOff();
|
toneGen_beepOff();
|
||||||
}
|
}
|
||||||
|
|
||||||
const void *platform_getCalibrationData()
|
|
||||||
{
|
|
||||||
return ((const void *) &calibration);
|
|
||||||
}
|
|
||||||
|
|
||||||
const hwInfo_t *platform_getHwInfo()
|
const hwInfo_t *platform_getHwInfo()
|
||||||
{
|
{
|
||||||
return &hwInfo;
|
return &hwInfo;
|
||||||
|
|
|
||||||
|
|
@ -220,11 +220,6 @@ void platform_beepStop()
|
||||||
/* TODO */
|
/* TODO */
|
||||||
}
|
}
|
||||||
|
|
||||||
const void *platform_getCalibrationData()
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
const hwInfo_t *platform_getHwInfo()
|
const hwInfo_t *platform_getHwInfo()
|
||||||
{
|
{
|
||||||
return &hwInfo;
|
return &hwInfo;
|
||||||
|
|
|
||||||
|
|
@ -200,11 +200,6 @@ void platform_beepStop()
|
||||||
toneGen_beepOff();
|
toneGen_beepOff();
|
||||||
}
|
}
|
||||||
|
|
||||||
const void *platform_getCalibrationData()
|
|
||||||
{
|
|
||||||
return ((const void *) &calibration);
|
|
||||||
}
|
|
||||||
|
|
||||||
const hwInfo_t *platform_getHwInfo()
|
const hwInfo_t *platform_getHwInfo()
|
||||||
{
|
{
|
||||||
return &hwInfo;
|
return &hwInfo;
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,8 @@
|
||||||
#include <calibInfo_Mod17.h>
|
#include <calibInfo_Mod17.h>
|
||||||
#include <MCP4551.h>
|
#include <MCP4551.h>
|
||||||
|
|
||||||
mod17Calib_t mod17CalData;
|
extern mod17Calib_t mod17CalData;
|
||||||
|
|
||||||
static hwInfo_t hwInfo =
|
static hwInfo_t hwInfo =
|
||||||
{
|
{
|
||||||
.vhf_maxFreq = 0,
|
.vhf_maxFreq = 0,
|
||||||
|
|
@ -187,11 +188,6 @@ void platform_beepStop()
|
||||||
/* TODO */
|
/* TODO */
|
||||||
}
|
}
|
||||||
|
|
||||||
const void *platform_getCalibrationData()
|
|
||||||
{
|
|
||||||
return ((const void *) &mod17CalData);
|
|
||||||
}
|
|
||||||
|
|
||||||
const hwInfo_t *platform_getHwInfo()
|
const hwInfo_t *platform_getHwInfo()
|
||||||
{
|
{
|
||||||
return &hwInfo;
|
return &hwInfo;
|
||||||
|
|
|
||||||
|
|
@ -134,11 +134,6 @@ void platform_beepStop()
|
||||||
printf("platform_beepStop()\n");
|
printf("platform_beepStop()\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
const void *platform_getCalibrationData()
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
const hwInfo_t *platform_getHwInfo()
|
const hwInfo_t *platform_getHwInfo()
|
||||||
{
|
{
|
||||||
return &hwInfo;
|
return &hwInfo;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue