From a6b874b591c81a7610787e49ff79cb8908d31a42 Mon Sep 17 00:00:00 2001 From: Jason Short Date: Wed, 15 Aug 2012 14:26:09 -0700 Subject: [PATCH] DataFlash : Removed Chip Erase - relying on Block erase only --- libraries/DataFlash/DataFlash.cpp | 33 ++++++------------------------- 1 file changed, 6 insertions(+), 27 deletions(-) diff --git a/libraries/DataFlash/DataFlash.cpp b/libraries/DataFlash/DataFlash.cpp index c09b351f61..5e490b5734 100644 --- a/libraries/DataFlash/DataFlash.cpp +++ b/libraries/DataFlash/DataFlash.cpp @@ -64,7 +64,7 @@ void DataFlash_Class::WriteByte(uint8_t data) if (df_PageAdr>df_NumPages) // If we reach the end of the memory, stop here df_Stop_Write=1; } - + if (df_BufferNum==1) // Change buffer to continue writing... df_BufferNum=2; else @@ -141,7 +141,7 @@ uint8_t DataFlash_Class::ReadByte() { df_Read_PageAdr = 0; } - + // We are starting a new page - read FileNumber and FilePage df_FileNumber = BufferRead(df_Read_BufferNum,0); // High byte df_FileNumber = (df_FileNumber<<8) | BufferRead(df_Read_BufferNum,1); // Low byte @@ -189,31 +189,10 @@ uint16_t DataFlash_Class::GetFilePage() void DataFlash_Class::EraseAll(void (*delay_cb)(unsigned long)) { - // write a bad value to the last page - StartWrite(df_NumPages+1); - WriteLong(DF_LOGGING_FORMAT_INVALID); - BufferToPage(df_BufferNum,df_PageAdr,1); - - ChipErase(delay_cb); - SetFileNumber(0xFFFF); - - StartRead(0); - StartRead(df_NumPages+1); - int32_t format = ReadLong(); - -// if (format == DF_LOGGING_FORMAT_INVALID) -// the current method for checking if chip erase worked is producing false positives -// we are forcing the block erase until we have a deterministic test method - { - // the chip erase didn't work - fall back to a erasing - // each page separately. The errata on the APM2 dataflash chip - // suggests that chip erase won't always work - for(uint16_t j = 1; j <= (df_NumPages+1)/8; j++) { - BlockErase(j); - delay_cb(1); - } - } - + for(uint16_t j = 1; j <= (df_NumPages+1)/8; j++) { + BlockErase(j); + delay_cb(1); + } // write the logging format in the last page StartWrite(df_NumPages+1); WriteLong(DF_LOGGING_FORMAT);