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
This commit is contained in:
Andrew Tridgell 2011-11-07 22:21:29 +11:00
parent 94f0e8a4a3
commit cfe058c5d5
2 changed files with 21 additions and 20 deletions

View File

@ -31,6 +31,7 @@
*/ */
#include <stdint.h>
#include "DataFlash.h" #include "DataFlash.h"
#include <SPI.h> #include <SPI.h>

View File

@ -44,49 +44,49 @@ class DataFlash_Class
// DataFlash Log variables... // DataFlash Log variables...
unsigned char df_BufferNum; unsigned char df_BufferNum;
unsigned char df_Read_BufferNum; unsigned char df_Read_BufferNum;
unsigned int df_BufferIdx; uint16_t df_BufferIdx;
unsigned int df_Read_BufferIdx; uint16_t df_Read_BufferIdx;
unsigned int df_PageAdr; uint16_t df_PageAdr;
unsigned int df_Read_PageAdr; uint16_t df_Read_PageAdr;
unsigned char df_Read_END; unsigned char df_Read_END;
unsigned char df_Stop_Write; unsigned char df_Stop_Write;
//Methods //Methods
unsigned char BufferRead (unsigned char BufferNum, unsigned int IntPageAdr); unsigned char BufferRead (unsigned char BufferNum, uint16_t IntPageAdr);
void BufferWrite (unsigned char BufferNum, unsigned int IntPageAdr, unsigned char Data); void BufferWrite (unsigned char BufferNum, uint16_t IntPageAdr, unsigned char Data);
void BufferToPage (unsigned char BufferNum, unsigned int PageAdr, unsigned char wait); void BufferToPage (unsigned char BufferNum, uint16_t PageAdr, unsigned char wait);
void PageToBuffer(unsigned char BufferNum, unsigned int PageAdr); void PageToBuffer(unsigned char BufferNum, uint16_t PageAdr);
void WaitReady(); void WaitReady();
unsigned char ReadStatusReg(); unsigned char ReadStatusReg();
unsigned char ReadStatus(); unsigned char ReadStatus();
unsigned int PageSize(); uint16_t PageSize();
public: public:
unsigned char df_manufacturer; unsigned char df_manufacturer;
unsigned char df_device_0; unsigned char df_device_0;
unsigned char df_device_1; unsigned char df_device_1;
unsigned int df_PageSize; uint16_t df_PageSize;
DataFlash_Class(); // Constructor DataFlash_Class(); // Constructor
void Init(); void Init();
void ReadManufacturerID(); void ReadManufacturerID();
int GetPage(); int16_t GetPage();
int GetWritePage(); int16_t GetWritePage();
void PageErase (unsigned int PageAdr); void PageErase (uint16_t PageAdr);
void ChipErase (); void ChipErase ();
// Write methods // Write methods
void StartWrite(int PageAdr); void StartWrite(int16_t PageAdr);
void FinishWrite(); void FinishWrite();
void WriteByte(unsigned char data); void WriteByte(unsigned char data);
void WriteInt(int data); void WriteInt(int16_t data);
void WriteLong(long data); void WriteLong(int32_t data);
// Read methods // Read methods
void StartRead(int PageAdr); void StartRead(int16_t PageAdr);
unsigned char ReadByte(); unsigned char ReadByte();
int ReadInt(); int16_t ReadInt();
long ReadLong(); int32_t ReadLong();
}; };
extern DataFlash_Class DataFlash; extern DataFlash_Class DataFlash;
#endif #endif