MiraOS  1.7
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

struct etimer mira_sleep_timer
 
uint8_t mira_wake_up_from_irq
 

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

#define mira_deep_sleep (   sleep_time)
Value:
{ \
mira_prepare_sleep(sleep_time); \
etimer_set(&mira_sleep_timer, (sleep_time)*CLOCK_SECOND); \
PROCESS_YIELD_UNTIL((etimer_expired(&mira_sleep_timer) || (mira_wake_up_from_irq))); \
}
struct etimer mira_sleep_timer
void mira_prepare_sleep(uint16_t sleep_time)
Prepare for sleep.
uint8_t mira_wake_up_from_irq
void mira_restore_from_sleep(void)
Restore from sleep.

Go to deep sleep for a certain amount of time.

Parameters
sleep_timethe time to sleep in seconds
Returns
void
#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.
void mira_sleepy_node_poll_for_fw(uint16_t firmware_image_id)
Polls neighbors for new firmware.

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

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
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
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)
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
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

Variable Documentation

struct etimer mira_sleep_timer
uint8_t mira_wake_up_from_irq