diff --git a/meson.build b/meson.build
index 339b1dd2..925a7011 100644
--- a/meson.build
+++ b/meson.build
@@ -168,8 +168,7 @@ mdx_src = ['openrtx/src/core/xmodem.c',
## GDx family: Radioddity GD-77 and Baofeng DM-1801
##
-gdx_src = ['openrtx/src/core/xmodem.c',
- 'openrtx/src/core/backup.c',
+gdx_src = ['platform/targets/GDx/platform.c',
'platform/drivers/NVM/W25Qx.c',
'platform/drivers/NVM/AT24Cx_GDx.c',
'platform/drivers/NVM/spiFlash_GDx.c',
@@ -185,6 +184,8 @@ gdx_src = ['openrtx/src/core/xmodem.c',
'platform/drivers/keyboard/keyboard_GDx.c',
'platform/drivers/audio/audio_GDx.c']
+gdx_inc = ['platform/targets/GDx']
+
##
## --------------------- MCU-dependent source files ----------------------------
##
@@ -390,23 +391,23 @@ md9600_def += openrtx_def + stm32f405_def + miosix_cm4f_def
##
## Radioddity GD-77
##
-gd77_src = ['platform/targets/GD-77/platform.c']
-gd77_inc = ['platform/targets/GD-77']
+gd77_src = []
+gd77_inc = []
gd77_def = {'PLATFORM_GD77': ''}
gd77_src += openrtx_src + mk22fn512_src + miosix_cm4f_src + ui_src_default + gdx_src
-gd77_inc += openrtx_inc + mk22fn512_inc + miosix_cm4f_inc
+gd77_inc += openrtx_inc + mk22fn512_inc + miosix_cm4f_inc + gdx_inc
gd77_def += openrtx_def + mk22fn512_def + miosix_cm4f_def
##
## Baofeng DM-1801
##
-dm1801_src = ['platform/targets/DM-1801/platform.c']
-dm1801_inc = ['platform/targets/DM-1801']
+dm1801_src = []
+dm1801_inc = []
dm1801_def = {'PLATFORM_DM1801': ''}
dm1801_src += openrtx_src + mk22fn512_src + miosix_cm4f_src + ui_src_default + gdx_src
-dm1801_inc += openrtx_inc + mk22fn512_inc + miosix_cm4f_inc
+dm1801_inc += openrtx_inc + mk22fn512_inc + miosix_cm4f_inc + gdx_inc
dm1801_def += openrtx_def + mk22fn512_def + miosix_cm4f_def
##
diff --git a/platform/targets/GD-77/hwconfig.h b/platform/targets/GD-77/hwconfig.h
deleted file mode 100644
index b2d613d8..00000000
--- a/platform/targets/GD-77/hwconfig.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/***************************************************************************
- * Copyright (C) 2020 - 2023 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 HWCONFIG_H
-#define HWCONFIG_H
-
-#include
-#include "pinmap.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Screen dimensions */
-#define CONFIG_SCREEN_WIDTH 128
-#define CONFIG_SCREEN_HEIGHT 64
-
-/* Screen pixel format */
-#define CONFIG_PIX_FMT_BW
-
-/* Screen has adjustable contrast */
-#define CONFIG_SCREEN_CONTRAST
-#define CONFIG_DEFAULT_CONTRAST 71
-
-/* Screen has adjustable brightness */
-#define CONFIG_SCREEN_BRIGHTNESS
-
-/* Battery type */
-#define CONFIG_BAT_LIPO_2S
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* HWCONFIG_H */
diff --git a/platform/targets/GD-77/platform.c b/platform/targets/GD-77/platform.c
deleted file mode 100644
index 22688eeb..00000000
--- a/platform/targets/GD-77/platform.c
+++ /dev/null
@@ -1,195 +0,0 @@
-/***************************************************************************
- * Copyright (C) 2020 - 2023 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
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include "hwconfig.h"
-
-pthread_mutex_t adc_mutex;
-
-gdxCalibration_t calibration;
-
-static const hwInfo_t hwInfo =
-{
- .vhf_maxFreq = 174,
- .vhf_minFreq = 136,
- .vhf_band = 1,
- .uhf_maxFreq = 470,
- .uhf_minFreq = 400,
- .uhf_band = 1,
- .hw_version = 0,
- .name = "GD-77"
-};
-
-void platform_init()
-{
- /* Configure GPIOs */
- gpio_setMode(GREEN_LED, OUTPUT);
- gpio_setMode(RED_LED, OUTPUT);
-
- gpio_setMode(PTT_SW, INPUT);
-
- #ifndef RUNNING_TESTSUITE
- gpio_setMode(PWR_SW, OUTPUT);
- #endif
-
- backlight_init(); /* Initialise backlight driver */
- audio_init(); /* Initialise audio management module */
- adc0_init(); /* Initialise ADC */
- nvm_init(); /* Initialise NVM manager */
- pthread_mutex_init(&adc_mutex, NULL);
-
- /*
- * Initialise I2C driver, once for all the modules
- */
- gpio_setMode(I2C_SDA, OPEN_DRAIN | ALTERNATE_FUNC(5));
- gpio_setMode(I2C_SCL, OPEN_DRAIN | ALTERNATE_FUNC(5));
- i2c0_init();
-}
-
-void platform_terminate()
-{
- /* Shut down backlight */
- backlight_terminate();
-
- gpio_clearPin(RED_LED);
- gpio_clearPin(GREEN_LED);
-
- adc0_terminate();
- pthread_mutex_destroy(&adc_mutex);
-
- i2c0_terminate();
- audio_terminate();
-
- /* Finally, remove power supply */
- gpio_clearPin(PWR_SW);
-}
-
-uint16_t platform_getVbat()
-{
- pthread_mutex_lock(&adc_mutex);
- uint16_t value = adc0_getMeasurement(1);
- pthread_mutex_unlock(&adc_mutex);
-
- /*
- * Battery voltage is measured through an 1:3 voltage divider and
- * adc1_getMeasurement returns a value in mV. Thus, to have effective
- * battery voltage, multiply by three.
- */
- return value * 3;
-}
-
-uint8_t platform_getMicLevel()
-{
- pthread_mutex_lock(&adc_mutex);
- uint16_t value = adc0_getRawSample(3);
- pthread_mutex_unlock(&adc_mutex);
-
- /* Value from ADC is 12 bit wide: shift right by four to get 0 - 255 */
- return value >> 4;
-}
-
-uint8_t platform_getVolumeLevel()
-{
- /* TODO */
- return 0;
-}
-
-int8_t platform_getChSelector()
-{
- /* GD77 does not have a channel selector */
- return 0;
-}
-
-bool platform_getPttStatus()
-{
- /* PTT line has a pullup resistor with PTT switch closing to ground */
- return (gpio_readPin(PTT_SW) == 0) ? true : false;
-}
-
-bool platform_pwrButtonStatus()
-{
- /*
- * When power knob is set to off, battery voltage measurement returns 0V.
- * Here we set the threshold to 1V since, with knob in off position, there
- * is always a bit of noise in the ADC measurement making the returned
- * voltage not to be exactly zero.
- */
- return (platform_getVbat() > 1.0f) ? true : false;
-}
-
-void platform_ledOn(led_t led)
-{
- switch(led)
- {
- case GREEN:
- gpio_setPin(GREEN_LED);
- break;
-
- case RED:
- gpio_setPin(RED_LED);
- break;
-
- default:
- break;
- }
-}
-
-void platform_ledOff(led_t led)
-{
- switch(led)
- {
- case GREEN:
- gpio_clearPin(GREEN_LED);
- break;
-
- case RED:
- gpio_clearPin(RED_LED);
- break;
-
- default:
- break;
- }
-}
-
-void platform_beepStart(uint16_t freq)
-{
- /* TODO */
-
- (void) freq;
-}
-
-void platform_beepStop()
-{
- /* TODO */
-}
-
-const hwInfo_t *platform_getHwInfo()
-{
- return &hwInfo;
-}
diff --git a/platform/targets/DM-1801/hwconfig.h b/platform/targets/GDx/hwconfig.h
similarity index 92%
rename from platform/targets/DM-1801/hwconfig.h
rename to platform/targets/GDx/hwconfig.h
index b2d613d8..9dee6354 100644
--- a/platform/targets/DM-1801/hwconfig.h
+++ b/platform/targets/GDx/hwconfig.h
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2020 - 2023 by Federico Amedeo Izzo IU2NUO, *
+ * Copyright (C) 2020 - 2024 by Federico Amedeo Izzo IU2NUO, *
* Niccolò Izzo IU2KIN *
* Frederik Saraci IU2NRO *
* Silvano Seva IU2KWO *
@@ -22,7 +22,12 @@
#define HWCONFIG_H
#include
-#include "pinmap.h"
+
+#ifdef PLATFORM_GD77
+#include "pinmap_GD77.h"
+#else
+#include "pinmap_DM1801.h"
+#endif
#ifdef __cplusplus
extern "C" {
diff --git a/platform/targets/DM-1801/pinmap.h b/platform/targets/GDx/pinmap_DM1801.h
similarity index 91%
rename from platform/targets/DM-1801/pinmap.h
rename to platform/targets/GDx/pinmap_DM1801.h
index 60662bfc..0def7797 100644
--- a/platform/targets/DM-1801/pinmap.h
+++ b/platform/targets/GDx/pinmap_DM1801.h
@@ -1,8 +1,8 @@
/***************************************************************************
- * Copyright (C) 2023 by Federico Amedeo Izzo IU2NUO, *
- * Niccolò Izzo IU2KIN, *
- * Frederik Saraci IU2NRO, *
- * Silvano Seva IU2KWO *
+ * Copyright (C) 2023 - 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 *
diff --git a/platform/targets/GD-77/pinmap.h b/platform/targets/GDx/pinmap_GD77.h
similarity index 91%
rename from platform/targets/GD-77/pinmap.h
rename to platform/targets/GDx/pinmap_GD77.h
index c2873991..a0f04f8b 100644
--- a/platform/targets/GD-77/pinmap.h
+++ b/platform/targets/GDx/pinmap_GD77.h
@@ -1,8 +1,8 @@
/***************************************************************************
- * Copyright (C) 2023 by Federico Amedeo Izzo IU2NUO, *
- * Niccolò Izzo IU2KIN, *
- * Frederik Saraci IU2NRO, *
- * Silvano Seva IU2KWO *
+ * Copyright (C) 2023 - 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 *
diff --git a/platform/targets/DM-1801/platform.c b/platform/targets/GDx/platform.c
similarity index 97%
rename from platform/targets/DM-1801/platform.c
rename to platform/targets/GDx/platform.c
index e12da75a..1f066827 100644
--- a/platform/targets/DM-1801/platform.c
+++ b/platform/targets/GDx/platform.c
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2020 - 2023 by Federico Amedeo Izzo IU2NUO, *
+ * Copyright (C) 2020 - 2024 by Federico Amedeo Izzo IU2NUO, *
* Niccolò Izzo IU2KIN *
* Frederik Saraci IU2NRO *
* Silvano Seva IU2KWO *
@@ -30,8 +30,8 @@
#include
#include "hwconfig.h"
-/* Mutex for concurrent access to ADC0 */
pthread_mutex_t adc_mutex;
+
gdxCalibration_t calibration;
static const hwInfo_t hwInfo =
@@ -43,7 +43,11 @@ static const hwInfo_t hwInfo =
.uhf_minFreq = 400,
.uhf_band = 1,
.hw_version = 0,
+ #ifdef PLATFORM_GD77
+ .name = "GD-77"
+ #else
.name = "DM-1801"
+ #endif
};
void platform_init()