semf
stm32systick.h
Go to the documentation of this file.
1
10#ifndef SEMF_HARDWAREABSTRACTION_STM32_STM32SYSTICK_H_
11#define SEMF_HARDWAREABSTRACTION_STM32_STM32SYSTICK_H_
12
16
17#if defined(STM32)
18namespace semf
19{
20template <typename T>
26{
27public:
32 static T& instance();
34 static void isr();
35 void start() override;
36 void stop() override;
37 void reset() override;
38
39protected:
40 Stm32Systick() = default;
41};
42
43template <typename T>
45{
46 static T timer;
47 return timer;
48}
49
50template <typename T>
52{
53 SEMF_SINGLETON_INFO(&instance(), "timeout");
54 instance().timeout();
55}
56
57template <typename T>
59{
60 volatile uint32_t* sysTickControl = reinterpret_cast<volatile uint32_t*>(0xE000E010);
61 *sysTickControl |= 1;
62}
63
64template <typename T>
66{
67 volatile uint32_t* sysTickControl = reinterpret_cast<volatile uint32_t*>(0xE000E010);
68 *sysTickControl &= 0xFFFFFFFE;
69}
70
71template <typename T>
73{
74 volatile uint32_t* sysTickCount = reinterpret_cast<volatile uint32_t*>(0xE000E018);
75 *sysTickCount = 0;
76}
77
78} /* namespace semf */
79#endif
80#endif /* SEMF_HARDWAREABSTRACTION_STM32_STM32SYSTICK_H_ */
Timer implementation for STM32 as single systick..
Definition: stm32systick.h:26
static void isr()
Definition: stm32systick.h:51
void stop() override
Definition: stm32systick.h:65
Stm32Systick()=default
void reset() override
Definition: stm32systick.h:72
void start() override
Definition: stm32systick.h:58
static T & instance()
Gets the single instance.
Definition: stm32systick.h:44
Class for using timer hardware.
Definition: timer.h:24
#define SEMF_SINGLETON_INFO(object,...)
Definition: debug.h:47