From bc16809d9cd58cc7c5cb7208a4267cf0165cbb6d Mon Sep 17 00:00:00 2001 From: Francisco Molina Date: Tue, 5 May 2020 12:10:15 +0200 Subject: [PATCH] sys/include/ztimer: add configuration header --- sys/include/ztimer/config.h | 121 ++++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 sys/include/ztimer/config.h diff --git a/sys/include/ztimer/config.h b/sys/include/ztimer/config.h new file mode 100644 index 0000000000..89b467423e --- /dev/null +++ b/sys/include/ztimer/config.h @@ -0,0 +1,121 @@ +/* + * Copyright (C) 2020 Inria + * + * This file is subject to the terms and conditions of the GNU Lesser General + * Public License v2.1. See the file LICENSE in the top level directory for more + * details. + */ + +/** + * @ingroup sys_ztimer + * @{ + * + * @file + * @brief ztimer default configuration + * + * + * @author Kaspar Schleiser + */ + +#ifndef ZTIMER_CONFIG_H +#define ZTIMER_CONFIG_H + +#include "board.h" +#include "periph_conf.h" + +#include "ztimer.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * @brief Use periph_timer as the base timer for ZTIMER_USEC + */ +#define CONFIG_ZTIMER_USEC_TYPE_PERIPH_TIMER (1) + +/* 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 +# endif +# ifndef CONFIG_ZTIMER_USEC_BASE_FREQ +# ifdef XTIMER_HZ +# define CONFIG_ZTIMER_USEC_BASE_FREQ XTIMER_HZ +# endif +# endif +# ifndef CONFIG_ZTIMER_USEC_WIDTH +# ifdef XTIMER_WIDTH +# define CONFIG_ZTIMER_USEC_WIDTH XTIMER_WIDTH +# endif +# endif +#endif + +/** + * @brief Default timer device for ZTIMER_USEC + */ +#ifndef CONFIG_ZTIMER_USEC_DEV +#define CONFIG_ZTIMER_USEC_DEV (TIMER_DEV(0)) +#endif + +/** + * @brief ZTIMER_USEC optimal minimum value for ztimer_set() + * + * When scheduling an ISR every timer will be set to: + * max(CONFIG_ZTIMER_USEC_MIN, value). + * + * This value only applies if the counter object used for ZTIMER_USEC is + * periph_timer. This is supposed to be defined per-device in e.g., board.h. + */ +#ifndef CONFIG_ZTIMER_USEC_MIN +#define CONFIG_ZTIMER_USEC_MIN (10) +#endif + +/** + @brief ZTIMER_USEC counter object width + */ +#ifndef CONFIG_ZTIMER_USEC_WIDTH +# if (TIMER_0_MAX_VALUE) == 0xffff +# define CONFIG_ZTIMER_USEC_WIDTH (16) +# elif (TIMER_0_MAX_VALUE) == 0xffffffUL +# define CONFIG_ZTIMER_USEC_WIDTH (24) +# else +# define CONFIG_ZTIMER_USEC_WIDTH (32) +# endif +#endif + +/** + * @brief The frequency of ZTIMER_USEC_BASE (base ztimer for ZTIMER_USEC) + */ +#ifndef CONFIG_ZTIMER_USEC_BASE_FREQ +#define CONFIG_ZTIMER_USEC_BASE_FREQ (1000000LU) +#endif + +/** + * @brief The frequency of ZTIMER_MSEC_BASE (base ztimer for ZTIMER_MSEC) + */ +#ifdef MODULE_ZTIMER_PERIPH_RTT +# define CONFIG_ZTIMER_MSEC_BASE_FREQ (RTT_FREQUENCY) +# else +# define CONFIG_ZTIMER_MSEC_BASE_FREQ (CONFIG_ZTIMER_USEC_BASE_FREQ) +#endif /* MODULE_ZTIMER_PERIPH_RTT */ + +/** + * @brief The minimum pm mode required for ZTIMER_USEC to run. + */ +#ifndef CONFIG_ZTIMER_USEC_REQUIRED_PM_MODE +#define CONFIG_ZTIMER_USEC_REQUIRED_PM_MODE ZTIMER_CLOCK_NO_REQUIRED_PM_MODE +#endif + +/** + * @brief The minimum pm mode required for ZTIMER_MSEC to run + */ +#ifndef CONFIG_ZTIMER_MSEC_REQUIRED_PM_MODE +#define CONFIG_ZTIMER_MSEC_REQUIRED_PM_MODE ZTIMER_CLOCK_NO_REQUIRED_PM_MODE +#endif + +#endif /* ZTIMER_CONFIG_H */ +/** @} */