Skip to content

Commit

Permalink
add api
Browse files Browse the repository at this point in the history
  • Loading branch information
geromueller committed Mar 23, 2019
1 parent dc4d16e commit 8b301eb
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 0 deletions.
1 change: 1 addition & 0 deletions sys/checkpoint/Makefile
@@ -0,0 +1 @@
include $(RIOTBASE)/Makefile.base
71 changes: 71 additions & 0 deletions sys/checkpoint/sytare.c
@@ -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);
}

0 comments on commit 8b301eb

Please sign in to comment.