LDL  0.5.0
Macros | Typedefs
System

Description

MAC accesses various things through system interfaces which must be passed as function pointers to MAC during LDL_MAC_init().

The interfaces are:

In addition to function pointers, the following macros MUST be defined if LDL_MAC_radioEvent(), LDL_MAC_radioEventWithTicks(), or LDL_MAC_ticksUntilNextEvent() are called from an interrupt:

Macros

#define LDL_SYSTEM_ENTER_CRITICAL(APP)
 
#define LDL_SYSTEM_LEAVE_CRITICAL(APP)
 

Typedefs

typedef uint32_t(* ldl_system_ticks_fn) (void *app)
 
typedef uint32_t(* ldl_system_rand_fn) (void *app)
 
typedef uint8_t(* ldl_system_get_battery_level_fn) (void *app)
 

Macro Definition Documentation

◆ LDL_SYSTEM_ENTER_CRITICAL

#define LDL_SYSTEM_ENTER_CRITICAL (   APP)

Expanded inside functions which might be called from both mainloop and interrupt. At the moment only LDL_MAC_ticksUntilNextEvent() and LDL_MAC_interrupt() are safe to call this way.

Always paired with LDL_SYSTEM_LEAVE_CRITICAL within the same function like so:

void some_function(void *app)
{
// critical section code
}

If you are using avr-libc:

#include <util/atomic.h>
#define LDL_SYSTEM_ENTER_CRITICAL(APP) ATOMIC_BLOCK(ATOMIC_RESTORESTATE){
#define LDL_SYSTEM_LEAVE_CRITICAL(APP) }

If you are using CMSIS:

#define LDL_SYSTEM_ENTER_CRITICAL(APP) volatile uint32_t primask = __get_PRIMASK(); __disable_irq();
#define LDL_SYSTEM_LEAVE_CRITICAL(APP) __set_PRIMASK(primask);
Parameters
[in]APPfrom ldl_mac_init_arg.app

◆ LDL_SYSTEM_LEAVE_CRITICAL

#define LDL_SYSTEM_LEAVE_CRITICAL (   APP)

Expanded inside functions which might be called from both mainloop and interrupt.

Always paired with LDL_SYSTEM_ENTER_CRITICAL within the same function.

Parameters
[in]APPfrom ldl_mac_init_arg.app

Typedef Documentation

◆ ldl_system_ticks_fn

typedef uint32_t(* ldl_system_ticks_fn) (void *app)

This function reads a free-running 32 bit counter. The counter is expected to increment at a rate of ldl_mac_init_arg.tps ticks per second.

LDL uses this changing value to track of the passage of time and perform scheduling.

If you intend to keep LDL running in deep sleep modes, make sure that the timer continues to increment in this mode.

Note
this may be called from mainloop or interrupt
Parameters
[in]appfrom ldl_mac_init_arg.app
Returns
ticks

◆ ldl_system_rand_fn

typedef uint32_t(* ldl_system_rand_fn) (void *app)

LDL uses this function to select channels and to add random dither to scheduled events.

Parameters
[in]appfrom ldl_mac_init_arg.app
Return values
(0..UINT32_MAX)

◆ ldl_system_get_battery_level_fn

typedef uint8_t(* ldl_system_get_battery_level_fn) (void *app)

LDL uses this function to discover the battery level for for device status MAC command.

Parameters
[in]appfrom ldl_mac_init_arg.app
Returns
DevStatusAns.battery
Return values
255not implemented