forked from RIOT-OS/RIOT
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dc4d16e
commit 8b301eb
Showing
2 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include $(RIOTBASE)/Makefile.base |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* Copyright (C) 2018 INRIA | ||
* | ||
* This file is subject to the terms and conditions of the GNU Lesser | ||
* General Public License v2.1. See the file LICENSE in the top level | ||
* directory for more details. | ||
*/ | ||
|
||
/** | ||
* @ingroup sys | ||
* @ingroup sys_sytare | ||
* @{ | ||
* | ||
* @file | ||
* @brief Sytare implementation | ||
* | ||
* @author Gero Müller <gero.mueller@inria.fr> | ||
* @} | ||
*/ | ||
|
||
#include "irq.h" | ||
#include <stdint.h> | ||
|
||
/** | ||
* @brief Save all active periphs state | ||
* | ||
* @param[out] state buffer to save the state | ||
*/ | ||
extern void _sytare_save_periphs_state(uint8_t checkpoint); | ||
|
||
/** | ||
* @brief Restore all active periphs state | ||
* | ||
* @param[in] state buffer storing the state | ||
*/ | ||
extern void _sytare_restore_periphs_state(uint8_t checkpoint); | ||
|
||
extern void _sytare_save_ram(uint8_t checkpoint); | ||
extern void _sytare_restore_ram(uint8_t checkpoint); | ||
|
||
// returns the next checkpoint index | ||
extern uint8_t _sytare_next_checkpoint(void); | ||
extern uint8_t _sytare_current_checkpoint(void); | ||
|
||
// returns the next checkpoint index | ||
|
||
void sytare_save(void) | ||
{ | ||
unsigned irq_status = irq_disable(); | ||
|
||
const uint8_t checkpoint = _sytare_next_checkpoint(); | ||
|
||
_sytare_save_periphs_state(checkpoint); | ||
|
||
_sytare_save_ram(checkpoint); | ||
|
||
irq_restore(irq_status); | ||
} | ||
|
||
void sytare_restore(void) | ||
{ | ||
unsigned irq_status = irq_disable(); | ||
|
||
const uint8_t checkpoint = _sytare_current_checkpoint(); | ||
|
||
_sytare_restore_periphs_state(checkpoint); | ||
|
||
_sytare_restore_ram(checkpoint); | ||
|
||
irq_restore(irq_status); | ||
} |