From 95e2221003d3e2d2d54bf98bf5d82dc6a4ceb902 Mon Sep 17 00:00:00 2001 From: Francisco Molina Date: Tue, 5 May 2020 12:12:16 +0200 Subject: [PATCH] sys/ztimer/auto_init: use default configuration header --- sys/ztimer/auto_init.c | 65 ++++++++---------------------------------- 1 file changed, 12 insertions(+), 53 deletions(-) diff --git a/sys/ztimer/auto_init.c b/sys/ztimer/auto_init.c index 886f9d5db4..83d85229e4 100644 --- a/sys/ztimer/auto_init.c +++ b/sys/ztimer/auto_init.c @@ -43,64 +43,23 @@ #include "ztimer/convert_muldiv64.h" #include "ztimer/periph_timer.h" #include "ztimer/periph_rtt.h" +#include "ztimer/config.h" #include "log.h" #define WIDTH_TO_MAXVAL(width) (UINT32_MAX >> (32 - width)) -#define CONFIG_ZTIMER_USEC_TYPE_PERIPH_TIMER (1) - #define FREQ_1MHZ 1000000LU #define FREQ_250KHZ 250000LU #define FREQ_1KHZ 1000LU -/* for ZTIMER_USEC, use xtimer configuration if available and no ztimer - * specific configuration is set. */ -#if CONFIG_ZTIMER_USEC_TYPE_PERIPH_TIMER -# ifndef CONFIG_ZTIMER_USEC_DEV -# ifdef XTIMER_DEV -# define CONFIG_ZTIMER_USEC_DEV XTIMER_DEV -# endif -# ifdef XTIMER_HZ -# define CONFIG_ZTIMER_USEC_FREQ XTIMER_HZ -# endif -# ifdef XTIMER_WIDTH -# define CONFIG_ZTIMER_USEC_WIDTH XTIMER_WIDTH -# endif -# endif -#endif - -#ifndef CONFIG_ZTIMER_USEC_DEV -#define CONFIG_ZTIMER_USEC_DEV (TIMER_DEV(0)) -#endif - -#ifndef CONFIG_ZTIMER_USEC_FREQ -#define CONFIG_ZTIMER_USEC_FREQ (FREQ_1MHZ) -#endif - -#ifndef CONFIG_ZTIMER_USEC_MIN -#define CONFIG_ZTIMER_USEC_MIN (10) -#endif - -#ifndef CONFIG_ZTIMER_USEC_WIDTH -#define CONFIG_ZTIMER_USEC_WIDTH (32) -#endif - -#ifndef CONFIG_ZTIMER_USEC_REQUIRED_PM_MODE -#define CONFIG_ZTIMER_USEC_REQUIRED_PM_MODE ZTIMER_CLOCK_NO_REQUIRED_PM_MODE -#endif - -#ifndef CONFIG_ZTIMER_MSEC_REQUIRED_PM_MODE -#define CONFIG_ZTIMER_MSEC_REQUIRED_PM_MODE ZTIMER_CLOCK_NO_REQUIRED_PM_MODE -#endif - #if MODULE_ZTIMER_USEC # if CONFIG_ZTIMER_USEC_TYPE_PERIPH_TIMER static ztimer_periph_timer_t _ztimer_periph_timer_usec = { .min = CONFIG_ZTIMER_USEC_MIN }; ztimer_clock_t *const ZTIMER_USEC_BASE = &_ztimer_periph_timer_usec.super; -# if CONFIG_ZTIMER_USEC_FREQ == FREQ_1MHZ +# if CONFIG_ZTIMER_USEC_BASE_FREQ == FREQ_1MHZ ztimer_clock_t *const ZTIMER_USEC = &_ztimer_periph_timer_usec.super; -# elif CONFIG_ZTIMER_USEC_FREQ == 250000LU +# elif CONFIG_ZTIMER_USEC_BASE_FREQ == 250000LU static ztimer_convert_shift_t _ztimer_convert_shift_usec; ztimer_clock_t *const ZTIMER_USEC = &_ztimer_convert_shift_usec.super.super; # else @@ -130,9 +89,9 @@ ztimer_clock_t *const ZTIMER_MSEC = &_ztimer_periph_timer_rtt_msec; static ztimer_convert_frac_t _ztimer_convert_frac_msec; ztimer_clock_t *const ZTIMER_MSEC = &_ztimer_convert_frac_msec.super.super; ztimer_clock_t *const ZTIMER_MSEC_BASE = &_ztimer_periph_timer_usec.super; -# if CONFIG_ZTIMER_USEC_FREQ < FREQ_1MHZ +# if CONFIG_ZTIMER_USEC_BASE_FREQ < FREQ_1MHZ # define ZTIMER_MSEC_CONVERT_LOWER ZTIMER_USEC_CONVERT_LOWER -# define ZTIMER_MSEC_CONVERT_LOWER_FREQ CONFIG_ZTIMER_USEC_FREQ +# define ZTIMER_MSEC_CONVERT_LOWER_FREQ CONFIG_ZTIMER_USEC_BASE_FREQ # else # define ZTIMER_MSEC_CONVERT_LOWER (ZTIMER_USEC) # define ZTIMER_MSEC_CONVERT_LOWER_FREQ FREQ_1MHZ @@ -148,22 +107,22 @@ void ztimer_init(void) # if CONFIG_ZTIMER_USEC_TYPE_PERIPH_TIMER LOG_DEBUG( "ztimer_init(): ZTIMER_USEC using periph timer %u, freq %lu, width %u\n", - CONFIG_ZTIMER_USEC_DEV, CONFIG_ZTIMER_USEC_FREQ, CONFIG_ZTIMER_USEC_WIDTH); + CONFIG_ZTIMER_USEC_DEV, CONFIG_ZTIMER_USEC_BASE_FREQ, CONFIG_ZTIMER_USEC_WIDTH); ztimer_periph_timer_init(&_ztimer_periph_timer_usec, CONFIG_ZTIMER_USEC_DEV, - CONFIG_ZTIMER_USEC_FREQ, + CONFIG_ZTIMER_USEC_BASE_FREQ, WIDTH_TO_MAXVAL(CONFIG_ZTIMER_USEC_WIDTH)); # endif -# if CONFIG_ZTIMER_USEC_FREQ != FREQ_1MHZ -# if CONFIG_ZTIMER_USEC_FREQ == FREQ_250KHZ +# if CONFIG_ZTIMER_USEC_BASE_FREQ != FREQ_1MHZ +# if CONFIG_ZTIMER_USEC_BASE_FREQ == FREQ_250KHZ LOG_DEBUG("ztimer_init(): ZTIMER_USEC convert_shift %lu to 1000000\n", - CONFIG_ZTIMER_USEC_FREQ); + CONFIG_ZTIMER_USEC_BASE_FREQ); ztimer_convert_shift_up_init(&_ztimer_convert_shift_usec, &_ztimer_periph_timer_usec.super, 2); # else LOG_DEBUG("ztimer_init(): ZTIMER_USEC convert_frac %lu to 1000000\n", - CONFIG_ZTIMER_USEC_FREQ); + CONFIG_ZTIMER_USEC_BASE_FREQ); ztimer_convert_frac_init(&_ztimer_convert_frac_usec, &_ztimer_periph_timer_usec.super, - FREQ_1MHZ, CONFIG_ZTIMER_USEC_FREQ); + FREQ_1MHZ, CONFIG_ZTIMER_USEC_BASE_FREQ); # endif # endif # ifdef CONFIG_ZTIMER_USEC_ADJUST