From 8010302d4d602306be4fa991100f22f47dd94f46 Mon Sep 17 00:00:00 2001 From: Silvano Seva Date: Mon, 4 Jan 2021 20:53:42 +0100 Subject: [PATCH] Tone generator and GPIO for audio control on MD-UV380 platform --- meson.build | 17 +++++----- platform/targets/MD-UV380/hwconfig.h | 8 +++++ tests/platform/tonegen.c | 47 ++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+), 8 deletions(-) create mode 100644 tests/platform/tonegen.c diff --git a/meson.build b/meson.build index 6c8b1432..a0288055 100644 --- a/meson.build +++ b/meson.build @@ -221,6 +221,7 @@ mduv380_src = src + stm32f405_src + ['platform/drivers/display/HX83XX_MDx.c', 'platform/drivers/NVM/spiFlash_MDx.c', 'platform/drivers/NVM/nvmem_MDUV3x0.c', 'platform/drivers/ADC/ADC1_MDx.c', + 'platform/drivers/tones/toneGenerator_MDx.c', 'platform/drivers/baseband/rtx_UV3x0.c', 'platform/targets/MD-UV380/platform.c'] @@ -228,6 +229,14 @@ mduv380_inc = inc + stm32f405_inc + ['platform/targets/MD-UV380'] mduv380_def = def + stm32f405_def + {'PLATFORM_MDUV380': ''} +## TYT MD-9600 +md9600_src = src + stm32f405_src + ['platform/targets/MD-9600/platform.c', + 'platform/drivers/tones/toneGenerator_MDx.c'] + +md9600_inc = inc + stm32f405_inc + ['platform/targets/MD-9600'] +md9600_def = def + stm32f405_def + {'PLATFORM_MD9600': ''} + + ## Radioddity GD77 gd77_src = src + mk22fn512_src + ['platform/targets/GD77/platform.c', 'platform/drivers/display/UC1701_GD77.c', @@ -257,14 +266,6 @@ dm1801_src = src + mk22fn512_src + ['platform/targets/DM-1801/platform.c', dm1801_inc = inc + mk22fn512_inc + ['platform/targets/DM-1801'] dm1801_def = def + mk22fn512_def + {'PLATFORM_DM1801': ''} - -## TYT MD-9600 -md9600_src = src + stm32f405_src + ['platform/targets/MD-9600/platform.c'] - -md9600_inc = inc + stm32f405_inc + ['platform/targets/MD-9600'] -md9600_def = def + stm32f405_def + {'PLATFORM_MD9600': ''} - - ## ## Compilation defines ## diff --git a/platform/targets/MD-UV380/hwconfig.h b/platform/targets/MD-UV380/hwconfig.h index e2230c42..758d05d8 100644 --- a/platform/targets/MD-UV380/hwconfig.h +++ b/platform/targets/MD-UV380/hwconfig.h @@ -89,12 +89,20 @@ #define MONI_SW LCD_D6 #define FUNC_SW LCD_D7 +/* Tone generator */ +#define CTCSS_OUT GPIOC,7 /* System "beep" */ +#define BEEP_OUT GPIOC,8 /* CTCSS tone */ + /* External flash */ #define FLASH_CS GPIOD,7 #define FLASH_CLK GPIOB,3 #define FLASH_SDO GPIOB,4 #define FLASH_SDI GPIOB,5 +/* Audio control */ +#define AMP_EN GPIOB,9 +#define SPK_MUTE GPIOB,8 + /* * To enable pwm for display backlight dimming uncomment this directive. * diff --git a/tests/platform/tonegen.c b/tests/platform/tonegen.c new file mode 100644 index 00000000..b134d983 --- /dev/null +++ b/tests/platform/tonegen.c @@ -0,0 +1,47 @@ +/*************************************************************************** + * Copyright (C) 2020 by Federico Izzo IU2NUO, Niccolò Izzo IU2KIN and * + * 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 "stm32f4xx.h" +#include "gpio.h" +#include "delays.h" +#include "toneGenerator_MDx.h" +#include "hwconfig.h" + +int main() +{ + gpio_setMode(SPK_MUTE, OUTPUT); // Turn on speaker + gpio_clearPin(SPK_MUTE); + + gpio_setMode(AMP_EN, OUTPUT); // Turn on audio amplifier + gpio_setPin(AMP_EN); + + toneGen_init(); + toneGen_setBeepFreq(440.0f); + + while(1) + { + toneGen_beepOn(); + delayMs(500); + toneGen_beepOff(); + delayMs(500); + } + + return 0; +}