diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index fcc1c9ce98..12af0d6056 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -224,6 +224,7 @@ config ARCH_CHIP_STM32 select ARM_HAVE_MPU_UNIFIED select ARCH_HAVE_I2CRESET select ARCH_HAVE_HEAPCHECK + select ARCH_HAVE_TICKLESS select ARMV7M_HAVE_STACKCHECK ---help--- STMicro STM32 architectures (ARM Cortex-M3/4). diff --git a/arch/arm/src/stm32/Kconfig b/arch/arm/src/stm32/Kconfig index bd8e0ca00c..932e74c81b 100644 --- a/arch/arm/src/stm32/Kconfig +++ b/arch/arm/src/stm32/Kconfig @@ -1285,7 +1285,6 @@ config STM32_LOWDENSITY config STM32_STM32F20XX bool default n - select ARCH_HAVE_TICKLESS config STM32_STM32F205 bool @@ -2167,42 +2166,6 @@ config STM32_TSC default n depends on STM32_STM32F30XX -config STM32_ONESHOT - bool "TIM one-shot wrapper" - default n if !SCHED_TICKLESS - default y if SCHED_TICKLESS - ---help--- - Enable a wrapper around the low level timer/counter functions to - support one-shot timer. - -config STM32_FREERUN - bool "TIM free-running wrapper" - default n if !SCHED_TICKLESS - default y if SCHED_TICKLESS - ---help--- - Enable a wrapper around the low level timer/counter functions to - support a free-running timer. - -if SCHED_TICKLESS - -config STM32_TICKLESS_ONESHOT - int "Tickless one-shot timer channel" - default 2 - range 1 14 - ---help--- - If the Tickless OS feature is enabled, the one clock must be - assigned to provided the one-shot timer needed by the OS. - -config STM32_TICKLESS_FREERUN - int "Tickless free-running timer channel" - default 5 - range 1 14 - ---help--- - If the Tickless OS feature is enabled, the one clock must be - assigned to provided the free-running timer needed by the OS. - -endif - config STM32_USART1 bool "USART1" default n @@ -2581,6 +2544,54 @@ config STM32_FSMC_SRAM menu "Timer Configuration" +if SCHED_TICKLESS + +config STM32_ONESHOT + bool + default y + +config STM32_FREERUN + bool + default y + +endif # SCHED_TICKLESS + +if !SCHED_TICKLESS + +config STM32_ONESHOT + bool "TIM one-shot wrapper" + default n + ---help--- + Enable a wrapper around the low level timer/counter functions to + support one-shot timer. + +config STM32_FREERUN + bool "TIM free-running wrapper" + default n + ---help--- + Enable a wrapper around the low level timer/counter functions to + support a free-running timer. + +endif # !SCHED_TICKLESS + +config STM32_TICKLESS_ONESHOT + int "Tickless one-shot timer channel" + default 2 + range 1 14 + depends on STM32_ONESHOT + ---help--- + If the Tickless OS feature is enabled, the one clock must be + assigned to provided the one-shot timer needed by the OS. + +config STM32_TICKLESS_FREERUN + int "Tickless free-running timer channel" + default 5 + range 1 14 + depends on STM32_FREERUN + ---help--- + If the Tickless OS feature is enabled, the one clock must be + assigned to provided the free-running timer needed by the OS. + config STM32_TIM1_PWM bool "TIM1 PWM" default n diff --git a/arch/arm/src/stm32/stm32_freerun.c b/arch/arm/src/stm32/stm32_freerun.c index 42a2128a6d..836df043ad 100644 --- a/arch/arm/src/stm32/stm32_freerun.c +++ b/arch/arm/src/stm32/stm32_freerun.c @@ -45,7 +45,7 @@ #include #include -#include +#include #include #include "stm32_freerun.h" @@ -201,7 +201,7 @@ int stm32_freerun_counter(struct stm32_freerun_s *freerun, * be lost. */ - flags = irqsave(); + flags = enter_critical_section(); overflow = freerun->overflow; counter = STM32_TIM_GETCOUNTER(freerun->tch); @@ -228,7 +228,7 @@ int stm32_freerun_counter(struct stm32_freerun_s *freerun, freerun->overflow = overflow; } - irqrestore(flags); + leave_critical_section(flags); tmrinfo("counter=%lu (%lu) overflow=%lu, pending=%i\n", (unsigned long)counter, (unsigned long)verify, diff --git a/arch/arm/src/stm32/stm32_freerun.h b/arch/arm/src/stm32/stm32_freerun.h index 1eae58941b..08dd1786da 100644 --- a/arch/arm/src/stm32/stm32_freerun.h +++ b/arch/arm/src/stm32/stm32_freerun.h @@ -44,6 +44,7 @@ #include #include +#include #include "stm32_tim.h" diff --git a/arch/arm/src/stm32/stm32_oneshot.c b/arch/arm/src/stm32/stm32_oneshot.c index db724ebfd1..8f5e89df62 100644 --- a/arch/arm/src/stm32/stm32_oneshot.c +++ b/arch/arm/src/stm32/stm32_oneshot.c @@ -44,8 +44,9 @@ #include #include #include +#include -#include +#include #include #include "stm32_oneshot.h" @@ -223,7 +224,7 @@ int stm32_oneshot_start(struct stm32_oneshot_s *oneshot, /* Was the oneshot already running? */ - flags = irqsave(); + flags = enter_critical_section(); if (oneshot->running) { /* Yes.. then cancel it */ @@ -276,7 +277,7 @@ int stm32_oneshot_start(struct stm32_oneshot_s *oneshot, */ oneshot->running = true; - irqrestore(flags); + leave_critical_section(flags); return OK; } @@ -317,7 +318,7 @@ int stm32_oneshot_cancel(struct stm32_oneshot_s *oneshot, /* Was the timer running? */ - flags = irqsave(); + flags = enter_critical_section(); if (!oneshot->running) { /* No.. Just return zero timer remaining and successful cancellation. @@ -327,7 +328,7 @@ int stm32_oneshot_cancel(struct stm32_oneshot_s *oneshot, ts->tv_sec = 0; ts->tv_nsec = 0; - irqrestore(flags); + leave_critical_section(flags); return OK; } @@ -355,7 +356,7 @@ int stm32_oneshot_cancel(struct stm32_oneshot_s *oneshot, oneshot->running = false; oneshot->handler = NULL; oneshot->arg = NULL; - irqrestore(flags); + leave_critical_section(flags); /* Did the caller provide us with a location to return the time * remaining?