Main Page | Modules | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages | Examples

at45db.c File Reference


Detailed Description

Routines for Atmel AT45 serial dataflash memory chips.

 *
 * $Log: at45db.c,v $
 * Revision 1.2  2006/10/08 16:48:09  haraldkipp
 * Documentation fixed
 *
 * Revision 1.1  2006/09/29 12:41:55  haraldkipp
 * Added support for AT45 serial DataFlash memory chips. Currently limited
 * to AT91 builds.
 *
 *
 * 


Defines

#define MAX_AT45_DEVICES   1
#define MAX_AT45_CMDLEN   8
#define AT45_CONF_DFSPI   SPI0_BASE
#define AT45_CONF_DFPCS   1
#define AT45_ERASE_WAIT   3000
#define AT45_CHIP_ERASE_WAIT   50000
#define AT45_WRITE_POLLS   1000
#define DFCMD_READ_PAGE   0xD2
#define DFCMD_READ_STATUS   0xD7
#define DFCMD_CONT_READ   0xE8
#define DFCMD_PAGE_ERASE   0x81
#define DFCMD_BUF1_WRITE   0x84
#define DFCMD_BUF1_FLASH   0x83

Typedefs

typedef _AT45_DEVTAB AT45_DEVTAB
 Known device type entry.
typedef _AT45DB_DCB AT45DB_DCB
 Active device entry.

Functions

int At45dbSendCmd (int dd, u_char op, u_long parm, int len, CONST void *tdata, void *rdata, int datalen)
u_char At45dbGetStatus (int dd)
int At45dbWaitReady (int dd, u_long tmo, int poll)
 Wait until flash memory cycle finished.
int At45dbInit (u_int spibas, u_int spipcs)
 Initialize dataflash at specified interface and chip select.
int At45dbPageErase (int dd, u_int pgn)
 Erase sector at the specified offset.
int At45dbChipErase (void)
 Erase entire flash memory chip.
int At45dbPageRead (int dd, u_long pgn, void *data, u_int len)
 Read data from flash memory.
int At45dbPageWrite (int dd, u_int pgn, CONST void *data, u_int len)
 Write data into flash memory.
u_long At45dbParamPage (void)
int At45dbParamSize (void)
int At45dbParamRead (u_int pos, void *data, u_int len)
 Load configuration parameters from flash memory.
int At45dbParamWrite (u_int pos, CONST void *data, u_int len)
 Store configuration parameters in flash memory.

Variables

AT45_DEVTAB at45_devt []
 Table of known Dataflash types.


Function Documentation

int At45dbWaitReady int  dd,
u_long  tmo,
int  poll
 

Wait until flash memory cycle finished.

Returns:
0 on success or -1 in case of an error.

int At45dbPageRead int  dd,
u_long  pgn,
void *  data,
u_int  len
 

Read data from flash memory.

Parameters:
dd Device descriptor.
pgn Page number to read, 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 At45dbPageWrite int  dd,
u_int  pgn,
CONST void *  data,
u_int  len
 

Write data into flash memory.

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

Parameters:
dd Device descriptor.
pgn 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.

int At45dbParamRead u_int  pos,
void *  data,
u_int  len
 

Load configuration parameters from flash memory.

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.

int At45dbParamWrite 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.


Variable Documentation

AT45_DEVTAB at45_devt[]
 

Initial value:

 {
    {512, 264, 9, 0x3C, 0x0C},  
    {1025, 264, 9, 0x3C, 0x14}, 
    {2048, 264, 9, 0x3C, 0x1C}, 
    {4096, 264, 9, 0x3C, 0x24}, 
    {4096, 528, 10, 0x3C, 0x2C},        
    {8192, 528, 10, 0x3C, 0x34},        
    {8192, 1056, 11, 0x38, 0x38},       
    {0, 0, 0, 0, 0}             
}
Table of known Dataflash types.


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