From 2658e9f053fc0fc43e853b94e589ee6d40669f57 Mon Sep 17 00:00:00 2001 From: Samuel Sadok Date: Tue, 13 Aug 2019 14:02:57 +0200 Subject: [PATCH] fix NVM bug This bug prevented the user from saving the configuration more than twice without rebooting. --- Firmware/MotorControl/nvm.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Firmware/MotorControl/nvm.c b/Firmware/MotorControl/nvm.c index e581beee..5a1b4a71 100644 --- a/Firmware/MotorControl/nvm.c +++ b/Firmware/MotorControl/nvm.c @@ -362,10 +362,12 @@ int NVM_commit(void) { read_sector_ = 1 - read_sector_; // invalidate the other sector - if (read_sector->index < read_sector->n_data) + if (read_sector->index < read_sector->n_data) { status = set_allocation_state(read_sector, read_sector->index, 1, INVALID); - else + read_sector->index += 1; + } else { status = erase(read_sector); + } return status; }