2014-02-02 16:48:18 +01:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2014 INRIA
|
|
|
|
*
|
2014-07-31 20:15:03 +02:00
|
|
|
* 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.
|
2014-02-02 16:48:18 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @ingroup boards
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* @brief msb-430 common config module functions
|
|
|
|
*
|
|
|
|
* @author Oliver Hahm <oliver.hahm@inria.fr>
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2010-12-03 18:42:03 +01:00
|
|
|
#include <stdint.h>
|
2010-12-09 13:24:24 +01:00
|
|
|
#include <string.h>
|
2013-12-16 17:54:58 +01:00
|
|
|
#include "board-conf.h"
|
|
|
|
#include "config.h"
|
|
|
|
#include "flashrom.h"
|
2010-12-03 18:42:03 +01:00
|
|
|
|
2013-07-29 16:41:43 +02:00
|
|
|
void config_load(void)
|
|
|
|
{
|
|
|
|
if (*((uint16_t *) INFOMEM) == CONFIG_KEY) {
|
|
|
|
memcpy(&sysconfig, (char *)(INFOMEM + sizeof(CONFIG_KEY)), sizeof(sysconfig));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
config_save();
|
|
|
|
}
|
2010-12-09 13:24:24 +01:00
|
|
|
}
|
|
|
|
|
2013-07-29 16:41:43 +02:00
|
|
|
uint8_t config_save(void)
|
|
|
|
{
|
2010-12-03 22:22:58 +01:00
|
|
|
configmem_t mem = { CONFIG_KEY, sysconfig };
|
2014-06-25 20:50:43 +02:00
|
|
|
return (flashrom_erase((uint8_t *) INFOMEM) && flashrom_write((uint8_t *) INFOMEM, (uint8_t *) &mem, sizeof(mem)));
|
2010-12-03 18:42:03 +01:00
|
|
|
}
|