* * $Log: at49bv.c,v $ * Revision 1.3 2006/10/08 16:48:09 haraldkipp * Documentation fixed * * 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. * * *
Definition in file at49bv.c.
Go to the source code of this file.
Defines | |
#define | FLASH_CHIP_BASE 0x10000000 |
Base address of the flash memory chip. | |
#define | FLASH_CONF_SECTOR 0x6000 |
Address offset of the configuration sector. | |
#define | FLASH_CONF_SIZE 512 |
Size of the configuration area. | |
#define | FLASH_ERASE_WAIT 3000 |
#define | FLASH_CHIP_ERASE_WAIT 50000 |
#define | FLASH_WRITE_POLLS 1000 |
#define | FLASH_UNLOCK(base) |
#define | FLASH_COMMAND(base, cmd) |
#define | FLASH_CMD_ERASE 0x80 |
#define | FLASH_CMD_ERASE_CHIP 0x10 |
#define | FLASH_CMD_ERASE_SECTOR 0x30 |
#define | FLASH_CMD_ENTER_ID 0x90 |
#define | FLASH_CMD_EXIT_ID 0xF0 |
#define | FLASH_CMD_PROGRAM 0xA0 |
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 FLASH_CHIP_BASE 0x10000000 |
#define FLASH_CONF_SECTOR 0x6000 |
#define FLASH_CONF_SIZE 512 |
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.
#define FLASH_WRITE_POLLS 1000 |
#define FLASH_UNLOCK | ( | base | ) |
Value:
{ \ base[0x0555] = 0xAA; \ base[0x0AAA] = 0x55; \ }
Definition at line 114 of file at49bv.c.
Referenced by At49bvChipErase(), At49bvInit(), At49bvSectorErase(), and At49bvSectorWrite().
#define FLASH_COMMAND | ( | base, | |||
cmd | ) |
Value:
{ \ base[0x0555] = cmd; \ }
Definition at line 119 of file at49bv.c.
Referenced by At49bvChipErase(), At49bvInit(), At49bvSectorErase(), and At49bvSectorWrite().
#define FLASH_CMD_ERASE 0x80 |
#define FLASH_CMD_ERASE_CHIP 0x10 |
#define FLASH_CMD_ERASE_SECTOR 0x30 |
#define FLASH_CMD_ENTER_ID 0x90 |
#define FLASH_CMD_EXIT_ID 0xF0 |
#define FLASH_CMD_PROGRAM 0xA0 |
typedef unsigned short flashdat_t |
typedef unsigned long flashadr_t |
typedef volatile flashdat_t* flashptr_t |
unsigned long At49bvInit | ( | void | ) |
Definition at line 153 of file at49bv.c.
References FLASH_CMD_ENTER_ID, FLASH_CMD_EXIT_ID, FLASH_COMMAND, and FLASH_UNLOCK.
int At49bvSectorErase | ( | u_int | off | ) |
Erase sector at the specified offset.
Definition at line 171 of file at49bv.c.
References FLASH_CHIP_BASE, FLASH_CMD_ERASE, FLASH_CMD_ERASE_SECTOR, FLASH_COMMAND, FLASH_ERASE_WAIT, and FLASH_UNLOCK.
Referenced by At49bvParamWrite().
int At49bvChipErase | ( | void | ) |
Erase entire flash memory chip.
Definition at line 186 of file at49bv.c.
References FLASH_CHIP_ERASE_WAIT, FLASH_CMD_ERASE, FLASH_CMD_ERASE_CHIP, FLASH_COMMAND, and FLASH_UNLOCK.
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. |
Definition at line 205 of file at49bv.c.
References FLASH_CHIP_BASE, and memcpy().
Referenced by At49bvParamRead(), and At49bvParamWrite().
Write data into flash memory.
The related sector must have been erased before calling this function.
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. |
Definition at line 223 of file at49bv.c.
References FLASH_CHIP_BASE, FLASH_CMD_PROGRAM, FLASH_COMMAND, FLASH_UNLOCK, and FLASH_WRITE_POLLS.
Referenced by At49bvParamWrite().
Load configuration parameters from flash memory.
pos | Start location within configuration sector. | |
data | Points to a buffer that receives the contents. | |
len | Number of bytes to read. |
Definition at line 256 of file at49bv.c.
References At49bvSectorRead(), and FLASH_CONF_SECTOR.
Referenced by NutNvMemLoad().
Store configuration parameters in flash memory.
pos | Start location within configuration sector. | |
data | Points to a buffer that contains the bytes to store. | |
len | Number of bytes to store. |
Definition at line 270 of file at49bv.c.
References At49bvSectorErase(), At49bvSectorRead(), At49bvSectorWrite(), FLASH_CONF_SECTOR, FLASH_CONF_SIZE, free, malloc, memcmp(), and memcpy().
Referenced by NutNvMemSave().