From d438ad983164fe15d943dae996282184f63bd9f9 Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Wed, 12 Feb 2020 15:15:49 +0000 Subject: [PATCH] Fixed bug #1073. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@13354 27425a3e-05d8-49a3-a47f-9c15f0e5edd8 --- demos/STM32/RT-STM32H755ZI-NUCLEO144/Makefile | 7 +- ...-NUCLEO144 (OpenOCD, Flash and Run).launch | 104 +++++++++--------- demos/STM32/RT-STM32H755ZI-NUCLEO144/main.c | 36 ++++++ os/hal/ports/STM32/LLD/ADCv1/hal_adc_lld.c | 1 + os/hal/ports/STM32/LLD/ADCv3/hal_adc_lld.c | 1 + readme.txt | 4 + 6 files changed, 98 insertions(+), 55 deletions(-) diff --git a/demos/STM32/RT-STM32H755ZI-NUCLEO144/Makefile b/demos/STM32/RT-STM32H755ZI-NUCLEO144/Makefile index f79323c3a..f08f2bd02 100644 --- a/demos/STM32/RT-STM32H755ZI-NUCLEO144/Makefile +++ b/demos/STM32/RT-STM32H755ZI-NUCLEO144/Makefile @@ -66,12 +66,12 @@ endif # Enables the use of FPU (no, softfp, hard). ifeq ($(USE_FPU),) - USE_FPU = no + USE_FPU = hard endif # FPU-related options. ifeq ($(USE_FPU_OPT),) - USE_FPU_OPT = -mfloat-abi=$(USE_FPU) -mfpu=fpv5-d16 + USE_FPU_OPT = -mfloat-abi=$(USE_FPU) -mfpu=fpv5-sp-d16 -fsingle-precision-constant endif # @@ -112,6 +112,7 @@ include $(CHIBIOS)/tools/mk/autobuild.mk include $(CHIBIOS)/test/lib/test.mk include $(CHIBIOS)/test/rt/rt_test.mk include $(CHIBIOS)/test/oslib/oslib_test.mk +include $(CHIBIOS)/os/hal/lib/streams/streams.mk # Define linker script file here LDSCRIPT= $(STARTUPLD)/STM32H755xI_M7.ld @@ -150,7 +151,7 @@ CPPWARN = -Wall -Wextra -Wundef # # List all user C define here, like -D_DEBUG=1 -UDEFS = -DCORE_CM7 +UDEFS = -DCORE_CM7 -DCHPRINTF_USE_FLOAT=1 # Define ASM defines here UADEFS = diff --git a/demos/STM32/RT-STM32H755ZI-NUCLEO144/debug/RT-STM32H755ZI-NUCLEO144 (OpenOCD, Flash and Run).launch b/demos/STM32/RT-STM32H755ZI-NUCLEO144/debug/RT-STM32H755ZI-NUCLEO144 (OpenOCD, Flash and Run).launch index 1f306d92a..0ee5ed369 100644 --- a/demos/STM32/RT-STM32H755ZI-NUCLEO144/debug/RT-STM32H755ZI-NUCLEO144 (OpenOCD, Flash and Run).launch +++ b/demos/STM32/RT-STM32H755ZI-NUCLEO144/debug/RT-STM32H755ZI-NUCLEO144 (OpenOCD, Flash and Run).launch @@ -1,52 +1,52 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/demos/STM32/RT-STM32H755ZI-NUCLEO144/main.c b/demos/STM32/RT-STM32H755ZI-NUCLEO144/main.c index 0549e6ea3..5a7f58f8c 100644 --- a/demos/STM32/RT-STM32H755ZI-NUCLEO144/main.c +++ b/demos/STM32/RT-STM32H755ZI-NUCLEO144/main.c @@ -19,6 +19,8 @@ #include "rt_test_root.h" #include "oslib_test_root.h" +#include "chprintf.h" + /* * This is a periodic thread that does absolutely nothing except flashing * a LED. @@ -44,9 +46,12 @@ static THD_FUNCTION(Thread1, arg) { } } +#include "i_ctrl.h" + /* * Application entry point. */ +__attribute__((section(".ram6_init.main"))) int main(void) { /* @@ -64,6 +69,37 @@ int main(void) { */ sdStart(&SD3, NULL); + time_measurement_t tm1; + chTMObjectInit(&tm1); + + float32_t vbridge[N_PHASES]; + + for (int i = 0; i < 10; i++) { + chTMStartMeasurementX(&tm1); + { + static float32_t duty[N_PHASES] = {0.0f}; + + float32_t il[N_PHASES] = {1.0f, 5.0f, 3.0f}; + float32_t vc[N_PHASES] = {300.0f, 400.0f, 100.0f}; + float32_t vDC[DC_RAILS] = {450.0f, 400.0f}; + float32_t iL_ref[N_PHASES] = {7.0f, 10.0f, 5.0f}; + bool enable = 1; + + ictrl_3L_step(il, vc, vDC, iL_ref, enable, vbridge); + + calculate_duty_cycle(vbridge, vDC, duty); + } + chTMStopMeasurementX(&tm1); + } + + chprintf((BaseSequentialStream *)&SD3, "Measurements: %d\r\n", tm1.n); + chprintf((BaseSequentialStream *)&SD3, "Best measurement: %d\r\n", tm1.best); + chprintf((BaseSequentialStream *)&SD3, "Worst measurement: %d\r\n", tm1.worst); + chprintf((BaseSequentialStream *)&SD3, "Last measurement: %d\r\n", tm1.last); + chprintf((BaseSequentialStream *)&SD3, "vbridge[0]: %f\r\n", vbridge[0]); + chprintf((BaseSequentialStream *)&SD3, "vbridge[1]: %f\r\n", vbridge[1]); + chprintf((BaseSequentialStream *)&SD3, "vbridge[2]: %f\r\n", vbridge[2]); + /* * Creates the example thread. */ diff --git a/os/hal/ports/STM32/LLD/ADCv1/hal_adc_lld.c b/os/hal/ports/STM32/LLD/ADCv1/hal_adc_lld.c index aa735a76b..12620003c 100644 --- a/os/hal/ports/STM32/LLD/ADCv1/hal_adc_lld.c +++ b/os/hal/ports/STM32/LLD/ADCv1/hal_adc_lld.c @@ -68,6 +68,7 @@ static void adc_lld_stop_adc(ADC_TypeDef *adc) { adc->CR |= ADC_CR_ADSTP; while (adc->CR & ADC_CR_ADSTP) ; + adcp->adc->IER = 0; } } diff --git a/os/hal/ports/STM32/LLD/ADCv3/hal_adc_lld.c b/os/hal/ports/STM32/LLD/ADCv3/hal_adc_lld.c index b9aa7b96e..663432ab2 100644 --- a/os/hal/ports/STM32/LLD/ADCv3/hal_adc_lld.c +++ b/os/hal/ports/STM32/LLD/ADCv3/hal_adc_lld.c @@ -258,6 +258,7 @@ static void adc_lld_stop_adc(ADCDriver *adcp) { adcp->adcm->CR |= ADC_CR_ADSTP; while (adcp->adcm->CR & ADC_CR_ADSTP) ; + adcp->adcm->IER = 0; } } diff --git a/readme.txt b/readme.txt index 583cc35d8..120e14dfc 100644 --- a/readme.txt +++ b/readme.txt @@ -154,6 +154,10 @@ - HAL: Added a new interface for range-finder devices (used by EX). - HAL: Added mcuconf.h updater tool for STM32F407 (backported to 19.1.1). - NIL: Integrated NIL 4.0. +- FIX: Fixed missing IRQ disabling in ADCv1 and ADCv3 STM32 drivers (bug #1073) + (backported to 19.1.4)(backported to 18.2.3). +- FIX: Fixed missing parenthesis in ADC _adc_isr_error_code macro (bug #1072) + (backported to 19.1.4)(backported to 18.2.3). - FIX: Fixed invalid macro check in test library (bug #1071) (backported to 19.1.4). - FIX: Fixed non-standard declaration in STM32 ADCv3 driver (bug #1070)