eepromCheck called inside eepromOpen
This commit is contained in:
@@ -84,8 +84,7 @@ void eeLoadModelHeaders()
|
|||||||
|
|
||||||
void eeReadAll()
|
void eeReadAll()
|
||||||
{
|
{
|
||||||
// TODO merge eepromOpen and eepromCheck
|
if (!eepromOpen() || !eeLoadGeneral()) {
|
||||||
if (!eepromOpen() || eepromCheck() < 0 || !eeLoadGeneral()) {
|
|
||||||
eeErase(true);
|
eeErase(true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -195,11 +195,6 @@ bool eepromOpen()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool eepromCheck()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t readFile(int index, uint8_t * data, uint32_t size)
|
uint32_t readFile(int index, uint8_t * data, uint32_t size)
|
||||||
{
|
{
|
||||||
uint16_t fileSize;
|
uint16_t fileSize;
|
||||||
|
|||||||
@@ -79,6 +79,5 @@ extern EepromWriteState eepromWriteState;
|
|||||||
void eepromWriteProcess();
|
void eepromWriteProcess();
|
||||||
void eepromWriteWait(EepromWriteState state = EEPROM_IDLE);
|
void eepromWriteWait(EepromWriteState state = EEPROM_IDLE);
|
||||||
bool eepromOpen();
|
bool eepromOpen();
|
||||||
bool eepromCheck();
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+19
-16
@@ -187,13 +187,13 @@ static void EeFsFree(blkid_t blk)
|
|||||||
blkid_t i = blk;
|
blkid_t i = blk;
|
||||||
blkid_t tmp;
|
blkid_t tmp;
|
||||||
|
|
||||||
#if defined(PCBTARANIS)
|
#if defined(CPUARM)
|
||||||
freeBlocks++;
|
freeBlocks++;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
while ((tmp=EeFsGetLink(i))) {
|
while ((tmp=EeFsGetLink(i))) {
|
||||||
i = tmp;
|
i = tmp;
|
||||||
#if defined(PCBTARANIS)
|
#if defined(CPUARM)
|
||||||
freeBlocks++;
|
freeBlocks++;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -203,7 +203,7 @@ static void EeFsFree(blkid_t blk)
|
|||||||
EeFsFlushFreelist();
|
EeFsFlushFreelist();
|
||||||
}
|
}
|
||||||
|
|
||||||
int8_t eepromCheck()
|
void eepromCheck()
|
||||||
{
|
{
|
||||||
ENABLE_SYNC_WRITE(true);
|
ENABLE_SYNC_WRITE(true);
|
||||||
|
|
||||||
@@ -211,11 +211,11 @@ int8_t eepromCheck()
|
|||||||
memclear(bufp, BLOCKS);
|
memclear(bufp, BLOCKS);
|
||||||
blkid_t blk ;
|
blkid_t blk ;
|
||||||
|
|
||||||
#if defined(PCBTARANIS)
|
#if defined(CPUARM)
|
||||||
blkid_t blocksCount;
|
blkid_t blocksCount;
|
||||||
#endif
|
#endif
|
||||||
for (uint8_t i=0; i<=MAXFILES; i++) {
|
for (uint8_t i=0; i<=MAXFILES; i++) {
|
||||||
#if defined(PCBTARANIS)
|
#if defined(CPUARM)
|
||||||
blocksCount = 0;
|
blocksCount = 0;
|
||||||
#endif
|
#endif
|
||||||
blkid_t *startP = (i==MAXFILES ? &eeFs.freeList : &eeFs.files[i].startBlk);
|
blkid_t *startP = (i==MAXFILES ? &eeFs.freeList : &eeFs.files[i].startBlk);
|
||||||
@@ -236,7 +236,7 @@ int8_t eepromCheck()
|
|||||||
blk = 0; // abort
|
blk = 0; // abort
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
#if defined(PCBTARANIS)
|
#if defined(CPUARM)
|
||||||
blocksCount++;
|
blocksCount++;
|
||||||
#endif
|
#endif
|
||||||
bufp[blk] = i+1;
|
bufp[blk] = i+1;
|
||||||
@@ -246,13 +246,13 @@ int8_t eepromCheck()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(PCBTARANIS)
|
#if defined(CPUARM)
|
||||||
freeBlocks = blocksCount;
|
freeBlocks = blocksCount;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (blk=FIRSTBLK; blk<BLOCKS; blk++) {
|
for (blk=FIRSTBLK; blk<BLOCKS; blk++) {
|
||||||
if (!bufp[blk]) { // unused block
|
if (!bufp[blk]) { // unused block
|
||||||
#if defined(PCBTARANIS)
|
#if defined(CPUARM)
|
||||||
freeBlocks++;
|
freeBlocks++;
|
||||||
#endif
|
#endif
|
||||||
EeFsSetLink(blk, eeFs.freeList);
|
EeFsSetLink(blk, eeFs.freeList);
|
||||||
@@ -262,8 +262,6 @@ int8_t eepromCheck()
|
|||||||
}
|
}
|
||||||
|
|
||||||
ENABLE_SYNC_WRITE(false);
|
ENABLE_SYNC_WRITE(false);
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void eepromFormat()
|
void eepromFormat()
|
||||||
@@ -280,7 +278,7 @@ void eepromFormat()
|
|||||||
}
|
}
|
||||||
EeFsSetLink(BLOCKS-1, 0);
|
EeFsSetLink(BLOCKS-1, 0);
|
||||||
eeFs.freeList = FIRSTBLK;
|
eeFs.freeList = FIRSTBLK;
|
||||||
#if defined(PCBTARANIS)
|
#if defined(CPUARM)
|
||||||
freeBlocks = BLOCKS;
|
freeBlocks = BLOCKS;
|
||||||
#endif
|
#endif
|
||||||
EeFsFlush();
|
EeFsFlush();
|
||||||
@@ -301,7 +299,12 @@ bool eepromOpen()
|
|||||||
}
|
}
|
||||||
#endif
|
#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)
|
bool EFile::exists(uint8_t i_fileId)
|
||||||
@@ -432,7 +435,7 @@ void RlcFile::nextWriteStep()
|
|||||||
if (!m_currBlk && m_pos==0) {
|
if (!m_currBlk && m_pos==0) {
|
||||||
eeFs.files[FILE_TMP].startBlk = m_currBlk = eeFs.freeList;
|
eeFs.files[FILE_TMP].startBlk = m_currBlk = eeFs.freeList;
|
||||||
if (m_currBlk) {
|
if (m_currBlk) {
|
||||||
#if defined(PCBTARANIS)
|
#if defined(CPUARM)
|
||||||
freeBlocks--;
|
freeBlocks--;
|
||||||
#endif
|
#endif
|
||||||
eeFs.freeList = EeFsGetLink(m_currBlk);
|
eeFs.freeList = EeFsGetLink(m_currBlk);
|
||||||
@@ -471,7 +474,7 @@ void RlcFile::nextWriteStep()
|
|||||||
switch (m_write_step & 0x0f) {
|
switch (m_write_step & 0x0f) {
|
||||||
case WRITE_NEXT_LINK_1:
|
case WRITE_NEXT_LINK_1:
|
||||||
m_currBlk = eeFs.freeList;
|
m_currBlk = eeFs.freeList;
|
||||||
#if defined(PCBTARANIS)
|
#if defined(CPUARM)
|
||||||
freeBlocks--;
|
freeBlocks--;
|
||||||
#endif
|
#endif
|
||||||
eeFs.freeList = EeFsGetLink(eeFs.freeList);
|
eeFs.freeList = EeFsGetLink(eeFs.freeList);
|
||||||
@@ -801,12 +804,12 @@ void RlcFile::nextRlcWriteStep()
|
|||||||
// TODO reuse EeFsFree!!!
|
// TODO reuse EeFsFree!!!
|
||||||
blkid_t prev_freeList = eeFs.freeList;
|
blkid_t prev_freeList = eeFs.freeList;
|
||||||
eeFs.freeList = fri;
|
eeFs.freeList = fri;
|
||||||
#if defined(PCBTARANIS)
|
#if defined(CPUARM)
|
||||||
freeBlocks++;
|
freeBlocks++;
|
||||||
#endif
|
#endif
|
||||||
while (EeFsGetLink(fri)) {
|
while (EeFsGetLink(fri)) {
|
||||||
fri = EeFsGetLink(fri);
|
fri = EeFsGetLink(fri);
|
||||||
#if defined(PCBTARANIS)
|
#if defined(CPUARM)
|
||||||
freeBlocks++;
|
freeBlocks++;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -116,7 +116,6 @@ extern EeFs eeFs;
|
|||||||
#define BLOCKS_OFFSET (RESV-BS)
|
#define BLOCKS_OFFSET (RESV-BS)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int8_t eepromCheck();
|
|
||||||
void eepromFormat();
|
void eepromFormat();
|
||||||
uint16_t EeFsGetFree();
|
uint16_t EeFsGetFree();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user