eepromCheck called inside eepromOpen

This commit is contained in:
bsongis
2015-04-20 18:17:57 +02:00
parent 2ed15a8388
commit 8425024eb9
5 changed files with 20 additions and 25 deletions
+1 -2
View File
@@ -84,8 +84,7 @@ void eeLoadModelHeaders()
void eeReadAll()
{
// TODO merge eepromOpen and eepromCheck
if (!eepromOpen() || eepromCheck() < 0 || !eeLoadGeneral()) {
if (!eepromOpen() || !eeLoadGeneral()) {
eeErase(true);
}
else {
-5
View File
@@ -195,11 +195,6 @@ bool eepromOpen()
}
}
bool eepromCheck()
{
return true;
}
uint32_t readFile(int index, uint8_t * data, uint32_t size)
{
uint16_t fileSize;
-1
View File
@@ -79,6 +79,5 @@ extern EepromWriteState eepromWriteState;
void eepromWriteProcess();
void eepromWriteWait(EepromWriteState state = EEPROM_IDLE);
bool eepromOpen();
bool eepromCheck();
#endif
+19 -16
View File
@@ -187,13 +187,13 @@ static void EeFsFree(blkid_t blk)
blkid_t i = blk;
blkid_t tmp;
#if defined(PCBTARANIS)
#if defined(CPUARM)
freeBlocks++;
#endif
while ((tmp=EeFsGetLink(i))) {
i = tmp;
#if defined(PCBTARANIS)
#if defined(CPUARM)
freeBlocks++;
#endif
}
@@ -203,7 +203,7 @@ static void EeFsFree(blkid_t blk)
EeFsFlushFreelist();
}
int8_t eepromCheck()
void eepromCheck()
{
ENABLE_SYNC_WRITE(true);
@@ -211,11 +211,11 @@ int8_t eepromCheck()
memclear(bufp, BLOCKS);
blkid_t blk ;
#if defined(PCBTARANIS)
#if defined(CPUARM)
blkid_t blocksCount;
#endif
for (uint8_t i=0; i<=MAXFILES; i++) {
#if defined(PCBTARANIS)
#if defined(CPUARM)
blocksCount = 0;
#endif
blkid_t *startP = (i==MAXFILES ? &eeFs.freeList : &eeFs.files[i].startBlk);
@@ -236,7 +236,7 @@ int8_t eepromCheck()
blk = 0; // abort
}
else {
#if defined(PCBTARANIS)
#if defined(CPUARM)
blocksCount++;
#endif
bufp[blk] = i+1;
@@ -246,13 +246,13 @@ int8_t eepromCheck()
}
}
#if defined(PCBTARANIS)
#if defined(CPUARM)
freeBlocks = blocksCount;
#endif
for (blk=FIRSTBLK; blk<BLOCKS; blk++) {
if (!bufp[blk]) { // unused block
#if defined(PCBTARANIS)
#if defined(CPUARM)
freeBlocks++;
#endif
EeFsSetLink(blk, eeFs.freeList);
@@ -262,8 +262,6 @@ int8_t eepromCheck()
}
ENABLE_SYNC_WRITE(false);
return 0;
}
void eepromFormat()
@@ -280,7 +278,7 @@ void eepromFormat()
}
EeFsSetLink(BLOCKS-1, 0);
eeFs.freeList = FIRSTBLK;
#if defined(PCBTARANIS)
#if defined(CPUARM)
freeBlocks = BLOCKS;
#endif
EeFsFlush();
@@ -301,7 +299,12 @@ bool eepromOpen()
}
#endif
return eeFs.version == EEFS_VERS && eeFs.mySize == sizeof(eeFs);
if (eeFs.version != EEFS_VERS || eeFs.mySize != sizeof(eeFs)) {
return false;
}
eepromCheck();
return true;
}
bool EFile::exists(uint8_t i_fileId)
@@ -432,7 +435,7 @@ void RlcFile::nextWriteStep()
if (!m_currBlk && m_pos==0) {
eeFs.files[FILE_TMP].startBlk = m_currBlk = eeFs.freeList;
if (m_currBlk) {
#if defined(PCBTARANIS)
#if defined(CPUARM)
freeBlocks--;
#endif
eeFs.freeList = EeFsGetLink(m_currBlk);
@@ -471,7 +474,7 @@ void RlcFile::nextWriteStep()
switch (m_write_step & 0x0f) {
case WRITE_NEXT_LINK_1:
m_currBlk = eeFs.freeList;
#if defined(PCBTARANIS)
#if defined(CPUARM)
freeBlocks--;
#endif
eeFs.freeList = EeFsGetLink(eeFs.freeList);
@@ -801,12 +804,12 @@ void RlcFile::nextRlcWriteStep()
// TODO reuse EeFsFree!!!
blkid_t prev_freeList = eeFs.freeList;
eeFs.freeList = fri;
#if defined(PCBTARANIS)
#if defined(CPUARM)
freeBlocks++;
#endif
while (EeFsGetLink(fri)) {
fri = EeFsGetLink(fri);
#if defined(PCBTARANIS)
#if defined(CPUARM)
freeBlocks++;
#endif
}
-1
View File
@@ -116,7 +116,6 @@ extern EeFs eeFs;
#define BLOCKS_OFFSET (RESV-BS)
#endif
int8_t eepromCheck();
void eepromFormat();
uint16_t EeFsGetFree();