Embedded Flash Controller
[AT91 Support]

Collaboration diagram for Embedded Flash Controller:


Detailed Description

Embedded flash controller registers.


Defines

#define FLASH_CHIP_BASE   0x00100000
 Base address of the flash memory chip.
#define FLASH_CONF_SECTOR   0x0003FF00
 Address offset of the configuration sector.
#define FLASH_CONF_SIZE   256
 Size of the configuration area.
#define FLASH_WRITE_WAIT   60000
#define FLASH_ERASE_WAIT   60000
#define FLASH_CHIP_ERASE_WAIT   600000

Typedefs

typedef u_long flashdat_t
typedef unsigned long flashadr_t
typedef volatile flashdat_tflashptr_t

Functions

RAMFUNC int At91EfcCmd (u_int cmd, u_long tmo)
 Execute flash controller command.
int At91EfcSectorRead (u_int off, void *data, u_int len)
 Read data from flash memory.
int At91EfcSectorWrite (u_int off, CONST void *data, u_int len)
 Write data into flash memory.
int At91EfcSectorErase (u_int off)
 Erase sector at the specified offset.
int At91EfcRegionLock (u_int off)
 Lock specified region.
int At91EfcRegionUnlock (u_int off)
 Unlock specified region.
int At91EfcParamRead (u_int pos, void *data, u_int len)
 Load configuration parameters from embedded flash memory.
int At91EfcParamWrite (u_int pos, CONST void *data, u_int len)
 Store configuration parameters in embedded flash memory.


Define Documentation

#define FLASH_CHIP_BASE   0x00100000

Base address of the flash memory chip.

Definition at line 67 of file at91_efc.c.

Referenced by At49bvSectorErase(), At49bvSectorRead(), At49bvSectorWrite(), At91EfcSectorRead(), and At91EfcSectorWrite().

#define FLASH_CONF_SECTOR   0x0003FF00

Address offset of the configuration sector.

Definition at line 73 of file at91_efc.c.

Referenced by At49bvParamRead(), At49bvParamWrite(), At91EfcParamRead(), and At91EfcParamWrite().

#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.

Definition at line 86 of file at91_efc.c.

Referenced by At49bvParamWrite(), and At91EfcParamWrite().

#define FLASH_WRITE_WAIT   60000

Definition at line 90 of file at91_efc.c.

Referenced by At91EfcRegionLock(), At91EfcRegionUnlock(), and At91EfcSectorWrite().

#define FLASH_ERASE_WAIT   60000

Definition at line 94 of file at91_efc.c.

Referenced by At49bvSectorErase().

#define FLASH_CHIP_ERASE_WAIT   600000

Definition at line 98 of file at91_efc.c.

Referenced by At49bvChipErase().


Typedef Documentation

typedef u_long flashdat_t

Definition at line 102 of file at91_efc.c.

typedef unsigned long flashadr_t

Definition at line 103 of file at91_efc.c.

typedef volatile flashdat_t* flashptr_t

Definition at line 104 of file at91_efc.c.


Function Documentation

RAMFUNC int At91EfcCmd ( u_int  cmd,
u_long  tmo 
)

Execute flash controller command.

This routine must not be located in internal flash memory.

Definition at line 112 of file at91_efc.c.

References inr, MC_FCR, MC_FRDY, MC_FSR, MC_KEY, MC_LOCKE, MC_PROGE, NutEnterCritical, NutExitCritical, and outr.

Referenced by At91EfcRegionLock(), At91EfcRegionUnlock(), and At91EfcSectorWrite().

int At91EfcSectorRead ( u_int  off,
void *  data,
u_int  len 
)

Read data from flash memory.

Parameters:
off Start location within the chip, starting at 0.
data Points to a buffer that receives the data.
len Number of bytes to read.
Returns:
Always 0.

Definition at line 157 of file at91_efc.c.

References FLASH_CHIP_BASE, and memcpy().

Referenced by At91EfcParamRead(), and At91EfcParamWrite().

int At91EfcSectorWrite ( u_int  off,
CONST void *  data,
u_int  len 
)

Write data into flash memory.

The related sector will be automatically erased before writing.

Parameters:
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.
Returns:
0 on success or -1 in case of an error.

Definition at line 176 of file at91_efc.c.

References At91EfcCmd(), FLASH_CHIP_BASE, FLASH_WRITE_WAIT, inr, MC_FCMD_WP, MC_FMR, MC_NEBP, MC_PAGEN_MASK, and outr.

Referenced by At91EfcParamWrite(), and At91EfcSectorErase().

int At91EfcSectorErase ( u_int  off  ) 

Erase sector at the specified offset.

Definition at line 210 of file at91_efc.c.

References At91EfcSectorWrite().

int At91EfcRegionLock ( u_int  off  ) 

Lock specified region.

Parameters:
off Location within the region to be locked.
Returns:
0 on success or -1 in case of an error.

Definition at line 222 of file at91_efc.c.

References At91EfcCmd(), FLASH_WRITE_WAIT, MC_FCMD_SLB, and MC_PAGEN_MASK.

Referenced by At91EfcParamWrite().

int At91EfcRegionUnlock ( u_int  off  ) 

Unlock specified region.

Parameters:
off Location within the region to be unlocked.
Returns:
0 on success or -1 in case of an error.

Definition at line 234 of file at91_efc.c.

References At91EfcCmd(), FLASH_WRITE_WAIT, MC_FCMD_CLB, and MC_PAGEN_MASK.

Referenced by At91EfcParamWrite().

int At91EfcParamRead ( u_int  pos,
void *  data,
u_int  len 
)

Load configuration parameters from embedded flash memory.

Applications should call NutNvMemLoad().

Parameters:
pos Start location within configuration sector.
data Points to a buffer that receives the contents.
len Number of bytes to read.
Returns:
Always 0.

Definition at line 250 of file at91_efc.c.

References At91EfcSectorRead(), and FLASH_CONF_SECTOR.

Referenced by NutNvMemLoad().

int At91EfcParamWrite ( u_int  pos,
CONST void *  data,
u_int  len 
)

Store configuration parameters in embedded flash memory.

Applications should call NutNvMemSave().

The region that contains the configuration sector will be automatically locked.

Parameters:
pos Start location within configuration sector.
data Points to a buffer that contains the bytes to store.
len Number of bytes to store.
Returns:
0 on success or -1 in case of an error.

Definition at line 269 of file at91_efc.c.

References At91EfcRegionLock(), At91EfcRegionUnlock(), At91EfcSectorRead(), At91EfcSectorWrite(), FLASH_CONF_SECTOR, FLASH_CONF_SIZE, free, malloc, memcmp(), and memcpy().

Referenced by NutNvMemSave().


© 2000-2007 by egnite Software GmbH - visit http://www.ethernut.de/