Merge pull request #29 from vas-dav/timer

Timer: add millis() for modbus
This commit is contained in:
Evgenii Meshcheriakov 2022-10-18 12:10:53 +03:00 committed by GitHub
commit 8952b0f3cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 0 deletions

View File

@ -13,6 +13,7 @@
#include <climits>
static volatile std::atomic_int timer;
static volatile unsigned int systicks = 0;
extern "C"
{
@ -23,6 +24,9 @@ extern "C"
void SysTick_Handler (void);
}
uint32_t millis();
class Timer
{
public:

View File

@ -12,6 +12,7 @@ extern "C"
void
SysTick_Handler (void)
{
systicks++;
if (timer > 0)
timer--;
}
@ -63,3 +64,7 @@ Timer::resetCounter ()
{
counter.store (0, std::memory_order_relaxed);
}
uint32_t millis() {
return systicks;
}