stm32f103
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
timer.h
Go to the documentation of this file.
1 #ifndef STM32F103_CORE_TIMER_H_
2 #define STM32F103_CORE_TIMER_H_
3 
4 #include <functional>
5 
6 #include <misc.h>
7 #include <stm32f10x_tim.h>
8 
14 class Timer {
15  public:
19  struct Config {
23  TIM_TypeDef* tim;
27  uint32_t rcc;
31  IRQn irqn;
32 
36  uint16_t prescaler;
40  uint16_t period;
41  };
42 
48  explicit Timer(const Config& config);
49 
53  void EnableInterrupt();
54 
55  protected:
62  void Init(uint16_t prescaler, uint16_t period);
63 
64  private:
65  TIM_TypeDef* tim_ = nullptr;
66  uint32_t rcc_;
67  IRQn irq_;
68 };
69 
70 #endif // STM32F103_CORE_TIMER_H_
void EnableInterrupt()
Enables interrupt handling for this timer.
Definition: timer.cpp:33
uint16_t period
Period value.
Definition: timer.h:40
Configuration for an individual TIM.
Definition: timer.h:19
uint32_t rcc
RCC: Reset & Clock Control.
Definition: timer.h:27
TIM_TypeDef * tim
Timer.
Definition: timer.h:23
void Init(uint16_t prescaler, uint16_t period)
Performs initialization for this TIM.
Definition: timer.cpp:16
IRQn irqn
Interrupt Handler.
Definition: timer.h:31
Timer(const Config &config)
Constructor for Timer.
Definition: timer.cpp:6
Implements an abstraction layer for TIM.
Definition: timer.h:14
uint16_t prescaler
Prescaler value.
Definition: timer.h:36