From 624c34661148f1990f6cab9141c21f4396c14f0d Mon Sep 17 00:00:00 2001 From: Olivier Matz Date: Wed, 4 Mar 2015 21:32:30 +0100 Subject: [PATCH] imuboard: add a command to reset eeprom --- imuboard/commands.c | 10 +++++++--- imuboard/eeprom_config.c | 5 +++++ imuboard/eeprom_config.h | 1 + 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/imuboard/commands.c b/imuboard/commands.c index 447e399..c42eed4 100644 --- a/imuboard/commands.c +++ b/imuboard/commands.c @@ -229,16 +229,20 @@ struct cmd_eeprom_list_result { static void cmd_eeprom_list_parsed(void *parsed_result, void *data) { - (void)parsed_result; + struct cmd_eeprom_list_result *res = parsed_result; + (void)data; - eeprom_dump_cmds(); + if (!strcmp_P(PSTR("list"), res->cmd)) + eeprom_dump_cmds(); + else + eeprom_reset(); } const char PROGMEM str_eeprom_list_eeprom[] = "eeprom"; const parse_token_string_t PROGMEM cmd_eeprom_list_cmd = TOKEN_STRING_INITIALIZER(struct cmd_eeprom_list_result, cmd, str_eeprom_list_eeprom); -const char PROGMEM str_eeprom_list_list[] = "list"; +const char PROGMEM str_eeprom_list_list[] = "list#reset"; const parse_token_string_t PROGMEM cmd_eeprom_list_action = TOKEN_STRING_INITIALIZER(struct cmd_eeprom_list_result, action, str_eeprom_list_list); diff --git a/imuboard/eeprom_config.c b/imuboard/eeprom_config.c index f3274d8..2eb39c1 100644 --- a/imuboard/eeprom_config.c +++ b/imuboard/eeprom_config.c @@ -155,3 +155,8 @@ int8_t eeprom_delete_cmd(uint8_t n) eeprom_set_ncmds(max - 1); return 0; } + +void eeprom_reset(void) +{ + eeprom_set_ncmds(0); +} diff --git a/imuboard/eeprom_config.h b/imuboard/eeprom_config.h index 7aff867..3f9fe68 100644 --- a/imuboard/eeprom_config.h +++ b/imuboard/eeprom_config.h @@ -44,5 +44,6 @@ void eeprom_dump_cmds(void); int8_t eeprom_insert_cmd_before(const char *str, uint8_t n); int8_t eeprom_append_cmd(const char *str); int8_t eeprom_delete_cmd(uint8_t n); +void eeprom_reset(void); #endif -- 2.39.5