Merged MD-380 and MD-390 targets into a new MD-3x0 one

replace/60b5163f3cc4f929dde1a4624a97e99d612bf6d4
Silvano Seva 2021-02-03 15:09:59 +01:00
rodzic 7bfc8c5fb1
commit 03d5184f86
7 zmienionych plików z 21 dodań i 408 usunięć

Wyświetl plik

@ -183,8 +183,8 @@ else
linux_dep = []
endif
## TYT MD380
md380_src = src + stm32f405_src + ['platform/drivers/display/HX8353_MDx.c',
## TYT MD-3x0 family
md3x0_src = src + stm32f405_src + ['platform/drivers/display/HX8353_MDx.c',
'platform/drivers/keyboard/keyboard_MDx.c',
'platform/drivers/NVM/W25Qx.c',
'platform/drivers/NVM/spiFlash_MDx.c',
@ -194,28 +194,10 @@ md380_src = src + stm32f405_src + ['platform/drivers/display/HX8353_MDx.c',
'platform/drivers/baseband/SKY72310.c',
'platform/drivers/baseband/radio_MD3x0.c',
'platform/drivers/baseband/HR_C5000.c',
'platform/targets/MD-380/platform.c']
md380_inc = inc + stm32f405_inc + ['platform/targets/MD-380']
md380_def = def + stm32f405_def + {'PLATFORM_MD380': ''}
## TYT MD390
md390_src = src + stm32f405_src + ['platform/drivers/display/HX8353_MDx.c',
'platform/drivers/keyboard/keyboard_MDx.c',
'platform/drivers/NVM/W25Qx.c',
'platform/drivers/NVM/spiFlash_MDx.c',
'platform/drivers/NVM/nvmem_MD3x0.c',
'platform/drivers/ADC/ADC1_MDx.c',
'platform/drivers/tones/toneGenerator_MDx.c',
'platform/drivers/baseband/SKY72310.c',
'platform/drivers/baseband/radio_MD3x0.c',
'platform/drivers/baseband/HR_C5000.c',
'platform/targets/MD-390/platform.c']
md390_inc = inc + stm32f405_inc + ['platform/targets/MD-390']
md390_def = def + stm32f405_def + {'PLATFORM_MD390': ''}
'platform/targets/MD-3x0/platform.c']
md3x0_inc = inc + stm32f405_inc + ['platform/targets/MD-3x0']
md3x0_def = def + stm32f405_def + {'PLATFORM_MD3x0': ''}
## TYT MD-UV380
mduv380_src = src + stm32f405_src + ['platform/drivers/display/HX8353_MDx.c',
@ -295,21 +277,12 @@ foreach k, v : linux_def
endif
endforeach
md380_args = []
foreach k, v : md380_def
md3x0_args = []
foreach k, v : md3x0_def
if v == ''
md380_args += '-D@0@'.format(k)
md3x0_args += '-D@0@'.format(k)
else
md380_args += '-D@0@=@1@'.format(k, v)
endif
endforeach
md390_args = []
foreach k, v : md390_def
if v == ''
md390_args += '-D@0@'.format(k)
else
md390_args += '-D@0@=@1@'.format(k, v)
md3x0_args += '-D@0@=@1@'.format(k, v)
endif
endforeach
@ -364,17 +337,11 @@ linux_opts = {'sources': linux_src,
'dependencies': linux_dep,
'link_args' : linux_l_args}
md380_opts = {'sources': md380_src,
'c_args': md380_args,
md3x0_opts = {'sources': md3x0_src,
'c_args': md3x0_args,
'link_args' : ['-Wl,-T../platform/mcu/STM32F4xx/linker_script.ld',
'-Wl,--print-memory-usage'],
'include_directories': md380_inc}
md390_opts = {'sources': md390_src,
'c_args': md390_args,
'link_args' : ['-Wl,-T../platform/mcu/STM32F4xx/linker_script.ld',
'-Wl,--print-memory-usage'],
'include_directories': md390_inc}
'include_directories': md3x0_inc}
mduv380_opts = {'sources': mduv380_src,
'c_args': mduv380_args,
@ -415,18 +382,12 @@ targets = [
'opts': linux_opts,
'flashable': false},
{'name': 'md380',
'opts': md380_opts,
{'name': 'md3x0',
'opts': md3x0_opts,
'flashable': true,
'wrap': 'MD380',
'load_addr': '0x0800C000'},
{'name': 'md390',
'opts': md390_opts,
'flashable': true,
'wrap': 'MD390',
'load_addr': '0x0800C000'},
{'name': 'mduv380',
'opts': mduv380_opts,
'flashable': true,

Wyświetl plik

@ -41,7 +41,7 @@ bool enterRx; /* Flag for RX mode activation */
void _afCtrlInit()
{
#if defined(PLATFORM_MD380) || defined(PLATFORM_MD390)
#if defined(PLATFORM_MD3x0)
gpio_setMode(SPK_MUTE, OUTPUT);
gpio_setMode(AMP_EN, OUTPUT);
gpio_setMode(FM_MUTE, OUTPUT);
@ -55,7 +55,7 @@ void _afCtrlSpeaker(bool enable)
{
if(enable)
{
#if defined(PLATFORM_MD380) || defined(PLATFORM_MD390)
#if defined(PLATFORM_MD3x0)
gpio_setPin(AMP_EN);
gpio_setPin(FM_MUTE);
gpio_clearPin(SPK_MUTE);
@ -65,7 +65,7 @@ void _afCtrlSpeaker(bool enable)
}
else
{
#if defined(PLATFORM_MD380) || defined(PLATFORM_MD390)
#if defined(PLATFORM_MD3x0)
gpio_clearPin(AMP_EN);
gpio_clearPin(FM_MUTE);
gpio_setPin(SPK_MUTE);
@ -79,13 +79,13 @@ void _afCtrlMic(bool enable)
{
if(enable)
{
#if defined(PLATFORM_MD380) || defined(PLATFORM_MD390)
#if defined(PLATFORM_MD3x0)
gpio_setPin(MIC_PWR);
#endif
}
else
{
#if defined(PLATFORM_MD380) || defined(PLATFORM_MD390)
#if defined(PLATFORM_MD3x0)
gpio_clearPin(MIC_PWR);
#endif
}

Wyświetl plik

@ -47,7 +47,7 @@ void adc1_init()
* - PB0: RSSI level
*/
gpio_setMode(AIN_VBAT, INPUT_ANALOG);
#if defined(PLATFORM_MD380) || defined(PLATFORM_MD390)
#if defined(PLATFORM_MD3x0)
gpio_setMode(AIN_VOLUME, INPUT_ANALOG);
gpio_setMode(AIN_MIC, INPUT_ANALOG);
gpio_setMode(AIN_RSSI, INPUT_ANALOG);
@ -77,7 +77,7 @@ void adc1_init()
| ADC_CR2_ADON;
/* Scan sequence config. */
#if defined(PLATFORM_MD380) || defined(PLATFORM_MD390)
#if defined(PLATFORM_MD3x0)
ADC1->SQR1 = 3 << 20; /* Four channels to be converted */
ADC1->SQR3 |= (1 << 0) /* CH1, battery voltage on PA1 */
| (8 << 5) /* CH8, RSSI value on PB0 */

Wyświetl plik

@ -1,144 +0,0 @@
/***************************************************************************
* Copyright (C) 2020 by Federico Amedeo Izzo IU2NUO, *
* Niccolò Izzo IU2KIN *
* 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 <http://www.gnu.org/licenses/> *
***************************************************************************/
#ifndef HWCONFIG_H
#define HWCONFIG_H
#include <stm32f4xx.h>
/* Device has a working real time clock */
#define HAS_RTC
/* Device has a channel selection knob */
#define HAS_ABSOLUTE_KNOB
/* Supported radio bands */
#define BAND_VHF
#define BAND_UHF
/* Band limits in Hz */
#define FREQ_LIMIT_VHF_LO 136000000
#define FREQ_LIMIT_VHF_HI 174000000
#define FREQ_LIMIT_UHF_LO 400000000
#define FREQ_LIMIT_UHF_HI 480000000
/* Screen dimensions */
#define SCREEN_WIDTH 160
#define SCREEN_HEIGHT 128
/* Screen pixel format */
#define PIX_FMT_RGB565
/* Screen needs x-axis mirroring */
#define DISPLAY_MIRROR_X
/* Battery type */
#define BAT_LIPO_2S
/* Display */
#define LCD_D0 GPIOD,14
#define LCD_D1 GPIOD,15
#define LCD_D2 GPIOD,0
#define LCD_D3 GPIOD,1
#define LCD_D4 GPIOE,7
#define LCD_D5 GPIOE,8
#define LCD_D6 GPIOE,9
#define LCD_D7 GPIOE,10
#define LCD_WR GPIOD,5
#define LCD_RD GPIOD,4
#define LCD_CS GPIOD,6
#define LCD_RS GPIOD,12
#define LCD_RST GPIOD,13
#define LCD_BKLIGHT GPIOC,6
/* Signalling LEDs */
#define GREEN_LED GPIOE,0
#define RED_LED GPIOE,1
/* Analog inputs */
#define AIN_VOLUME GPIOA,0
#define AIN_VBAT GPIOA,1
#define AIN_MIC GPIOA,3
#define AIN_RSSI GPIOB,0
/* Channel selection rotary encoder */
#define CH_SELECTOR_0 GPIOE,14
#define CH_SELECTOR_1 GPIOE,15
#define CH_SELECTOR_2 GPIOB,10
#define CH_SELECTOR_3 GPIOB,11
/* Push-to-talk switch */
#define PTT_SW GPIOE,11
/*
* Keyboard. Here we define only rows, since coloumn lines are the same as
* LCD_Dx. See also: https://www.qsl.net/dl4yhf/RT3/md380_hw.html#keyboard
*
* "Monitor" and "Function" buttons, on the other hand, are connected to
* keyboard row 3 and on LCD_D7 and LCD_D6. See also the schematic.
*/
#define KB_ROW1 GPIOA,6 /* K1 */
#define KB_ROW2 GPIOD,2 /* K2 */
#define KB_ROW3 GPIOD,3 /* K3 */
#define MONI_SW LCD_D7
#define FUNC_SW LCD_D6
/* 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
/* PLL */
#define PLL_CS GPIOD,11
#define PLL_CLK GPIOE,4
#define PLL_DAT GPIOE,5 /* WARNING: this line is also HR_C5000 MOSI */
#define PLL_LD GPIOD,10
/* HR_C5000 */
#define DMR_CS GPIOE,2
#define DMR_CLK GPIOC,13
#define DMR_MOSI PLL_DAT
#define DMR_MISO GPIOE,3
#define DMR_SLEEP GPIOE,6
#define V_CS GPIOB,12
/* RTX control */
#define PLL_PWR GPIOA,8
#define VCOVCC_SW GPIOA,9
#define DMR_SW GPIOA,10
#define FM_SW GPIOB,2
#define WN_SW GPIOA,13
#define RF_APC_SW GPIOC,4
#define TX_STG_EN GPIOC,5
#define RX_STG_EN GPIOC,9
#define APC_TV GPIOA,4
#define MOD2_BIAS GPIOA,5
/* Audio control */
#define AMP_EN GPIOB,9
#define SPK_MUTE GPIOB,8
#define FM_MUTE GPIOE,13
#define MIC_PWR GPIOA,14
#endif

Wyświetl plik

@ -1,204 +0,0 @@
/***************************************************************************
* Copyright (C) 2020 by Federico Amedeo Izzo IU2NUO, *
* Niccolò Izzo IU2KIN *
* 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 <http://www.gnu.org/licenses/> *
***************************************************************************/
#include <interfaces/gpio.h>
#include <interfaces/nvmem.h>
#include <interfaces/platform.h>
#include <hwconfig.h>
#include <string.h>
#include <ADC1_MDx.h>
#include <calibInfo_MDx.h>
#include <toneGenerator_MDx.h>
#include <interfaces/rtc.h>
md3x0Calib_t calibration;
hwInfo_t hwInfo;
void platform_init()
{
/* Configure GPIOs */
gpio_setMode(GREEN_LED, OUTPUT);
gpio_setMode(RED_LED, OUTPUT);
gpio_setMode(LCD_BKLIGHT, ALTERNATE);
gpio_setAlternateFunction(LCD_BKLIGHT, 3);
gpio_setMode(CH_SELECTOR_0, INPUT);
gpio_setMode(CH_SELECTOR_1, INPUT);
gpio_setMode(CH_SELECTOR_2, INPUT);
gpio_setMode(CH_SELECTOR_3, INPUT);
gpio_setMode(PTT_SW, INPUT);
/*
* Initialise ADC1, for vbat, RSSI, ...
* Configuration of corresponding GPIOs in analog input mode is done inside
* the driver.
*/
adc1_init();
memset(&hwInfo, 0x00, sizeof(hwInfo));
nvm_init(); /* Initialise non volatile memory manager */
nvm_readCalibData(&calibration); /* Load calibration data */
nvm_loadHwInfo(&hwInfo); /* Load hardware information data */
toneGen_init(); /* Initialise tone generator */
rtc_init(); /* Initialise RTC */
/*
* Configure TIM8 for backlight PWM: Fpwm = 100kHz with 8 bit of resolution.
* APB2 freq. is 84MHz, but timer runs at twice this frequency.
* Then: PSC = 655 to have Ftick = 256.097kHz
* With ARR = 256, Fpwm is 100kHz;
* Backlight pin is connected to TIM8 CR1.
*/
RCC->APB2ENR |= RCC_APB2ENR_TIM8EN;
__DSB();
TIM8->ARR = 255;
TIM8->PSC = 654;
TIM8->CNT = 0;
TIM8->CR1 |= TIM_CR1_ARPE; /* LCD backlight is on PC6, TIM8-CH1 */
TIM8->CCMR1 |= TIM_CCMR1_OC1M_2
| TIM_CCMR1_OC1M_1
| TIM_CCMR1_OC1PE;
TIM8->CCER |= TIM_CCER_CC1E;
TIM8->BDTR |= TIM_BDTR_MOE;
TIM8->CCR1 = 0;
TIM8->EGR = TIM_EGR_UG; /* Update registers */
TIM8->CR1 |= TIM_CR1_CEN; /* Start timer */
}
void platform_terminate()
{
/* Shut down backlight */
gpio_setMode(LCD_BKLIGHT, OUTPUT);
gpio_clearPin(LCD_BKLIGHT);
/* Shut down LEDs */
gpio_clearPin(GREEN_LED);
gpio_clearPin(RED_LED);
/* Shut down timer */
RCC->APB2ENR &= ~RCC_APB2ENR_TIM8EN;
__DSB();
/* Shut down all the modules */
adc1_terminate();
nvm_terminate();
toneGen_terminate();
rtc_terminate();
}
float platform_getVbat()
{
/*
* 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 and divide by 1000
*/
return adc1_getMeasurement(0)*3.0f/1000.0f;
}
float platform_getMicLevel()
{
return adc1_getMeasurement(2);
}
float platform_getVolumeLevel()
{
return adc1_getMeasurement(3);
}
uint8_t platform_getChSelector()
{
static const uint8_t rsPositions[] = { 11, 14, 10, 15, 6, 3, 7, 2, 12, 13,
9, 16, 5, 4, 8, 1 };
int pos = gpio_readPin(CH_SELECTOR_0)
| (gpio_readPin(CH_SELECTOR_1) << 1)
| (gpio_readPin(CH_SELECTOR_2) << 2)
| (gpio_readPin(CH_SELECTOR_3) << 3);
return rsPositions[pos];
}
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)
{
TIM8->CCR1 = level;
}
const void *platform_getCalibrationData()
{
return ((const void *) &calibration);
}
const hwInfo_t *platform_getHwInfo()
{
return &hwInfo;
}