diff --git a/meson.build b/meson.build index 478ac40e..f2dc1d59 100644 --- a/meson.build +++ b/meson.build @@ -5,6 +5,12 @@ project('OpenRTX', ['c', 'cpp'], version : '0.3.1', default_options : ['warning_level=3']) +## +## Optional defines, common to all souces (e.g. to enable debugging) +## + +def = { } + ## ## ----------------- Platform-independent source files ------------------------- ## @@ -71,7 +77,7 @@ rtos_inc = ['lib/miosix-kernel', src = openrtx_src + minmea_src inc = openrtx_inc + rtos_inc + minmea_inc + qdec_inc -def = {'DONT_USE_CMSIS_INIT': ''} +def = def + {'DONT_USE_CMSIS_INIT': ''} ## Add git commit or tag to print in OpenRTX r = run_command('git', 'describe', '--tags', '--dirty') diff --git a/platform/drivers/audio/audio_MDx.c b/platform/drivers/audio/audio_MDx.c index 86ce780d..4e610a07 100644 --- a/platform/drivers/audio/audio_MDx.c +++ b/platform/drivers/audio/audio_MDx.c @@ -28,14 +28,18 @@ void audio_init() gpio_setMode(SPK_MUTE, OUTPUT); #ifndef PLATFORM_MD9600 gpio_setMode(AUDIO_AMP_EN, OUTPUT); + #ifndef MDx_ENABLE_SWD gpio_setMode(MIC_PWR, OUTPUT); #endif + #endif gpio_setPin(SPK_MUTE); /* Speaker muted */ #ifndef PLATFORM_MD9600 gpio_clearPin(AUDIO_AMP_EN); /* Audio PA off */ + #ifndef MDx_ENABLE_SWD gpio_clearPin(MIC_PWR); /* Mic preamp. off */ #endif + #endif } void audio_terminate() @@ -43,20 +47,22 @@ void audio_terminate() gpio_setPin(SPK_MUTE); /* Speaker muted */ #ifndef PLATFORM_MD9600 gpio_clearPin(AUDIO_AMP_EN); /* Audio PA off */ + #ifndef MDx_ENABLE_SWD gpio_clearPin(MIC_PWR); /* Mic preamp. off */ #endif + #endif } void audio_enableMic() { - #ifndef PLATFORM_MD9600 + #if !defined(PLATFORM_MD9600) && !defined(MDx_ENABLE_SWD) gpio_setPin(MIC_PWR); #endif } void audio_disableMic() { - #ifndef PLATFORM_MD9600 + #if !defined(PLATFORM_MD9600) && !defined(MDx_ENABLE_SWD) gpio_clearPin(MIC_PWR); #endif } diff --git a/platform/drivers/baseband/radio_MD3x0.cpp b/platform/drivers/baseband/radio_MD3x0.cpp index 30a5ca1e..ca8c3f62 100644 --- a/platform/drivers/baseband/radio_MD3x0.cpp +++ b/platform/drivers/baseband/radio_MD3x0.cpp @@ -61,17 +61,23 @@ void _setBandwidth(const enum bandwidth bw) switch(bw) { case BW_12_5: + #ifndef MDx_ENABLE_SWD gpio_clearPin(WN_SW); + #endif C5000.setModFactor(0x1E); break; case BW_20: + #ifndef MDx_ENABLE_SWD gpio_setPin(WN_SW); + #endif C5000.setModFactor(0x30); break; case BW_25: + #ifndef MDx_ENABLE_SWD gpio_setPin(WN_SW); + #endif C5000.setModFactor(0x3C); break; @@ -97,7 +103,9 @@ void radio_init(const rtxStatus_t *rtxState) gpio_setMode(PLL_PWR, OUTPUT); gpio_setMode(VCOVCC_SW, OUTPUT); gpio_setMode(DMR_SW, OUTPUT); + #ifndef MDx_ENABLE_SWD gpio_setMode(WN_SW, OUTPUT); + #endif gpio_setMode(FM_SW, OUTPUT); gpio_setMode(RF_APC_SW, OUTPUT); gpio_setMode(TX_STG_EN, OUTPUT); @@ -108,7 +116,9 @@ void radio_init(const rtxStatus_t *rtxState) gpio_clearPin(PLL_PWR); // PLL off gpio_setPin(VCOVCC_SW); // VCOVCC high enables RX VCO, TX VCO if low + #ifndef MDx_ENABLE_SWD gpio_setPin(WN_SW); // 25kHz bandwidth + #endif gpio_clearPin(DMR_SW); // Disconnect HR_C5000 input IF signal and audio out gpio_clearPin(FM_SW); // Disconnect analog FM audio path gpio_clearPin(RF_APC_SW); // Disable TX power control diff --git a/platform/mcu/STM32F4xx/boot/bsp.cpp b/platform/mcu/STM32F4xx/boot/bsp.cpp index 51da8938..33d471eb 100644 --- a/platform/mcu/STM32F4xx/boot/bsp.cpp +++ b/platform/mcu/STM32F4xx/boot/bsp.cpp @@ -52,6 +52,18 @@ void IRQbspInit() GPIOE->OSPEEDR=0xaaaaaaaa; GPIOH->OSPEEDR=0xaaaaaaaa; + /* + * Enable SWD interface on PA13 and PA14 (Tytera's bootloader disables this + * functionality). + * NOTE: these pins are used also for other functions (MIC power and wide/ + * narrow FM reception), thus they cannot be always used for debugging! + */ + #ifdef MDx_ENABLE_SWD + GPIOA->MODER &= ~0x3C000000; // Clear current setting + GPIOA->MODER |= 0x28000000; // Put back to alternate function + GPIOA->AFR[1] &= ~0x0FF00000; // SWD is AF0 + #endif + #ifdef MD3x0_ENABLE_DBG usart3_init(115200); usart3_IRQwrite("starting...\r\n");