From 5410dff523caca939253e622a329df148b92f09d Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 7 Nov 2011 22:21:29 +1100 Subject: [PATCH] DataFlash: use CPU independent data types this ensures that the DataFlash API is consistent for different CPU architectures, which matters for the Desktop build, and will matter for ARM and other CPUs later --- libraries/DataFlash/DataFlash.cpp | 1 + libraries/DataFlash/DataFlash.h | 40 +++++++++++++++---------------- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/libraries/DataFlash/DataFlash.cpp b/libraries/DataFlash/DataFlash.cpp index 30c5174227..82a3ed5b5c 100644 --- a/libraries/DataFlash/DataFlash.cpp +++ b/libraries/DataFlash/DataFlash.cpp @@ -31,6 +31,7 @@ */ +#include #include "DataFlash.h" #include diff --git a/libraries/DataFlash/DataFlash.h b/libraries/DataFlash/DataFlash.h index 0185aa8d9b..4cf4eb3cf9 100644 --- a/libraries/DataFlash/DataFlash.h +++ b/libraries/DataFlash/DataFlash.h @@ -44,49 +44,49 @@ class DataFlash_Class // DataFlash Log variables... unsigned char df_BufferNum; unsigned char df_Read_BufferNum; - unsigned int df_BufferIdx; - unsigned int df_Read_BufferIdx; - unsigned int df_PageAdr; - unsigned int df_Read_PageAdr; + uint16_t df_BufferIdx; + uint16_t df_Read_BufferIdx; + uint16_t df_PageAdr; + uint16_t df_Read_PageAdr; unsigned char df_Read_END; unsigned char df_Stop_Write; //Methods - unsigned char BufferRead (unsigned char BufferNum, unsigned int IntPageAdr); - void BufferWrite (unsigned char BufferNum, unsigned int IntPageAdr, unsigned char Data); - void BufferToPage (unsigned char BufferNum, unsigned int PageAdr, unsigned char wait); - void PageToBuffer(unsigned char BufferNum, unsigned int PageAdr); + unsigned char BufferRead (unsigned char BufferNum, uint16_t IntPageAdr); + void BufferWrite (unsigned char BufferNum, uint16_t IntPageAdr, unsigned char Data); + void BufferToPage (unsigned char BufferNum, uint16_t PageAdr, unsigned char wait); + void PageToBuffer(unsigned char BufferNum, uint16_t PageAdr); void WaitReady(); unsigned char ReadStatusReg(); unsigned char ReadStatus(); - unsigned int PageSize(); + uint16_t PageSize(); public: unsigned char df_manufacturer; unsigned char df_device_0; unsigned char df_device_1; - unsigned int df_PageSize; + uint16_t df_PageSize; DataFlash_Class(); // Constructor void Init(); void ReadManufacturerID(); - int GetPage(); - int GetWritePage(); - void PageErase (unsigned int PageAdr); + int16_t GetPage(); + int16_t GetWritePage(); + void PageErase (uint16_t PageAdr); void ChipErase (); // Write methods - void StartWrite(int PageAdr); + void StartWrite(int16_t PageAdr); void FinishWrite(); void WriteByte(unsigned char data); - void WriteInt(int data); - void WriteLong(long data); + void WriteInt(int16_t data); + void WriteLong(int32_t data); // Read methods - void StartRead(int PageAdr); + void StartRead(int16_t PageAdr); unsigned char ReadByte(); - int ReadInt(); - long ReadLong(); + int16_t ReadInt(); + int32_t ReadLong(); }; extern DataFlash_Class DataFlash; -#endif \ No newline at end of file +#endif