Embedded flash controller registers. More...
Defines | |
#define | EFC_CHIP_BASE 0x00100000 |
Base address of the flash memory chip. | |
#define | EFC_CHIP_SIZE 0x00040000 |
Size handled by each controller. | |
#define | FLASH_CONF_SECTOR 0x0003FF00 |
Address offset of the configuration sector. | |
#define | FLASH_CONF_SIZE 256 |
Size of the configuration area. | |
#define | EFC_WRITE_WAIT 60000 |
#define | EFC_ERASE_WAIT 60000 |
#define | EFC_CHIP_ERASE_WAIT 600000 |
Typedefs | |
typedef uint32_t | flashdat_t |
typedef unsigned long | flashadr_t |
typedef volatile flashdat_t * | flashptr_t |
Functions | |
RAMFUNC int | At91EfcCmdEx (int fci, unsigned int cmd, uint32_t tmo) |
Execute flash controller command. | |
RAMFUNC int | At91EfcCmd (unsigned int cmd, uint32_t tmo) |
Execute flash controller command. | |
int | At91EfcSectorRead (unsigned int off, void *data, unsigned int len) |
Read data from flash memory. | |
int | At91EfcSectorWrite (unsigned int off, const void *data, unsigned int len) |
Write data into flash memory. | |
int | At91EfcSectorErase (unsigned int off) |
Erase sector at the specified offset. | |
int | At91EfcRegionLock (unsigned int off) |
Lock specified region. | |
int | At91EfcRegionUnlock (unsigned int off) |
Unlock specified region. | |
int | At91EfcParamRead (unsigned int pos, void *data, unsigned int len) |
Load configuration parameters from embedded flash memory. | |
int | At91EfcParamWrite (unsigned int pos, const void *data, unsigned int len) |
Store configuration parameters in embedded flash memory. |
Embedded flash controller registers.
#define EFC_CHIP_BASE 0x00100000 |
Base address of the flash memory chip.
Referenced by At91EfcSectorRead(), and At91EfcSectorWrite().
#define EFC_CHIP_SIZE 0x00040000 |
Size handled by each controller.
Referenced by At91EfcRegionLock(), At91EfcRegionUnlock(), and At91EfcSectorWrite().
#define FLASH_CONF_SECTOR 0x0003FF00 |
Address offset of the configuration sector.
Although this is a configurable item, we try to determine a default value for some of the most widely used CPUs.
Referenced by At91EfcParamRead(), At91EfcParamWrite(), FLASH_EraseAllPages(), and ShowHardwareConfiguration().
#define FLASH_CONF_SIZE 256 |
Size of the configuration area.
During write operations a buffer with this size is allocated from heap and may cause memory problems with large sectors. Thus, this value may be less than the size of the configuration sector, in which case the rest of the sector is unused.
Currently only 1 sector can be used for system configurations.
Referenced by At91EfcParamWrite(), FLASH_EraseAllPages(), and ShowHardwareConfiguration().
#define EFC_WRITE_WAIT 60000 |
Referenced by At91EfcRegionLock(), At91EfcRegionUnlock(), and At91EfcSectorWrite().
#define EFC_ERASE_WAIT 60000 |
#define EFC_CHIP_ERASE_WAIT 600000 |
typedef uint32_t flashdat_t |
typedef unsigned long flashadr_t |
typedef volatile flashdat_t* flashptr_t |
RAMFUNC int At91EfcCmdEx | ( | int | fci, |
unsigned int | cmd, | ||
uint32_t | tmo | ||
) |
Execute flash controller command.
This routine must not be located in internal flash memory.
References inr, MC_FCR_EFC0, MC_FCR_EFC1, MC_FRDY, MC_FSR_EFC0, MC_FSR_EFC1, MC_KEY, MC_LOCKE, MC_PROGE, NutEnterCritical, NutExitCritical, outr, and rc.
Referenced by At91EfcCmd(), and At91EfcSectorWrite().
RAMFUNC int At91EfcCmd | ( | unsigned int | cmd, |
uint32_t | tmo | ||
) |
Execute flash controller command.
This routine must not be located in internal flash memory.
References At91EfcCmdEx().
Referenced by At91EfcRegionLock(), At91EfcRegionUnlock(), and At91EfcSectorWrite().
int At91EfcSectorRead | ( | unsigned int | off, |
void * | data, | ||
unsigned int | len | ||
) |
Read data from flash memory.
off | Start location within the chip, starting at 0. |
data | Points to a buffer that receives the data. |
len | Number of bytes to read. |
References EFC_CHIP_BASE, and memcpy().
Referenced by At91EfcParamRead(), and At91EfcParamWrite().
int At91EfcSectorWrite | ( | unsigned int | off, |
const void * | data, | ||
unsigned int | len | ||
) |
Write data into flash memory.
The related sector will be automatically erased before writing.
off | Start location within the chip, starting at 0. |
data | Points to a buffer that contains the bytes to be written. If this is a NULL pointer, then the sector will be reased. |
len | Number of bytes to write, 1 full sector max. |
References At91EfcCmd(), At91EfcCmdEx(), EFC_CHIP_BASE, EFC_CHIP_SIZE, EFC_WRITE_WAIT, inr, MC_FCMD_WP, MC_FMR, MC_FMR_EFC1, MC_NEBP, MC_PAGEN_MASK, outr, and rc.
Referenced by At91EfcParamWrite(), and At91EfcSectorErase().
int At91EfcSectorErase | ( | unsigned int | off | ) |
Erase sector at the specified offset.
References At91EfcSectorWrite(), and NULL.
int At91EfcRegionLock | ( | unsigned int | off | ) |
Lock specified region.
off | Location within the region to be locked. |
References At91EfcCmd(), EFC_CHIP_SIZE, EFC_WRITE_WAIT, MC_FCMD_SLB, and MC_PAGEN_MASK.
Referenced by At91EfcParamWrite().
int At91EfcRegionUnlock | ( | unsigned int | off | ) |
Unlock specified region.
off | Location within the region to be unlocked. |
References At91EfcCmd(), EFC_CHIP_SIZE, EFC_WRITE_WAIT, MC_FCMD_CLB, and MC_PAGEN_MASK.
Referenced by At91EfcParamWrite().
int At91EfcParamRead | ( | unsigned int | pos, |
void * | data, | ||
unsigned int | len | ||
) |
Load configuration parameters from embedded flash memory.
Applications should call NutNvMemLoad().
pos | Start location within configuration sector. |
data | Points to a buffer that receives the contents. |
len | Number of bytes to read. |
References At91EfcSectorRead(), and FLASH_CONF_SECTOR.
Referenced by NutNvMemLoad().
int At91EfcParamWrite | ( | unsigned int | pos, |
const void * | data, | ||
unsigned int | len | ||
) |
Store configuration parameters in embedded flash memory.
Applications should call NutNvMemSave().
The region that contains the configuration sector will be automatically locked.
pos | Start location within configuration sector. |
data | Points to a buffer that contains the bytes to store. |
len | Number of bytes to store. |
References At91EfcRegionLock(), At91EfcRegionUnlock(), At91EfcSectorRead(), At91EfcSectorWrite(), FLASH_CONF_SECTOR, FLASH_CONF_SIZE, free(), malloc(), memcmp(), memcpy(), NULL, and rc.
Referenced by NutNvMemSave().