From 0d008cc2720a8c4bb3b76c6dec5040464d048adf Mon Sep 17 00:00:00 2001 From: Jérémy Dufour Date: Tue, 1 Apr 2008 10:48:54 +0200 Subject: * digital/io/src - add configuration settings of sharp module data to the eeprom module. --- digital/io/src/eeprom.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'digital') diff --git a/digital/io/src/eeprom.c b/digital/io/src/eeprom.c index 1a6dc4fa..31f03641 100644 --- a/digital/io/src/eeprom.c +++ b/digital/io/src/eeprom.c @@ -28,6 +28,7 @@ #include "servo.h" /* SERVO_NUMBER */ #include "trap.h" /* trap_high_time_pos */ +#include "sharp.h" /* sharp_threshold */ #include /* eeprom_{read,write}_byte */ @@ -45,7 +46,7 @@ /** * Current version of the parameters organization. */ -#define EEPROM_PARAM_KEY 0x01 +#define EEPROM_PARAM_KEY 0x02 /** @} */ @@ -54,6 +55,8 @@ void eeprom_load_param () { uint8_t compt; + uint16_t *ptr16; + /* The parameters start at the given address */ uint8_t *ptr8 = (uint8_t *) EEPROM_PARAM_START; /* Check if the key/version is correct */ @@ -68,6 +71,15 @@ eeprom_load_param () trap_high_time_pos[0][compt] = eeprom_read_byte(ptr8++); trap_high_time_pos[1][compt] = eeprom_read_byte(ptr8++); } + + /* Load sharp module data */ + ptr16 = (uint16_t *) ptr8; + /* Threshold values, high and low */ + for (compt = 0; compt < SHARP_NUMBER; compt++) + { + sharp_threshold[compt][0] = eeprom_read_word (ptr16++); + sharp_threshold[compt][1] = eeprom_read_word (ptr16++); + } } /* Store parameters in the EEPROM. */ @@ -75,6 +87,8 @@ void eeprom_save_param () { uint8_t compt; + uint16_t *ptr16; + /* The parameters start at the given address */ uint8_t *ptr8 = (uint8_t *) EEPROM_PARAM_START; /* Store the key */ @@ -87,6 +101,15 @@ eeprom_save_param () eeprom_write_byte (ptr8++, trap_high_time_pos[0][compt]); eeprom_write_byte (ptr8++, trap_high_time_pos[1][compt]); } + + /* Store sharp module data */ + ptr16 = (uint16_t *) ptr8; + /* Threshold values, high and low */ + for (compt = 0; compt < SHARP_NUMBER; compt++) + { + eeprom_write_word (ptr16++, sharp_threshold[compt][0]); + eeprom_write_word (ptr16++, sharp_threshold[compt][1]); + } } /* Clear parameters in the EEPROM by invalidating the key. */ -- cgit v1.2.3