1
0
forked from me/IronOS

Handle devices where flash is not 1:1 memory mapped

This commit is contained in:
Ben V. Brown
2023-06-19 16:41:47 +10:00
parent 03eb8b9417
commit 9b5d155d31
3 changed files with 21 additions and 10 deletions

View File

@@ -162,6 +162,7 @@
#define HARDWARE_MAX_WATTAGE_X10 750
#define TIP_THERMAL_MASS 65 // X10 watts to raise 1 deg C in 1 second
#define TIP_RESISTANCE 75 // x10 ohms, 7.5 typical for Pinecil tips
#define CANT_DIRECT_READ_SETTINGS
#endif
#endif

View File

@@ -163,7 +163,7 @@
#define TIP_THERMAL_MASS 65 // X10 watts to raise 1 deg C in 1 second
#define BLE_ENABLED
#define NEEDS_VBUS_PROBE 0
#define CANT_DIRECT_READ_SETTINGS
#endif
#endif

View File

@@ -106,9 +106,20 @@ static const SettingConstants settingsConstants[(int)SettingsOptions::SettingsOp
static_assert((sizeof(settingsConstants) / sizeof(SettingConstants)) == ((int)SettingsOptions::SettingsOptionsLength));
void saveSettings() {
#ifdef CANT_DIRECT_READ_SETTINGS
// For these devices flash is not 1:1 mapped, so need to read into staging buffer
systemSettingsType temp;
flash_read_buffer((uint8_t *)&temp, sizeof(systemSettingsType));
if (memcmp((void *)&temp, (void *)&systemSettings, sizeof(systemSettingsType))) {
flash_save_buffer((uint8_t *)&systemSettings, sizeof(systemSettingsType));
}
#else
if (memcmp((void *)SETTINGS_START_PAGE, (void *)&systemSettings, sizeof(systemSettingsType))) {
flash_save_buffer((uint8_t *)&systemSettings, sizeof(systemSettingsType));
}
#endif
}
bool loadSettings() {
@@ -162,8 +173,7 @@ void setSettingValue(const enum SettingsOptions option, const uint16_t newValue)
if (constrainedValue < constants.min) {
// If less than min, constrain
constrainedValue = constants.min;
}
else if (constrainedValue > constants.max) {
} else if (constrainedValue > constants.max) {
// If hit max, constrain
constrainedValue = constants.max;
}