diff --git a/meson.build b/meson.build
index f188d423..3d861139 100644
--- a/meson.build
+++ b/meson.build
@@ -389,6 +389,7 @@ mod17_src = ['platform/targets/Module17/platform.c',
'platform/drivers/audio/inputStream_Mod17.cpp',
'platform/drivers/audio/outputStream_Mod17.cpp',
'platform/drivers/audio/audio_Mod17.c',
+ 'platform/drivers/audio/MAX9814_Mod17.cpp',
'platform/drivers/baseband/MCP4551_Mod17.cpp']
mod17_src = src + openrtx_ui_module17 + mod17_src + stm32f405_src
diff --git a/platform/drivers/audio/MAX9814.h b/platform/drivers/audio/MAX9814.h
new file mode 100644
index 00000000..d9171fea
--- /dev/null
+++ b/platform/drivers/audio/MAX9814.h
@@ -0,0 +1,34 @@
+/***************************************************************************
+ * Copyright (C) 2022 by Mathis Schmieder DB9MAT *
+ * *
+ * 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 MAX9814_H
+#define MAX9814_H
+
+#include
+#include
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void max9814_setGain(uint8_t gain);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* MAX9814_H */
diff --git a/platform/drivers/audio/MAX9814_Mod17.cpp b/platform/drivers/audio/MAX9814_Mod17.cpp
new file mode 100644
index 00000000..df48ca15
--- /dev/null
+++ b/platform/drivers/audio/MAX9814_Mod17.cpp
@@ -0,0 +1,42 @@
+/***************************************************************************
+ * Copyright (C) 2021 - 2022 by Mathis Schmieder DB9MAT *
+ * *
+ * 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
+#include
+#include "MAX9814.h"
+
+/*
+ * Implementation of MAX9814 gain setting
+ */
+
+void max9814_setGain(uint8_t gain)
+{
+ if (gain == 0)
+ {
+ gpio_setMode(MIC_GAIN, OUTPUT);
+ gpio_setPin(MIC_GAIN); // 40 dB gain
+ }
+ else if (gain == 1)
+ {
+ gpio_setMode(MIC_GAIN, OUTPUT);
+ gpio_clearPin(MIC_GAIN); // 50 dB gain
+ }
+ else
+ {
+ gpio_setMode(MIC_GAIN, INPUT); // High impedance, 60 dB gain
+ }
+}
diff --git a/platform/drivers/audio/audio_Mod17.c b/platform/drivers/audio/audio_Mod17.c
index a76a76e2..867dddf3 100644
--- a/platform/drivers/audio/audio_Mod17.c
+++ b/platform/drivers/audio/audio_Mod17.c
@@ -21,6 +21,7 @@
#include
#include
#include
+#include "MAX9814.h"
static const uint8_t pathCompatibilityMatrix[9][9] =
@@ -42,11 +43,10 @@ void audio_init()
{
gpio_setMode(SPK_MUTE, OUTPUT);
gpio_setMode(MIC_MUTE, OUTPUT);
- gpio_setMode(MIC_GAIN, OUTPUT);
gpio_setPin(SPK_MUTE); // Off = logic high
gpio_clearPin(MIC_MUTE); // Off = logic low
- gpio_setPin(MIC_GAIN); // gain = 40 dB
+ max9814_setGain(0); // 40 dB gain
}
void audio_terminate()
diff --git a/platform/drivers/baseband/radio_Mod17.cpp b/platform/drivers/baseband/radio_Mod17.cpp
index a2c0ab1e..1e45ddea 100644
--- a/platform/drivers/baseband/radio_Mod17.cpp
+++ b/platform/drivers/baseband/radio_Mod17.cpp
@@ -24,6 +24,7 @@
#include
#include
#include
+#include "../audio/MAX9814.h"
enum opstatus radioStatus; // Current operating status
const mod17Calib_t *calData; // Calibration data
@@ -87,6 +88,7 @@ void radio_enableTx()
mcp4551_setWiper(SOFTPOT_TX, calData->tx_wiper);
mcp4551_setWiper(SOFTPOT_RX, calData->rx_wiper);
+ max9814_setGain(calData->mic_gain);
}
void radio_disableRtx()