DataFlash: use ChipErase() instead of PageErase() on all pages

This makes the DataFlash erase much faster (about 6 seconds instead of
about 60 seconds).

We need to test and ensure the behaviour is equivalent apart from the
speed
This commit is contained in:
Andrew Tridgell 2012-05-22 16:35:53 +10:00 committed by Craig Elder
parent 4e4ff84cf1
commit fc73fd6531
6 changed files with 14 additions and 14 deletions

View File

@ -188,13 +188,8 @@ uint16_t DataFlash_Class::GetFilePage()
void DataFlash_Class::EraseAll(void (*delay_cb)(unsigned long))
{
ChipErase(delay_cb);
SetFileNumber(0xFFFF);
for(uint16_t j = 1; j <= df_NumPages; j++) {
PageErase(j);
StartWrite(j);
delay_cb(1);
}
// write the logging format in the last page
StartWrite(df_NumPages+1);
WriteLong(DF_LOGGING_FORMAT);

View File

@ -32,7 +32,7 @@ class DataFlash_Class
virtual void PageToBuffer(unsigned char BufferNum, uint16_t PageAdr) = 0;
virtual unsigned char BufferRead (unsigned char BufferNum, uint16_t IntPageAdr) = 0;
virtual void PageErase(uint16_t PageAdr) = 0;
virtual void ChipErase(void) = 0;
virtual void ChipErase(void (*delay_cb)(unsigned long)) = 0;
// internal high level functions
int find_last_page(void);

View File

@ -294,7 +294,7 @@ void DataFlash_APM1::PageErase (uint16_t PageAdr)
}
void DataFlash_APM1::ChipErase ()
void DataFlash_APM1::ChipErase(void (*delay_cb)(unsigned long))
{
dataflash_CS_active(); // activate dataflash command decoder
@ -306,7 +306,9 @@ void DataFlash_APM1::ChipErase ()
dataflash_CS_inactive(); //initiate flash page erase
dataflash_CS_active();
while(!ReadStatus());
while (!ReadStatus()) {
delay_cb(1);
}
dataflash_CS_inactive(); // deactivate dataflash command decoder
}

View File

@ -19,7 +19,7 @@ class DataFlash_APM1 : public DataFlash_Class
unsigned char ReadStatus();
uint16_t PageSize();
void PageErase (uint16_t PageAdr);
void ChipErase ();
void ChipErase(void (*delay_cb)(unsigned long));
public:

View File

@ -350,7 +350,7 @@ void DataFlash_APM2::PageErase (uint16_t PageAdr)
}
void DataFlash_APM2::ChipErase ()
void DataFlash_APM2::ChipErase(void (*delay_cb)(unsigned long))
{
// activate dataflash command decoder
CS_active();
@ -364,8 +364,11 @@ void DataFlash_APM2::ChipErase ()
//initiate flash page erase
CS_inactive();
CS_active();
while(!ReadStatus());
while(!ReadStatus()) {
delay_cb(1);
}
// release SPI bus for use by other sensors
CS_inactive();
}
}

View File

@ -23,7 +23,7 @@ class DataFlash_APM2 : public DataFlash_Class
void CS_inactive();
void CS_active();
void PageErase (uint16_t PageAdr);
void ChipErase ();
void ChipErase(void (*delay_cb)(unsigned long));
public:
DataFlash_APM2(); // Constructor