2.11 Flash Driver
Overview
The Flash Driver helps the users to generate the Flash driver code. It provides the users easy to use Flash read, write and erase API's along with the required helper functions.
2.11.1 Module Documentation
2.11.1.1 Flash Driver
FLASH Driver using dsPIC MCUs.
2.11.1.1.1 Module description
FLASH Driver using dsPIC MCUs.
Data structures
struct FLASH_INTERFACE
Structure containing the function pointers of FLASH driver.
Definitions
#define FLASH_PC_UNIT_SIZE 2U
Defines FLASH Flash PC unit size.
#define FLASH_UNLOCK_KEY 0x00AA0055
Defines FLASH unlock key value.
#define FLASH_WRITE_ROW_SIZE_IN_INSTRUCTIONS 128U
Defines FLASH write row size in instruction counts.
#define FLASH_WRITE_ROW_SIZE_IN_PC_UNITS (FLASH_WRITE_ROW_SIZE_IN_INSTRUCTIONS * FLASH_PC_UNIT_SIZE)
Defines FLASH write row size in PC counts.
#define FLASH_ERASE_PAGE_SIZE_IN_INSTRUCTIONS 1024U
Defines FLASH erase page size in instruction counts.
#define FLASH_ERASE_PAGE_SIZE_IN_PC_UNITS (FLASH_ERASE_PAGE_SIZE_IN_INSTRUCTIONS * FLASH_PC_UNIT_SIZE)
Defines FLASH erase page size in PC counts.
#define FLASH_HAS_ECC 1
Defines if FLASH has ECC.
#define FLASH_ERASE_PAGE_MASK (~(FLASH_ERASE_PAGE_SIZE_IN_PC_UNITS - 1U))
Defines FLASH erase page mask value.
#define FLASH_ODD_ADDRESS_MASK 1U
Defines FLASH odd address mask value.
#define FLASH_PC_UNIT_SIZE 2U
Defines FLASH Flash PC unit size.
#define FLASH_UNLOCK_KEY 0x00AA0055
Defines FLASH unlock key value.
#define FLASH_WRITE_ROW_SIZE_IN_INSTRUCTIONS 128U
Defines FLASH write row size in instruction counts.
#define FLASH_WRITE_ROW_SIZE_IN_PC_UNITS (FLASH_WRITE_ROW_SIZE_IN_INSTRUCTIONS * FLASH_PC_UNIT_SIZE)
Defines FLASH write row size in PC counts.
#define FLASH_ERASE_PAGE_SIZE_IN_INSTRUCTIONS 1024U
Defines FLASH erase page size in instruction counts.
#define FLASH_ERASE_PAGE_SIZE_IN_PC_UNITS (FLASH_ERASE_PAGE_SIZE_IN_INSTRUCTIONS * FLASH_PC_UNIT_SIZE)
Defines FLASH erase page size in PC counts.
#define FLASH_HAS_ECC 1
Defines if FLASH has ECC.
#define FLASH_ERASE_PAGE_MASK (~(FLASH_ERASE_PAGE_SIZE_IN_PC_UNITS - 1U))
Defines FLASH erase page mask value.
#define FLASH_ODD_ADDRESS_MASK 1U
Defines FLASH odd address mask value.
#define FLASH_ERROR_MASK 0x2100
Defines FLASH flash error mask value.
Enumerations
enum FLASH_PANEL { FLASH_PANEL_1 = 0, FLASH_PANEL_2 = 1, FLASH_PANEL_MAX_PANELS }
This enum is be used for the flash panel numbers and maximum flash panels.
enum FLASH_RETURN_STATUS { FLASH_NO_ERROR, FLASH_INVALID_ADDRESS, FLASH_INVALID_DATA, FLASH_WRITE_ERROR, FLASH_READ_ERROR, FLASH_ERASE_ERROR, FLASH_INVALID_CALLBACK_HANDLER, FLASH_OP_BUSY, FLASH_OP_IN_PROGRESS }
This enum is be used to return the status of write, read and erase operation.
Functions
enum FLASH_RETURN_STATUS FLASH_PageErase (flash_adr_t flashAddress, flash_key_t unlockKey)
This function erases a page.
enum FLASH_RETURN_STATUS FLASH_WordWrite (flash_adr_t flashAddress, flash_data_t *data, flash_key_t unlockKey)
This function writes the specified data to the specified address.
enum FLASH_RETURN_STATUS FLASH_RowWrite (flash_adr_t flashAddress, flash_data_t *data, flash_key_t unlockKey)
This function writes the specified data to the specified address.
enum FLASH_RETURN_STATUS FLASH_Read (flash_adr_t flashAddress, size_t count, flash_data_t *data)
This function reads the data from the specified address.
bool FLASH_ErasePage (flash_adr_t address, flash_key_t unlockKey)
This routine erases a page indicated by the page aligned address.
uint32_t FLASH_ReadWord24 (flash_adr_t address)
This routine reads a 24 bit instruction from the indicated address in flash.
uint16_t FLASH_ReadWord16 (flash_adr_t address)
This routine reads a 16 bit instruction from the indicated address in flash.
bool FLASH_WriteDoubleWord24 (flash_adr_t address, flash_data_t Data0, flash_data_t Data1, flash_key_t unlockKey)
This routine writes two 24 bit instructions to the indicated address in flash.
bool FLASH_WriteDoubleWord16 (flash_adr_t flashAddress, uint16_t Data0, uint16_t Data1, flash_key_t unlockKey)
This routine writes two ,16 bit instructions to the indicated address in flash.
bool FLASH_WriteRow24 (flash_adr_t flashAddress, flash_data_t *data, flash_key_t unlockKey)
This routine writes a single row of data from the location given in *data to the flash location in address. Since the flash is only 24 bits wide all data in the upper 8 bits of the source will be lost.The address in *data must be row aligned.
bool FLASH_WriteRow16 (flash_adr_t address, uint16_t *data, flash_key_t unlockKey)
This routine writes a single row of data from the location given in *data to the flash location in address. Each 16 bit source data word is stored in the lower 16 bits of each flash entry and the upper 8 bits of the flash is not programmed.The address in *data must be row aligned.
uint16_t FLASH_ErasePageOffsetGet (flash_adr_t address)
This routiner returns the page offset the given flash address.
uint32_t FLASH_ErasePageAddressGet (flash_adr_t address)
This routine returns the page aligned address for a given flash address..
bool FLASH_NonBlockingErasePage (flash_adr_t address, flash_key_t unlockKey)
This routine erases a page indicated by the page aligned address.
bool FLASH_NonBlockingEraseBulk (uint32_t panel, flash_key_t unlockKey)
This routine erases a page indicated by the page aligned address.
bool FLASH_NonBlockingWriteDoubleWord24 (flash_adr_t address, flash_data_t Data0, flash_data_t Data1, flash_key_t unlockKey)
This routine writes two 24 bit instructions to the indicated address in flash.
bool FLASH_NonBlockingWriteDoubleWord16 (flash_adr_t flashAddress, uint16_t Data0, uint16_t Data1, flash_key_t unlockKey)
This routine writes two ,16 bit instructions to the indicated address in flash.
bool FLASH_NonBlockingWriteRow24 (flash_adr_t flashAddress, flash_data_t *data, flash_key_t unlockKey)
This routine writes a single row of data from the location given in *data to the flash location in address. Since the flash is only 24 bits wide all data in the upper 8 bits of the source will be lost.The address in *data must be row aligned.
bool FLASH_NonBlockingWriteRow16 (flash_adr_t address, uint16_t *data, flash_key_t unlockKey)
This routine writes a single row of data from the location given in *data to the flash location in address. Each 16 bit source data word is stored in the lower 16 bits of each flash entry and the upper 8 bits of the flash is not programmed.The address in *data must be row aligned.
uint32_t FLASH_NonBlockingReadWord24 (flash_adr_t address)
This routine reads a 24 bit instruction from the indicated address in flash.
uint16_t FLASH_NonBlockingReadWord16 (flash_adr_t address)
This routine reads a 16 bit instruction from the indicated address in flash.
void FLASH_Initialize ()
This function initializes the nvm controller.
enum FLASH_RETURN_STATUS FLASH_OperationStatusGet ()
This function gets the status of nvm controller.
enum FLASH_RETURN_STATUS FLASH_NonBlockingPageErase (flash_adr_t flashAddress, flash_key_t unlockKey, FLASH_CALLBACK callbackHandler, void *context)
This function erases a page.
enum FLASH_RETURN_STATUS FLASH_NonBlockingBulkErase (enum FLASH_PANEL panel, flash_key_t unlockKey, FLASH_CALLBACK callbackHandler, void *context)
This function erases a panel.
enum FLASH_RETURN_STATUS FLASH_NonBlockingWordWrite (flash_adr_t flashAddress, flash_data_t *data, flash_key_t unlockKey, FLASH_CALLBACK callbackHandler, void *context)
This function writes the specified data to the specified address.
enum FLASH_RETURN_STATUS FLASH_NonBlockingRowWrite (flash_adr_t flashAddress, flash_data_t *data, flash_key_t unlockKey, FLASH_CALLBACK callback, void *context)
This function writes the specified data to the specified address.
enum FLASH_RETURN_STATUS FLASH_NonBlockingRead (flash_adr_t flashAddress, size_t count, flash_data_t *data)
This function reads the data from the specified address.
Variables
const struct FLASH_INTERFACE flash
Structure object of type FLASH_INTERFACE assigned with name displayed in the Melody Driver User interface. A structure pointer can be used to achieve portability across the FLASH having same interface structure.
2.11.1.1.2 Definition Documentation
FLASH_ERASE_PAGE_MASK[1/2]
#define FLASH_ERASE_PAGE_MASK (~(FLASH_ERASE_PAGE_SIZE_IN_PC_UNITS - 1U))
Defines FLASH erase page mask value.
FLASH_ERASE_PAGE_MASK[1/2]
#define FLASH_ERASE_PAGE_MASK (~(FLASH_ERASE_PAGE_SIZE_IN_PC_UNITS - 1U))
Defines FLASH erase page mask value.
FLASH_ERASE_PAGE_SIZE_IN_INSTRUCTIONS[1/2]
#define FLASH_ERASE_PAGE_SIZE_IN_INSTRUCTIONS 1024U
Defines FLASH erase page size in instruction counts.
FLASH_ERASE_PAGE_SIZE_IN_INSTRUCTIONS[1/2]
#define FLASH_ERASE_PAGE_SIZE_IN_INSTRUCTIONS 1024U
Defines FLASH erase page size in instruction counts.
FLASH_ERASE_PAGE_SIZE_IN_PC_UNITS[1/2]
#define FLASH_ERASE_PAGE_SIZE_IN_PC_UNITS (FLASH_ERASE_PAGE_SIZE_IN_INSTRUCTIONS * FLASH_PC_UNIT_SIZE)
Defines FLASH erase page size in PC counts.
FLASH_ERASE_PAGE_SIZE_IN_PC_UNITS[1/2]
#define FLASH_ERASE_PAGE_SIZE_IN_PC_UNITS (FLASH_ERASE_PAGE_SIZE_IN_INSTRUCTIONS * FLASH_PC_UNIT_SIZE)
Defines FLASH erase page size in PC counts.
FLASH_ERROR_MASK
#define FLASH_ERROR_MASK 0x2100
Defines FLASH flash error mask value.
FLASH_HAS_ECC[1/2]
#define FLASH_HAS_ECC 1
Defines if FLASH has ECC.
FLASH_HAS_ECC[1/2]
#define FLASH_HAS_ECC 1
Defines if FLASH has ECC.
FLASH_ODD_ADDRESS_MASK[1/2]
#define FLASH_ODD_ADDRESS_MASK 1U
Defines FLASH odd address mask value.
FLASH_ODD_ADDRESS_MASK[1/2]
#define FLASH_ODD_ADDRESS_MASK 1U
Defines FLASH odd address mask value.
FLASH_PC_UNIT_SIZE[1/2]
#define FLASH_PC_UNIT_SIZE 2U
Defines FLASH Flash PC unit size.
FLASH_PC_UNIT_SIZE[1/2]
#define FLASH_PC_UNIT_SIZE 2U
Defines FLASH Flash PC unit size.
FLASH_UNLOCK_KEY[1/2]
#define FLASH_UNLOCK_KEY 0x00AA0055
Defines FLASH unlock key value.
FLASH_UNLOCK_KEY[1/2]
#define FLASH_UNLOCK_KEY 0x00AA0055
Defines FLASH unlock key value.
FLASH_WRITE_ROW_SIZE_IN_INSTRUCTIONS[1/2]
#define FLASH_WRITE_ROW_SIZE_IN_INSTRUCTIONS 128U
Defines FLASH write row size in instruction counts.
FLASH_WRITE_ROW_SIZE_IN_INSTRUCTIONS[1/2]
#define FLASH_WRITE_ROW_SIZE_IN_INSTRUCTIONS 128U
Defines FLASH write row size in instruction counts.
FLASH_WRITE_ROW_SIZE_IN_PC_UNITS[1/2]
#define FLASH_WRITE_ROW_SIZE_IN_PC_UNITS (FLASH_WRITE_ROW_SIZE_IN_INSTRUCTIONS * FLASH_PC_UNIT_SIZE)
Defines FLASH write row size in PC counts.
FLASH_WRITE_ROW_SIZE_IN_PC_UNITS[1/2]
#define FLASH_WRITE_ROW_SIZE_IN_PC_UNITS (FLASH_WRITE_ROW_SIZE_IN_INSTRUCTIONS * FLASH_PC_UNIT_SIZE)
Defines FLASH write row size in PC counts.
2.11.1.1.3 Function Documentation
FLASH_ErasePage()
bool FLASH_ErasePage (flash_adr_t address, flash_key_t unlockKey)
This routine erases a page indicated by the page aligned address.
in | address |
- Flash page aligned address. |
bool - Returns True if operation successful else returns false. |
FLASH_ErasePageAddressGet()
uint32_t FLASH_ErasePageAddressGet (flash_adr_t address)
This routine returns the page aligned address for a given flash address..
in | address |
- Flash address. |
uint32_t - Returns page aligned flash address. |
FLASH_ErasePageOffsetGet()
uint16_t FLASH_ErasePageOffsetGet (flash_adr_t address)
This routiner returns the page offset the given flash address.
in | address |
- Flash address. |
uint32_t - returns offset. |
FLASH_Initialize()
void FLASH_Initialize ( )
This function initializes the nvm controller.
FLASH_NonBlockingBulkErase()
enum FLASH_RETURN_STATUS FLASH_NonBlockingBulkErase (enum FLASH_PANEL panel, flash_key_t unlockKey, FLASH_CALLBACK callbackHandler, void * context)
This function erases a panel.
in | panel |
: Flash panel to erase |
in | unlockKey |
: Flash unlock key |
* returns FLASH_NO_ERROR if operation is successful, if the operation is in progress then it returns FLASH_OP_IN_PROGRESS, if there is a previous operation in progress then it returns FLASH_OP_BUSY , in case of any unsuccessful operation it returns errors like FLASH_INVALID_ADDRESS, FLASH_INVALID_CALLBACK_HANDLER, FLASH_WRITE_ERROR |
FLASH_NonBlockingEraseBulk()
bool FLASH_NonBlockingEraseBulk (uint32_t panel, flash_key_t unlockKey)
This routine erases a page indicated by the page aligned address.
in | panel |
- Panel to erase. |
bool - Returns True if operation successful else returns false. |
FLASH_NonBlockingErasePage()
bool FLASH_NonBlockingErasePage (flash_adr_t address, flash_key_t unlockKey)
This routine erases a page indicated by the page aligned address.
in | address |
- Flash page aligned address. |
bool - Returns True if operation successful else returns false. |
FLASH_NonBlockingPageErase()
enum FLASH_RETURN_STATUS FLASH_NonBlockingPageErase (flash_adr_t flashAddress, flash_key_t unlockKey, FLASH_CALLBACK callbackHandler, void * context)
This function erases a page.
in | flashAddress |
: Flash address |
in | unlockKey |
: Flash unlock key |
in | callbackHandler |
: Pointer to call back handler |
in | context |
: Optional pointer to context to handle user contexts |
FLASH_RETURN_STATUS: returns FLASH_NO_ERROR if operation is successful, if the operation is in progress then it returns FLASH_OP_IN_PROGRESS, if there is a previous operation in progress then it returns FLASH_OP_BUSY , in case of any unsuccessful operation it returns errors like FLASH_INVALID_ADDRESS, FLASH_INVALID_CALLBACK_HANDLER, FLASH_WRITE_ERROR |
FLASH_NonBlockingRead()
enum FLASH_RETURN_STATUS FLASH_NonBlockingRead (flash_adr_t flashAddress, size_t count, flash_data_t * data)
This function reads the data from the specified address.
in | flashAddress |
: Flash address of |
out | data |
: Pointer to read the data |
FLASH_RETURN_STATUS: returns FLASH_NO_ERROR if operation is successful, if the operation is in progress then it returns FLASH_OP_IN_PROGRESS, if there is a previous operation in progress then it returns FLASH_OP_BUSY , in case of any unsuccessful operation it returns errors like FLASH_INVALID_ADDRESS, FLASH_INVALID_DATA |
FLASH_NonBlockingReadWord16()
uint16_t FLASH_NonBlockingReadWord16 (flash_adr_t address)
This routine reads a 16 bit instruction from the indicated address in flash.
in | address |
- Flash address. |
uint16_t - 16 bit data. |
FLASH_NonBlockingReadWord24()
uint32_t FLASH_NonBlockingReadWord24 (flash_adr_t address)
This routine reads a 24 bit instruction from the indicated address in flash.
in | address |
- Flash address. |
uint32_t - 24 bit data. |
FLASH_NonBlockingRowWrite()
enum FLASH_RETURN_STATUS FLASH_NonBlockingRowWrite (flash_adr_t flashAddress, flash_data_t * data, flash_key_t unlockKey, FLASH_CALLBACK callback, void * context)
This function writes the specified data to the specified address.
in | flashAddress |
: Flash address |
in | data |
: Pointer of the data to be written |
in | unlockKey |
: Flash unlock Key. |
in | callbackHandler |
: Pointer to call back handler |
in | context |
: Optional pointer to context to handle user contexts |
FLASH_RETURN_STATUS: returns FLASH_NO_ERROR if operation is successful, if the operation is in progress then it returns FLASH_OP_IN_PROGRESS, if there is a previous operation in progress then it returns FLASH_OP_BUSY , in case of any unsuccessful operation it returns errors like FLASH_INVALID_ADDRESS, FLASH_INVALID_CALLBACK_HANDLER, FLASH_WRITE_ERROR |
FLASH_NonBlockingWordWrite()
enum FLASH_RETURN_STATUS FLASH_NonBlockingWordWrite (flash_adr_t flashAddress, flash_data_t * data, flash_key_t unlockKey, FLASH_CALLBACK callbackHandler, void * context)
This function writes the specified data to the specified address.
in | flashAddress |
: Flash address |
in | data |
: Pointer of the data to be written. |
in | unlockKey |
: Flash unlock Key. |
in | callbackHandler |
: pointer to call back handler |
in | context |
: Optional pointer to context to handle user contexts This will write the TWO WORDS pointed to by the pointer. |
FLASH_RETURN_STATUS: returns FLASH_NO_ERROR if operation is successful, if the operation is in progress then it returns FLASH_OP_IN_PROGRESS, if there is a previous operation in progress then it returns FLASH_OP_BUSY , in case of any unsuccessful operation it returns errors like FLASH_INVALID_ADDRESS, FLASH_INVALID_CALLBACK_HANDLER, FLASH_WRITE_ERROR |
FLASH_NonBlockingWriteDoubleWord16()
bool FLASH_NonBlockingWriteDoubleWord16 (flash_adr_t flashAddress, uint16_t Data0, uint16_t Data1, flash_key_t unlockKey)
This routine writes two ,16 bit instructions to the indicated address in flash.
in | address |
- Flash address. |
in | data1 |
- First 16 bit data to be written(First word). |
in | data2 |
- Second 16 bit data to be written(Second word). |
bool - Returns true if operation is successful else returns false. |
FLASH_NonBlockingWriteDoubleWord24()
bool FLASH_NonBlockingWriteDoubleWord24 (flash_adr_t address, flash_data_t Data0, flash_data_t Data1, flash_key_t unlockKey)
This routine writes two 24 bit instructions to the indicated address in flash.
in | address |
- Flash address. |
in | data1 |
- First 24 bit data to be written(First word). |
in | data2 |
- Second 24 bit data to be written(Second word). |
bool - Returns true if operation is successful else returns false. |
FLASH_NonBlockingWriteRow16()
bool FLASH_NonBlockingWriteRow16 (flash_adr_t address, uint16_t * data, flash_key_t unlockKey)
This routine writes a single row of data from the location given in *data to the flash location in address. Each 16 bit source data word is stored in the lower 16 bits of each flash entry and the upper 8 bits of the flash is not programmed.The address in *data must be row aligned.
in | address |
- Flash address. |
in | *data |
- Address of the data to be written. |
bool - Returns true if operation is successful else returns false. |
FLASH_NonBlockingWriteRow24()
bool FLASH_NonBlockingWriteRow24 (flash_adr_t flashAddress, flash_data_t * data, flash_key_t unlockKey)
This routine writes a single row of data from the location given in *data to the flash location in address. Since the flash is only 24 bits wide all data in the upper 8 bits of the source will be lost.The address in *data must be row aligned.
in | address |
- Flash address. |
in | *data |
- Address of the data to be written. |
bool - Returns true if operation is successful else returns false. |
FLASH_OperationStatusGet()
enum FLASH_RETURN_STATUS FLASH_OperationStatusGet ( )
This function gets the status of nvm controller.
FLASH_PageErase()
enum FLASH_RETURN_STATUS FLASH_PageErase (flash_adr_t flashAddress, flash_key_t unlockKey)
This function erases a page.
in | flashAddress |
: Flash address |
in | unlockKey |
: Pointer of the data to be written |
FLASH_RETURN_STATUS: returns FLASH_NO_ERROR if operation is successful , else returns errors like FLASH_INVALID_ADDRESS, FLASH_WRITE_ERROR |
FLASH_Read()
enum FLASH_RETURN_STATUS FLASH_Read (flash_adr_t flashAddress, size_t count, flash_data_t * data)
This function reads the data from the specified address.
in | flashAddress |
: Flash address of |
out | data |
: Pointer to read the data |
FLASH_RETURN_STATUS: returns FLASH_NO_ERROR if operation is successful , else returns errors like FLASH_INVALID_ADDRESS, FLASH_INVALID_DATA |
FLASH_ReadWord16()
uint16_t FLASH_ReadWord16 (flash_adr_t address)
This routine reads a 16 bit instruction from the indicated address in flash.
in | address |
- Flash address. |
uint16_t - 16 bit data. |
FLASH_ReadWord24()
uint32_t FLASH_ReadWord24 (flash_adr_t address)
This routine reads a 24 bit instruction from the indicated address in flash.
in | address |
- Flash address. |
uint32_t - 24 bit data. |
FLASH_RowWrite()
enum FLASH_RETURN_STATUS FLASH_RowWrite (flash_adr_t flashAddress, flash_data_t * data, flash_key_t unlockKey)
This function writes the specified data to the specified address.
in | flashAddress |
: Flash address |
in | data |
: Pointer of the data to be written |
FLASH_RETURN_STATUS: returns FLASH_NO_ERROR if operation is successful , else returns errors like FLASH_INVALID_ADDRESS, FLASH_INVALID_DATA, FLASH_WRITE_ERROR |
FLASH_WordWrite()
enum FLASH_RETURN_STATUS FLASH_WordWrite (flash_adr_t flashAddress, flash_data_t * data, flash_key_t unlockKey)
This function writes the specified data to the specified address.
in | flashAddress |
: Flash address |
in | data |
: Pointer of the data to be written. This will write the TWO WORDS pointed to by the pointer. |
FLASH_RETURN_STATUS: returns FLASH_NO_ERROR if operation is successful , else returns errors like FLASH_INVALID_ADDRESS, FLASH_INVALID_DATA, FLASH_WRITE_ERROR |
FLASH_WriteDoubleWord16()
bool FLASH_WriteDoubleWord16 (flash_adr_t flashAddress, uint16_t Data0, uint16_t Data1, flash_key_t unlockKey)
This routine writes two ,16 bit instructions to the indicated address in flash.
in | address |
- Flash address. |
in | data1 |
- First 16 bit data to be written(First word). |
in | data2 |
- Second 16 bit data to be written(Second word). |
bool - Returns true if operation is successful else returns false. |
FLASH_WriteDoubleWord24()
bool FLASH_WriteDoubleWord24 (flash_adr_t address, flash_data_t Data0, flash_data_t Data1, flash_key_t unlockKey)
This routine writes two 24 bit instructions to the indicated address in flash.
in | address |
- Flash address. |
in | data1 |
- First 24 bit data to be written(First word). |
in | data2 |
- Second 24 bit data to be written(Second word). |
bool - Returns true if operation is successful else returns false. |
FLASH_WriteRow16()
bool FLASH_WriteRow16 (flash_adr_t address, uint16_t * data, flash_key_t unlockKey)
This routine writes a single row of data from the location given in *data to the flash location in address. Each 16 bit source data word is stored in the lower 16 bits of each flash entry and the upper 8 bits of the flash is not programmed.The address in *data must be row aligned.
in | address |
- Flash address. |
in | *data |
- Address of the data to be written. |
bool - Returns true if operation is successful else returns false. |
FLASH_WriteRow24()
bool FLASH_WriteRow24 (flash_adr_t flashAddress, flash_data_t * data, flash_key_t unlockKey)
This routine writes a single row of data from the location given in *data to the flash location in address. Since the flash is only 24 bits wide all data in the upper 8 bits of the source will be lost.The address in *data must be row aligned.
in | address |
- Flash address. |
in | *data |
- Address of the data to be written. |
bool - Returns true if operation is successful else returns false. |
2.11.1.1.4 Enumeration Type Documentation
FLASH_PANEL
enum FLASH_PANEL
This enum is be used for the flash panel numbers and maximum flash panels.
FLASH_PANEL_1 | |
FLASH_PANEL_2 | |
FLASH_PANEL_MAX_PANELS |
FLASH_RETURN_STATUS
enum FLASH_RETURN_STATUS
This enum is be used to return the status of write, read and erase operation.
FLASH_NO_ERROR |
No error occurred |
FLASH_INVALID_ADDRESS |
Invalid address |
FLASH_INVALID_DATA |
Invalid data |
FLASH_WRITE_ERROR |
Write error has occurred |
FLASH_READ_ERROR |
Read error has occurred |
FLASH_ERASE_ERROR |
Flash erase error occurred |
FLASH_INVALID_CALLBACK_HANDLER |
Invalid parameter to operation |
FLASH_OP_BUSY |
Flash is physically busy |
FLASH_OP_IN_PROGRESS |
Flash operation is in progress |
2.11.1.1.5 Variable Documentation
flash
const struct FLASH_INTERFACE flash
Structure object of type FLASH_INTERFACE assigned with name displayed in the Melody Driver User interface. A structure pointer can be used to achieve portability across the FLASH having same interface structure.
2.11.2 Class Documentation
2.11.2.1 FLASH_INTERFACE Struct Reference
Structure containing the function pointers of FLASH driver.
2.11.2.1.1 Detailed Description
Structure containing the function pointers of FLASH driver.
#include <flash_interface.h>
Public Attributes
enum FLASH_RETURN_STATUS(* PageErase )(flash_adr_t address, flash_key_t unlockKey)
Pointer to FLASH_PageErase e.g. FLASH_PageErase.
enum FLASH_RETURN_STATUS(* Write )(flash_adr_t address, flash_data_t *data, flash_key_t unlockKey)
Pointer to FLASH_WordWrite e.g. FLASH_WordWrite.
enum FLASH_RETURN_STATUS(* RowWrite )(flash_adr_t address, flash_data_t *data, flash_key_t unlockKey)
Pointer to FLASH_RowWrite e.g. FLASH_RowWrite.
enum FLASH_RETURN_STATUS(* Read )(flash_adr_t address, size_t count, uint32_t *data)
Pointer to FLASH_Read e.g. FLASH_Read.
uint32_t(* PageAddressGet )(flash_adr_t address)
Pointer to FLASH_ErasePageAddressGet e.g. FLASH_ErasePageAddressGet.
uint16_t(* PageOffsetGet )(flash_adr_t address)
Pointer to FLASH_ErasePageOffsetGet e.g. FLASH_ErasePageOffsetGet.
enum FLASH_RETURN_STATUS(* OperationStatusGet )(void)
Pointer to FLASH_OperationStatusGet e.g. FLASH_OperationStatusGet.
enum FLASH_RETURN_STATUS(* NonBlockingPageErase )(flash_adr_t address, flash_key_t unlockKey, FLASH_CALLBACK callbackHandler, void *context)
Pointer to FLASH_NonBlockingPageErase e.g. FLASH_NonBlockingPageErase.
enum FLASH_RETURN_STATUS(* NonBlockingBulkErase )(enum FLASH_PANEL panel, flash_key_t unlockKey, FLASH_CALLBACK callbackHandler, void *context)
Pointer to FLASH_NonBlockingBulkErase e.g. FLASH_NonBlockingBulkErase.
enum FLASH_RETURN_STATUS(* NonBlockingWordWrite )(flash_adr_t address, flash_data_t *data, flash_key_t unlockKey, FLASH_CALLBACK callbackHandler, void *context)
Pointer to FLASH_NonBlockingWordWrite e.g. FLASH_NonBlockingWordWrite.
enum FLASH_RETURN_STATUS(* NonBlockingRowWrite )(flash_adr_t address, flash_data_t *data, flash_key_t unlockKey, FLASH_CALLBACK callbackHandler, void *context)
Pointer to FLASH_NonBlockingRowWrite e.g. FLASH_NonBlockingRowWrite.
enum FLASH_RETURN_STATUS(* NonBlockingRead )(flash_adr_t address, size_t count, uint32_t *data)
Pointer to FLASH_NonBlockingRead e.g. FLASH_NonBlockingRead.
enum FLASH_RETURN_STATUS(* NonBlockingPolledPageErase )(flash_adr_t address, flash_key_t unlockKey)
Pointer to FLASH_NonBlockingPolledPageErase e.g. FLASH_NonBlockingPolledPageErase.
enum FLASH_RETURN_STATUS(* NonBlockingPolledBulkErase )(enum FLASH_PANEL panel, flash_key_t unlockKey)
Pointer to FLASH_NonBlockingPolledBulkErase e.g. FLASH_NonBlockingPolledBulkErase.
enum FLASH_RETURN_STATUS(* NonBlockingPolledWordWrite )(flash_adr_t address, flash_data_t *data, flash_key_t unlockKey)
Pointer to FLASH_NonBlockingPolledWordWrite e.g. FLASH_NonBlockingPolledWordWrite.
enum FLASH_RETURN_STATUS(* NonBlockingPolledRowWrite )(flash_adr_t address, flash_data_t *data, flash_key_t unlockKey)
Pointer to FLASH_NonBlockingPolledRowWrite e.g. FLASH_NonBlockingPolledRowWrite.
enum FLASH_RETURN_STATUS(* NonBlockingPolledRead )(flash_adr_t address, size_t count, uint32_t *data)
Pointer to FLASH_NonBlockingPolledRead e.g. FLASH_NonBlockingPolledRead.
2.11.2.1.2 Member Data Documentation
NonBlockingBulkErase
enum FLASH_RETURN_STATUS(* NonBlockingBulkErase) (enum FLASH_PANEL panel, flash_key_t unlockKey, FLASH_CALLBACK callbackHandler, void *context)
Pointer to FLASH_NonBlockingBulkErase e.g. FLASH_NonBlockingBulkErase.
NonBlockingPageErase
enum FLASH_RETURN_STATUS(* NonBlockingPageErase) (flash_adr_t address, flash_key_t unlockKey, FLASH_CALLBACK callbackHandler, void *context)
Pointer to FLASH_NonBlockingPageErase e.g. FLASH_NonBlockingPageErase.
NonBlockingPolledBulkErase
enum FLASH_RETURN_STATUS(* NonBlockingPolledBulkErase) (enum FLASH_PANEL panel, flash_key_t unlockKey)
Pointer to FLASH_NonBlockingPolledBulkErase e.g. FLASH_NonBlockingPolledBulkErase.
NonBlockingPolledPageErase
enum FLASH_RETURN_STATUS(* NonBlockingPolledPageErase) (flash_adr_t address, flash_key_t unlockKey)
Pointer to FLASH_NonBlockingPolledPageErase e.g. FLASH_NonBlockingPolledPageErase.
NonBlockingPolledRead
enum FLASH_RETURN_STATUS(* NonBlockingPolledRead) (flash_adr_t address, size_t count, uint32_t *data)
Pointer to FLASH_NonBlockingPolledRead e.g. FLASH_NonBlockingPolledRead.
NonBlockingPolledRowWrite
enum FLASH_RETURN_STATUS(* NonBlockingPolledRowWrite) (flash_adr_t address, flash_data_t *data, flash_key_t unlockKey)
Pointer to FLASH_NonBlockingPolledRowWrite e.g. FLASH_NonBlockingPolledRowWrite.
NonBlockingPolledWordWrite
enum FLASH_RETURN_STATUS(* NonBlockingPolledWordWrite) (flash_adr_t address, flash_data_t *data, flash_key_t unlockKey)
Pointer to FLASH_NonBlockingPolledWordWrite e.g. FLASH_NonBlockingPolledWordWrite.
NonBlockingRead
enum FLASH_RETURN_STATUS(* NonBlockingRead) (flash_adr_t address, size_t count, uint32_t *data)
Pointer to FLASH_NonBlockingRead e.g. FLASH_NonBlockingRead.
NonBlockingRowWrite
enum FLASH_RETURN_STATUS(* NonBlockingRowWrite) (flash_adr_t address, flash_data_t *data, flash_key_t unlockKey, FLASH_CALLBACK callbackHandler, void *context)
Pointer to FLASH_NonBlockingRowWrite e.g. FLASH_NonBlockingRowWrite.
NonBlockingWordWrite
enum FLASH_RETURN_STATUS(* NonBlockingWordWrite) (flash_adr_t address, flash_data_t *data, flash_key_t unlockKey, FLASH_CALLBACK callbackHandler, void *context)
Pointer to FLASH_NonBlockingWordWrite e.g. FLASH_NonBlockingWordWrite.
OperationStatusGet
enum FLASH_RETURN_STATUS(* OperationStatusGet) (void)
Pointer to FLASH_OperationStatusGet e.g. FLASH_OperationStatusGet.
PageAddressGet
uint32_t(* PageAddressGet) (flash_adr_t address)
Pointer to FLASH_ErasePageAddressGet e.g. FLASH_ErasePageAddressGet.
PageErase
enum FLASH_RETURN_STATUS(* PageErase) (flash_adr_t address, flash_key_t unlockKey)
Pointer to FLASH_PageErase e.g. FLASH_PageErase.
PageOffsetGet
uint16_t(* PageOffsetGet) (flash_adr_t address)
Pointer to FLASH_ErasePageOffsetGet e.g. FLASH_ErasePageOffsetGet.
Read
enum FLASH_RETURN_STATUS(* Read) (flash_adr_t address, size_t count, uint32_t *data)
Pointer to FLASH_Read e.g. FLASH_Read.
RowWrite
enum FLASH_RETURN_STATUS(* RowWrite) (flash_adr_t address, flash_data_t *data, flash_key_t unlockKey)
Pointer to FLASH_RowWrite e.g. FLASH_RowWrite.
Write
enum FLASH_RETURN_STATUS(* Write) (flash_adr_t address, flash_data_t *data, flash_key_t unlockKey)
Pointer to FLASH_WordWrite e.g. FLASH_WordWrite.
2.11.3 File Documentation
2.11.3.1 source/flash.h File Reference
FLASH driver using dsPIC MCUs.
#include <stdint.h> #include <stddef.h> #include <stdbool.h> #include "flash_hardware.h" #include "flash_interface.h"
2.11.3.1.1 Functions
enum FLASH_RETURN_STATUS FLASH_PageErase (flash_adr_t flashAddress, flash_key_t unlockKey)
This function erases a page.
enum FLASH_RETURN_STATUS FLASH_WordWrite (flash_adr_t flashAddress, flash_data_t *data, flash_key_t unlockKey)
This function writes the specified data to the specified address.
enum FLASH_RETURN_STATUS FLASH_RowWrite (flash_adr_t flashAddress, flash_data_t *data, flash_key_t unlockKey)
This function writes the specified data to the specified address.
enum FLASH_RETURN_STATUS FLASH_Read (flash_adr_t flashAddress, size_t count, flash_data_t *data)
This function reads the data from the specified address.
2.11.3.1.2 Variables
const struct FLASH_INTERFACE flash
Structure object of type FLASH_INTERFACE assigned with name displayed in the Melody Driver User interface. A structure pointer can be used to achieve portability across the FLASH having same interface structure.
2.11.3.1.3 Detailed Description
FLASH driver using dsPIC MCUs.
This is the generated driver header file for the FLASH driver.
FLASH Generated Driver Header File
2.11.3.2 source/flash_hardware.h File Reference
#include <xc.h> #include <stdint.h> #include <stdbool.h> #include "flash_types.h"
2.11.3.2.1 Functions
bool FLASH_ErasePage (flash_adr_t address, flash_key_t unlockKey)
This routine erases a page indicated by the page aligned address.
uint32_t FLASH_ReadWord24 (flash_adr_t address)
This routine reads a 24 bit instruction from the indicated address in flash.
uint16_t FLASH_ReadWord16 (flash_adr_t address)
This routine reads a 16 bit instruction from the indicated address in flash.
bool FLASH_WriteDoubleWord24 (flash_adr_t address, flash_data_t Data0, flash_data_t Data1, flash_key_t unlockKey)
This routine writes two 24 bit instructions to the indicated address in flash.
bool FLASH_WriteDoubleWord16 (flash_adr_t flashAddress, uint16_t Data0, uint16_t Data1, flash_key_t unlockKey)
This routine writes two ,16 bit instructions to the indicated address in flash.
bool FLASH_WriteRow24 (flash_adr_t flashAddress, flash_data_t *data, flash_key_t unlockKey)
This routine writes a single row of data from the location given in *data to the flash location in address. Since the flash is only 24 bits wide all data in the upper 8 bits of the source will be lost.The address in *data must be row aligned.
bool FLASH_WriteRow16 (flash_adr_t address, uint16_t *data, flash_key_t unlockKey)
This routine writes a single row of data from the location given in *data to the flash location in address. Each 16 bit source data word is stored in the lower 16 bits of each flash entry and the upper 8 bits of the flash is not programmed.The address in *data must be row aligned.
uint16_t FLASH_ErasePageOffsetGet (flash_adr_t address)
This routiner returns the page offset the given flash address.
uint32_t FLASH_ErasePageAddressGet (flash_adr_t address)
This routine returns the page aligned address for a given flash address..
2.11.3.2.2 Macros
#define FLASH_PC_UNIT_SIZE 2U
Defines FLASH Flash PC unit size.
#define FLASH_UNLOCK_KEY 0x00AA0055
Defines FLASH unlock key value.
#define FLASH_WRITE_ROW_SIZE_IN_INSTRUCTIONS 128U
Defines FLASH write row size in instruction counts.
#define FLASH_WRITE_ROW_SIZE_IN_PC_UNITS (FLASH_WRITE_ROW_SIZE_IN_INSTRUCTIONS * FLASH_PC_UNIT_SIZE)
Defines FLASH write row size in PC counts.
#define FLASH_ERASE_PAGE_SIZE_IN_INSTRUCTIONS 1024U
Defines FLASH erase page size in instruction counts.
#define FLASH_ERASE_PAGE_SIZE_IN_PC_UNITS (FLASH_ERASE_PAGE_SIZE_IN_INSTRUCTIONS * FLASH_PC_UNIT_SIZE)
Defines FLASH erase page size in PC counts.
#define FLASH_HAS_ECC 1
Defines if FLASH has ECC.
#define FLASH_ERASE_PAGE_MASK (~(FLASH_ERASE_PAGE_SIZE_IN_PC_UNITS - 1U))
Defines FLASH erase page mask value.
#define FLASH_ODD_ADDRESS_MASK 1U
Defines FLASH odd address mask value.
2.11.3.3 source/flash_hardware_nonblocking.h File Reference
#include <xc.h> #include <stdint.h> #include <stdbool.h> #include "flash_types.h"
2.11.3.3.1 Functions
bool FLASH_NonBlockingErasePage (flash_adr_t address, flash_key_t unlockKey)
This routine erases a page indicated by the page aligned address.
bool FLASH_NonBlockingEraseBulk (uint32_t panel, flash_key_t unlockKey)
This routine erases a page indicated by the page aligned address.
bool FLASH_NonBlockingWriteDoubleWord24 (flash_adr_t address, flash_data_t Data0, flash_data_t Data1, flash_key_t unlockKey)
This routine writes two 24 bit instructions to the indicated address in flash.
bool FLASH_NonBlockingWriteDoubleWord16 (flash_adr_t flashAddress, uint16_t Data0, uint16_t Data1, flash_key_t unlockKey)
This routine writes two ,16 bit instructions to the indicated address in flash.
bool FLASH_NonBlockingWriteRow24 (flash_adr_t flashAddress, flash_data_t *data, flash_key_t unlockKey)
This routine writes a single row of data from the location given in *data to the flash location in address. Since the flash is only 24 bits wide all data in the upper 8 bits of the source will be lost.The address in *data must be row aligned.
bool FLASH_NonBlockingWriteRow16 (flash_adr_t address, uint16_t *data, flash_key_t unlockKey)
This routine writes a single row of data from the location given in *data to the flash location in address. Each 16 bit source data word is stored in the lower 16 bits of each flash entry and the upper 8 bits of the flash is not programmed.The address in *data must be row aligned.
uint32_t FLASH_NonBlockingReadWord24 (flash_adr_t address)
This routine reads a 24 bit instruction from the indicated address in flash.
uint16_t FLASH_NonBlockingReadWord16 (flash_adr_t address)
This routine reads a 16 bit instruction from the indicated address in flash.
2.11.3.3.2 Macros
#define FLASH_PC_UNIT_SIZE 2U
Defines FLASH Flash PC unit size.
#define FLASH_UNLOCK_KEY 0x00AA0055
Defines FLASH unlock key value.
#define FLASH_WRITE_ROW_SIZE_IN_INSTRUCTIONS 128U
Defines FLASH write row size in instruction counts.
#define FLASH_WRITE_ROW_SIZE_IN_PC_UNITS (FLASH_WRITE_ROW_SIZE_IN_INSTRUCTIONS * FLASH_PC_UNIT_SIZE)
Defines FLASH write row size in PC counts.
#define FLASH_ERASE_PAGE_SIZE_IN_INSTRUCTIONS 1024U
Defines FLASH erase page size in instruction counts.
#define FLASH_ERASE_PAGE_SIZE_IN_PC_UNITS (FLASH_ERASE_PAGE_SIZE_IN_INSTRUCTIONS * FLASH_PC_UNIT_SIZE)
Defines FLASH erase page size in PC counts.
#define FLASH_HAS_ECC 1
Defines if FLASH has ECC.
#define FLASH_ERASE_PAGE_MASK (~(FLASH_ERASE_PAGE_SIZE_IN_PC_UNITS - 1U))
Defines FLASH erase page mask value.
#define FLASH_ODD_ADDRESS_MASK 1U
Defines FLASH odd address mask value.
#define FLASH_ERROR_MASK 0x2100
Defines FLASH flash error mask value.
2.11.3.4 source/flash_interface.h File Reference
#include <stdint.h> #include <stdbool.h> #include <stddef.h> #include "flash_types.h"
2.11.3.4.1 Data structures
struct FLASH_INTERFACE
Structure containing the function pointers of FLASH driver.
2.11.3.4.2 Detailed Description
flash Generated Driver Interface Header File
2.11.3.5 source/flash_nonblocking.h File Reference
#include <stdint.h> #include <stddef.h> #include <stdbool.h> #include "xc.h" #include "flash_interface.h" #include "flash_hardware_nonblocking.h" #include "../flash/flash.h"
2.11.3.5.1 Functions
void FLASH_Initialize ()
This function initializes the nvm controller.
enum FLASH_RETURN_STATUS FLASH_OperationStatusGet ()
This function gets the status of nvm controller.
enum FLASH_RETURN_STATUS FLASH_NonBlockingPageErase (flash_adr_t flashAddress, flash_key_t unlockKey, FLASH_CALLBACK callbackHandler, void *context)
This function erases a page.
enum FLASH_RETURN_STATUS FLASH_NonBlockingBulkErase (enum FLASH_PANEL panel, flash_key_t unlockKey, FLASH_CALLBACK callbackHandler, void *context)
This function erases a panel.
enum FLASH_RETURN_STATUS FLASH_NonBlockingWordWrite (flash_adr_t flashAddress, flash_data_t *data, flash_key_t unlockKey, FLASH_CALLBACK callbackHandler, void *context)
This function writes the specified data to the specified address.
enum FLASH_RETURN_STATUS FLASH_NonBlockingRowWrite (flash_adr_t flashAddress, flash_data_t *data, flash_key_t unlockKey, FLASH_CALLBACK callback, void *context)
This function writes the specified data to the specified address.
enum FLASH_RETURN_STATUS FLASH_NonBlockingRead (flash_adr_t flashAddress, size_t count, flash_data_t *data)
This function reads the data from the specified address.
2.11.3.6 source/flash_types.h File Reference
FLASH Driver using dsPIC MCUs.
2.11.3.6.1 Typedefs
typedef void(* FLASH_CALLBACK) (void *)
typedef uint32_t flash_adr_t
typedef uint32_t flash_data_t
typedef uint32_t flash_key_t
2.11.3.6.2 Enumerations
enum FLASH_PANEL { FLASH_PANEL_1 = 0, FLASH_PANEL_2 = 1, FLASH_PANEL_MAX_PANELS }
This enum is be used for the flash panel numbers and maximum flash panels.
enum FLASH_RETURN_STATUS { FLASH_NO_ERROR, FLASH_INVALID_ADDRESS, FLASH_INVALID_DATA, FLASH_WRITE_ERROR, FLASH_READ_ERROR, FLASH_ERASE_ERROR, FLASH_INVALID_CALLBACK_HANDLER, FLASH_OP_BUSY, FLASH_OP_IN_PROGRESS }
This enum is be used to return the status of write, read and erase operation.
2.11.3.6.3 Detailed Description
FLASH Driver using dsPIC MCUs.
flash Generated Driver Types Header File
2.11.3.6.4 Typedef Documentation
flash_adr_t
typedef uint32_t flash_adr_t
FLASH_CALLBACK
typedef void(* FLASH_CALLBACK) (void *)
flash_data_t
typedef uint32_t flash_data_t
flash_key_t
typedef uint32_t flash_key_t