1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/boards/wsn430-common/board_config.c

27 lines
672 B
C
Raw Normal View History

/**
* board-config.c.
*
* This source code is licensed under the GNU Lesser General Public License,
* Version 2. See the file LICENSE for more details.
*/
2013-05-25 12:34:18 +02:00
#include <stdint.h>
#include <string.h>
2013-12-16 17:54:58 +01:00
#include "board-conf.h"
#include "config.h"
#include "flashrom.h"
2013-05-25 12:34:18 +02:00
void config_load(void) {
if (*((uint16_t*) INFOMEM) == CONFIG_KEY) {
memcpy(&sysconfig, (char*) (INFOMEM + sizeof(CONFIG_KEY)), sizeof(sysconfig));
}
else {
config_save();
}
}
uint8_t config_save(void) {
configmem_t mem = { CONFIG_KEY, sysconfig };
return (flashrom_erase((uint8_t*) INFOMEM) && flashrom_write((uint8_t*) INFOMEM, (char*) &mem, sizeof(mem)));
}