From 887d95ec583e9bf03bd00ecdecd4c3179c3439bf Mon Sep 17 00:00:00 2001 From: Silvano Seva Date: Thu, 15 Apr 2021 22:36:36 +0200 Subject: [PATCH] Created 'wrappers' subfolder in platform/drivers/baseband containing the C wrappers for the AT1846S, HR_C5000 and HR_C6000 drivers --- .../{ => wrappers}/AT1846S_wrapper.cpp | 3 +- .../baseband/{ => wrappers}/AT1846S_wrapper.h | 6 +- .../baseband/wrappers/HR_C5000_wrapper.cpp | 68 +++++++++++++ .../baseband/wrappers/HR_C5000_wrapper.h | 96 ++++++++++++++++++ .../baseband/wrappers/HR_C6000_wrapper.cpp | 78 +++++++++++++++ .../baseband/wrappers/HR_C6000_wrapper.h | 97 +++++++++++++++++++ 6 files changed, 343 insertions(+), 5 deletions(-) rename platform/drivers/baseband/{ => wrappers}/AT1846S_wrapper.cpp (98%) rename platform/drivers/baseband/{ => wrappers}/AT1846S_wrapper.h (98%) create mode 100644 platform/drivers/baseband/wrappers/HR_C5000_wrapper.cpp create mode 100644 platform/drivers/baseband/wrappers/HR_C5000_wrapper.h create mode 100644 platform/drivers/baseband/wrappers/HR_C6000_wrapper.cpp create mode 100644 platform/drivers/baseband/wrappers/HR_C6000_wrapper.h diff --git a/platform/drivers/baseband/AT1846S_wrapper.cpp b/platform/drivers/baseband/wrappers/AT1846S_wrapper.cpp similarity index 98% rename from platform/drivers/baseband/AT1846S_wrapper.cpp rename to platform/drivers/baseband/wrappers/AT1846S_wrapper.cpp index 7335e0f9..e7ed5329 100644 --- a/platform/drivers/baseband/AT1846S_wrapper.cpp +++ b/platform/drivers/baseband/wrappers/AT1846S_wrapper.cpp @@ -18,8 +18,7 @@ * along with this program; if not, see * ***************************************************************************/ -#include -#include "new/AT1846S.h" +#include "AT1846S_wrapper.h" #include "AT1846S.h" void AT1846S_init() diff --git a/platform/drivers/baseband/AT1846S_wrapper.h b/platform/drivers/baseband/wrappers/AT1846S_wrapper.h similarity index 98% rename from platform/drivers/baseband/AT1846S_wrapper.h rename to platform/drivers/baseband/wrappers/AT1846S_wrapper.h index 33caf450..d086d90b 100644 --- a/platform/drivers/baseband/AT1846S_wrapper.h +++ b/platform/drivers/baseband/wrappers/AT1846S_wrapper.h @@ -18,8 +18,8 @@ * along with this program; if not, see * ***************************************************************************/ -#ifndef AT1846S_H -#define AT1846S_H +#ifndef AT1846S_WRAPPER_H +#define AT1846S_WRAPPER_H #include #include @@ -186,4 +186,4 @@ void AT1846S_setAnalogSqlThresh(const uint8_t thresh); } #endif -#endif /* AT1846S_H */ +#endif /* AT1846S_WRAPPER_H */ diff --git a/platform/drivers/baseband/wrappers/HR_C5000_wrapper.cpp b/platform/drivers/baseband/wrappers/HR_C5000_wrapper.cpp new file mode 100644 index 00000000..d9c0649c --- /dev/null +++ b/platform/drivers/baseband/wrappers/HR_C5000_wrapper.cpp @@ -0,0 +1,68 @@ +/*************************************************************************** + * Copyright (C) 2021 by Federico Amedeo Izzo IU2NUO, * + * Niccolò Izzo IU2KIN * + * Frederik Saraci IU2NRO * + * Silvano Seva IU2KWO * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, see * + ***************************************************************************/ + +#include "HR_C5000_wrapper.h" +#include "HR_C5000.h" + +void C5000_init() +{ + HR_C5000::instance().init(); +} + +void C5000_terminate() +{ + HR_C5000::instance().terminate(); +} + +void C5000_setModOffset(uint8_t offset) +{ + HR_C5000::instance().setModOffset(offset); +} + +void C5000_setModAmplitude(uint8_t iAmp, uint8_t qAmp) +{ + HR_C5000::instance().setModAmplitude(iAmp, qAmp); +} + +void C5000_setModFactor(uint8_t mf) +{ + HR_C5000::instance().setModFactor(mf); +} + +void C5000_dmrMode() +{ + HR_C5000::instance().dmrMode(); +} + +void C5000_fmMode() +{ + HR_C5000::instance().fmMode(); +} + +void C5000_startAnalogTx() +{ + HR_C5000::instance().startAnalogTx(TxAudioSource::MIC, FmConfig::PREEMPH_EN | + FmConfig::BW_25kHz); +} + +void C5000_stopAnalogTx() +{ + HR_C5000::instance().stopAnalogTx(); +} diff --git a/platform/drivers/baseband/wrappers/HR_C5000_wrapper.h b/platform/drivers/baseband/wrappers/HR_C5000_wrapper.h new file mode 100644 index 00000000..48bf461f --- /dev/null +++ b/platform/drivers/baseband/wrappers/HR_C5000_wrapper.h @@ -0,0 +1,96 @@ +/*************************************************************************** + * Copyright (C) 2021 by Federico Amedeo Izzo IU2NUO, * + * Niccolò Izzo IU2KIN * + * Frederik Saraci IU2NRO * + * Silvano Seva IU2KWO * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, see * + ***************************************************************************/ + +#ifndef HRC5000_WRAPPER_H +#define HRC5000_WRAPPER_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Driver for HR_C5000 "baseband" chip. + * + * WARNING: on MD3x0 devices the PLL and DMR chips share the SPI MOSI line, + * thus particular care has to be put to avoid them stomping reciprocally. + * This driver does not make any check if a SPI transfer is already in progress, + * deferring the correct bus management to higher level modules. However, + * a function returning true if the bus is currently in use by this driver is + * provided. + */ + +/** + * Initialise the HR_C5000 driver. + */ +void C5000_init(); + +/** + * Terminate the HR_C5000 driver. + */ +void C5000_terminate(); + +/** + * Set value for two-point modulation offset adjustment. This value usually is + * stored in radio calibration data. + * @param offset: value for modulation offset adjustment. + */ +void C5000_setModOffset(uint8_t offset); + +/** + * Set values for two-point modulation amplitude adjustment. These values + * usually are stored in radio calibration data. + * @param iMag: value for modulation offset adjustment. + */ +void C5000_setModAmplitude(uint8_t iAmp, uint8_t qAmp); + +/** + * Set value for FM-mode modulation factor, a value dependent on bandwidth. + * @param mf: value for FM modulation factor. + */ +void C5000_setModFactor(uint8_t mf); + +/** + * Configure chipset for DMR operation. + */ +void C5000_dmrMode(); + +/** + * Configure chipset for analog FM operation. + */ +void C5000_fmMode(); + +/** + * Start analog FM transmission. + */ +void C5000_startAnalogTx(); + +/** + * Stop analog FM transmission. + */ +void C5000_stopAnalogTx(); + +#ifdef __cplusplus +} +#endif + +#endif // HRC5000_WRAPPER_H diff --git a/platform/drivers/baseband/wrappers/HR_C6000_wrapper.cpp b/platform/drivers/baseband/wrappers/HR_C6000_wrapper.cpp new file mode 100644 index 00000000..9d2a024b --- /dev/null +++ b/platform/drivers/baseband/wrappers/HR_C6000_wrapper.cpp @@ -0,0 +1,78 @@ +/*************************************************************************** + * Copyright (C) 2021 by Federico Amedeo Izzo IU2NUO, * + * Niccolò Izzo IU2KIN * + * Frederik Saraci IU2NRO * + * Silvano Seva IU2KWO * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, see * + ***************************************************************************/ + +#include "HR_C6000_wrapper.h" +#include "HR_C6000.h" + +void C6000_init() +{ + HR_C6000::instance().init(); +} + +void C6000_terminate() +{ + HR_C6000::instance().terminate(); +} + +void C6000_setModOffset(uint16_t offset) +{ + HR_C6000::instance().setModOffset(offset); +} + +void C6000_setModAmplitude(uint8_t iAmp, uint8_t qAmp) +{ + HR_C6000::instance().setModAmplitude(iAmp, qAmp); +} + +void C6000_setMod2Bias(uint8_t bias) +{ + HR_C6000::instance().writeCfgRegister(0x04, bias); +} + +void C6000_setModFactor(uint8_t mf) +{ + HR_C6000::instance().setModFactor(mf); +} + +void C6000_setDacGain(uint8_t value) +{ + HR_C6000::instance().setDacGain(value); +} + +void C6000_dmrMode() +{ + HR_C6000::instance().dmrMode(); +} + +void C6000_fmMode() +{ + HR_C6000::instance().fmMode(); +} + +void C6000_startAnalogTx() +{ + HR_C6000::instance().startAnalogTx(TxAudioSource::MIC, FmConfig::PREEMPH_EN | + FmConfig::BW_25kHz); +} + +void C6000_stopAnalogTx() +{ + HR_C6000::instance().stopAnalogTx(); +} diff --git a/platform/drivers/baseband/wrappers/HR_C6000_wrapper.h b/platform/drivers/baseband/wrappers/HR_C6000_wrapper.h new file mode 100644 index 00000000..e7d615e6 --- /dev/null +++ b/platform/drivers/baseband/wrappers/HR_C6000_wrapper.h @@ -0,0 +1,97 @@ +/*************************************************************************** + * Copyright (C) 2021 by Federico Amedeo Izzo IU2NUO, * + * Niccolò Izzo IU2KIN * + * Frederik Saraci IU2NRO * + * Silvano Seva IU2KWO * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, see * + ***************************************************************************/ + +#ifndef HRC6000_WRAPPER_H +#define HRC6000_WRAPPER_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Initialise the HR_C6000 driver. + */ +void C6000_init(); + +/** + * Terminate the HR_C6000 driver. + */ +void C6000_terminate(); + +/** + * Set value for two-point modulation offset adjustment. This value usually is + * stored in radio calibration data. + * @param offset: value for modulation offset adjustment. + */ +void C6000_setModOffset(uint16_t offset); + +/** + * Set values for two-point modulation amplitude adjustment. These values + * usually are stored in radio calibration data. + * @param iMag: value for modulation offset adjustment. + */ +void C6000_setModAmplitude(uint8_t iAmp, uint8_t qAmp); + +/** + * + */ +void C6000_setMod2Bias(uint8_t bias); + +/** + * Set value for FM-mode modulation factor, a value dependent on bandwidth. + * @param mf: value for FM modulation factor. + */ +void C6000_setModFactor(uint8_t mf); + +/** + * Configure the gain of lineout DAC stage. Allowed range is 1 - 31 and each + * step corresponds to a variation of 1.5dB. + * @param value: gain for the DAC stage. + */ +void C6000_setDacGain(uint8_t value); + +/** + * Configure chipset for DMR operation. + */ +void C6000_dmrMode(); + +/** + * Configure chipset for analog FM operation. + */ +void C6000_fmMode(); + +/** + * Start analog FM transmission. + */ +void C6000_startAnalogTx(); + +/** + * Stop analog FM transmission. + */ +void C6000_stopAnalogTx(); + +#ifdef __cplusplus +} +#endif + +#endif // HRC6000_WRAPPER_H