The friendly Operating System for the Internet of Things

Low-level RTT (Real Time Timer) peripheral driver. More...

Detailed Description

Files

file  rtt.h
 Low-level RTT (Real Time Timer) peripheral driver interface definitions.
 

Macros

#define RTT_US_TO_TICKS(us)   ((uint32_t)((uint64_t)(us) * RTT_FREQUENCY / 1000000UL))
 Convert microseconds to rtt ticks. More...
 
#define RTT_MS_TO_TICKS(ms)   ( RTT_US_TO_TICKS((ms) * 1000) )
 Convert milliseconds to rtt ticks. More...
 
#define RTT_SEC_TO_TICKS(sec)   ( RTT_MS_TO_TICKS((sec) * 1000) )
 Convert seconds to rtt ticks. More...
 
#define RTT_MIN_TO_TICKS(min)   ( RTT_SEC_TO_TICKS((min) * 60) )
 Convert minutes to rtt ticks. More...
 
#define RTT_TICKS_TO_US(ticks)   ((uint32_t)((uint64_t)(ticks) * 1000000UL / RTT_FREQUENCY))
 Convert rtt ticks to microseconds. More...
 
#define RTT_TICKS_TO_MS(ticks)   (RTT_TICKS_TO_US(ticks) / 1000)
 Convert rtt ticks to milliseconds. More...
 
#define RTT_TICKS_TO_SEC(ticks)   (RTT_TICKS_TO_MS(ticks) / 1000)
 Convert rtt ticks to seconds. More...
 
#define RTT_TICKS_TO_MIN(ticks)   (RTT_TICKS_TO_SEC(ticks) / 60)
 Convert rtt ticks to minutes. More...
 

Typedefs

typedef void(* rtt_cb_t) (void *arg)
 Signature for the alarm callback. More...
 

Functions

void rtt_init (void)
 Initialize RTT module.
 
void rtt_set_overflow_cb (rtt_cb_t cb, void *arg)
 Set a callback for the counter overflow event. More...
 
void rtt_clear_overflow_cb (void)
 Clear the overflow callback.
 
uint32_t rtt_get_counter (void)
 Get the current RTT counter. More...
 
void rtt_set_counter (uint32_t counter)
 Set the RTT counter to a specified value. More...
 
void rtt_set_alarm (uint32_t alarm, rtt_cb_t cb, void *arg)
 Set an alarm for RTT to the specified value. More...
 
uint32_t rtt_get_alarm (void)
 Get the value of a set alarm. More...
 
void rtt_clear_alarm (void)
 Clear any set alarm, do nothing if nothing set.
 
void rtt_poweron (void)
 Turn the RTT hardware module on.
 
void rtt_poweroff (void)
 Turn the RTT hardware module off.
 

Macro Definition Documentation

#define RTT_MIN_TO_TICKS (   min)    ( RTT_SEC_TO_TICKS((min) * 60) )
Parameters
[in]minnumber of minutes
Returns
rtt ticks

Definition at line 66 of file rtt.h.

#define RTT_MS_TO_TICKS (   ms)    ( RTT_US_TO_TICKS((ms) * 1000) )
Parameters
[in]msnumber of milliseconds
Returns
rtt ticks

Definition at line 52 of file rtt.h.

#define RTT_SEC_TO_TICKS (   sec)    ( RTT_MS_TO_TICKS((sec) * 1000) )
Parameters
[in]secnumber of seconds
Returns
rtt ticks

Definition at line 59 of file rtt.h.

#define RTT_TICKS_TO_MIN (   ticks)    (RTT_TICKS_TO_SEC(ticks) / 60)
Parameters
[in]ticksrtt ticks
Returns
number of minutes

Definition at line 94 of file rtt.h.

#define RTT_TICKS_TO_MS (   ticks)    (RTT_TICKS_TO_US(ticks) / 1000)
Parameters
[in]ticksrtt ticks
Returns
number of milliseconds

Definition at line 80 of file rtt.h.

#define RTT_TICKS_TO_SEC (   ticks)    (RTT_TICKS_TO_MS(ticks) / 1000)
Parameters
[in]ticksrtt ticks
Returns
number of seconds

Definition at line 87 of file rtt.h.

#define RTT_TICKS_TO_US (   ticks)    ((uint32_t)((uint64_t)(ticks) * 1000000UL / RTT_FREQUENCY))
Parameters
[in]ticksrtt ticks
Returns
number of microseconds

Definition at line 73 of file rtt.h.

#define RTT_US_TO_TICKS (   us)    ((uint32_t)((uint64_t)(us) * RTT_FREQUENCY / 1000000UL))
Parameters
[in]usnumber of microseconds
Returns
rtt ticks

Definition at line 45 of file rtt.h.

Typedef Documentation

typedef void(* rtt_cb_t) (void *arg)
Parameters
[in]argOptional argument which is passed to the callback

Definition at line 102 of file rtt.h.

Function Documentation

uint32_t rtt_get_alarm ( void  )

If no alarm is set, the return value is arbitrary.

Returns
Value the alarm is set to
uint32_t rtt_get_counter ( void  )
Returns
Current value of the RTT counter
void rtt_set_alarm ( uint32_t  alarm,
rtt_cb_t  cb,
void *  arg 
)
Parameters
[in]alarmThe value to trigger an alarm when hit
[in]cbCallback executed when alarm is hit
[in]argArgument passed to callback when alarm is hit
void rtt_set_counter ( uint32_t  counter)
Parameters
[in]counterThe value to set the RTT to.
void rtt_set_overflow_cb ( rtt_cb_t  cb,
void *  arg 
)
Parameters
[in]cbCallback to execute on overflow
[in]argArgument passed to the callback