diff --git a/meson.build b/meson.build
index 84748289..65fc422c 100644
--- a/meson.build
+++ b/meson.build
@@ -162,6 +162,7 @@ mdx_src = ['platform/drivers/GPS/GPS_MDx.cpp',
'platform/drivers/NVM/nvmem_MDx.c',
'platform/drivers/audio/audio_MDx.cpp',
'platform/drivers/baseband/HR_Cx000.cpp',
+ 'platform/drivers/baseband/HR_C6000.cpp',
'platform/drivers/tones/toneGenerator_MDx.cpp',
'platform/drivers/SPI/spi_custom.c',
'platform/drivers/SPI/spi_bitbang.c']
@@ -180,6 +181,7 @@ gdx_src = ['platform/targets/GDx/platform.c',
'platform/drivers/backlight/backlight_GDx.c',
'platform/drivers/baseband/radio_GDx.cpp',
'platform/drivers/baseband/HR_Cx000.cpp',
+ 'platform/drivers/baseband/HR_C6000.cpp',
'platform/drivers/baseband/AT1846S_GDx.cpp',
'platform/drivers/baseband/HR_C6000_GDx.cpp',
'platform/drivers/display/UC1701_GDx.c',
diff --git a/platform/drivers/baseband/HR_C6000.cpp b/platform/drivers/baseband/HR_C6000.cpp
new file mode 100644
index 00000000..795e0719
--- /dev/null
+++ b/platform/drivers/baseband/HR_C6000.cpp
@@ -0,0 +1,69 @@
+/***************************************************************************
+ * Copyright (C) 2024 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
+#include "HR_C6000.h"
+
+/*
+ * Table of HR_C6000 CTCSS tones, used for reverse lookup of tone index to be
+ * written in the configuration register. Taken from datasheet at page 90.
+ */
+static const uint16_t ctcssToneTable[] =
+{
+ 670, 719, 744, 770, 797, 825, 854,
+ 885, 915, 948, 974, 1000, 1035, 1072,
+ 1109, 1148, 1188, 1230, 1273, 1318, 1365,
+ 1413, 1462, 1514, 1567, 1622, 1679, 1738,
+ 1799, 1862, 1928, 2035, 2107, 2181, 2257,
+ 2336, 2418, 2503, 693, 625, 1598, 1655,
+ 1713, 1773, 1835, 1899, 1966, 1995, 2065,
+ 2291, 2541
+};
+
+static uint8_t getToneIndex(const tone_t tone)
+{
+ uint8_t idx;
+
+ for(idx = 0; idx < ARRAY_SIZE(ctcssToneTable); idx += 1)
+ {
+ if(ctcssToneTable[idx] == tone)
+ break;
+ }
+
+ return idx + 1;
+}
+
+void HR_C6000::setTxCtcss(const tone_t tone, const uint8_t deviation)
+{
+ uint8_t index = getToneIndex(tone);
+ writeCfgRegister(0xA8, index); // Set CTCSS tone index
+ writeCfgRegister(0xA0, deviation); // Set CTCSS tone deviation
+ writeCfgRegister(0xA1, 0x08); // Enable CTCSS
+}
+
+void HR_C6000::setRxCtcss(const tone_t tone)
+{
+ uint8_t index = getToneIndex(tone);
+ writeCfgRegister(0xA1, 0x08); // Enable CTCSS
+ writeCfgRegister(0xA7, 0x10); // CTCSS detection threshold, value from datasheet
+ writeCfgRegister(0xD3, 0x07); // CTCSS sampling depth, value from datasheet
+ writeCfgRegister(0xD2, 0xD0);
+ writeCfgRegister(0xD4, index); // Tone index
+}
diff --git a/platform/drivers/baseband/HR_C6000.h b/platform/drivers/baseband/HR_C6000.h
index b4b4b25e..943b0038 100644
--- a/platform/drivers/baseband/HR_C6000.h
+++ b/platform/drivers/baseband/HR_C6000.h
@@ -21,6 +21,7 @@
#ifndef HRC6000_H
#define HRC6000_H
+#include
#include "HR_Cx000.h"
enum class C6000_SpiOpModes : uint8_t
@@ -46,6 +47,40 @@ public:
*/
HR_C6000(const struct spiDevice *uSpi, const struct gpioPin uCs) :
HR_Cx000< C6000_SpiOpModes >(uSpi, uCs) { }
+
+ /**
+ * Configure CTCSS tone transmission.
+ *
+ * @param tone: CTCSS tone frequency.
+ * @param deviation: CTCSS tone deviation.
+ */
+ void setTxCtcss(const tone_t tone, const uint8_t deviation);
+
+ /**
+ * Configure CTCSS tone detection.
+ *
+ * @param tone: CTCSS tone frequency.
+ */
+ void setRxCtcss(const tone_t tone);
+
+ /**
+ * Test if RX CTCSS tone has been detected.
+ *
+ * @return true if RX CTCSS tone has been detected.
+ */
+ inline bool ctcssDetected()
+ {
+ uint8_t reg = readCfgRegister(0x93);
+ return ((reg & 0x01) != 0) ? true : false;
+ }
+
+ /**
+ * Disable CTCSS tone encode and decode.
+ */
+ inline void disableCtcss()
+ {
+ writeCfgRegister(0xA1, 0x00); // Disable all tones
+ }
};
#endif /* HRC6000_H */