From 94a9e2c3deb15a541473e9abebf67c2e200c182c Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Fri, 5 Jul 2019 19:18:47 +0200 Subject: [PATCH 01/10] boards/stm32: introduce common timer config with TIM2 --- boards/common/stm32/include/cfg_timer_tim2.h | 60 ++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 boards/common/stm32/include/cfg_timer_tim2.h diff --git a/boards/common/stm32/include/cfg_timer_tim2.h b/boards/common/stm32/include/cfg_timer_tim2.h new file mode 100644 index 0000000000..9590ae32c9 --- /dev/null +++ b/boards/common/stm32/include/cfg_timer_tim2.h @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2019 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 boards_common_stm32 + * @{ + * + * @file + * @brief Common configuration for STM32 Timer peripheral based on TIM2 + * + * @author Alexandre Abadie + */ + +#ifndef CFG_TIMER_TIM2_H +#define CFG_TIMER_TIM2_H + +#include "periph_cpu.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @name Timer configuration + * @{ + */ +static const timer_conf_t timer_config[] = { + { + .dev = TIM2, +#if defined(CPU_FAM_STM32L0) || defined(CPU_FAM_STM32L1) + .max = 0x0000ffff, +#else + .max = 0xffffffff, +#endif +#if CPU_FAM_STM32L4 + .rcc_mask = RCC_APB1ENR1_TIM2EN, +#else + .rcc_mask = RCC_APB1ENR_TIM2EN, +#endif + .bus = APB1, + .irqn = TIM2_IRQn + } +}; + +#define TIMER_0_ISR isr_tim2 + +#define TIMER_NUMOF (sizeof(timer_config) / sizeof(timer_config[0])) +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* CFG_TIMER_TIM2_H */ +/** @} */ From e7e3f15d5d589118d736303c8302c0f09dafe47a Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Fri, 5 Jul 2019 19:21:08 +0200 Subject: [PATCH 02/10] boards/nucleo-f0/3/7: use common timer configuration --- boards/nucleo-f031k6/include/periph_conf.h | 20 +----------------- boards/nucleo-f042k6/include/periph_conf.h | 21 +------------------ boards/nucleo-f302r8/include/periph_conf.h | 20 +----------------- boards/nucleo-f303k8/include/periph_conf.h | 20 +----------------- boards/nucleo-f303re/include/periph_conf.h | 20 +----------------- boards/nucleo-f303ze/include/periph_conf.h | 20 +----------------- boards/nucleo-f334r8/include/periph_conf.h | 20 +----------------- boards/nucleo-f722ze/include/periph_conf.h | 20 +----------------- boards/nucleo-f746zg/include/periph_conf.h | 20 +----------------- boards/nucleo-f767zi/include/periph_conf.h | 20 +----------------- boards/stm32f769i-disco/include/periph_conf.h | 20 +----------------- 11 files changed, 11 insertions(+), 210 deletions(-) diff --git a/boards/nucleo-f031k6/include/periph_conf.h b/boards/nucleo-f031k6/include/periph_conf.h index ed5b8df88b..8a981f615b 100644 --- a/boards/nucleo-f031k6/include/periph_conf.h +++ b/boards/nucleo-f031k6/include/periph_conf.h @@ -21,6 +21,7 @@ #define PERIPH_CONF_H #include "periph_cpu.h" +#include "cfg_timer_tim2.h" #ifdef __cplusplus extern "C" { @@ -54,25 +55,6 @@ extern "C" { #define CLOCK_PLL_MUL (12) /** @} */ -/** - * @name Timer configuration - * @{ - */ -static const timer_conf_t timer_config[] = { - { - .dev = TIM2, - .max = 0xffffffff, - .rcc_mask = RCC_APB1ENR_TIM2EN, - .bus = APB1, - .irqn = TIM2_IRQn - } -}; - -#define TIMER_0_ISR isr_tim2 - -#define TIMER_NUMOF (sizeof(timer_config) / sizeof(timer_config[0])) -/** @} */ - /** * @name UART configuration * @{ diff --git a/boards/nucleo-f042k6/include/periph_conf.h b/boards/nucleo-f042k6/include/periph_conf.h index 2477916fa1..201ccad0b7 100644 --- a/boards/nucleo-f042k6/include/periph_conf.h +++ b/boards/nucleo-f042k6/include/periph_conf.h @@ -20,6 +20,7 @@ #define PERIPH_CONF_H #include "periph_cpu.h" +#include "cfg_timer_tim2.h" #ifdef __cplusplus extern "C" { @@ -53,26 +54,6 @@ extern "C" { #define CLOCK_PLL_MUL (12) /** @} */ - -/** - * @name Timer configuration - * @{ - */ -static const timer_conf_t timer_config[] = { - { - .dev = TIM2, - .max = 0xffffffff, - .rcc_mask = RCC_APB1ENR_TIM2EN, - .bus = APB1, - .irqn = TIM2_IRQn - } -}; - -#define TIMER_0_ISR isr_tim2 - -#define TIMER_NUMOF (sizeof(timer_config) / sizeof(timer_config[0])) -/** @} */ - /** * @name UART configuration * @{ diff --git a/boards/nucleo-f302r8/include/periph_conf.h b/boards/nucleo-f302r8/include/periph_conf.h index 7c63fc6f8a..5d90021967 100644 --- a/boards/nucleo-f302r8/include/periph_conf.h +++ b/boards/nucleo-f302r8/include/periph_conf.h @@ -26,6 +26,7 @@ #define PERIPH_CONF_H #include "periph_cpu.h" +#include "cfg_timer_tim2.h" #ifdef __cplusplus extern "C" { @@ -60,25 +61,6 @@ extern "C" { #define CLOCK_PLL_MUL (9) /** @} */ -/** - * @name Timer configuration - * @{ - */ -static const timer_conf_t timer_config[] = { - { - .dev = TIM2, - .max = 0xffffffff, - .rcc_mask = RCC_APB1ENR_TIM2EN, - .bus = APB1, - .irqn = TIM2_IRQn - } -}; - -#define TIMER_0_ISR isr_tim2 - -#define TIMER_NUMOF (sizeof(timer_config) / sizeof(timer_config[0])) -/** @} */ - /** * @name UART configuration * @{ diff --git a/boards/nucleo-f303k8/include/periph_conf.h b/boards/nucleo-f303k8/include/periph_conf.h index c436fecf1f..fa97db8cf5 100644 --- a/boards/nucleo-f303k8/include/periph_conf.h +++ b/boards/nucleo-f303k8/include/periph_conf.h @@ -22,6 +22,7 @@ #define PERIPH_CONF_H #include "periph_cpu.h" +#include "cfg_timer_tim2.h" #ifdef __cplusplus extern "C" { @@ -56,25 +57,6 @@ extern "C" { #define CLOCK_PLL_MUL (16) /** @} */ -/** - * @name Timer configuration - * @{ - */ -static const timer_conf_t timer_config[] = { - { - .dev = TIM2, - .max = 0xffffffff, - .rcc_mask = RCC_APB1ENR_TIM2EN, - .bus = APB1, - .irqn = TIM2_IRQn - } -}; - -#define TIMER_0_ISR isr_tim2 - -#define TIMER_NUMOF (sizeof(timer_config) / sizeof(timer_config[0])) -/** @} */ - /** * @name UART configuration * @{ diff --git a/boards/nucleo-f303re/include/periph_conf.h b/boards/nucleo-f303re/include/periph_conf.h index 1fd6b37262..e799ec0cea 100644 --- a/boards/nucleo-f303re/include/periph_conf.h +++ b/boards/nucleo-f303re/include/periph_conf.h @@ -24,6 +24,7 @@ #define PERIPH_CONF_H #include "periph_cpu.h" +#include "cfg_timer_tim2.h" #ifdef __cplusplus extern "C" { @@ -58,25 +59,6 @@ extern "C" { #define CLOCK_PLL_MUL (9) /** @} */ -/** - * @name Timer configuration - * @{ - */ -static const timer_conf_t timer_config[] = { - { - .dev = TIM2, - .max = 0xffffffff, - .rcc_mask = RCC_APB1ENR_TIM2EN, - .bus = APB1, - .irqn = TIM2_IRQn - } -}; - -#define TIMER_0_ISR isr_tim2 - -#define TIMER_NUMOF (sizeof(timer_config) / sizeof(timer_config[0])) -/** @} */ - /** * @name UART configuration * @{ diff --git a/boards/nucleo-f303ze/include/periph_conf.h b/boards/nucleo-f303ze/include/periph_conf.h index 835026347c..d8ab0900a9 100644 --- a/boards/nucleo-f303ze/include/periph_conf.h +++ b/boards/nucleo-f303ze/include/periph_conf.h @@ -22,6 +22,7 @@ #define PERIPH_CONF_H #include "periph_cpu.h" +#include "cfg_timer_tim2.h" #ifdef __cplusplus extern "C" { @@ -56,25 +57,6 @@ extern "C" { #define CLOCK_PLL_MUL (9) /** @} */ -/** - * @name Timer configuration - * @{ - */ -static const timer_conf_t timer_config[] = { - { - .dev = TIM2, - .max = 0xffffffff, - .rcc_mask = RCC_APB1ENR_TIM2EN, - .bus = APB1, - .irqn = TIM2_IRQn - } -}; - -#define TIMER_0_ISR isr_tim2 - -#define TIMER_NUMOF (sizeof(timer_config) / sizeof(timer_config[0])) -/** @} */ - /** * @name UART configuration * @{ diff --git a/boards/nucleo-f334r8/include/periph_conf.h b/boards/nucleo-f334r8/include/periph_conf.h index 2e32e8a57b..acced536c5 100644 --- a/boards/nucleo-f334r8/include/periph_conf.h +++ b/boards/nucleo-f334r8/include/periph_conf.h @@ -23,6 +23,7 @@ #define PERIPH_CONF_H #include "periph_cpu.h" +#include "cfg_timer_tim2.h" #ifdef __cplusplus extern "C" { @@ -57,25 +58,6 @@ extern "C" { #define CLOCK_PLL_MUL (9) /** @} */ -/** - * @name Timer configuration - * @{ - */ -static const timer_conf_t timer_config[] = { - { - .dev = TIM2, - .max = 0xffffffff, - .rcc_mask = RCC_APB1ENR_TIM2EN, - .bus = APB1, - .irqn = TIM2_IRQn - } -}; - -#define TIMER_0_ISR (isr_tim2) - -#define TIMER_NUMOF (sizeof(timer_config) / sizeof(timer_config[0])) -/** @} */ - /** * @name UART configuration * @{ diff --git a/boards/nucleo-f722ze/include/periph_conf.h b/boards/nucleo-f722ze/include/periph_conf.h index 5cc77ce4f5..fcb6222948 100644 --- a/boards/nucleo-f722ze/include/periph_conf.h +++ b/boards/nucleo-f722ze/include/periph_conf.h @@ -25,30 +25,12 @@ #include "f7/cfg_clock_216_8_1.h" #include "cfg_i2c1_pb8_pb9.h" #include "cfg_rtt_default.h" +#include "cfg_timer_tim2.h" #ifdef __cplusplus extern "C" { #endif -/** - * @name Timer configuration - * @{ - */ -static const timer_conf_t timer_config[] = { - { - .dev = TIM2, - .max = 0xffffffff, - .rcc_mask = RCC_APB1ENR_TIM2EN, - .bus = APB1, - .irqn = TIM2_IRQn - } -}; - -#define TIMER_0_ISR isr_tim2 - -#define TIMER_NUMOF (sizeof(timer_config) / sizeof(timer_config[0])) -/** @} */ - /** * @name UART configuration * @{ diff --git a/boards/nucleo-f746zg/include/periph_conf.h b/boards/nucleo-f746zg/include/periph_conf.h index 0cfbc413d8..9da171e9fd 100644 --- a/boards/nucleo-f746zg/include/periph_conf.h +++ b/boards/nucleo-f746zg/include/periph_conf.h @@ -25,30 +25,12 @@ #include "f7/cfg_clock_216_8_1.h" #include "cfg_i2c1_pb8_pb9.h" #include "cfg_rtt_default.h" +#include "cfg_timer_tim2.h" #ifdef __cplusplus extern "C" { #endif -/** - * @name Timer configuration - * @{ - */ -static const timer_conf_t timer_config[] = { - { - .dev = TIM2, - .max = 0xffffffff, - .rcc_mask = RCC_APB1ENR_TIM2EN, - .bus = APB1, - .irqn = TIM2_IRQn - } -}; - -#define TIMER_0_ISR isr_tim2 - -#define TIMER_NUMOF (sizeof(timer_config) / sizeof(timer_config[0])) -/** @} */ - /** * @name UART configuration * @{ diff --git a/boards/nucleo-f767zi/include/periph_conf.h b/boards/nucleo-f767zi/include/periph_conf.h index 29237d3f87..14ceadddf4 100644 --- a/boards/nucleo-f767zi/include/periph_conf.h +++ b/boards/nucleo-f767zi/include/periph_conf.h @@ -26,6 +26,7 @@ #include "cfg_i2c1_pb8_pb9.h" #include "cfg_spi_divtable.h" #include "cfg_rtt_default.h" +#include "cfg_timer_tim2.h" #ifdef __cplusplus extern "C" { @@ -52,25 +53,6 @@ static const dma_conf_t dma_config[] = { #endif /** @} */ -/** - * @name Timer configuration - * @{ - */ -static const timer_conf_t timer_config[] = { - { - .dev = TIM2, - .max = 0xffffffff, - .rcc_mask = RCC_APB1ENR_TIM2EN, - .bus = APB1, - .irqn = TIM2_IRQn - } -}; - -#define TIMER_0_ISR isr_tim2 - -#define TIMER_NUMOF (sizeof(timer_config) / sizeof(timer_config[0])) -/** @} */ - /** * @name UART configuration * @{ diff --git a/boards/stm32f769i-disco/include/periph_conf.h b/boards/stm32f769i-disco/include/periph_conf.h index 2b9be38d7c..9c55d11997 100644 --- a/boards/stm32f769i-disco/include/periph_conf.h +++ b/boards/stm32f769i-disco/include/periph_conf.h @@ -21,6 +21,7 @@ #include "periph_cpu.h" #include "cfg_rtt_default.h" +#include "cfg_timer_tim2.h" #ifdef __cplusplus extern "C" { @@ -57,25 +58,6 @@ extern "C" { #define CLOCK_PLL_Q (9) /** @} */ -/** - * @name Timer configuration - * @{ - */ -static const timer_conf_t timer_config[] = { - { - .dev = TIM2, - .max = 0xffffffff, - .rcc_mask = RCC_APB1ENR_TIM2EN, - .bus = APB1, - .irqn = TIM2_IRQn - } -}; - -#define TIMER_0_ISR isr_tim2 - -#define TIMER_NUMOF (sizeof(timer_config) / sizeof(timer_config[0])) -/** @} */ - /** * @name UART configuration * @{ From 7ee73154188f7a1ba515ad74f0c181f40ce50242 Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Fri, 5 Jul 2019 19:21:39 +0200 Subject: [PATCH 03/10] boards/stm32l0: use common timer configuration --- boards/b-l072z-lrwan1/include/periph_conf.h | 20 +------------------- boards/i-nucleo-lrwan1/include/periph_conf.h | 20 +------------------- boards/lsn50/include/periph_conf.h | 20 +------------------- boards/nucleo-l031k6/include/periph_conf.h | 20 +------------------- boards/nucleo-l053r8/include/periph_conf.h | 20 +------------------- boards/nucleo-l073rz/include/periph_conf.h | 20 +------------------- 6 files changed, 6 insertions(+), 114 deletions(-) diff --git a/boards/b-l072z-lrwan1/include/periph_conf.h b/boards/b-l072z-lrwan1/include/periph_conf.h index fb4b4a81c3..2b3b6292d9 100644 --- a/boards/b-l072z-lrwan1/include/periph_conf.h +++ b/boards/b-l072z-lrwan1/include/periph_conf.h @@ -23,6 +23,7 @@ #include "l0/cfg_clock_32_16_1.h" #include "cfg_rtt_default.h" #include "cfg_i2c1_pb8_pb9.h" +#include "cfg_timer_tim2.h" #ifdef __cplusplus extern "C" { @@ -50,25 +51,6 @@ static const dma_conf_t dma_config[] = { #endif /** @} */ -/** - * @name Timer configuration - * @{ - */ -static const timer_conf_t timer_config[] = { - { - .dev = TIM2, - .max = 0x0000ffff, - .rcc_mask = RCC_APB1ENR_TIM2EN, - .bus = APB1, - .irqn = TIM2_IRQn - } -}; - -#define TIMER_0_ISR isr_tim2 - -#define TIMER_NUMOF (sizeof(timer_config) / sizeof(timer_config[0])) -/** @} */ - /** * @name UART configuration * @{ diff --git a/boards/i-nucleo-lrwan1/include/periph_conf.h b/boards/i-nucleo-lrwan1/include/periph_conf.h index ee86a9ec34..1b867497d6 100644 --- a/boards/i-nucleo-lrwan1/include/periph_conf.h +++ b/boards/i-nucleo-lrwan1/include/periph_conf.h @@ -22,30 +22,12 @@ #include "periph_cpu.h" #include "l0/cfg_clock_32_16_1.h" #include "cfg_rtt_default.h" +#include "cfg_timer_tim2.h" #ifdef __cplusplus extern "C" { #endif -/** - * @name Timer configuration - * @{ - */ -static const timer_conf_t timer_config[] = { - { - .dev = TIM2, - .max = 0x0000ffff, - .rcc_mask = RCC_APB1ENR_TIM2EN, - .bus = APB1, - .irqn = TIM2_IRQn - } -}; - -#define TIMER_0_ISR isr_tim2 - -#define TIMER_NUMOF (sizeof(timer_config) / sizeof(timer_config[0])) -/** @} */ - /** * @name UART configuration * @{ diff --git a/boards/lsn50/include/periph_conf.h b/boards/lsn50/include/periph_conf.h index 514848ce0a..889dbdeae6 100644 --- a/boards/lsn50/include/periph_conf.h +++ b/boards/lsn50/include/periph_conf.h @@ -22,6 +22,7 @@ #include "periph_cpu.h" #include "l0/cfg_clock_32_16_1.h" #include "cfg_rtt_default.h" +#include "cfg_timer_tim2.h" #ifdef __cplusplus extern "C" { @@ -49,25 +50,6 @@ static const dma_conf_t dma_config[] = { #endif /** @} */ -/** - * @name Timer configuration - * @{ - */ -static const timer_conf_t timer_config[] = { - { - .dev = TIM2, - .max = 0x0000ffff, - .rcc_mask = RCC_APB1ENR_TIM2EN, - .bus = APB1, - .irqn = TIM2_IRQn - } -}; - -#define TIMER_0_ISR isr_tim2 - -#define TIMER_NUMOF (sizeof(timer_config) / sizeof(timer_config[0])) -/** @} */ - /** * @name UART configuration * @{ diff --git a/boards/nucleo-l031k6/include/periph_conf.h b/boards/nucleo-l031k6/include/periph_conf.h index 574917ebd4..20f11ebfd9 100644 --- a/boards/nucleo-l031k6/include/periph_conf.h +++ b/boards/nucleo-l031k6/include/periph_conf.h @@ -26,30 +26,12 @@ #include "periph_cpu.h" #include "l0/cfg_clock_32_16_1.h" #include "cfg_rtt_default.h" +#include "cfg_timer_tim2.h" #ifdef __cplusplus extern "C" { #endif -/** - * @name Timer configuration - * @{ - */ -static const timer_conf_t timer_config[] = { - { - .dev = TIM2, - .max = 0x0000ffff, - .rcc_mask = RCC_APB1ENR_TIM2EN, - .bus = APB1, - .irqn = TIM2_IRQn - } -}; - -#define TIMER_0_ISR isr_tim2 - -#define TIMER_NUMOF (sizeof(timer_config) / sizeof(timer_config[0])) -/** @} */ - /** * @name UART configuration * @{ diff --git a/boards/nucleo-l053r8/include/periph_conf.h b/boards/nucleo-l053r8/include/periph_conf.h index f54deb252a..84949974a7 100644 --- a/boards/nucleo-l053r8/include/periph_conf.h +++ b/boards/nucleo-l053r8/include/periph_conf.h @@ -26,30 +26,12 @@ #include "periph_cpu.h" #include "l0/cfg_clock_32_16_1.h" #include "cfg_rtt_default.h" +#include "cfg_timer_tim2.h" #ifdef __cplusplus extern "C" { #endif -/** - * @name Timer configuration - * @{ - */ -static const timer_conf_t timer_config[] = { - { - .dev = TIM2, - .max = 0x0000ffff, - .rcc_mask = RCC_APB1ENR_TIM2EN, - .bus = APB1, - .irqn = TIM2_IRQn - } -}; - -#define TIMER_0_ISR isr_tim2 - -#define TIMER_NUMOF (sizeof(timer_config) / sizeof(timer_config[0])) -/** @} */ - /** * @name UART configuration * @{ diff --git a/boards/nucleo-l073rz/include/periph_conf.h b/boards/nucleo-l073rz/include/periph_conf.h index 829b6c76c1..6f4e401f72 100644 --- a/boards/nucleo-l073rz/include/periph_conf.h +++ b/boards/nucleo-l073rz/include/periph_conf.h @@ -26,30 +26,12 @@ #include "periph_cpu.h" #include "l0/cfg_clock_32_16_1.h" #include "cfg_rtt_default.h" +#include "cfg_timer_tim2.h" #ifdef __cplusplus extern "C" { #endif -/** - * @name Timer configuration - * @{ - */ -static const timer_conf_t timer_config[] = { - { - .dev = TIM2, - .max = 0x0000ffff, - .rcc_mask = RCC_APB1ENR_TIM2EN, - .bus = APB1, - .irqn = TIM2_IRQn - } -}; - -#define TIMER_0_ISR isr_tim2 - -#define TIMER_NUMOF (sizeof(timer_config) / sizeof(timer_config[0])) -/** @} */ - /** * @name UART configuration * @{ From 564686f8826003337528ea9fa261d89dd2bd7dc7 Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Fri, 5 Jul 2019 19:22:08 +0200 Subject: [PATCH 04/10] boards/nucleo-l4*: use common timer configuration --- boards/nucleo-l432kc/include/periph_conf.h | 20 +------------------- boards/nucleo-l433rc/include/periph_conf.h | 20 +------------------- boards/nucleo-l452re/include/periph_conf.h | 20 +------------------- 3 files changed, 3 insertions(+), 57 deletions(-) diff --git a/boards/nucleo-l432kc/include/periph_conf.h b/boards/nucleo-l432kc/include/periph_conf.h index 4a18c0a139..96579c26d5 100644 --- a/boards/nucleo-l432kc/include/periph_conf.h +++ b/boards/nucleo-l432kc/include/periph_conf.h @@ -25,6 +25,7 @@ #include "periph_cpu.h" #include "cfg_rtt_default.h" +#include "cfg_timer_tim2.h" #ifdef __cplusplus extern "C" { @@ -74,25 +75,6 @@ extern "C" { #define CLOCK_APB2 (CLOCK_CORECLOCK / 2) /** @} */ -/** - * @name Timer configuration - * @{ - */ -static const timer_conf_t timer_config[] = { - { - .dev = TIM2, - .max = 0xffffffff, - .rcc_mask = RCC_APB1ENR1_TIM2EN, - .bus = APB1, - .irqn = TIM2_IRQn - } -}; - -#define TIMER_0_ISR isr_tim2 - -#define TIMER_NUMOF (sizeof(timer_config) / sizeof(timer_config[0])) -/** @} */ - /** * @name UART configuration * @{ diff --git a/boards/nucleo-l433rc/include/periph_conf.h b/boards/nucleo-l433rc/include/periph_conf.h index 648333312c..fd6f744208 100644 --- a/boards/nucleo-l433rc/include/periph_conf.h +++ b/boards/nucleo-l433rc/include/periph_conf.h @@ -23,6 +23,7 @@ #include "periph_cpu.h" #include "cfg_rtt_default.h" +#include "cfg_timer_tim2.h" #ifdef __cplusplus extern "C" { @@ -83,25 +84,6 @@ extern "C" { #define CLOCK_APB2 (CLOCK_CORECLOCK / 2) /** @} */ -/** - * @name Timer configuration - * @{ - */ -static const timer_conf_t timer_config[] = { - { - .dev = TIM2, - .max = 0xffffffff, - .rcc_mask = RCC_APB1ENR1_TIM2EN, - .bus = APB1, - .irqn = TIM2_IRQn - } -}; - -#define TIMER_0_ISR isr_tim2 - -#define TIMER_NUMOF (sizeof(timer_config) / sizeof(timer_config[0])) -/** @} */ - /** * @name UART configuration * @{ diff --git a/boards/nucleo-l452re/include/periph_conf.h b/boards/nucleo-l452re/include/periph_conf.h index 83e5ae2fa5..47b0bc275d 100644 --- a/boards/nucleo-l452re/include/periph_conf.h +++ b/boards/nucleo-l452re/include/periph_conf.h @@ -27,6 +27,7 @@ #include "periph_cpu.h" #include "cfg_rtt_default.h" +#include "cfg_timer_tim2.h" #ifdef __cplusplus extern "C" { @@ -86,25 +87,6 @@ extern "C" { #define CLOCK_APB2 (CLOCK_CORECLOCK / 2) /** @} */ -/** - * @name Timer configuration - * @{ - */ -static const timer_conf_t timer_config[] = { - { - .dev = TIM2, - .max = 0xffffffff, - .rcc_mask = RCC_APB1ENR1_TIM2EN, - .bus = APB1, - .irqn = TIM2_IRQn - } -}; - -#define TIMER_0_ISR isr_tim2 - -#define TIMER_NUMOF (sizeof(timer_config) / sizeof(timer_config[0])) -/** @} */ - /** * @name UART configuration * @{ From 6b5a977f081a5e0503b4d36c6af653ad68beea8d Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Fri, 5 Jul 2019 19:28:25 +0200 Subject: [PATCH 05/10] boards/stm32: introduce common timer config with TIM5 --- boards/common/stm32/include/cfg_timer_tim5.h | 52 ++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 boards/common/stm32/include/cfg_timer_tim5.h diff --git a/boards/common/stm32/include/cfg_timer_tim5.h b/boards/common/stm32/include/cfg_timer_tim5.h new file mode 100644 index 0000000000..021ba6e528 --- /dev/null +++ b/boards/common/stm32/include/cfg_timer_tim5.h @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2019 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 boards_common_stm32 + * @{ + * + * @file + * @brief Common configuration for STM32 Timer peripheral based on TIM5 + * + * @author Alexandre Abadie + */ + +#ifndef CFG_TIMER_TIM5_H +#define CFG_TIMER_TIM5_H + +#include "periph_cpu.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @name Timer configuration + * @{ + */ +static const timer_conf_t timer_config[] = { + { + .dev = TIM5, + .max = 0xffffffff, + .rcc_mask = RCC_APB1ENR_TIM5EN, + .bus = APB1, + .irqn = TIM5_IRQn + } +}; + +#define TIMER_0_ISR isr_tim5 + +#define TIMER_NUMOF (sizeof(timer_config) / sizeof(timer_config[0])) +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* CFG_TIMER_TIM5_H */ +/** @} */ From 27230c7c104a679fffd91ea6e9bf239fe0652044 Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Fri, 5 Jul 2019 19:29:09 +0200 Subject: [PATCH 06/10] boards/stm32f4: use common timer configuration --- boards/nucleo-f401re/include/periph_conf.h | 20 +----------------- boards/nucleo-f410rb/include/periph_conf.h | 20 +----------------- boards/nucleo-f411re/include/periph_conf.h | 21 +------------------ boards/nucleo-f412zg/include/periph_conf.h | 20 +----------------- boards/nucleo-f413zh/include/periph_conf.h | 20 +----------------- boards/nucleo-f429zi/include/periph_conf.h | 20 +----------------- boards/nucleo-f446re/include/periph_conf.h | 20 +----------------- boards/nucleo-f446ze/include/periph_conf.h | 20 +----------------- boards/stm32f429i-disc1/include/periph_conf.h | 20 +----------------- 9 files changed, 9 insertions(+), 172 deletions(-) diff --git a/boards/nucleo-f401re/include/periph_conf.h b/boards/nucleo-f401re/include/periph_conf.h index fd45bb01d3..a5ae0c650d 100644 --- a/boards/nucleo-f401re/include/periph_conf.h +++ b/boards/nucleo-f401re/include/periph_conf.h @@ -24,30 +24,12 @@ #include "periph_cpu.h" #include "f4/cfg_clock_84_8_1.h" #include "cfg_i2c1_pb8_pb9.h" +#include "cfg_timer_tim5.h" #ifdef __cplusplus extern "C" { #endif -/** - * @name Timer configuration - * @{ - */ -static const timer_conf_t timer_config[] = { - { - .dev = TIM5, - .max = 0xffffffff, - .rcc_mask = RCC_APB1ENR_TIM5EN, - .bus = APB1, - .irqn = TIM5_IRQn - } -}; - -#define TIMER_0_ISR isr_tim5 - -#define TIMER_NUMOF (sizeof(timer_config) / sizeof(timer_config[0])) -/** @} */ - /** * @name UART configuration * @{ diff --git a/boards/nucleo-f410rb/include/periph_conf.h b/boards/nucleo-f410rb/include/periph_conf.h index 17e4524369..e70f0dcdd6 100644 --- a/boards/nucleo-f410rb/include/periph_conf.h +++ b/boards/nucleo-f410rb/include/periph_conf.h @@ -24,30 +24,12 @@ #include "periph_cpu.h" #include "f4/cfg_clock_96_8_1.h" #include "cfg_i2c1_pb8_pb9.h" +#include "cfg_timer_tim5.h" #ifdef __cplusplus extern "C" { #endif -/** - * @name Timer configuration - * @{ - */ -static const timer_conf_t timer_config[] = { - { - .dev = TIM5, - .max = 0xffffffff, - .rcc_mask = RCC_APB1ENR_TIM5EN, - .bus = APB1, - .irqn = TIM5_IRQn - } -}; - -#define TIMER_0_ISR isr_tim5 - -#define TIMER_NUMOF (sizeof(timer_config) / sizeof(timer_config[0])) -/** @} */ - /** * @name UART configuration * @{ diff --git a/boards/nucleo-f411re/include/periph_conf.h b/boards/nucleo-f411re/include/periph_conf.h index 558ecd2fb6..bb7d3170dc 100644 --- a/boards/nucleo-f411re/include/periph_conf.h +++ b/boards/nucleo-f411re/include/periph_conf.h @@ -24,31 +24,12 @@ #include "periph_cpu.h" #include "f4/cfg_clock_96_8_1.h" #include "cfg_i2c1_pb8_pb9.h" +#include "cfg_timer_tim5.h" #ifdef __cplusplus extern "C" { #endif -/** - * @name Timer configuration - * @{ - */ -static const timer_conf_t timer_config[] = { - { - .dev = TIM5, - .max = 0xffffffff, - .rcc_mask = RCC_APB1ENR_TIM5EN, - .bus = APB1, - .irqn = TIM5_IRQn - } -}; - -#define TIMER_0_ISR isr_tim5 -#define TIMER_1_ISR isr_tim4 - -#define TIMER_NUMOF (sizeof(timer_config) / sizeof(timer_config[0])) -/** @} */ - /** * @name UART configuration * @{ diff --git a/boards/nucleo-f412zg/include/periph_conf.h b/boards/nucleo-f412zg/include/periph_conf.h index 44e2ce3243..7b4dab4037 100644 --- a/boards/nucleo-f412zg/include/periph_conf.h +++ b/boards/nucleo-f412zg/include/periph_conf.h @@ -26,30 +26,12 @@ #include "periph_cpu.h" #include "f4/cfg_clock_100_8_1.h" #include "cfg_i2c1_pb8_pb9.h" +#include "cfg_timer_tim5.h" #ifdef __cplusplus extern "C" { #endif -/** - * @name Timer configuration - * @{ - */ -static const timer_conf_t timer_config[] = { - { - .dev = TIM5, - .max = 0xffffffff, - .rcc_mask = RCC_APB1ENR_TIM5EN, - .bus = APB1, - .irqn = TIM5_IRQn - } -}; - -#define TIMER_0_ISR isr_tim5 - -#define TIMER_NUMOF (sizeof(timer_config) / sizeof(timer_config[0])) -/** @} */ - /** * @name UART configuration * @{ diff --git a/boards/nucleo-f413zh/include/periph_conf.h b/boards/nucleo-f413zh/include/periph_conf.h index 0529acd02c..6a2d9b28cd 100644 --- a/boards/nucleo-f413zh/include/periph_conf.h +++ b/boards/nucleo-f413zh/include/periph_conf.h @@ -26,6 +26,7 @@ #include "periph_cpu.h" #include "f4/cfg_clock_100_8_1.h" #include "cfg_i2c1_pb8_pb9.h" +#include "cfg_timer_tim5.h" #ifdef __cplusplus extern "C" { @@ -54,25 +55,6 @@ static const dma_conf_t dma_config[] = { #endif /** @} */ -/** - * @name Timer configuration - * @{ - */ -static const timer_conf_t timer_config[] = { - { - .dev = TIM5, - .max = 0xffffffff, - .rcc_mask = RCC_APB1ENR_TIM5EN, - .bus = APB1, - .irqn = TIM5_IRQn - } -}; - -#define TIMER_0_ISR isr_tim5 - -#define TIMER_NUMOF (sizeof(timer_config) / sizeof(timer_config[0])) -/** @} */ - /** * @name UART configuration * @{ diff --git a/boards/nucleo-f429zi/include/periph_conf.h b/boards/nucleo-f429zi/include/periph_conf.h index acccd0d258..a1926b086c 100644 --- a/boards/nucleo-f429zi/include/periph_conf.h +++ b/boards/nucleo-f429zi/include/periph_conf.h @@ -25,30 +25,12 @@ #include "f4/cfg_clock_168_8_1.h" #include "cfg_i2c1_pb8_pb9.h" #include "cfg_spi_divtable.h" +#include "cfg_timer_tim5.h" #ifdef __cplusplus extern "C" { #endif -/** - * @name Timer configuration - * @{ - */ -static const timer_conf_t timer_config[] = { - { - .dev = TIM5, - .max = 0xffffffff, - .rcc_mask = RCC_APB1ENR_TIM5EN, - .bus = APB1, - .irqn = TIM5_IRQn - } -}; - -#define TIMER_0_ISR isr_tim5 - -#define TIMER_NUMOF (sizeof(timer_config) / sizeof(timer_config[0])) -/** @} */ - /** * @name UART configuration * @{ diff --git a/boards/nucleo-f446re/include/periph_conf.h b/boards/nucleo-f446re/include/periph_conf.h index 25ca136d84..01084c5b88 100644 --- a/boards/nucleo-f446re/include/periph_conf.h +++ b/boards/nucleo-f446re/include/periph_conf.h @@ -25,30 +25,12 @@ #include "f4/cfg_clock_180_8_1.h" #include "cfg_i2c1_pb8_pb9.h" #include "cfg_spi_divtable.h" +#include "cfg_timer_tim5.h" #ifdef __cplusplus extern "C" { #endif -/** - * @name Timer configuration - * @{ - */ -static const timer_conf_t timer_config[] = { - { - .dev = TIM5, - .max = 0xffffffff, - .rcc_mask = RCC_APB1ENR_TIM5EN, - .bus = APB1, - .irqn = TIM5_IRQn - } -}; - -#define TIMER_0_ISR isr_tim5 - -#define TIMER_NUMOF (sizeof(timer_config) / sizeof(timer_config[0])) -/** @} */ - /** * @name UART configuration * @{ diff --git a/boards/nucleo-f446ze/include/periph_conf.h b/boards/nucleo-f446ze/include/periph_conf.h index 4f3cd2fac3..9ca1995db2 100644 --- a/boards/nucleo-f446ze/include/periph_conf.h +++ b/boards/nucleo-f446ze/include/periph_conf.h @@ -25,30 +25,12 @@ #include "f4/cfg_clock_180_8_1.h" #include "cfg_i2c1_pb8_pb9.h" #include "cfg_spi_divtable.h" +#include "cfg_timer_tim5.h" #ifdef __cplusplus extern "C" { #endif -/** - * @name Timer configuration - * @{ - */ -static const timer_conf_t timer_config[] = { - { - .dev = TIM5, - .max = 0xffffffff, - .rcc_mask = RCC_APB1ENR_TIM5EN, - .bus = APB1, - .irqn = TIM5_IRQn - } -}; - -#define TIMER_0_ISR isr_tim5 - -#define TIMER_NUMOF (sizeof(timer_config) / sizeof(timer_config[0])) -/** @} */ - /** * @name UART configuration * @{ diff --git a/boards/stm32f429i-disc1/include/periph_conf.h b/boards/stm32f429i-disc1/include/periph_conf.h index ce3f1523f8..8301d04447 100644 --- a/boards/stm32f429i-disc1/include/periph_conf.h +++ b/boards/stm32f429i-disc1/include/periph_conf.h @@ -22,30 +22,12 @@ #include "periph_cpu.h" #include "f4/cfg_clock_168_8_1.h" #include "cfg_spi_divtable.h" +#include "cfg_timer_tim5.h" #ifdef __cplusplus extern "C" { #endif -/** - * @name Timer configuration - * @{ - */ -static const timer_conf_t timer_config[] = { - { - .dev = TIM5, - .max = 0xffffffff, - .rcc_mask = RCC_APB1ENR_TIM5EN, - .bus = APB1, - .irqn = TIM5_IRQn - } -}; - -#define TIMER_0_ISR isr_tim5 - -#define TIMER_NUMOF (sizeof(timer_config) / sizeof(timer_config[0])) -/** @} */ - /** * @name UART configuration * @{ From 3c00d41764c0031784e6b0eb920a24e2b839bda9 Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Fri, 5 Jul 2019 19:29:48 +0200 Subject: [PATCH 07/10] boards/ublox-c030-u201: use common timer configuration This also requires to include the STM32 shared include directory --- boards/ublox-c030-u201/Makefile.include | 3 +++ boards/ublox-c030-u201/include/periph_conf.h | 20 +------------------- 2 files changed, 4 insertions(+), 19 deletions(-) diff --git a/boards/ublox-c030-u201/Makefile.include b/boards/ublox-c030-u201/Makefile.include index 964e8d0212..5d9010842b 100644 --- a/boards/ublox-c030-u201/Makefile.include +++ b/boards/ublox-c030-u201/Makefile.include @@ -2,6 +2,9 @@ export CPU = stm32f4 export CPU_MODEL = stm32f437vg +# we use shared STM32 configuration snippets +INCLUDES += -I$(RIOTBOARD)/common/stm32/include + # define the default port depending on the host OS PORT_LINUX ?= /dev/ttyACM0 PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.usbmodem*))) diff --git a/boards/ublox-c030-u201/include/periph_conf.h b/boards/ublox-c030-u201/include/periph_conf.h index 63f73ca620..1e94b578cc 100644 --- a/boards/ublox-c030-u201/include/periph_conf.h +++ b/boards/ublox-c030-u201/include/periph_conf.h @@ -20,6 +20,7 @@ #define PERIPH_CONF_H #include "periph_cpu.h" +#include "cfg_timer_tim5.h" #ifdef __cplusplus extern "C" { @@ -56,25 +57,6 @@ extern "C" { #define CLOCK_PLL_Q (7) /** @} */ -/** - * @name Timer configuration - * @{ - */ -static const timer_conf_t timer_config[] = { - { - .dev = TIM5, - .max = 0xffffffff, - .rcc_mask = RCC_APB1ENR_TIM5EN, - .bus = APB1, - .irqn = TIM5_IRQn - } -}; - -#define TIMER_0_ISR isr_tim5 - -#define TIMER_NUMOF (sizeof(timer_config) / sizeof(timer_config[0])) -/** @} */ - /** * @name UART configuration * @{ From b710cda1560bbb5283406187266ebd5792db2e28 Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Fri, 5 Jul 2019 19:35:29 +0200 Subject: [PATCH 08/10] boards/lobaro-lorabox: use common timer configuration --- boards/lobaro-lorabox/Makefile.include | 2 +- boards/lobaro-lorabox/include/periph_conf.h | 20 +------------------- 2 files changed, 2 insertions(+), 20 deletions(-) diff --git a/boards/lobaro-lorabox/Makefile.include b/boards/lobaro-lorabox/Makefile.include index fe3ff9316a..ab0bcab31d 100644 --- a/boards/lobaro-lorabox/Makefile.include +++ b/boards/lobaro-lorabox/Makefile.include @@ -3,7 +3,7 @@ export CPU = stm32l1 export CPU_MODEL = stm32l151cb_a # add the common header files to the include path -INCLUDES += -I$(RIOTBOARD)/lobaro-lorabox/include +INCLUDES += -I$(RIOTBOARD)/common/stm32/include # configure the serial terminal PORT_LINUX ?= /dev/ttyUSB0 diff --git a/boards/lobaro-lorabox/include/periph_conf.h b/boards/lobaro-lorabox/include/periph_conf.h index 30a727f2ba..38f0c51887 100644 --- a/boards/lobaro-lorabox/include/periph_conf.h +++ b/boards/lobaro-lorabox/include/periph_conf.h @@ -25,6 +25,7 @@ #define PERIPH_CONF_H #include "periph_cpu.h" +#include "cfg_timer_tim2.h" #ifdef __cplusplus extern "C" { @@ -70,25 +71,6 @@ extern "C" { #define CLOCK_APB1 (CLOCK_CORECLOCK / 1) /** @} */ -/** - * @name Timer configuration - * @{ - */ -static const timer_conf_t timer_config[] = { - { - .dev = TIM2, - .max = 0x0000ffff, - .rcc_mask = RCC_APB1ENR_TIM2EN, - .bus = APB1, - .irqn = TIM2_IRQn - } -}; - -#define TIMER_0_ISR (isr_tim2) - -#define TIMER_NUMOF (sizeof(timer_config) / sizeof(timer_config[0])) -/** @} */ - /** * @name UART configuration * @{ From b1fa4fb2d9f5453204e40f00a5a867321cfa74d0 Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Fri, 5 Jul 2019 19:52:48 +0200 Subject: [PATCH 09/10] boards/nucleo-l152re: use TIM5 common timer configuration --- boards/nucleo-l152re/include/periph_conf.h | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/boards/nucleo-l152re/include/periph_conf.h b/boards/nucleo-l152re/include/periph_conf.h index 935a733763..20b18f0173 100644 --- a/boards/nucleo-l152re/include/periph_conf.h +++ b/boards/nucleo-l152re/include/periph_conf.h @@ -23,6 +23,7 @@ #define PERIPH_CONF_H #include "periph_cpu.h" +#include "cfg_timer_tim5.h" #ifdef __cplusplus extern "C" { @@ -83,25 +84,6 @@ static const dma_conf_t dma_config[] = { #endif /** @} */ -/** - * @name Timer configuration - * @{ - */ -static const timer_conf_t timer_config[] = { - { - .dev = TIM5, - .max = 0xffffffff, - .rcc_mask = RCC_APB1ENR_TIM5EN, - .bus = APB1, - .irqn = TIM5_IRQn - } -}; - -#define TIMER_0_ISR (isr_tim5) - -#define TIMER_NUMOF (sizeof(timer_config) / sizeof(timer_config[0])) -/** @} */ - /** * @name UART configuration * @{ From 927f283d9728102f40d36b869064d1506d157f2d Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Fri, 5 Jul 2019 19:53:21 +0200 Subject: [PATCH 10/10] boards/nz32-sc151: use TIM5 common timer configuration This requires including STM32 common include directoy as well --- boards/nz32-sc151/Makefile.include | 3 +++ boards/nz32-sc151/include/periph_conf.h | 20 +------------------- 2 files changed, 4 insertions(+), 19 deletions(-) diff --git a/boards/nz32-sc151/Makefile.include b/boards/nz32-sc151/Makefile.include index e5e377cbea..2934e3c2fc 100644 --- a/boards/nz32-sc151/Makefile.include +++ b/boards/nz32-sc151/Makefile.include @@ -2,6 +2,9 @@ export CPU = stm32l1 export CPU_MODEL = stm32l151rc +# we use shared STM32 configuration snippets +INCLUDES += -I$(RIOTBOARD)/common/stm32/include + # define the default port depending on the host OS PORT_LINUX ?= /dev/ttyUSB0 PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.SLAB_USBtoUART*))) diff --git a/boards/nz32-sc151/include/periph_conf.h b/boards/nz32-sc151/include/periph_conf.h index 65d5d60014..c9b6aa2b39 100644 --- a/boards/nz32-sc151/include/periph_conf.h +++ b/boards/nz32-sc151/include/periph_conf.h @@ -20,6 +20,7 @@ #define PERIPH_CONF_H #include "periph_cpu.h" +#include "cfg_timer_tim5.h" #ifdef __cplusplus extern "C" { @@ -49,25 +50,6 @@ extern "C" { #define CLOCK_APB2 (CLOCK_CORECLOCK / 1) /** @} */ -/** - * @name Timer configuration - * @{ - */ -static const timer_conf_t timer_config[] = { - { - .dev = TIM5, - .max = 0xffffffff, - .rcc_mask = RCC_APB1ENR_TIM5EN, - .bus = APB1, - .irqn = TIM5_IRQn - } -}; - -#define TIMER_0_ISR (isr_tim5) - -#define TIMER_NUMOF (sizeof(timer_config) / sizeof(timer_config[0])) -/** @} */ - /** * @name UART configuration * @{