This example demonstrates how to create and use software timers.
extern "C" {
void __cxa_pure_virtual(void) {}
void DebugPrint(const char* szString_);
}
namespace
{
#define APP1_STACK_SIZE (PORT_KERNEL_DEFAULT_STACK_SIZE)
K_WORD awApp1Stack[APP1_STACK_SIZE];
void App1Main(void* unused_);
void IdleMain(void* )
{
while (1) {}
}
void PeriodicCallback(
Thread* owner,
void* pvData_)
{
auto* pclSem =
static_cast<Semaphore*
>(pvData_);
}
void OneShotCallback(
Thread* owner,
void* pvData_)
{
}
void App1Main(void* unused_)
{
clMyTimer.
Start(
true, 500, PeriodicCallback, (
void*)&clMySem);
clOneShot.
Start(
false, 2500, OneShotCallback, 0);
while (1) {
clMySem.Pend();
}
}
}
int main(void)
{
clIdleThread.Init(awIdleStack, sizeof(awIdleStack), 0, IdleMain, 0);
clIdleThread.Start();
clApp1Thread.Init(awApp1Stack, sizeof(awApp1Stack), 1, App1Main, 0);
clApp1Thread.Start();
return 0;
}