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 b314fd8cd3
commit 5410dff523
2 changed files with 21 additions and 20 deletions

View File

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

View File

@ -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
#endif