From 927c2dbd67d50b115d47db22e5e70c9af68cdce1 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 18 Nov 2011 17:50:03 +1100 Subject: [PATCH] desktop: added support for new DataFlash functions --- libraries/Desktop/support/DataFlash.cpp | 27 +++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/libraries/Desktop/support/DataFlash.cpp b/libraries/Desktop/support/DataFlash.cpp index 80ddd52bb1..798b8e9e1b 100644 --- a/libraries/Desktop/support/DataFlash.cpp +++ b/libraries/Desktop/support/DataFlash.cpp @@ -123,6 +123,11 @@ void DataFlash_Class::StartWrite(int16_t PageAdr) df_BufferIdx = 0; df_PageAdr = PageAdr; df_Stop_Write = 0; + + BufferWrite(df_BufferNum,0,df_FileNumber>>8); // High byte + BufferWrite(df_BufferNum,1,df_FileNumber&0xFF); // Low byte + BufferWrite(df_BufferNum,2,df_FilePage>>8); // High byte + BufferWrite(df_BufferNum,3,df_FilePage&0xFF); // Low byte } void DataFlash_Class::FinishWrite(void) @@ -145,6 +150,12 @@ void DataFlash_Class::FinishWrite(void) df_BufferNum=2; else df_BufferNum=1; + + BufferWrite(df_BufferNum,0,df_FileNumber>>8); // High byte + BufferWrite(df_BufferNum,1,df_FileNumber&0xFF); // Low byte + df_FilePage++; + BufferWrite(df_BufferNum,2,df_FilePage>>8); // High byte + BufferWrite(df_BufferNum,3,df_FilePage&0xFF); // Low byte } @@ -255,5 +266,21 @@ int32_t DataFlash_Class::ReadLong() return (int32_t)result; } +void DataFlash_Class::SetFileNumber(uint16_t FileNumber) +{ + df_FileNumber = FileNumber; + df_FilePage = 1; +} + +uint16_t DataFlash_Class::GetFileNumber() +{ + return df_FileNumber; +} + +uint16_t DataFlash_Class::GetFilePage() +{ + return df_FilePage; +} + // make one instance for the user to use DataFlash_Class DataFlash;