timer: resolve a constructor issue

This commit is contained in:
Vasily Davydov 2022-10-14 16:07:03 +03:00
parent 52c4ebb003
commit 17116e84ce
2 changed files with 3 additions and 1 deletions

View File

@ -70,6 +70,7 @@ public:
private:
volatile std::atomic_int counter;
volatile std::atomic_int timer;
uint32_t freq;
};
#endif /* TIMER_H_ */

View File

@ -17,12 +17,13 @@ extern "C"
}
}
Timer::Timer (uint32_t freq = 1000)
Timer::Timer (uint32_t freq) : freq (freq)
{
Chip_Clock_SetSysTickClockDiv (1);
uint32_t sysTickRate = Chip_Clock_GetSysTickClockRate ();
SysTick_Config (sysTickRate / freq);
counter = 0;
timer = 0;
}
Timer::~Timer ()