diff --git a/libraries/DataFlash/DataFlash.cpp b/libraries/DataFlash/DataFlash.cpp index 3ca6d4ea3e..a18dcb3e17 100644 --- a/libraries/DataFlash/DataFlash.cpp +++ b/libraries/DataFlash/DataFlash.cpp @@ -231,6 +231,29 @@ void DataFlash_Class::StartWrite(int PageAdr) WaitReady(); } +void DataFlash_Class::FinishWrite(void) +{ + df_BufferIdx=0; + BufferToPage(df_BufferNum,df_PageAdr,0); // Write Buffer to memory, NO WAIT + df_PageAdr++; + if (OVERWRITE_DATA==1) + { + if (df_PageAdr>=4096) // If we reach the end of the memory, start from the begining + df_PageAdr = 1; + } + else + { + if (df_PageAdr>=4096) // 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 + df_BufferNum=1; +} + + void DataFlash_Class::WriteByte(byte data) { if (!df_Stop_Write) diff --git a/libraries/DataFlash/DataFlash.h b/libraries/DataFlash/DataFlash.h index b55efb93e7..fee3149263 100644 --- a/libraries/DataFlash/DataFlash.h +++ b/libraries/DataFlash/DataFlash.h @@ -71,6 +71,7 @@ class DataFlash_Class void PageErase (unsigned int PageAdr); // Write methods void StartWrite(int PageAdr); + void FinishWrite(); void WriteByte(unsigned char data); void WriteInt(int data); void WriteLong(long data);