Serial flash memory, binary access
Dependents: S25FL216K_USBFileSystem SPItest S25FL216K_USBFileSystem S25FL216K_FATFileSystem
Revision 1:2bcefc9e64f8, committed 2013-07-31
- Comitter:
- Sissors
- Date:
- Wed Jul 31 19:17:11 2013 +0000
- Parent:
- 0:3cb41d985302
- Commit message:
- v1.0
Changed in this revision
S25FL216K.cpp | Show annotated file Show diff for this revision Revisions of this file |
S25FL216K.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 3cb41d985302 -r 2bcefc9e64f8 S25FL216K.cpp --- a/S25FL216K.cpp Sat Jul 20 12:03:38 2013 +0000 +++ b/S25FL216K.cpp Wed Jul 31 19:17:11 2013 +0000 @@ -30,7 +30,6 @@ _spi.write(address>>16); _spi.write(address>>8); _spi.write(address); - for (int i = 0; i<length; i++) buffer[i]=_spi.write(0x00);
diff -r 3cb41d985302 -r 2bcefc9e64f8 S25FL216K.h --- a/S25FL216K.h Sat Jul 20 12:03:38 2013 +0000 +++ b/S25FL216K.h Wed Jul 31 19:17:11 2013 +0000 @@ -13,31 +13,85 @@ #define S25FL216K_BLOCK_ERASE 0xD8 #define S25FL216K_JEDEC 0x9F +/** +* Class to write/read from S25FL216K serial flash memory +* +* This class is used for binary access, for file system access +* there is S25FL216K_USBFileSystem. +* +* No write restrictions are implemented, the memory also should not +* have write restrictions enabled, this is factory default. +*/ class S25FL216K { public: + +/** Constructor +* +* @param mosi - Mosi pin to be used +* @param miso - Miso pin to be used +* @param sclk - Sclk pin to be used +* @param cs - CS pin to be used +*/ S25FL216K(PinName mosi, PinName miso, PinName sclk, PinName cs); -/* Checks if communication with the device functions +/** Checks if communication with the device functions * * @return - true upon succesfull communication, false if it failed */ bool testConnection( void ); +/** Read a number of memory locations +* +* Take into account reading will stay within the page (256B) the address is in +* +* @param address - start address to read from +* @param buffer - char array to read the data into +* @param length - number of samples to read +*/ void read(int address, char *buffer, int length); +/** Write a number of memory locations +* +* Take into account writing will stay within the page (256B) the address is in +* +* @param address - start address to write to +* @param buffer - char array to read the data from +* @param length - number of samples to write +* @param block - true (default) to block until writing is finished +*/ void write(int address, char *buffer, int length, bool block = true); +/** Erase a sector (4KB) +* +* @param address - address in the sector that needs to be erased +* @param block - true (default) to block until erasing is finished +*/ void eraseSector(int address, bool block = true); + +/** Erase a block (64KB) +* +* @param address - address in the block that needs to be erased +* @param block - true (default) to block until erasing is finished +*/ void eraseBlock(int address, bool block = true); + +/** Erase the entire chip +* +* @param block - true (default) to block until erasing is finished +*/ void eraseChip(bool block = true); -char getStatus( void ); - -void setWriteEnable( void ); - +/** Check if writing/erasing is being performed +* +* @return - true if busy, false if idle +*/ bool isBusy( void ); private: + +char getStatus( void ); +void setWriteEnable( void ); + SPI _spi; DigitalOut _cs;