Mercurial > public > ostc4
changeset 429:7f351c25608a ImprovmentNVM_2
Marked possible code improvment for future activities:
parameters stored in the settings were not trusted. LastDive ID and Sample index are usually calculated at startup. This calculation could be avoided, nevertheless the implementation works => only TODO
Removed function without effect:
Calling writeblock with legth 0 has no effect
author | ideenmodellierer |
---|---|
date | Mon, 17 Feb 2020 19:43:09 +0100 |
parents | 0e5341951079 |
children | 30580cf5ee77 |
files | Discovery/Src/externLogbookFlash.c |
diffstat | 1 files changed, 8 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/Discovery/Src/externLogbookFlash.c Mon Feb 17 19:04:10 2020 +0100 +++ b/Discovery/Src/externLogbookFlash.c Mon Feb 17 19:43:09 2020 +0100 @@ -660,7 +660,7 @@ void ext_flash_create_new_dive_log(uint8_t *pHeaderPreDive) { SSettings *settings; - uint8_t id, id_next; + uint8_t id; uint8_t header1, header2; settings = settingsGetPointer(); @@ -668,10 +668,12 @@ actualAddress = HEADERSTART + (0x800 * id); ext_flash_read_block_start(); - ext_flash_read_block(&header1, EF_SAMPLE); - ext_flash_read_block(&header2, EF_SAMPLE); + ext_flash_read_block(&header1, EF_SAMPLE); /* the sample ring is increased instead of header... not sure if that is planned intention */ + ext_flash_read_block(&header2, EF_SAMPLE); /* does not matter because actual address is reset in write_block call */ ext_flash_read_block_stop(); + /* TODO Cleanup_Ref_2: The code below should not be necessary in case of a proper shutdown and startup */ + /* the implementation fixes an issue which might happen at Cleanup_Ref_1 (in case of more then 254 dives) */ if((header1 == 0xFA) && (header2 == 0xFA)) { id += 1; /* 0-255, auto rollover */ @@ -691,11 +693,6 @@ id = 0; } - /* delete next header */ - id_next = id + 1; - actualPointerHeader = HEADERSTART + (0x800 * id_next); - ef_write_block(0,0, EF_HEADER, 0); - settings->lastDiveLogId = id; actualPointerHeader = HEADERSTART + (0x800 * id); @@ -1407,6 +1404,9 @@ uint8_t header1, header2; convert_Type dataStart, dataEnd; + /* TODO Cleanup_Ref_1: cleanup logFlashNextSampleStartAddress and lastDiveLogId */ + /* The implementation below would cause problems in case more then 254 dives would be done. */ + /* This is avoided by Cleanup_Ref2 */ for(id = 0; id < 255;id++) { actualAddress = HEADERSTART + (0x800 * id) + HEADER2OFFSET;