kopia lustrzana https://github.com/OpenRTX/OpenRTX
Basic audio management module, controlling only speaker PA and microphone preamplifier. TG-61
rodzic
90048700ba
commit
c0ecf2e13f
|
@ -89,6 +89,7 @@ def = def + {'GIT_VERSION': git_version}
|
|||
mdx_src = ['platform/drivers/ADC/ADC1_MDx.c',
|
||||
'platform/drivers/GPS/GPS_MDx.cpp',
|
||||
'platform/drivers/NVM/W25Qx.c',
|
||||
'platform/drivers/audio/audio_MDx.c',
|
||||
'platform/drivers/backlight/backlight_MDx.c',
|
||||
'platform/drivers/tones/toneGenerator_MDx.cpp']
|
||||
|
||||
|
@ -107,7 +108,8 @@ gdx_src = ['platform/drivers/NVM/W25Qx.c',
|
|||
'platform/drivers/baseband/HR_C6000.c',
|
||||
'platform/drivers/baseband/interfaces_GDx.c',
|
||||
'platform/drivers/display/UC1701_GDx.c',
|
||||
'platform/drivers/keyboard/keyboard_GDx.c',]
|
||||
'platform/drivers/keyboard/keyboard_GDx.c',
|
||||
'platform/drivers/audio/audio_GDx.c']
|
||||
|
||||
##
|
||||
## --------------------- MCU-dependent source files ----------------------------
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
/***************************************************************************
|
||||
* 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 <http://www.gnu.org/licenses/> *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef AUDIO_H
|
||||
#define AUDIO_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <rtx.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* This file provides a common interface for the platform-dependent low-level
|
||||
* audio driver, in charge of managing microphone and audio amplifier.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Initialise low-level audio management module.
|
||||
*/
|
||||
void audio_init();
|
||||
|
||||
/**
|
||||
* Shut down low-level audio management module.
|
||||
*/
|
||||
void audio_terminate();
|
||||
|
||||
/**
|
||||
* Enable microphone.
|
||||
*/
|
||||
void audio_enableMic();
|
||||
|
||||
/**
|
||||
* Disable microphone.
|
||||
*/
|
||||
void audio_disableMic();
|
||||
|
||||
/**
|
||||
* Enable audio PA.
|
||||
*/
|
||||
void audio_enableAmp();
|
||||
|
||||
/**
|
||||
* Disable audio PA.
|
||||
*/
|
||||
void audio_disableAmp();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* AUDIO_H */
|
|
@ -21,15 +21,13 @@
|
|||
#include <interfaces/platform.h>
|
||||
#include <interfaces/delays.h>
|
||||
#include <interfaces/radio.h>
|
||||
#include <interfaces/audio.h>
|
||||
#include <string.h>
|
||||
#include <rtx.h>
|
||||
#ifdef PLATFORM_MDUV3x0
|
||||
#include "../../platform/drivers/baseband/HR_C6000.h"
|
||||
#endif
|
||||
|
||||
#include <interfaces/gpio.h>
|
||||
#include <hwconfig.h>
|
||||
|
||||
pthread_mutex_t *cfgMutex; /* Mutex for incoming config messages */
|
||||
|
||||
const rtxStatus_t *newCnf; /* Pointer for incoming config messages */
|
||||
|
@ -40,76 +38,6 @@ bool enterRx; /* Flag for RX mode activation */
|
|||
|
||||
float rssi; /* Current RSSI in dBm */
|
||||
|
||||
/*
|
||||
* These functions below provide a basic API for audio path management. They
|
||||
* will be removed once the audio driver is set up.
|
||||
*/
|
||||
|
||||
void _afCtrlInit()
|
||||
{
|
||||
#if defined(PLATFORM_MD3x0) || defined(PLATFORM_MDUV3x0)
|
||||
gpio_setMode(SPK_MUTE, OUTPUT);
|
||||
gpio_setMode(AUDIO_AMP_EN, OUTPUT);
|
||||
gpio_setMode(MIC_PWR, OUTPUT);
|
||||
#ifdef PLATFORM_MD3x0
|
||||
gpio_setMode(FM_MUTE, OUTPUT);
|
||||
#endif
|
||||
#elif defined(PLATFORM_GD77) || defined(PLATFORM_DM1801)
|
||||
gpio_setMode(AUDIO_AMP_EN, OUTPUT);
|
||||
#endif
|
||||
}
|
||||
|
||||
void _afCtrlSpeaker(bool enable)
|
||||
{
|
||||
if(enable)
|
||||
{
|
||||
#if defined(PLATFORM_MD3x0) || defined(PLATFORM_MDUV3x0)
|
||||
gpio_setPin(AUDIO_AMP_EN);
|
||||
delayMs(10);
|
||||
gpio_clearPin(SPK_MUTE);
|
||||
#ifdef PLATFORM_MD3x0
|
||||
gpio_setPin(FM_MUTE);
|
||||
#endif
|
||||
#elif defined(PLATFORM_GD77) || defined(PLATFORM_DM1801)
|
||||
gpio_setPin(AUDIO_AMP_EN);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined(PLATFORM_MD3x0) || defined(PLATFORM_MDUV3x0)
|
||||
gpio_setPin(SPK_MUTE);
|
||||
gpio_clearPin(AUDIO_AMP_EN);
|
||||
#ifdef PLATFORM_MD3x0
|
||||
gpio_clearPin(FM_MUTE);
|
||||
#endif
|
||||
#elif defined(PLATFORM_GD77) || defined(PLATFORM_DM1801)
|
||||
gpio_clearPin(AUDIO_AMP_EN);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void _afCtrlMic(bool enable)
|
||||
{
|
||||
if(enable)
|
||||
{
|
||||
#if defined(PLATFORM_MD3x0) || defined(PLATFORM_MDUV3x0)
|
||||
gpio_setPin(MIC_PWR);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined(PLATFORM_MD3x0) || defined(PLATFORM_MDUV3x0)
|
||||
gpio_clearPin(MIC_PWR);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void _afCtrlTerminate()
|
||||
{
|
||||
_afCtrlMic(false);
|
||||
_afCtrlSpeaker(false);
|
||||
}
|
||||
|
||||
/*
|
||||
* Unfortunately on MD-UV3x0 radios the volume knob does not regulate
|
||||
* the amplitude of the analog signal towards the audio amplifier but it
|
||||
|
@ -120,17 +48,17 @@ void _afCtrlTerminate()
|
|||
* which has to be mapped in a range between 1 and 31.
|
||||
*/
|
||||
#ifdef PLATFORM_MDUV3x0
|
||||
void _afSetVolume()
|
||||
void _setVolume()
|
||||
{
|
||||
float level = (platform_getVolumeLevel() / 1560.0f) * 30.0f;
|
||||
uint8_t volume = ((uint8_t) (level + 0.5f));
|
||||
|
||||
// Mute volume when knob is set below 10%
|
||||
if(volume < 1)
|
||||
_afCtrlSpeaker(false);
|
||||
audio_disableAmp();
|
||||
else
|
||||
{
|
||||
_afCtrlSpeaker(true);
|
||||
audio_enableAmp();
|
||||
/* Update HR_C6000 gain only if volume changed */
|
||||
static uint8_t old_volume = 0;
|
||||
if(volume != old_volume)
|
||||
|
@ -177,13 +105,10 @@ void rtx_init(pthread_mutex_t *m)
|
|||
* Initial value for RSSI filter
|
||||
*/
|
||||
rssi = radio_getRssi(rtxStatus.rxFrequency);
|
||||
|
||||
_afCtrlInit();
|
||||
}
|
||||
|
||||
void rtx_terminate()
|
||||
{
|
||||
_afCtrlTerminate();
|
||||
radio_terminate();
|
||||
}
|
||||
|
||||
|
@ -280,20 +205,21 @@ void rtx_taskFunc()
|
|||
|
||||
if((sqlOpen == false) && (rssi > (squelch + 0.1f)))
|
||||
{
|
||||
_afCtrlSpeaker(true);
|
||||
audio_enableAmp();
|
||||
sqlOpen = true;
|
||||
}
|
||||
|
||||
if((sqlOpen == true) && (rssi < (squelch - 0.1f)))
|
||||
{
|
||||
_afCtrlSpeaker(false);
|
||||
audio_disableAmp();
|
||||
sqlOpen = false;
|
||||
}
|
||||
|
||||
#ifdef PLATFORM_MDUV3x0
|
||||
if(sqlOpen == true)
|
||||
{
|
||||
// Set output volume by changing the HR_C6000 DAC gain
|
||||
_afSetVolume();
|
||||
_setVolume();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -313,10 +239,10 @@ void rtx_taskFunc()
|
|||
/* TX logic */
|
||||
if(platform_getPttStatus() && (rtxStatus.opStatus != TX))
|
||||
{
|
||||
_afCtrlSpeaker(false);
|
||||
audio_disableAmp();
|
||||
radio_disableRtx();
|
||||
|
||||
_afCtrlMic(true);
|
||||
audio_enableMic();
|
||||
radio_setVcoFrequency(rtxStatus.txFrequency, true);
|
||||
radio_enableTx(rtxStatus.txPower, rtxStatus.txToneEn);
|
||||
|
||||
|
@ -325,7 +251,7 @@ void rtx_taskFunc()
|
|||
|
||||
if(!platform_getPttStatus() && (rtxStatus.opStatus == TX))
|
||||
{
|
||||
_afCtrlMic(false);
|
||||
audio_disableMic();
|
||||
radio_disableRtx();
|
||||
|
||||
rtxStatus.opStatus = OFF;
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
/***************************************************************************
|
||||
* 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 <http://www.gnu.org/licenses/> *
|
||||
***************************************************************************/
|
||||
|
||||
#include <interfaces/audio.h>
|
||||
#include <interfaces/gpio.h>
|
||||
#include <hwconfig.h>
|
||||
|
||||
void audio_init()
|
||||
{
|
||||
gpio_setMode(AUDIO_AMP_EN, OUTPUT);
|
||||
gpio_clearPin(AUDIO_AMP_EN); /* Audio PA off */
|
||||
}
|
||||
|
||||
void audio_terminate()
|
||||
{
|
||||
gpio_clearPin(AUDIO_AMP_EN); /* Audio PA off */
|
||||
}
|
||||
|
||||
void audio_enableMic()
|
||||
{
|
||||
/* No mic control on this family */
|
||||
}
|
||||
|
||||
void audio_disableMic()
|
||||
{
|
||||
/* No mic control on this family */
|
||||
}
|
||||
|
||||
void audio_enableAmp()
|
||||
{
|
||||
gpio_setPin(AUDIO_AMP_EN);
|
||||
}
|
||||
|
||||
void audio_disableAmp()
|
||||
{
|
||||
gpio_clearPin(AUDIO_AMP_EN);
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
/***************************************************************************
|
||||
* 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 <http://www.gnu.org/licenses/> *
|
||||
***************************************************************************/
|
||||
|
||||
#include <interfaces/audio.h>
|
||||
#include <interfaces/gpio.h>
|
||||
#include <interfaces/delays.h>
|
||||
#include <hwconfig.h>
|
||||
|
||||
void audio_init()
|
||||
{
|
||||
gpio_setMode(SPK_MUTE, OUTPUT);
|
||||
gpio_setMode(AUDIO_AMP_EN, OUTPUT);
|
||||
gpio_setMode(MIC_PWR, OUTPUT);
|
||||
|
||||
gpio_setPin(SPK_MUTE); /* Speaker muted */
|
||||
gpio_clearPin(AUDIO_AMP_EN); /* Audio PA off */
|
||||
gpio_clearPin(MIC_PWR); /* Mic preamp. off */
|
||||
}
|
||||
|
||||
void audio_terminate()
|
||||
{
|
||||
gpio_setPin(SPK_MUTE); /* Speaker muted */
|
||||
gpio_clearPin(AUDIO_AMP_EN); /* Audio PA off */
|
||||
gpio_clearPin(MIC_PWR); /* Mic preamp. off */
|
||||
}
|
||||
|
||||
void audio_enableMic()
|
||||
{
|
||||
gpio_setPin(MIC_PWR);
|
||||
}
|
||||
|
||||
void audio_disableMic()
|
||||
{
|
||||
gpio_clearPin(MIC_PWR);
|
||||
}
|
||||
|
||||
void audio_enableAmp()
|
||||
{
|
||||
gpio_setPin(AUDIO_AMP_EN);
|
||||
sleepFor(0, 10); /* 10ms anti-pop delay */
|
||||
gpio_clearPin(SPK_MUTE);
|
||||
}
|
||||
|
||||
void audio_disableAmp()
|
||||
{
|
||||
gpio_setPin(SPK_MUTE);
|
||||
gpio_clearPin(AUDIO_AMP_EN);
|
||||
}
|
|
@ -71,6 +71,9 @@ void radio_init()
|
|||
gpio_setMode(TX_STG_EN, OUTPUT);
|
||||
gpio_setMode(RX_STG_EN, OUTPUT);
|
||||
|
||||
gpio_setMode(FM_MUTE, OUTPUT);
|
||||
gpio_clearPin(FM_MUTE);
|
||||
|
||||
gpio_clearPin(PLL_PWR); /* PLL off */
|
||||
gpio_setPin(VCOVCC_SW); /* VCOVCC high enables RX VCO, TX VCO if low */
|
||||
gpio_setPin(WN_SW); /* 25kHz bandwidth */
|
||||
|
@ -205,6 +208,11 @@ void radio_enableRx()
|
|||
DAC->DHR12L1 = vtune_rx * 0xFF;
|
||||
|
||||
gpio_setPin(RX_STG_EN);
|
||||
|
||||
if(currOpMode == FM)
|
||||
{
|
||||
gpio_setPin(FM_MUTE);
|
||||
}
|
||||
}
|
||||
|
||||
void radio_enableTx(const float txPower, const bool enableCss)
|
||||
|
@ -244,6 +252,7 @@ void radio_disableRtx()
|
|||
|
||||
gpio_clearPin(TX_STG_EN);
|
||||
gpio_clearPin(RX_STG_EN);
|
||||
gpio_clearPin(FM_MUTE);
|
||||
}
|
||||
|
||||
void radio_updateCalibrationParams(const rtxStatus_t* rtxCfg)
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
#include <interfaces/platform.h>
|
||||
#include <interfaces/nvmem.h>
|
||||
#include <interfaces/audio.h>
|
||||
#include <interfaces/gpio.h>
|
||||
#include <calibInfo_GDx.h>
|
||||
#include <ADC0_GDx.h>
|
||||
|
@ -45,15 +46,9 @@ void platform_init()
|
|||
|
||||
gpio_setMode(PWR_SW, OUTPUT);
|
||||
|
||||
/*
|
||||
* Initialise backlight driver
|
||||
*/
|
||||
backlight_init();
|
||||
|
||||
/*
|
||||
* Initialise ADC
|
||||
*/
|
||||
adc0_init();
|
||||
backlight_init(); /* Initialise backlight driver */
|
||||
audio_init(); /* Initialise audio management module */
|
||||
adc0_init(); /* Initialise ADC */
|
||||
pthread_mutex_init(&adc_mutex, NULL);
|
||||
|
||||
/*
|
||||
|
@ -97,6 +92,7 @@ void platform_terminate()
|
|||
pthread_mutex_destroy(&adc_mutex);
|
||||
|
||||
i2c0_terminate();
|
||||
audio_terminate();
|
||||
|
||||
/* Finally, remove power supply */
|
||||
gpio_clearPin(PWR_SW);
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
#include <interfaces/platform.h>
|
||||
#include <interfaces/nvmem.h>
|
||||
#include <interfaces/audio.h>
|
||||
#include <interfaces/gpio.h>
|
||||
#include <calibInfo_GDx.h>
|
||||
#include <ADC0_GDx.h>
|
||||
|
@ -44,15 +45,9 @@ void platform_init()
|
|||
|
||||
gpio_setMode(PWR_SW, OUTPUT);
|
||||
|
||||
/*
|
||||
* Initialise backlight driver
|
||||
*/
|
||||
backlight_init();
|
||||
|
||||
/*
|
||||
* Initialise ADC
|
||||
*/
|
||||
adc0_init();
|
||||
backlight_init(); /* Initialise backlight driver */
|
||||
audio_init(); /* Initialise audio management module */
|
||||
adc0_init(); /* Initialise ADC */
|
||||
pthread_mutex_init(&adc_mutex, NULL);
|
||||
|
||||
/*
|
||||
|
@ -96,6 +91,7 @@ void platform_terminate()
|
|||
pthread_mutex_destroy(&adc_mutex);
|
||||
|
||||
i2c0_terminate();
|
||||
audio_terminate();
|
||||
|
||||
/* Finally, remove power supply */
|
||||
gpio_clearPin(PWR_SW);
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include <calibInfo_MDx.h>
|
||||
#include <toneGenerator_MDx.h>
|
||||
#include <interfaces/rtc.h>
|
||||
#include <interfaces/audio.h>
|
||||
|
||||
md3x0Calib_t calibration;
|
||||
hwInfo_t hwInfo;
|
||||
|
@ -64,6 +65,7 @@ void platform_init()
|
|||
toneGen_init(); /* Initialise tone generator */
|
||||
rtc_init(); /* Initialise RTC */
|
||||
backlight_init(); /* Initialise backlight driver */
|
||||
audio_init(); /* Initialise audio management module */
|
||||
}
|
||||
|
||||
void platform_terminate()
|
||||
|
@ -80,6 +82,7 @@ void platform_terminate()
|
|||
nvm_terminate();
|
||||
toneGen_terminate();
|
||||
rtc_terminate();
|
||||
audio_terminate();
|
||||
|
||||
/* Finally, remove power supply */
|
||||
gpio_clearPin(PWR_SW);
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include <calibInfo_MDx.h>
|
||||
#include <toneGenerator_MDx.h>
|
||||
#include <interfaces/rtc.h>
|
||||
#include <interfaces/audio.h>
|
||||
#include <SPI2.h>
|
||||
#include <chSelector.h>
|
||||
|
||||
|
@ -77,6 +78,7 @@ void platform_init()
|
|||
rtc_init(); /* Initialise RTC */
|
||||
backlight_init(); /* Initialise backlight driver */
|
||||
chSelector_init(); /* Initialise channel selector handler */
|
||||
audio_init(); /* Initialise audio management module */
|
||||
}
|
||||
|
||||
void platform_terminate()
|
||||
|
@ -89,6 +91,7 @@ void platform_terminate()
|
|||
toneGen_terminate();
|
||||
rtc_terminate();
|
||||
chSelector_terminate();
|
||||
audio_terminate();
|
||||
|
||||
/* Finally, remove power supply */
|
||||
gpio_clearPin(PWR_SW);
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include <calibInfo_MDx.h>
|
||||
#include <interfaces/nvmem.h>
|
||||
#include <interfaces/rtc.h>
|
||||
#include <interfaces/audio.h>
|
||||
#include <chSelector.h>
|
||||
|
||||
#ifdef ENABLE_BKLIGHT_DIMMING
|
||||
|
@ -58,6 +59,7 @@ void platform_init()
|
|||
nvm_loadHwInfo(&hwInfo); /* Load hardware information data */
|
||||
rtc_init(); /* Initialise RTC */
|
||||
chSelector_init(); /* Initialise channel selector handler */
|
||||
audio_init(); /* Initialise audio management module */
|
||||
|
||||
#ifdef ENABLE_BKLIGHT_DIMMING
|
||||
backlight_init(); /* Initialise backlight driver */
|
||||
|
@ -85,6 +87,7 @@ void platform_terminate()
|
|||
nvm_terminate();
|
||||
rtc_terminate();
|
||||
chSelector_terminate();
|
||||
audio_terminate();
|
||||
|
||||
/* Finally, remove power supply */
|
||||
gpio_clearPin(PWR_SW);
|
||||
|
|
Ładowanie…
Reference in New Issue