MiraOS  1.26
Macros | Functions | Variables
mira_sleep.h File Reference

MiraOS deep sleep functions. More...

#include "sys/process.h"

Go to the source code of this file.

Macros

#define mira_deep_sleep(sleep_time)
 Go to deep sleep for a certain amount of time. More...
 
#define mira_sleepy_node_poll_firmware(firmware_image_id)
 Polls for new firmware, and install if available. More...
 

Functions

void mira_prepare_sleep (uint16_t sleep_time)
 Prepare for sleep. More...
 
void mira_restore_from_sleep (void)
 Restore from sleep. More...
 
void mira_wake_up_process (void)
 Wake up the thread that went to deep sleep. More...
 
void mira_sleepy_node_poll_for_fw (uint16_t firmware_image_id)
 Polls neighbors for new firmware. More...
 
uint8_t mira_sleepy_node_poll_done (void)
 Checks if firmware polling is done. More...
 

Variables

process_event_t mira_wake_up_event
 Event that gets sent to wake up the sleeping thread.
 

Detailed Description

MiraOS deep sleep functions.

Author
LumenRadio AB
Date
10 June 2016 The MiraOS library provides functions for controlling the Mira radio module, sending/receiving messages, controlling peripherals, etc.
See also
http://docs.lumenrad.io/mira

Macro Definition Documentation

◆ mira_deep_sleep

#define mira_deep_sleep (   sleep_time)
Value:
{ \
mira_prepare_sleep(sleep_time); \
PROCESS_WAIT_EVENT_UNTIL(ev == mira_wake_up_event); \
mira_restore_from_sleep(); \
}
process_event_t mira_wake_up_event
Event that gets sent to wake up the sleeping thread.

Go to deep sleep for a certain amount of time.

To use any deep sleep functions, the section .nrdata shall be linked to the lower 16kB of RAM, all other variable section shall be linked to upper 16kB of RAM.

Parameters
sleep_timethe time to sleep in seconds
Returns
void

◆ mira_sleepy_node_poll_firmware

#define mira_sleepy_node_poll_firmware (   firmware_image_id)
Value:
{ \
mira_sleepy_node_poll_for_fw(firmware_image_id); \
PROCESS_WAIT_UNTIL(mira_sleepy_node_poll_done()); \
}
uint8_t mira_sleepy_node_poll_done(void)
Checks if firmware polling is done.

Polls for new firmware, and install if available.

This function will join the network and download available firmware and install it. The device will reboot after installation. If no new firmware is available then the network will not be joined.

Returns
void

Function Documentation

◆ mira_prepare_sleep()

void mira_prepare_sleep ( uint16_t  sleep_time)

Prepare for sleep.

This function is not supposed to be called by the user, it's only called as part of the mira_deep_sleep macro

Parameters
sleep_timethe time to sleep in seconds
Returns
void

◆ mira_restore_from_sleep()

void mira_restore_from_sleep ( void  )

Restore from sleep.

This function is not supposed to be called by the user, it's only called as part of the mira_deep_sleep macro

Returns
void

◆ mira_sleepy_node_poll_done()

uint8_t mira_sleepy_node_poll_done ( void  )

Checks if firmware polling is done.

This function shall only be called as part of the mira_sleepy_node_poll_firmware macro

Returns
poll status (1 = done, 0 = in progress)

◆ mira_sleepy_node_poll_for_fw()

void mira_sleepy_node_poll_for_fw ( uint16_t  firmware_image_id)

Polls neighbors for new firmware.

This function shall only be called as part of the mira_sleepy_node_poll_firmware macro

Parameters
firmware_image_idthe firmware update session id to poll for
Returns
void

◆ mira_wake_up_process()

void mira_wake_up_process ( void  )

Wake up the thread that went to deep sleep.

This function can be called from an ISR to wake up the sleeping thread. If this is not called the CPU will still wake up, but the thread will not wake up again until the sleep timer runs out.

Returns
void