cfg_timer_tim5_and_tim2.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2019 Inria
3  * SPDX-License-Identifier: LGPL-2.1-only
4  */
5 
6 #pragma once
7 
19 #include "periph_cpu.h"
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
29 static const timer_conf_t timer_config[] = {
30  /* intentionally not sorted alphabetically: E.g. on STM32L1 TIM5 is
31  * 32 bit while TIM2 is only 16 bit. ztimer defaults to the first timer
32  * defined and does profit from using a 32 bit timer */
33  {
34  .dev = TIM5,
35  .max = 0xffffffff,
36 #if defined(RCC_APB1ENR1_TIM5EN)
37  .rcc_mask = RCC_APB1ENR1_TIM5EN,
38 #else
39  .rcc_mask = RCC_APB1ENR_TIM5EN,
40 #endif
41  .bus = APB1,
42  .irqn = TIM5_IRQn
43  },
44  {
45  .dev = TIM2,
46 #if defined(CPU_FAM_STM32L0) || defined(CPU_FAM_STM32L1)
47  .max = 0x0000ffff,
48 #else
49  .max = 0xffffffff,
50 #endif
51 #if defined(RCC_APB1ENR1_TIM2EN)
52  .rcc_mask = RCC_APB1ENR1_TIM2EN,
53 #elif defined(RCC_MC_APB1ENSETR_TIM2EN)
54  .rcc_mask = RCC_MC_APB1ENSETR_TIM2EN,
55 #else
56  .rcc_mask = RCC_APB1ENR_TIM2EN,
57 #endif
58  .bus = APB1,
59  .irqn = TIM2_IRQn
60  },
61 };
62 
63 #define TIMER_0_ISR isr_tim5
64 #define TIMER_1_ISR isr_tim2
66 #define TIMER_NUMOF ARRAY_SIZE(timer_config)
69 #ifdef __cplusplus
70 }
71 #endif
72 
@ APB1
Advanced Peripheral Bus 1
Definition: periph_cpu.h:78
Timer device configuration.
Definition: periph_cpu.h:263
TC0_t * dev
Pointer to the used as Timer device.
Definition: periph_cpu.h:264