Serial flash memory, binary access
Dependents: S25FL216K_USBFileSystem SPItest S25FL216K_USBFileSystem S25FL216K_FATFileSystem
Diff: S25FL216K.h
- Revision:
- 0:3cb41d985302
- Child:
- 1:2bcefc9e64f8
diff -r 000000000000 -r 3cb41d985302 S25FL216K.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/S25FL216K.h Sat Jul 20 12:03:38 2013 +0000 @@ -0,0 +1,52 @@ +#ifndef S25FL216K_H +#define S25FL216K_H + +#include "mbed.h" + +#define S25FL_WRITE_STATUS 0x01 +#define S25FL216K_WRITE 0x02 +#define S25FL216K_READ 0x03 +#define S25FL216K_RDSR 0x05 +#define S25FL216K_WREN 0x06 +#define S25FL216K_SECTOR_ERASE 0x20 +#define S25FL216K_CHIP_ERASE 0xC7 +#define S25FL216K_BLOCK_ERASE 0xD8 +#define S25FL216K_JEDEC 0x9F + +class S25FL216K { +public: +S25FL216K(PinName mosi, PinName miso, PinName sclk, PinName cs); + +/* Checks if communication with the device functions +* +* @return - true upon succesfull communication, false if it failed +*/ +bool testConnection( void ); + +void read(int address, char *buffer, int length); + +void write(int address, char *buffer, int length, bool block = true); + +void eraseSector(int address, bool block = true); +void eraseBlock(int address, bool block = true); +void eraseChip(bool block = true); + +char getStatus( void ); + +void setWriteEnable( void ); + +bool isBusy( void ); + +private: +SPI _spi; +DigitalOut _cs; + + + + + +}; + + + +#endif \ No newline at end of file