diff options
author | Lisin Dmitriy <d.lisin@thirdpin.ru> | 2019-09-18 18:09:44 +0300 |
---|---|---|
committer | Lisin Dmitriy <d.lisin@thirdpin.ru> | 2019-09-18 18:09:44 +0300 |
commit | bfcf79cbe22e93edab3d6d4e40199c33b6245498 (patch) | |
tree | 0ef3d9de72a5bcd660e2935eeec89ff5b66e56e3 | |
parent | 2a655bba403e1ee85c387f7ff860bf3adea58863 (diff) |
IMPR: [tim] Add assert if TIM number is out of range
-rw-r--r-- | cm3cpp/timer.hpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/cm3cpp/timer.hpp b/cm3cpp/timer.hpp index 497e190..2fe079b 100644 --- a/cm3cpp/timer.hpp +++ b/cm3cpp/timer.hpp @@ -26,6 +26,8 @@ TIM C++ Wrapper of libopencm3 library for STM32F2, STM32F4 #ifndef CM3CPP_TIMER_H_ #define CM3CPP_TIMER_H_ +#include <cassert> + #include <libopencm3/stm32/rcc.h> #include <libopencm3/stm32/timer.h> @@ -178,10 +180,13 @@ class Timer HI_RISING_EDGE }; - Timer(uint8_t timer_num) using ExtTriggerFilter = tim_ic_filter; using ExtTriggerPrescaler = tim_ic_psc; using ExtTriggerPolarity = tim_et_pol; + + using TimerNumber = uint8_t; + + Timer(TimerNumber timer_num) { #if defined(STM32F2) || defined(STM32F4) switch (timer_num) { @@ -241,6 +246,8 @@ class Timer _timer = TIM14; rcc_periph_reset_pulse(RST_TIM14); break; + default: + assert(false); } #endif } |