Fixed some major issues with RAM shortage. Also moved the cached storage to a MALLOC design instead of fixed memory usage. Using freertos porteds malloc and free required to move to HEAP4 to make sure memory does not get fragmented.

Resized nearly all task stacks

Also: 
- Menu fixes for insertion. Almost done, just need to fix the negative voltage insertion for mcp and cathode
- Added Device parameters, must be filled in

git-svn-id: https://svn.vbchaos.nl/svn/hsb/trunk@271 05563f52-14a8-4384-a975-3d1654cca0fa
This commit is contained in:
mmi
2017-11-07 15:50:25 +00:00
parent 27755498e6
commit 17207a3a4b
32 changed files with 1833 additions and 280 deletions

View File

@@ -74,7 +74,6 @@ struct RepairPresets* const self = &_self;
static ErrorStatus RepairPresets_verifyCRCs(void);
static ErrorStatus RepairPresets_verifyPresetCRC(struct RepairPresetStorageClass* repairPreset);
static ErrorStatus RepairPresets_writePreset(struct RepairPreset* preset);
// -----------------------------------------------------------------------------
// Function definitions
@@ -184,7 +183,7 @@ ErrorStatus RepairPresets_loadPresets(REPAIR_PRESETS_ID presetID)
if (returnValue == SUCCESS)
{
// Create new cachedStorage with preset page number
returnValue = CachedStorage_construct(self->presetStorage, self->memoryDevice, pageNumber);
returnValue = CachedStorage_construct(self->presetStorage, self->memoryDevice, pageNumber, ((sizeof(struct RepairPresetStorageClass) * REPAIR_PRESETS_NUMBER_OF_PRESETS) / 4));
}
else
{
@@ -215,9 +214,9 @@ ErrorStatus RepairPresets_loadPresets(REPAIR_PRESETS_ID presetID)
}
const struct RepairPreset* RepairPresets_getPreset(unsigned int index)
struct RepairPreset* RepairPresets_getPreset(unsigned int index)
{
const struct RepairPreset* returnValue = NULL;
struct RepairPreset* returnValue = NULL;
if (self->initialized)
{
if (self->presetsLoaded)
@@ -226,8 +225,8 @@ const struct RepairPreset* RepairPresets_getPreset(unsigned int index)
if ((index > 0) || (index <= REPAIR_PRESETS_NUMBER_OF_PRESETS))
{
struct RepairPresetStorageClass* tempPreset;
tempPreset = CachedStorage_readBlob(self->presetStorage, (index - 1) * sizeof(struct RepairPresetStorageClass));
returnValue = (const struct RepairPreset*)&tempPreset->preset;
tempPreset = CachedStorage_readBlob(self->presetStorage, (index - 1) * sizeof(struct RepairPresetStorageClass) / 4);
returnValue = (struct RepairPreset*)&tempPreset->preset;
}
}
}
@@ -235,6 +234,13 @@ const struct RepairPreset* RepairPresets_getPreset(unsigned int index)
}
void RepairPresets_savePresets(void)
{
// Commit cache to memory - will not write if no changes have been made
CachedStorage_commit(self->presetStorage);
}
static ErrorStatus RepairPresets_verifyCRCs(void)
{
ErrorStatus returnValue = SUCCESS;
@@ -246,7 +252,7 @@ static ErrorStatus RepairPresets_verifyCRCs(void)
for (loopCounter = 0; loopCounter < REPAIR_PRESETS_NUMBER_OF_PRESETS; loopCounter++)
{
// Load next preset from cache
tempPresetStorage = CachedStorage_readBlob(self->presetStorage, loopCounter * sizeof(struct RepairPresetStorageClass));
tempPresetStorage = CachedStorage_readBlob(self->presetStorage, loopCounter * sizeof(struct RepairPresetStorageClass) / 4);
// Verify CRC
returnValue = RepairPresets_verifyPresetCRC(tempPresetStorage);
// Check CRC verification
@@ -285,10 +291,6 @@ static ErrorStatus RepairPresets_verifyPresetCRC(struct RepairPresetStorageClass
returnValue = ERROR;
LOGGER_ERROR(mainLog, "CRC ERROR at repair preset %d (calculated %X but loaded %X)", repairPreset->preset.presetNumber, (unsigned int)tempCRC, (unsigned int)repairPreset->crc);
}
else
{
LOGGER_INFO(mainLog, "CRC OK at repair preset %d (calculated %X and loaded %X)", repairPreset->preset.presetNumber, (unsigned int)tempCRC, (unsigned int)repairPreset->crc);
}
}
else
{
@@ -299,7 +301,7 @@ static ErrorStatus RepairPresets_verifyPresetCRC(struct RepairPresetStorageClass
static ErrorStatus RepairPresets_writePreset(struct RepairPreset* preset)
ErrorStatus RepairPresets_writePreset(struct RepairPreset* preset)
{
ErrorStatus returnValue = SUCCESS;
if (self->initialized)
@@ -309,7 +311,8 @@ static ErrorStatus RepairPresets_writePreset(struct RepairPreset* preset)
// Calculate CRC over preset
tempPresetStorage.crc = crc32_calculate(0, &tempPresetStorage.preset, sizeof(struct RepairPreset));
// Put default preset on Cache
CachedStorage_writeBlob(self->presetStorage, (tempPresetStorage.preset.presetNumber - 1) * sizeof(struct RepairPresetStorageClass), &tempPresetStorage, sizeof(struct RepairPresetStorageClass));
CachedStorage_writeBlob(self->presetStorage, (tempPresetStorage.preset.presetNumber - 1) * sizeof(struct RepairPresetStorageClass) / 4,
&tempPresetStorage, sizeof(struct RepairPresetStorageClass) / 4);
}
else