34 lines
1014 B
C++
34 lines
1014 B
C++
#ifndef __SPI_H__
|
||
#define __SPI_H__
|
||
|
||
#include "Sys.h"
|
||
#include "Port.h"
|
||
|
||
// Flash类
|
||
class Flash
|
||
{
|
||
public:
|
||
bool WriteBlock(uint address, byte* buf, uint numBytes, bool fIncrementDataPtr = true);
|
||
// 擦除块 (段地址)
|
||
bool EraseBlock(uint address);
|
||
// 指定块是否被擦除
|
||
bool IsBlockErased(uint address, uint numBytes);
|
||
|
||
public:
|
||
uint Size; // 容量大小,字节
|
||
uint BytesPerBlock; // 每块字节数
|
||
uint StartAddress; // 起始地址
|
||
|
||
Flash();
|
||
|
||
// 擦除块。其实地址,字节数量默认0表示擦除全部
|
||
bool Erase(uint address = 0, uint numBytes = 0);
|
||
// 读取段数据 (起始段,字节数量,目标缓冲区)
|
||
bool Read(uint address, byte* buf, uint numBytes);
|
||
// 写入段数据 (起始段,段数量,目标缓冲区,读改写)
|
||
bool Write(uint address, byte* buf, uint numBytes, bool readModifyWrite = true);
|
||
bool Memset(uint address, byte data, uint numBytes);
|
||
};
|
||
|
||
#endif
|