Skip to content

Commit

Permalink
examples use std::chrono::duration in Timer**::setPeriod(...)
Browse files Browse the repository at this point in the history
  • Loading branch information
TomSaw committed Jun 12, 2022
1 parent 5ddcab3 commit c949daf
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 14 deletions.
19 changes: 10 additions & 9 deletions examples/blue_pill_f103/encoder_input_bitbang/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,19 @@ MODM_ISR(TIM2)
encoder.update();
}

template<class Timer, class Rep, class Period>
void
init_Timer2(const uint16_t period)
initPeriodicInterrupt(std::chrono::duration<Rep, Period> period)
{
Timer2::enable();
Timer2::setMode(Timer2::Mode::UpCounter);
Timer::enable();
Timer::setMode(Timer::Mode::UpCounter);

Timer2::template setPeriod<Board::SystemClock>(period);
Timer2::enableInterruptVector(true, 10);
Timer2::enableInterrupt(Timer2::Interrupt::Update);
Timer::template setPeriod<Board::SystemClock>(period);
Timer::enableInterruptVector(true, 10);
Timer::enableInterrupt(Timer::Interrupt::Update);

Timer2::applyAndReset();
Timer2::start();
Timer::applyAndReset();
Timer::start();
}

int
Expand All @@ -61,7 +62,7 @@ main()
Usart2::initialize<Board::SystemClock, 115200_Bd>();

encoder.initialize();
init_Timer2(1000); // 1ms period
initPeriodicInterrupt<Timer2>(1ms);

int value(0);

Expand Down
2 changes: 1 addition & 1 deletion examples/nucleo_f042k6/vector_table_ram/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ main()

Timer14::enable();
Timer14::setMode(Timer14::Mode::UpCounter);
Timer14::setPeriod<Board::SystemClock>(500'000 /* us */);
Timer14::setPeriod<Board::SystemClock>(500ms);
Timer14::applyAndReset();
Timer14::start();
Timer14::enableInterrupt(Timer14::Interrupt::Update);
Expand Down
2 changes: 1 addition & 1 deletion examples/nucleo_l031k6/vector_table_ram/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ main()

Timer2::enable();
Timer2::setMode(Timer2::Mode::UpCounter);
Timer2::setPeriod<Board::SystemClock>(500'000 /* us */);
Timer2::setPeriod<Board::SystemClock>(500ms);
Timer2::applyAndReset();
Timer2::start();
Timer2::enableInterrupt(Timer2::Interrupt::Update);
Expand Down
2 changes: 1 addition & 1 deletion examples/stm32f3_discovery/timer/basic/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ main()
//Timer1::setMode(Timer1::Mode::CenterAligned3);
Timer1::setMode(Timer1::Mode::UpCounter);
Timer1::setOverflow(0xff);
//Timer1::setPeriod(4);
//Timer1::setPeriod(4us);
Timer1::applyAndReset();
Timer1::start();

Expand Down
4 changes: 2 additions & 2 deletions examples/stm32f4_discovery/timer_test/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ testTimerAdvancedStart()
TIMER::enable();
TIMER::setMode(TIMER::Mode::UpCounter);

TIMER::template setPeriod<Board::SystemClock>(250000);
TIMER::template setPeriod<Board::SystemClock>(250ms);
TIMER::enableInterruptVector(TIMER::Interrupt::Update, true, 10);
TIMER::enableInterrupt(TIMER::Interrupt::Update);

Expand All @@ -54,7 +54,7 @@ testTimerStart()
TIMER::enable();
TIMER::setMode(TIMER::Mode::UpCounter);

TIMER::template setPeriod<Board::SystemClock>(250000);
TIMER::template setPeriod<Board::SystemClock>(250ms);
TIMER::enableInterruptVector(true, 10);
TIMER::enableInterrupt(TIMER::Interrupt::Update);

Expand Down

0 comments on commit c949daf

Please sign in to comment.