From 2d876b8d8e29b45b42ca7d30dad12584f3744742 Mon Sep 17 00:00:00 2001 From: Geoffrey Merck Date: Sun, 3 May 2020 15:36:10 +0200 Subject: [PATCH 1/5] Fix Fancy LED effect accessing unused ports --- IOSTM_CMSIS.cpp | 43 ++++++++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/IOSTM_CMSIS.cpp b/IOSTM_CMSIS.cpp index e3763b4..17e6518 100644 --- a/IOSTM_CMSIS.cpp +++ b/IOSTM_CMSIS.cpp @@ -158,16 +158,29 @@ void GPIOConfigPin(GPIO_TypeDef *port_ptr, uint32_t pin, uint32_t mode_cnf_value #if defined(STM32F1_POG) void FancyLEDEffect() { - bitband_t foo[] = {&BB_LED, &BB_COSLED, &BB_PTT, &BB_DMR, &BB_DSTAR, &BB_YSF, &BB_P25, &BB_NXDN, &BB_POCSAG, &BB_FM}; - - for(int i=0; i<10; i++){ - *foo[i] = 0x01; + int ledCount = 10; + + bitband_t foo[] = {&BB_LED, &BB_COSLED, &BB_PTT, &BB_DMR, &BB_DSTAR, &BB_YSF, &BB_P25, NULL, NULL, NULL}; +#if !defined(USE_ALTERNATE_NXDN_LEDS) + foo_[7] = &BB_NXDN; +#endif +#if !defined(USE_ALTERNATE_POCSAG_LEDS) + foo__[8] = &BB_POCSAG; +#endif +#if !defined(USE_ALTERNATE_FM_LEDS) + foo__[9] = &BB_FM; +#endif + + for(int i=0; iODR, PIN_USART1_TXD)) = 0x00; delay(SystemCoreClock/1000*100); - for(int i=0; i<7; i++){ - *foo[i] = 0x00; + for(int i=0; iODR, PIN_USART1_TXD)) = 0x01; delay(SystemCoreClock/1000*20); @@ -176,18 +189,22 @@ void FancyLEDEffect() *((bitband_t)BITBAND_PERIPH(&PORT_USART1_TXD->ODR, PIN_USART1_TXD)) = 0x01; *foo[0] = 0x01; - for(int i=1; i<10; i++){ + for(int i=1; i=0; i--){ + for(int i=ledCount - 2; i>=0; i--) { delay(SystemCoreClock/1000*10); - *foo[i+1] = 0x00; - *foo[i] = 0x01; + if (foo[i+1] != NULL) + *foo[i+1] = 0x00; + if (foo[i] != NULL) + *foo[i] = 0x01; } delay(SystemCoreClock/1000*10); - *foo[5+1-6] = 0x00; + *foo[0] = 0x00; *((bitband_t)BITBAND_PERIPH(&PORT_USART1_TXD->ODR, PIN_USART1_TXD)) = 0x00; delay(SystemCoreClock/1000*10); *((bitband_t)BITBAND_PERIPH(&PORT_USART1_TXD->ODR, PIN_USART1_TXD)) = 0x01; From 5e8556520818d339e8175d35ef16e12f24798906 Mon Sep 17 00:00:00 2001 From: Geoffrey Merck Date: Mon, 4 May 2020 15:26:17 +0200 Subject: [PATCH 2/5] Fix compile isue --- IOSTM_CMSIS.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/IOSTM_CMSIS.cpp b/IOSTM_CMSIS.cpp index 17e6518..4d36e9f 100644 --- a/IOSTM_CMSIS.cpp +++ b/IOSTM_CMSIS.cpp @@ -162,13 +162,13 @@ void FancyLEDEffect() bitband_t foo[] = {&BB_LED, &BB_COSLED, &BB_PTT, &BB_DMR, &BB_DSTAR, &BB_YSF, &BB_P25, NULL, NULL, NULL}; #if !defined(USE_ALTERNATE_NXDN_LEDS) - foo_[7] = &BB_NXDN; + foo[7] = &BB_NXDN; #endif #if !defined(USE_ALTERNATE_POCSAG_LEDS) - foo__[8] = &BB_POCSAG; + foo[8] = &BB_POCSAG; #endif #if !defined(USE_ALTERNATE_FM_LEDS) - foo__[9] = &BB_FM; + foo[9] = &BB_FM; #endif for(int i=0; i Date: Mon, 4 May 2020 16:43:08 +0200 Subject: [PATCH 3/5] Change FM LED Pin --- IOSTM_CMSIS.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IOSTM_CMSIS.cpp b/IOSTM_CMSIS.cpp index 17e6518..4418d1a 100644 --- a/IOSTM_CMSIS.cpp +++ b/IOSTM_CMSIS.cpp @@ -85,7 +85,7 @@ USART1_RXD PA10 input (AF) #define PIN_POCSAG 11 #define PORT_POCSAG GPIOB #define BB_POCSAG *((bitband_t)BITBAND_PERIPH(&PORT_POCSAG->ODR, PIN_POCSAG)) -#define PIN_FM 12 +#define PIN_FM 14 #define PORT_FM GPIOB #define BB_FM *((bitband_t)BITBAND_PERIPH(&PORT_FM->ODR, PIN_FM)) From 87feadd4514548c3d6c27621ba522a084ce12a85 Mon Sep 17 00:00:00 2001 From: Geoffrey Merck Date: Mon, 4 May 2020 19:12:45 +0200 Subject: [PATCH 4/5] Better LED management --- IOSTM_CMSIS.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/IOSTM_CMSIS.cpp b/IOSTM_CMSIS.cpp index 938a6db..6cd92a2 100644 --- a/IOSTM_CMSIS.cpp +++ b/IOSTM_CMSIS.cpp @@ -160,15 +160,21 @@ void FancyLEDEffect() { int ledCount = 10; - bitband_t foo[] = {&BB_LED, &BB_COSLED, &BB_PTT, &BB_DMR, &BB_DSTAR, &BB_YSF, &BB_P25, NULL, NULL, NULL}; -#if !defined(USE_ALTERNATE_NXDN_LEDS) - foo[7] = &BB_NXDN; + bitband_t foo[] = {&BB_LED, &BB_COSLED, &BB_PTT, &BB_DMR, &BB_DSTAR, &BB_YSF, &BB_P25, +#if defined(USE_ALTERNATE_NXDN_LEDS) + NULL, +#else + &BB_NXDN, #endif -#if !defined(USE_ALTERNATE_POCSAG_LEDS) - foo[8] = &BB_POCSAG; +#if defined(USE_ALTERNATE_POCSAG_LEDS) + NULL, +#else + &BB_POCSAG, #endif -#if !defined(USE_ALTERNATE_FM_LEDS) - foo[9] = &BB_FM; +#if defined(USE_ALTERNATE_FM_LEDS) + NULL}; +#else + &BB_FM}; #endif for(int i=0; i Date: Tue, 5 May 2020 10:48:44 +0200 Subject: [PATCH 5/5] Reduce buffer size --- FM.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FM.cpp b/FM.cpp index e843996..9f238da 100644 --- a/FM.cpp +++ b/FM.cpp @@ -44,7 +44,7 @@ m_deemphasis (32768, -18801, 0, 32768, 13967, 0),//75µS 24kHz sampling rate m_blanking(), m_useCOS(true), m_rfAudioBoost(1U), -m_downsampler(1024)//Size might need adjustement +m_downsampler(128)//Size might need adjustement { }