summaryrefslogtreecommitdiff
path: root/ucoo/hal/timer/timer.stm32.hh
diff options
context:
space:
mode:
authorNicolas Schodet2016-07-25 15:18:40 +0200
committerNicolas Schodet2019-10-09 23:05:44 +0200
commit4695b47da68a5b2f75270bea21e15b8f1b9fd6ff (patch)
tree6e5ef4d34ee69bcd6c6627f25a0ca3aa902d47e3 /ucoo/hal/timer/timer.stm32.hh
parentd7df91926bdb529e68eff9a215aef72072803b6e (diff)
Switch to CMSIS
Diffstat (limited to 'ucoo/hal/timer/timer.stm32.hh')
-rw-r--r--ucoo/hal/timer/timer.stm32.hh29
1 files changed, 23 insertions, 6 deletions
diff --git a/ucoo/hal/timer/timer.stm32.hh b/ucoo/hal/timer/timer.stm32.hh
index 85941e4..6b2f2dd 100644
--- a/ucoo/hal/timer/timer.stm32.hh
+++ b/ucoo/hal/timer/timer.stm32.hh
@@ -27,8 +27,23 @@
namespace ucoo {
+/// Available instances.
+enum class TimerInstance
+{
+ TIM1,
+ TIM2,
+ TIM3,
+ TIM4,
+ TIM5,
+ TIM10,
+ TIM11,
+};
+
+template<TimerInstance inst>
+struct TimerHardware { };
+
/// STM32 timer very basic support.
-template<uint32_t Base>
+template<TimerInstance inst>
class TimerHard
{
public:
@@ -39,7 +54,7 @@ class TimerHard
~TimerHard ();
/// Enable timer.
template <typename... Options>
- void enable (int freq, bool start = true);
+ void enable (int freq_hz, bool start = true);
/// Disable timer.
void disable ();
/// Manually start timer.
@@ -57,7 +72,7 @@ class TimerHard
/// Wait until a new input capture value is available.
void wait_input_capture (int ch) const;
/// Get timer frequency.
- int get_freq () const { return freq_; }
+ int get_freq_hz () const { return freq_hz_; }
/// Enable interrupts on update event.
void enable_interrupt ();
/// Disable interrupts on update event.
@@ -95,11 +110,11 @@ class TimerHard
{
public:
/// Disable updates.
- UpdateDisabled (TimerHard<Base> &timer);
+ UpdateDisabled (TimerHard<inst> &timer);
/// Enable updates.
~UpdateDisabled ();
private:
- TimerHard<Base> &timer_;
+ TimerHard<inst> &timer_;
};
friend class UpdateDisabled;
/// Base class for options.
@@ -129,7 +144,9 @@ class TimerHard
struct CombinedOptions;
private:
/// When enabled, programmed frequency.
- int freq_ = 0;
+ int freq_hz_ = 0;
+ /// Hardware characteristics.
+ using Hard = TimerHardware<inst>;
};
} // namespace ucoo