MiraOS  1.7
mira_sleep.h
Go to the documentation of this file.
1 /****************************************************************************
2  * Copyright (C) 2016 LumenRadio AB *
3  * *
4  * This file is part of MiraOS. *
5  * *
6  * MiraOS contains software components that are patented by LumenRadio. *
7  * Use of this software is under the terms of the LumenRadio MiraOS *
8  * license.
9  * *
10  * You should have received a copy of the MiraOS license from your *
11  * LumenRadio representative. If not, email to <licenses@lumenradio.com> *
12  ****************************************************************************/
13 
25 #ifndef LIBMIRA_SLEEP_H_
26 #define LIBMIRA_SLEEP_H_
27 
28 #include "sys/process.h"
29 
39 void mira_prepare_sleep(uint16_t sleep_time);
40 
48 void mira_restore_from_sleep(void);
49 
57 #define mira_deep_sleep(sleep_time) \
58  { \
59  mira_prepare_sleep(sleep_time); \
60  etimer_set(&mira_sleep_timer, (sleep_time)*CLOCK_SECOND); \
61  PROCESS_YIELD_UNTIL((etimer_expired(&mira_sleep_timer) || (mira_wake_up_from_irq))); \
62  mira_restore_from_sleep(); \
63  }
64 
73 void mira_wake_up_process(void);
74 
75 
85 void mira_sleepy_node_poll_for_fw(uint16_t firmware_image_id);
86 
94 uint8_t mira_sleepy_node_poll_done(void);
95 
104 #define mira_sleepy_node_poll_firmware(firmware_image_id) \
105  { \
106  mira_sleepy_node_poll_for_fw(firmware_image_id); \
107  PROCESS_WAIT_UNTIL(mira_sleepy_node_poll_done()); \
108  }
109 
110 extern struct etimer mira_sleep_timer;
111 extern uint8_t mira_wake_up_from_irq;
112 
113 #endif /* LIBMIRA_SLEEP_H_ */
uint8_t mira_sleepy_node_poll_done(void)
Checks if firmware polling is done.
void mira_wake_up_process(void)
Wake up the thread that went to deep sleep.
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.
void mira_sleepy_node_poll_for_fw(uint16_t firmware_image_id)
Polls neighbors for new firmware.