From 343c6565db59c2255949903464af56f57dd4c3a6 Mon Sep 17 00:00:00 2001 From: "deweibel@gmail.com" Date: Sun, 30 Jan 2011 01:53:04 +0000 Subject: [PATCH] Add FinishWrite method to the DataFlash class to support using an index system. git-svn-id: https://arducopter.googlecode.com/svn/trunk@1575 f9c3cf11-9bcb-44bc-f272-b75c42450872 --- libraries/DataFlash/DataFlash.cpp | 23 +++++++++++++++++++++++ libraries/DataFlash/DataFlash.h | 1 + 2 files changed, 24 insertions(+) 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);