diff --git a/meson.build b/meson.build
index fe17425c..2510e083 100644
--- a/meson.build
+++ b/meson.build
@@ -222,6 +222,16 @@ gd77_inc = inc + mk22fn512_inc + ['platform/targets/GD77']
gd77_def = def + mk22fn512_def + {'PLATFORM_GD77': ''}
+## Baofeng DM-1801
+dm1801_src = src + mk22fn512_src + ['platform/targets/DM-1801/platform.c',
+ 'platform/drivers/display/UC1701_GD77.c',
+ 'platform/drivers/keyboard/keyboard_GD77.c',
+ 'platform/drivers/baseband/rtx_GDx.c']
+
+dm1801_inc = inc + mk22fn512_inc + ['platform/targets/DM-1801']
+dm1801_def = def + mk22fn512_def + {'PLATFORM_DM1801': ''}
+
+
##
## Compilation defines
##
@@ -278,6 +288,14 @@ foreach k, v : gd77_def
endif
endforeach
+dm1801_args = []
+foreach k, v : dm1801_def
+ if v == ''
+ dm1801_args += '-D@0@'.format(k)
+ else
+ dm1801_args += '-D@0@=@1@'.format(k, v)
+ endif
+endforeach
linux_opts = {'sources': linux_src,
'c_args': linux_c_args,
@@ -309,6 +327,12 @@ gd77_opts = {'sources': gd77_src,
'-Wl,--print-memory-usage'],
'include_directories':gd77_inc}
+dm1801_opts = {'sources': dm1801_src,
+ 'c_args': dm1801_args,
+ 'link_args' : ['-Wl,-T../platform/mcu/MK22FN512xxx12/linker_script.ld',
+ '-Wl,--print-memory-usage'],
+ 'include_directories':dm1801_inc}
+
##
## Targets
##
@@ -341,6 +365,12 @@ targets = [
'flashable': true,
'wrap': 'UV3X0',
'load_addr': '0x0800C000'},
+
+ {'name': 'dm1801',
+ 'opts': dm1801_opts,
+ 'flashable': true,
+ 'wrap': 'UV3X0',
+ 'load_addr': '0x0800C000'},
]
objcopy = find_program('objcopy', required:false, disabler:true)
diff --git a/platform/targets/DM-1801/hwconfig.h b/platform/targets/DM-1801/hwconfig.h
new file mode 100644
index 00000000..371fc2b7
--- /dev/null
+++ b/platform/targets/DM-1801/hwconfig.h
@@ -0,0 +1,65 @@
+/***************************************************************************
+ * Copyright (C) 2020 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 "MK22F51212.h"
+
+/* Screen dimensions */
+#define SCREEN_WIDTH 128
+#define SCREEN_HEIGHT 64
+
+/* Screen pixel format */
+#define PIX_FMT_BW
+
+/* Battery type */
+#define BAT_LIPO_2S
+
+/* Display */
+#define LCD_BKLIGHT GPIOC,4
+#define LCD_CS GPIOC,8
+#define LCD_RST GPIOC,9
+#define LCD_RS GPIOC,10
+#define LCD_CLK GPIOC,11
+#define LCD_DAT GPIOC,12
+
+/* Signalling LEDs */
+#define GREEN_LED GPIOA,17
+#define RED_LED GPIOC,14
+
+/* Keyboard */
+#define KB_ROW0 GPIOB,19
+#define KB_ROW1 GPIOB,20
+#define KB_ROW2 GPIOB,21
+#define KB_ROW3 GPIOB,22
+#define KB_ROW4 GPIOB,23
+
+#define KB_COL0 GPIOC,0
+#define KB_COL1 GPIOC,1
+#define KB_COL2 GPIOC,2
+#define KB_COL3 GPIOC,3
+
+#define PTT_SW GPIOA,1
+#define FUNC_SW GPIOA,2
+#define FUNC2_SW GPIOB,1
+#define MONI_SW GPIOB,9
+
+#endif
diff --git a/platform/targets/DM-1801/platform.c b/platform/targets/DM-1801/platform.c
new file mode 100644
index 00000000..0b7fda89
--- /dev/null
+++ b/platform/targets/DM-1801/platform.c
@@ -0,0 +1,131 @@
+/***************************************************************************
+ * Copyright (C) 2020 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 "hwconfig.h"
+
+void platform_init()
+{
+ /* Configure GPIOs */
+ gpio_setMode(GREEN_LED, OUTPUT);
+ gpio_setMode(RED_LED, OUTPUT);
+
+ gpio_setMode(LCD_BKLIGHT, OUTPUT);
+ gpio_clearPin(LCD_BKLIGHT);
+
+ gpio_setMode(PTT_SW, INPUT);
+}
+
+void platform_terminate()
+{
+ gpio_clearPin(LCD_BKLIGHT);
+ gpio_clearPin(RED_LED);
+ gpio_clearPin(GREEN_LED);
+}
+
+float platform_getVbat()
+{
+ /* TODO */
+ return 0.0f;
+}
+
+float platform_getMicLevel()
+{
+ /* TODO */
+ return 0.0f;
+}
+
+float platform_getVolumeLevel()
+{
+ /* TODO */
+ return 0.0f;
+}
+
+uint8_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;
+}
+
+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 */
+}
+
+void platform_setBacklightLevel(uint8_t level)
+{
+ /* TODO: backlight dimming */
+ if(level > 1)
+ {
+ gpio_setPin(LCD_BKLIGHT);
+ }
+ else
+ {
+ gpio_clearPin(LCD_BKLIGHT);
+ }
+}