KM3NeT CLB
2.0
KM3NeT CLB v2 Embedded Software
|
This driver implements access to the Serial Flash. More...
Go to the source code of this file.
Data Structures | |
struct | SfInfo |
Macros | |
#define | SF_MF_SPANSION 0x01 |
Manufacturer Spansion. | |
#define | SF_MF_MICRON 0x20 |
Manufacturer Micron. | |
#define | SF_DEV_MICRON_N25QA 0xBA |
#define | SF_DEV_SPANSION_S25FL 0x02 |
#define | E_SF_DEVNOTFOUND ( E_SFLASH + 1 ) |
#define | E_SF_DEVNOTFOUND_DESCR "Device not supported or no device found" |
#define | E_SF_WRITEERASE ( E_SFLASH + 2 ) |
#define | E_SF_WRITEERASE_DESCR "Flash write or erase error" |
#define | E_SF_PASSWORD ( E_SFLASH + 3 ) |
#define | E_SF_PASSWORD_DESCR "Password failed" |
#define | SF_INFO_CAP_PASSWORD 0x1 |
Device supports password protection. More... | |
#define | SF_INFO_CAP_SECTOR_PROTECT 0x2 |
Device support per sector protection. | |
#define | SF_INFO_STS_PASSWORD_PROTECT 0x1 |
Whether (part of) the flash is password. More... | |
#define | SF_INFO_STS_LOCKED 0x2 |
Whether part of the flash is locked. More... | |
Typedefs | |
typedef uint8_t | SfPassword [8] |
Serial Flash password. | |
Functions | |
bool | sfInit () |
Initializes the Serial Flash. More... | |
bool | sfReset () |
Resets the flash. More... | |
bool | sfRead (uint32_t address, uint8_t *data, uint32_t count) |
Read from a specific address in flash. More... | |
bool | sfProg (uint32_t address, uint8_t *data, uint32_t count) |
Program an page in flash. More... | |
bool | sfProgXPage (uint32_t address, uint8_t *data, uint32_t count) |
Program cross pages. More... | |
bool | sfErase (uint32_t address) |
Erase a sector in flash. More... | |
bool | sfQuadEnable (bool enable) |
Quad enable,. More... | |
bool | sfSetPasswordOTP (SfPassword *password) |
Password protects specific sectors from being modified. More... | |
bool | sfLockUnlock (SfPassword *password) |
Unlocks or locks the flash with the specified password. More... | |
bool | sfProtect (uint32_t address) |
Protects a specific sector from being erased or programmed. More... | |
bool | sfUnProtect () |
Unprotects the entire flash array. More... | |
void | sfSpDiag () |
Shows diagnostic state of Spansion Flash. | |
Variables | |
SfInfo | sfInfo |
Flash info, only valid after successful initialization. | |
This driver implements access to the Serial Flash.
Note that this interface is probably a standard, but I could not find it.
Definition in file sflash.h.
#define SF_INFO_CAP_PASSWORD 0x1 |
#define SF_INFO_STS_LOCKED 0x2 |
#define SF_INFO_STS_PASSWORD_PROTECT 0x1 |
bool sfErase | ( | uint32_t | address | ) |
Erase a sector in flash.
Erases a 'sfInfo.sectorSize'-sized sector in flash. Note that though a full 32 bit address is accepted, only the most significant bits will be used.
address | Offset address |
true | Flash read successfully. |
false | Some error occurred. Check error module for error. |
bool sfInit | ( | ) |
bool sfLockUnlock | ( | SfPassword * | password | ) |
bool sfProg | ( | uint32_t | address, |
uint8_t * | data, | ||
uint32_t | count | ||
) |
Program an page in flash.
Note that a maximum of 'sfInfo.pageSize' bytes can be programmed at once, and only per page. If programming continues over the page boundary it will continue at the beginning of the same page.
address | Offset address |
data | Data array to read up to 'count' bytes. |
count | No. of bytes to write. |
true | Flash read successfully. |
false | Some error occurred. Check error module for error. |
bool sfProgXPage | ( | uint32_t | address, |
uint8_t * | data, | ||
uint32_t | count | ||
) |
Program cross pages.
Unlike sfProg this function can write over page boundaries and multiple pages, e.g. it does not really matter where you start or end. There is a small performance penalty.
address | Offset address |
data | Data array to read up to 'count' bytes. |
count | No. of bytes to write. |
true | Flash read successfully. |
false | Some error occurred. Check error module for error. |
bool sfProtect | ( | uint32_t | address | ) |
Protects a specific sector from being erased or programmed.
address | First location of the sector to be protected. |
true | Command successful |
false | Command failed, check error module for error. |
bool sfQuadEnable | ( | bool | enable | ) |
bool sfRead | ( | uint32_t | address, |
uint8_t * | data, | ||
uint32_t | count | ||
) |
bool sfReset | ( | ) |
bool sfSetPasswordOTP | ( | SfPassword * | password | ) |
Password protects specific sectors from being modified.
Before setting the password you can select wich sectors need to be protected.
password | A poiner to the password. |
true | Command successful |
false | Command failed, check error module for error. |
bool sfUnProtect | ( | ) |
Unprotects the entire flash array.
true | Command successful |
false | Command failed, check error module for error. |