RTEMS  5.1
Macros | Functions
flashd.c File Reference
#include "chip.h"
#include <string.h>
#include <assert.h>

Macros

#define GPNVM_NUM_MAX   9
 

Functions

void FLASHD_Initialize (uint32_t dwMCk, uint32_t dwUseIAP)
 Initializes the flash driver. More...
 
uint32_t FLASHD_Erase (uint32_t dwAddress)
 Erases the entire flash. More...
 
uint32_t FLASHD_EraseSector (uint32_t dwAddress)
 Erases flash by sector. More...
 
uint32_t FLASHD_ErasePages (uint32_t dwAddress, uint32_t dwPageNum)
 Erases flash by pages. More...
 
uint32_t FLASHD_Write (uint32_t dwAddress, const void *pvBuffer, uint32_t dwSize)
 Writes a data buffer in the internal flash. More...
 
uint32_t FLASHD_Lock (uint32_t start, uint32_t end, uint32_t *pActualStart, uint32_t *pActualEnd)
 Locks all the regions in the given address range. The actual lock range is reported through two output parameters. More...
 
uint32_t FLASHD_Unlock (uint32_t start, uint32_t end, uint32_t *pActualStart, uint32_t *pActualEnd)
 Unlocks all the regions in the given address range. The actual unlock range is reported through two output parameters. More...
 
uint32_t FLASHD_IsLocked (uint32_t start, uint32_t end)
 Returns the number of locked regions inside the given address range. More...
 
uint32_t FLASHD_IsGPNVMSet (uint8_t ucGPNVM)
 Check if the given GPNVM bit is set or not. More...
 
uint32_t FLASHD_SetGPNVM (uint8_t ucGPNVM)
 Sets the selected GPNVM bit. More...
 
uint32_t FLASHD_ClearGPNVM (uint8_t ucGPNVM)
 Clears the selected GPNVM bit. More...
 
 __attribute__ ((section(".ramfunc")))
 Read the unique ID. More...
 

Detailed Description

The flash driver provides the unified interface for flash program operations.

Function Documentation

◆ __attribute__()

__attribute__ ( (section(".ramfunc"))  )

Read the unique ID.

Parameters
pdwUniqueIDpointer on a 4bytes char containing the unique ID value.
Returns
0 if successful; otherwise returns an error code.

◆ FLASHD_ClearGPNVM()

uint32_t FLASHD_ClearGPNVM ( uint8_t  ucGPNVM)

Clears the selected GPNVM bit.

Parameters
gpnvmGPNVM bit index.
Returns
0 if successful; otherwise returns an error code.

◆ FLASHD_Erase()

uint32_t FLASHD_Erase ( uint32_t  dwAddress)

Erases the entire flash.

Parameters
dwAddressFlash start address.
Returns
0 if successful; otherwise returns an error code.

◆ FLASHD_ErasePages()

uint32_t FLASHD_ErasePages ( uint32_t  dwAddress,
uint32_t  dwPageNum 
)

Erases flash by pages.

Parameters
dwAddressStart address of be erased pages.
dwPageNumNumber of pages to be erased with EPA command (4, 8, 16, 32)
Returns
0 if successful; otherwise returns an error code.

◆ FLASHD_EraseSector()

uint32_t FLASHD_EraseSector ( uint32_t  dwAddress)

Erases flash by sector.

Parameters
dwAddressStart address of be erased sector.
Returns
0 if successful; otherwise returns an error code.

◆ FLASHD_Initialize()

void FLASHD_Initialize ( uint32_t  dwMCk,
uint32_t  dwUseIAP 
)

Initializes the flash driver.

Parameters
dwMCkMaster clock frequency in Hz.
dwUseIAP0: use EEFC controller interface, 1: use IAP interface. dwUseIAP should be set to 1 when running out of flash.

◆ FLASHD_IsGPNVMSet()

uint32_t FLASHD_IsGPNVMSet ( uint8_t  ucGPNVM)

Check if the given GPNVM bit is set or not.

Parameters
gpnvmGPNVM bit index.
Returns
1 if the given GPNVM bit is currently set; otherwise returns 0.

◆ FLASHD_IsLocked()

uint32_t FLASHD_IsLocked ( uint32_t  start,
uint32_t  end 
)

Returns the number of locked regions inside the given address range.

Parameters
startStart address of range
endEnd address of range.

◆ FLASHD_Lock()

uint32_t FLASHD_Lock ( uint32_t  start,
uint32_t  end,
uint32_t *  pActualStart,
uint32_t *  pActualEnd 
)

Locks all the regions in the given address range. The actual lock range is reported through two output parameters.

Parameters
startStart address of lock range.
endEnd address of lock range.
pActualStartStart address of the actual lock range (optional).
pActualEndEnd address of the actual lock range (optional).
Returns
0 if successful, otherwise returns an error code.

◆ FLASHD_SetGPNVM()

uint32_t FLASHD_SetGPNVM ( uint8_t  ucGPNVM)

Sets the selected GPNVM bit.

Parameters
gpnvmGPNVM bit index.
Returns
0 if successful; otherwise returns an error code.

◆ FLASHD_Unlock()

uint32_t FLASHD_Unlock ( uint32_t  start,
uint32_t  end,
uint32_t *  pActualStart,
uint32_t *  pActualEnd 
)

Unlocks all the regions in the given address range. The actual unlock range is reported through two output parameters.

Parameters
startStart address of unlock range.
endEnd address of unlock range.
pActualStartStart address of the actual unlock range (optional).
pActualEndEnd address of the actual unlock range (optional).
Returns
0 if successful, otherwise returns an error code.

◆ FLASHD_Write()

uint32_t FLASHD_Write ( uint32_t  dwAddress,
const void *  pvBuffer,
uint32_t  dwSize 
)

Writes a data buffer in the internal flash.

Note
This function works in polling mode, and thus only returns when the data has been effectively written.
Parameters
addressWrite address.
pBufferData buffer.
sizeSize of data buffer in bytes.
Returns
0 if successful, otherwise returns an error code.