1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

sys/ztimer/auto_init: use default configuration header

This commit is contained in:
Francisco Molina 2020-05-05 12:12:16 +02:00
parent bc16809d9c
commit 95e2221003
No known key found for this signature in database
GPG Key ID: 3E94EAC3DBDEEDA8

View File

@ -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