NetBurner 3.5.0
PDF Version
 
Interval Timer

Functions

int IntervalOSSem (OS_SEM *p_toSem, int num_per_sec, int timer=FIRST_UNUSED_TIMER)
 Posts to a semaphore at the requested interval.
 
int IntervalOSFlag (OS_FLAGS *p_toFlag, uint32_t flag_value, int num_per_sec, int timer=FIRST_UNUSED_TIMER)
 Sets a flag at requested interval.
 
int IntervalInterruptCallback (void(*p_toCallbackFunc)(), int num_per_sec, int timer=FIRST_UNUSED_TIMER)
 Calls a function at requested interval. Note that the callback function is called from within the timer's interrupt handler so you should treat your callback function as an interrupt.
 
void IntervalStop (int timer_number)
 Stops an existing Interval Timer and frees the resource.
 

Detailed Description

#include< IntervalTimer.h >

The Interval Timer is used to create a periodic interrupt (IRQ) that can trigger the following:

Example: Create an interval timer that posts 20 times per second

OS_SEM timerSem;
timerSem.Init();
int timerNumer = IntervalOSSem(&timerSem, 20);
if(timerNumer < 0)
{
iprintf("Error %d\r\n", timerNumer);
break;
}
int IntervalOSSem(OS_SEM *p_toSem, int num_per_sec, int timer=FIRST_UNUSED_TIMER)
Posts to a semaphore at the requested interval.
Semaphores are used to control access to shared resources or or to communicate between tasks in a mul...
Definition nbrtos.h:386
uint8_t Init(int32_t cnt=0)
Initialize the semaphore object count value.

When you have no further use for the interval timer, call IntervalStop() so that the hardware timer is released.

See also
High Resolution Delay Timer
Stopwatch Timer
OSTimeDly()

Function Documentation

◆ IntervalInterruptCallback()

int IntervalInterruptCallback ( void(*)() p_toCallbackFunc,
int num_per_sec,
int timer = FIRST_UNUSED_TIMER )

#include <IntervalTimer.h>

Calls a function at requested interval. Note that the callback function is called from within the timer's interrupt handler so you should treat your callback function as an interrupt.

Parameters
p_toCallbackFuncPointer to the callback function
num_per_secNumber of posts per second, minimum is 20 posts per second.
timerOptional parameter, timer number of -1 for first unused timer
Returns
The timer number, -1 if no timer is available, or -2 if num_per_sec is invalid.

◆ IntervalOSFlag()

int IntervalOSFlag ( OS_FLAGS * p_toFlag,
uint32_t flag_value,
int num_per_sec,
int timer = FIRST_UNUSED_TIMER )

#include <IntervalTimer.h>

Sets a flag at requested interval.

Parameters
p_toFlagPointer to the semaphore
flag_valueOS Flag value to set
num_per_secNumber of posts per second, minimum is 20 posts per second.
timerOptional parameter, timer number of -1 for first unused timer
Returns
The timer number, -1 if no timer is available, or -2 if num_per_sec is invalid.

◆ IntervalOSSem()

int IntervalOSSem ( OS_SEM * p_toSem,
int num_per_sec,
int timer = FIRST_UNUSED_TIMER )

#include <IntervalTimer.h>

Posts to a semaphore at the requested interval.

Parameters
p_toSemPointer to the semaphore
num_per_secNumber of posts per second, minimum is 20 posts per second
timerOptional parameter, timer number of -1 for first unused timer
Returns
The timer number, -1 if no timer is available, or -2 if num_per_sec is invalid.

◆ IntervalStop()

void IntervalStop ( int timer_number)

#include <IntervalTimer.h>

Stops an existing Interval Timer and frees the resource.

Parameters
timer_numberNumber of the timer to stop.