BIOS Reference - FLASH Functions
From NanoComputerWiki
FLASH Module Functions
NanoComputer BIOS Reference
FLASH Module
Note: This information may be out of date. For the latest information always check the header files shipped with the NanoComputer SDK.
Last update: Oct 31 2008
// --------------------------------------------------
// Defines
// --------------------------------------------------
#define E_FLASH_TIMEOUT -100
#define FLASH_PAGE_FULLPAGE 0x0000
#define FLASH_PAGE_SUBAREA_0 0x0000
#define FLASH_PAGE_SUBAREA_1 0x0200
#define FLASH_PAGE_SUBAREA_2 0x0400
#define FLASH_PAGE_SUBAREA_3 0x0600
#define FLASH_PAGE_EXTRA_SUBAREA_0 0x0800
#define FLASH_PAGE_EXTRA_SUBAREA_1 0x0840
#define FLASH_PAGE_EXTRA_SUBAREA_2 0x0880
#define FLASH_PAGE_EXTRA_SUBAREA_3 0x08C0
// --------------------------------------------------
// Structures & Typedefs
// --------------------------------------------------
struct _FLASH_Info {
unsigned short PageSize;
unsigned short PageSubSize;
unsigned short PageExtraSize;
unsigned short PageExtraSubSize;
unsigned short PagesPerBlock;
unsigned long Blocks;
};
typedef struct _FLASH_Info FLASH_Info;
// --------------------------------------------------
// Function Prototypes
// --------------------------------------------------
/**
* Erases a block in the FLASH
*
* BlockNumber - [in] Index of the block to erase
*
* Returns E_OK on success, other error on failure.
**/
char FLASH_EraseBlock(unsigned long BlockNumber);
/**
* Retrieves information about the FLASH storage
*
* pInfo - [out] FLASH_Info structure which will be filled in with information about the FLASH storage.
*
* Returns E_OK on success, other error on failure.
**/
char FLASH_GetInfo(FLASH_Info* pInfo);
/**
* Reads data from FLASH and places the data into a buffer.
*
* PageOffset - [in] Position in the page to begin reading
* PageNumber - [in] Index of the page inside the block to read
* BlockNumber - [in] Index of the block to read from
* Size - [in] The number of bytes to read
* pBuf - [out] Buffer to place read bytes into
*
* Returns E_OK on success, other error on failure.
**/
char FLASH_ReadPage(unsigned short PageOffset, unsigned short PageNumber, unsigned long BlockNumber, unsigned short Size, unsigned char *buf);
/**
* Sets up a page in FLASH to be written. After setup, data is fed into the write buffer using FLASH_WritePage_Data
*
* PageSubArea - [in] Sub area of the page to write to, or FLASH_PAGE_FULLPAGE to write full page
* PageNumber - [in] Index of the page inside the block to write to
* BlockNumber - [in] Index of the block to write to
*
* Returns E_OK on success, other error on failure.
**/
char FLASH_WritePage_Setup(unsigned short PageSubArea, unsigned short PageNumber, unsigned long BlockNumber);
/**
* Fills the page write buffer with data. This can be called many times to fill in the page sequentially.
*
* Size - [in] The number of bytes to send to the FLASH write buffer
* pBuf - [in] Buffer containing data to send to the FLASH write buffer
*
* Returns E_OK on success, other error on failure.
**/
char FLASH_WritePage_Data(unsigned char* pBuf, unsigned short BufSize);
/**
* Commits the data in the FLASH write buffer to the FLASH page
*
* Returns E_OK on success, other error on failure.
**/
char FLASH_WritePage_Commit(void);
Navigation
- Click on any of the links below to navigate to a new page
