at49bv.c File Reference


Detailed Description

Routines for Atmel AT49 flash memory chips.

 *
 * $Log: at49bv.c,v $
 * Revision 1.2  2006/05/25 09:33:35  haraldkipp
 * Bugfix. At49bvParamWrite() returned an error when flash sector contents
 * was equal to the contents to write.
 *
 * Revision 1.1  2006/04/07 13:51:36  haraldkipp
 * AT49BV flash memory support added. A single sector may be used to
 * store system configurations in case there is no EEPROM available.
 *
 *
 * 


Defines

#define FLASH_CHIP_BASE
 Base address of the flash memory chip.
#define FLASH_CONF_SECTOR
 Address offset of the configuration sector.
#define FLASH_CONF_SIZE
 Size of the configuration area.
#define FLASH_ERASE_WAIT
#define FLASH_CHIP_ERASE_WAIT
#define FLASH_WRITE_POLLS
#define FLASH_UNLOCK(base)
#define FLASH_COMMAND(base, cmd)
#define FLASH_CMD_ERASE
#define FLASH_CMD_ERASE_CHIP
#define FLASH_CMD_ERASE_SECTOR
#define FLASH_CMD_ENTER_ID
#define FLASH_CMD_EXIT_ID
#define FLASH_CMD_PROGRAM

Typedefs

typedef unsigned short flashdat_t
typedef unsigned long flashadr_t
typedef volatile flashdat_t * flashptr_t

Functions

unsigned long At49bvInit (void)
int At49bvSectorErase (u_int off)
 Erase sector at the specified offset.
int At49bvChipErase (void)
 Erase entire flash memory chip.
int At49bvSectorRead (u_int off, void *data, u_int len)
 Read data from flash memory.
int At49bvSectorWrite (u_int off, CONST void *data, u_int len)
 Write data into flash memory.
int At49bvParamRead (u_int pos, void *data, u_int len)
 Load configuration parameters from flash memory.
int At49bvParamWrite (u_int pos, CONST void *data, u_int len)
 Store configuration parameters in flash memory.


Define Documentation

#define FLASH_CONF_SIZE
 

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.


Function Documentation

int At49bvParamRead u_int  pos,
void *  data,
u_int  len
 

Load configuration parameters from flash memory.

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

int At49bvParamWrite u_int  pos,
CONST void *  data,
u_int  len
 

Store configuration parameters in flash memory.

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.

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

int At49bvSectorWrite u_int  off,
CONST void *  data,
u_int  len
 

Write data into flash memory.

The related sector must have been erased before calling this function.

Parameters:
off Start location within the chip, starting at 0.
data Points to a buffer that contains the bytes to be written.
len Number of bytes to write.
Returns:
0 on success or -1 in case of an error.


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