|
@ -28,15 +28,6 @@ |
|
|
|
|
|
|
|
|
#include "../shared/eeprom_api.h" |
|
|
#include "../shared/eeprom_api.h" |
|
|
|
|
|
|
|
|
#if HAS_SERVOS |
|
|
|
|
|
#include "Servo.h" |
|
|
|
|
|
#define PAUSE_SERVO_OUTPUT() libServo::pause_all_servos() |
|
|
|
|
|
#define RESUME_SERVO_OUTPUT() libServo::resume_all_servos() |
|
|
|
|
|
#else |
|
|
|
|
|
#define PAUSE_SERVO_OUTPUT() |
|
|
|
|
|
#define RESUME_SERVO_OUTPUT() |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* The STM32 HAL supports chips that deal with "pages" and some with "sectors" and some that |
|
|
* The STM32 HAL supports chips that deal with "pages" and some with "sectors" and some that |
|
|
* even have multiple "banks" of flash. |
|
|
* even have multiple "banks" of flash. |
|
@ -172,11 +163,11 @@ bool PersistentStore::access_finish() { |
|
|
current_slot = EEPROM_SLOTS - 1; |
|
|
current_slot = EEPROM_SLOTS - 1; |
|
|
UNLOCK_FLASH(); |
|
|
UNLOCK_FLASH(); |
|
|
|
|
|
|
|
|
PAUSE_SERVO_OUTPUT(); |
|
|
TERN_(HAS_PAUSE_SERVO_OUTPUT, PAUSE_SERVO_OUTPUT()); |
|
|
DISABLE_ISRS(); |
|
|
DISABLE_ISRS(); |
|
|
status = HAL_FLASHEx_Erase(&EraseInitStruct, &SectorError); |
|
|
status = HAL_FLASHEx_Erase(&EraseInitStruct, &SectorError); |
|
|
ENABLE_ISRS(); |
|
|
ENABLE_ISRS(); |
|
|
RESUME_SERVO_OUTPUT(); |
|
|
TERN_(HAS_PAUSE_SERVO_OUTPUT, RESUME_SERVO_OUTPUT()); |
|
|
if (status != HAL_OK) { |
|
|
if (status != HAL_OK) { |
|
|
DEBUG_ECHOLNPAIR("HAL_FLASHEx_Erase=", status); |
|
|
DEBUG_ECHOLNPAIR("HAL_FLASHEx_Erase=", status); |
|
|
DEBUG_ECHOLNPAIR("GetError=", HAL_FLASH_GetError()); |
|
|
DEBUG_ECHOLNPAIR("GetError=", HAL_FLASH_GetError()); |
|
@ -227,11 +218,11 @@ bool PersistentStore::access_finish() { |
|
|
// Interrupts during this time can have unpredictable results, such as killing Servo
|
|
|
// Interrupts during this time can have unpredictable results, such as killing Servo
|
|
|
// output. Servo output still glitches with interrupts disabled, but recovers after the
|
|
|
// output. Servo output still glitches with interrupts disabled, but recovers after the
|
|
|
// erase.
|
|
|
// erase.
|
|
|
PAUSE_SERVO_OUTPUT(); |
|
|
TERN_(HAS_PAUSE_SERVO_OUTPUT, PAUSE_SERVO_OUTPUT()); |
|
|
DISABLE_ISRS(); |
|
|
DISABLE_ISRS(); |
|
|
eeprom_buffer_flush(); |
|
|
eeprom_buffer_flush(); |
|
|
ENABLE_ISRS(); |
|
|
ENABLE_ISRS(); |
|
|
RESUME_SERVO_OUTPUT(); |
|
|
TERN_(HAS_PAUSE_SERVO_OUTPUT, RESUME_SERVO_OUTPUT()); |
|
|
|
|
|
|
|
|
eeprom_data_written = false; |
|
|
eeprom_data_written = false; |
|
|
#endif |
|
|
#endif |
|
|