SmartOS/Flash.h

34 lines
1014 B
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#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