Software timers extend module for embedded
MultiTimer is a software timer extension module that allows for the expansion of timer tasks as needed, replacing the traditional flag-checking method. It offers a more elegant and convenient way to manage the timing sequences of a program.
uint64_t PlatformTicksGetFunc(void)
{
/* Platform-specific implementation */
}
multiTimerInstall(PlatformTicksGetFunc);MultiTimer timer1;int multiTimerStart(MultiTimer* timer, uint64_t timing, MultiTimerCallback_t callback, void* userData);int main(int argc, char *argv[])
{
...
while (1) {
...
multiTimerYield();
}
}The clock frequency of the timer directly affects its accuracy. It is recommended to use ticks with higher precision such as 1ms, 5ms, or 10ms.
The callback function of the timer should not perform time-consuming operations, as this may occupy too much time, causing other timers to not timeout properly.
Since the timer's callback function is executed within multiTimerYield, care should be taken not to use too much stack space to avoid stack overflow.
The test_linux.c file serves as a demo for Linux platforms, showcasing how to use MultiTimer for creating and managing multiple timers with different intervals and behaviors.
…No open issues yet, or sync has not completed.