System class. More...

#include <System.h>

Public Member Functions

 SystemClass ()
 
bool isReady ()
 Check if system ready. More...
 
void restart (unsigned deferMillis=0)
 Request a restart of the system. More...
 
void setCpuFrequency (CpuFrequency freq)
 Set the CPU frequency. More...
 
CpuFrequency getCpuFrequency ()
 Get the CPU frequency. More...
 
bool deepSleep (uint32_t timeMilliseconds, DeepSleepOptions options=eDSO_RF_CAL_BY_INIT_DATA)
 Enter deep sleep mode. More...
 
void onReady (SystemReadyDelegate readyHandler)
 Set handler for system ready event. More...
 
void onReady (ISystemReadyHandler *readyHandler)
 Set handler for system ready event. More...
 

Static Public Member Functions

static bool initialize ()
 System initialisation. More...
 
static bool queueCallback (TaskCallback32 callback, uint32_t param=0)
 Queue a deferred callback. More...
 
static bool queueCallback (TaskCallback callback, void *param=nullptr)
 Queue a deferred callback, with optional void* parameter. More...
 
static bool queueCallback (InterruptCallback callback)
 Queue a deferred callback with no callback parameter. More...
 
static bool queueCallback (TaskDelegate callback)
 Queue a deferred Delegate callback. More...
 
static unsigned getTaskCount ()
 Get number of tasks currently on queue. More...
 
static unsigned getMaxTaskCount ()
 Get maximum number of tasks seen on queue at any one time. More...
 

Detailed Description

System class.

Constructor & Destructor Documentation

◆ SystemClass()

SystemClass::SystemClass ( )
inline

Member Function Documentation

◆ deepSleep()

bool SystemClass::deepSleep ( uint32_t  timeMilliseconds,
DeepSleepOptions  options = eDSO_RF_CAL_BY_INIT_DATA 
)

Enter deep sleep mode.

Parameters
timeMillisecondsQuantity of milliseconds to remain in deep sleep mode
optionsDeep sleep options

◆ getCpuFrequency()

CpuFrequency SystemClass::getCpuFrequency ( )
inline

Get the CPU frequency.

Return values
CpuFrequencyThe frequency of the CPU

◆ getMaxTaskCount()

static unsigned SystemClass::getMaxTaskCount ( )
inlinestatic

Get maximum number of tasks seen on queue at any one time.

Return values
unsigned
Note
If return value is higher than maximum task queue TASK_QUEUE_LENGTH then the queue has overflowed at some point and tasks have been left un-executed.

◆ getTaskCount()

static unsigned SystemClass::getTaskCount ( )
inlinestatic

Get number of tasks currently on queue.

Return values
unsigned

◆ initialize()

static bool SystemClass::initialize ( )
static

System initialisation.

Return values
booltrue on success
Note
Called by user_main: applications should not call this function or the task queue will be re-initialised and any currently queued tasks won't be called.

◆ isReady()

bool SystemClass::isReady ( )
inline

Check if system ready.

Return values
boolTrue if system initialisation is complete and system is now ready

◆ onReady() [1/2]

void SystemClass::onReady ( SystemReadyDelegate  readyHandler)
inline

Set handler for system ready event.

Parameters
readyHandlerFunction to handle event
Note
if system is ready, callback is executed immediately without deferral

◆ onReady() [2/2]

void SystemClass::onReady ( ISystemReadyHandler readyHandler)
inline

Set handler for system ready event.

Parameters
readyHandlerFunction to handle event
Note
if system is ready, callback is executed immediately without deferral

◆ queueCallback() [1/4]

static bool SystemClass::queueCallback ( TaskCallback32  callback,
uint32_t  param = 0 
)
static

Queue a deferred callback.

Parameters
callbackThe function to be called
paramParameter passed to the callback (optional)
Return values
boolfalse if callback could not be queued
Note
It is important to check the return value to avoid memory leaks and other issues, for example if memory is allocated and relies on the callback to free it again. Note also that this method is typically called from interrupt context so must avoid things like heap allocation, etc.

◆ queueCallback() [2/4]

static bool SystemClass::queueCallback ( TaskCallback  callback,
void *  param = nullptr 
)
inlinestatic

Queue a deferred callback, with optional void* parameter.

◆ queueCallback() [3/4]

static bool SystemClass::queueCallback ( InterruptCallback  callback)
inlinestatic

Queue a deferred callback with no callback parameter.

◆ queueCallback() [4/4]

static bool SystemClass::queueCallback ( TaskDelegate  callback)
static

Queue a deferred Delegate callback.

Parameters
callbackThe Delegate to be called
Return values
boolfalse if callback could not be queued
Note
Provides flexibility and ease of use for using capturing lambdas, etc. but requires heap allocation and not as fast as a function callback. DO NOT use from interrupt context, use a Task/Interrupt callback.

◆ restart()

void SystemClass::restart ( unsigned  deferMillis = 0)

Request a restart of the system.

Parameters
deferMillisdefer restart request by a number of milliseconds
Note
A delay is often required to allow network callback code to complete correctly. The restart is always deferred, either using the task queue (if deferMillis == 0) or using a timer. This method always returns immediately.

◆ setCpuFrequency()

void SystemClass::setCpuFrequency ( CpuFrequency  freq)
inline

Set the CPU frequency.

Parameters
freqFrequency to set CPU

The documentation for this class was generated from the following file: