USER MANUAL RC188x-GPR
2019 Radiocrafts AS
RIIM User Manual (rev.1.2)
Page
20
of
23
8.12. Timer
The Timer module enables the user to create various timers. The timers will call a function when they are triggered,
and can be configured as periodic or one-shot, started and stopped.
The following example creates a periodic timer that calls the function
ReadSensor
every 10 seconds:
Example : ICI code
static
const
uint32_t
TimerPeriod
=
10
;
static
uint8_t
Sensor_timer_handler
;
static
void
ReadSensor
()
{
Util
.
printf
(
"Reading sensors....\n"
);
return
;
}
RIIM_SETUP
()
{
// Create timer that sends the CoAP PUT message
Sensor_timer_handler
=
Timer
.
create
(
PERIODIC
,
TimerPeriod
,
ReadSensor
);
Timer
.
start
(
Sensor_timer_handler
);
return
UAPI_OK
;
}
Example 12 - Timer example code
Function
Description
create
(TimerMode, Period, Handler)
Create a new timer
start
(TimerID)
Start the timer
stop
(TimerID)
Stop the timer
isActive
(TimerID)
Check if the timer is active
config
(TimerID, TimerMode,Period,
TimerHandler)
(Re)-configure a timer
Table 12 - Timer functions