Serial flash memory, binary access
Dependents: S25FL216K_USBFileSystem SPItest S25FL216K_USBFileSystem S25FL216K_FATFileSystem
S25FL216K.h@0:3cb41d985302, 2013-07-20 (annotated)
- Committer:
- Sissors
- Date:
- Sat Jul 20 12:03:38 2013 +0000
- Revision:
- 0:3cb41d985302
- Child:
- 1:2bcefc9e64f8
Basic functionality
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Sissors | 0:3cb41d985302 | 1 | #ifndef S25FL216K_H |
Sissors | 0:3cb41d985302 | 2 | #define S25FL216K_H |
Sissors | 0:3cb41d985302 | 3 | |
Sissors | 0:3cb41d985302 | 4 | #include "mbed.h" |
Sissors | 0:3cb41d985302 | 5 | |
Sissors | 0:3cb41d985302 | 6 | #define S25FL_WRITE_STATUS 0x01 |
Sissors | 0:3cb41d985302 | 7 | #define S25FL216K_WRITE 0x02 |
Sissors | 0:3cb41d985302 | 8 | #define S25FL216K_READ 0x03 |
Sissors | 0:3cb41d985302 | 9 | #define S25FL216K_RDSR 0x05 |
Sissors | 0:3cb41d985302 | 10 | #define S25FL216K_WREN 0x06 |
Sissors | 0:3cb41d985302 | 11 | #define S25FL216K_SECTOR_ERASE 0x20 |
Sissors | 0:3cb41d985302 | 12 | #define S25FL216K_CHIP_ERASE 0xC7 |
Sissors | 0:3cb41d985302 | 13 | #define S25FL216K_BLOCK_ERASE 0xD8 |
Sissors | 0:3cb41d985302 | 14 | #define S25FL216K_JEDEC 0x9F |
Sissors | 0:3cb41d985302 | 15 | |
Sissors | 0:3cb41d985302 | 16 | class S25FL216K { |
Sissors | 0:3cb41d985302 | 17 | public: |
Sissors | 0:3cb41d985302 | 18 | S25FL216K(PinName mosi, PinName miso, PinName sclk, PinName cs); |
Sissors | 0:3cb41d985302 | 19 | |
Sissors | 0:3cb41d985302 | 20 | /* Checks if communication with the device functions |
Sissors | 0:3cb41d985302 | 21 | * |
Sissors | 0:3cb41d985302 | 22 | * @return - true upon succesfull communication, false if it failed |
Sissors | 0:3cb41d985302 | 23 | */ |
Sissors | 0:3cb41d985302 | 24 | bool testConnection( void ); |
Sissors | 0:3cb41d985302 | 25 | |
Sissors | 0:3cb41d985302 | 26 | void read(int address, char *buffer, int length); |
Sissors | 0:3cb41d985302 | 27 | |
Sissors | 0:3cb41d985302 | 28 | void write(int address, char *buffer, int length, bool block = true); |
Sissors | 0:3cb41d985302 | 29 | |
Sissors | 0:3cb41d985302 | 30 | void eraseSector(int address, bool block = true); |
Sissors | 0:3cb41d985302 | 31 | void eraseBlock(int address, bool block = true); |
Sissors | 0:3cb41d985302 | 32 | void eraseChip(bool block = true); |
Sissors | 0:3cb41d985302 | 33 | |
Sissors | 0:3cb41d985302 | 34 | char getStatus( void ); |
Sissors | 0:3cb41d985302 | 35 | |
Sissors | 0:3cb41d985302 | 36 | void setWriteEnable( void ); |
Sissors | 0:3cb41d985302 | 37 | |
Sissors | 0:3cb41d985302 | 38 | bool isBusy( void ); |
Sissors | 0:3cb41d985302 | 39 | |
Sissors | 0:3cb41d985302 | 40 | private: |
Sissors | 0:3cb41d985302 | 41 | SPI _spi; |
Sissors | 0:3cb41d985302 | 42 | DigitalOut _cs; |
Sissors | 0:3cb41d985302 | 43 | |
Sissors | 0:3cb41d985302 | 44 | |
Sissors | 0:3cb41d985302 | 45 | |
Sissors | 0:3cb41d985302 | 46 | |
Sissors | 0:3cb41d985302 | 47 | |
Sissors | 0:3cb41d985302 | 48 | }; |
Sissors | 0:3cb41d985302 | 49 | |
Sissors | 0:3cb41d985302 | 50 | |
Sissors | 0:3cb41d985302 | 51 | |
Sissors | 0:3cb41d985302 | 52 | #endif |