diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index dd6ce83af0..1decfd3543 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -190,6 +190,7 @@ config ARCH_CHIP_SAMV7 select ARCH_CORTEXM7 select ARCH_HAVE_MPU select ARCH_HAVE_RAMFUNCS + select ARCH_HAVE_TICKLESS select ARMV7M_HAVE_STACKCHECK ---help--- Atmel SAMV7 (ARM Cortex-M7) architectures diff --git a/arch/arm/src/sama5/sam_tickless.c b/arch/arm/src/sama5/sam_tickless.c index ad5a923269..64d481649a 100644 --- a/arch/arm/src/sama5/sam_tickless.c +++ b/arch/arm/src/sama5/sam_tickless.c @@ -243,6 +243,9 @@ static void sam_oneshot_handler(void *arg) void up_timer_initialize(void) { +#ifdef CONFIG_SCHED_TICKLESS_LIMIT_MAX_SLEEP + uint64_t max_delay; +#endif int ret; /* Initialize the one-shot timer */ @@ -256,6 +259,29 @@ void up_timer_initialize(void) PANIC(); } +#ifdef CONFIG_SCHED_TICKLESS_LIMIT_MAX_SLEEP + /* Get the maximum delay of the one-shot timer in microseconds */ + + ret = sam_oneshot_max_delay(&g_tickless.oneshot, &max_delay); + if (ret < 0) + { + tclldbg("ERROR: sam_oneshot_max_delay failed\n"); + PANIC(); + } + + /* Convert this to configured clock ticks for use by the OS timer logic */ + + max_delay /= CONFIG_USEC_PER_TICK; + if (max_delay > (uint64_t)UINT32_MAX) + { + g_oneshot_maxticks = UINT32_MAX; + } + else + { + g_oneshot_maxticks = (uint32_t)max_delay; + } +#endif + /* Initialize the free-running timer */ ret = sam_freerun_initialize(&g_tickless.freerun, diff --git a/arch/arm/src/samv7/sam_oneshot.c b/arch/arm/src/samv7/sam_oneshot.c index 9c165bd687..b9ac3c209e 100644 --- a/arch/arm/src/samv7/sam_oneshot.c +++ b/arch/arm/src/samv7/sam_oneshot.c @@ -467,7 +467,7 @@ int sam_oneshot_cancel(struct sam_oneshot_s *oneshot, struct timespec *ts) * ****************************************************************************/ -#if 0 /* Not used */ +#ifdef CONFIG_SCHED_TICKLESS_LIMIT_MAX_SLEEP int sam_oneshot_max_delay(struct sam_oneshot_s *oneshot, uint64_t *usec) { DEBUGASSERT(oneshot && usec); diff --git a/arch/arm/src/samv7/sam_oneshot.h b/arch/arm/src/samv7/sam_oneshot.h index 09b341cdf2..dec668a331 100644 --- a/arch/arm/src/samv7/sam_oneshot.h +++ b/arch/arm/src/samv7/sam_oneshot.h @@ -141,7 +141,7 @@ int sam_oneshot_initialize(struct sam_oneshot_s *oneshot, int chan, * ****************************************************************************/ -#if 0 /* Not used */ +#ifdef CONFIG_SCHED_TICKLESS_LIMIT_MAX_SLEEP int sam_oneshot_max_delay(struct sam_oneshot_s *oneshot, uint64_t *usec); #endif