Nut/OS  4.10.3
API Reference
at45db.h File Reference

Dataflash helper routines. More...

#include <sys/types.h>
#include <stdint.h>
Include dependency graph for at45db.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

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

Detailed Description

Dataflash helper routines.

 *
 * $Log$
 * Revision 1.5  2009/01/17 11:26:47  haraldkipp
 * Getting rid of two remaining BSD types in favor of stdint.
 * Replaced 'u_int' by 'unsinged int' and 'uptr_t' by 'uintptr_t'.
 *
 * Revision 1.4  2008/08/11 06:59:59  haraldkipp
 * BSD types replaced by stdint types (feature request #1282721).
 *
 * Revision 1.3  2008/02/15 17:10:44  haraldkipp
 * At45dbPageErase selected the wrong bank. Fixed. Parameter pgn (page number)
 * of At45dbPageWrite() changed from unsigned int to unsigned long.
 * New routines At45dbPages() and At45dbPageSize() allow to determine the
 * chip's layout.
 *
 * 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.
 *
 *
 * 

Definition in file at45db.h.


Function Documentation

int At45dbSendCmd ( int  dd,
uint8_t  op,
uint32_t  parm,
int  len,
CONST void *  tdata,
void *  rdata,
int  datalen 
)

Send DataFlash command.

Parameters:
ddDevice descriptor.
opCommand operation code.
parmCommand parameter.
lenCommand length.
tdataTransmit data.
rdataReceive data buffer.
datalenData length.

Definition at line 304 of file at45db.c.

References At91SpiTransfer2(), _AT45DB_DCB::dcb_cmdbuf, MAX_AT45_CMDLEN, and memset().

Referenced by At45dbPageErase(), At45dbPageRead(), and At45dbPageWrite().

Here is the call graph for this function:

uint8_t At45dbGetStatus ( int  dd)

Definition at line 321 of file at45db.c.

References At91SpiTransfer2(), and DFCMD_READ_STATUS.

Referenced by At45dbInit(), and At45dbWaitReady().

Here is the call graph for this function:

int At45dbWaitReady ( int  dd,
uint32_t  tmo,
int  poll 
)

Wait until flash memory cycle finished.

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

Definition at line 336 of file at45db.c.

References At45dbGetStatus(), and NutSleep().

Referenced by At45dbPageWrite().

Here is the call graph for this function:

int At45dbInit ( unsigned int  spibas,
unsigned int  spipcs 
)

Initialize dataflash at specified interface and chip select.

Parameters:
spibasInterface base address. For ARM MCUs this may be the I/O base address of the hardware SPI.
spipcsDevice chip select.
Returns:
Device descriptor or -1 in case of an error.

Definition at line 360 of file at45db.c.

References _BV, At45dbGetStatus(), At91SpiInit(), At91SpiInitChipSelects(), At91SpiReset(), At91SpiSetModeFlags(), At91SpiSetRate(), _AT45DB_DCB::dcb_devt, _AT45DB_DCB::dcb_spibas, _AT45DB_DCB::dcb_spipcs, _AT45_DEVTAB::devt_pages, MAX_AT45_DEVICES, SPIMF_CAPRISE, SPIMF_MASTER, and SPIMF_SCKIAHI.

Referenced by At45dbParamSize().

Here is the call graph for this function:

int At45dbPageErase ( int  dd,
uint32_t  pgn 
)

Erase sector at the specified offset.

Definition at line 402 of file at45db.c.

References At45dbSendCmd(), _AT45DB_DCB::dcb_devt, _AT45_DEVTAB::devt_offs, and DFCMD_PAGE_ERASE.

Here is the call graph for this function:

int At45dbChipErase ( void  )

Erase entire flash memory chip.

Definition at line 411 of file at45db.c.

int At45dbPageRead ( int  dd,
uint32_t  pgn,
void *  data,
unsigned int  len 
)

Read data from flash memory.

Parameters:
ddDevice descriptor.
pgnPage number to read, starting at 0.
dataPoints to a buffer that receives the data.
lenNumber of bytes to read.
Returns:
0 on success or -1 in case of an error.

Definition at line 426 of file at45db.c.

References At45dbSendCmd(), _AT45DB_DCB::dcb_devt, _AT45_DEVTAB::devt_offs, and DFCMD_CONT_READ.

Referenced by At45dbParamRead(), and At45dbParamWrite().

Here is the call graph for this function:

int At45dbPageWrite ( int  dd,
uint32_t  pgn,
CONST void *  data,
unsigned int  len 
)

Write data into flash memory.

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

Parameters:
ddDevice descriptor.
pgnStart location within the chip, starting at 0.
dataPoints to a buffer that contains the bytes to be written.
lenNumber of bytes to write.
Returns:
0 on success or -1 in case of an error.

Definition at line 444 of file at45db.c.

References AT45_WRITE_POLLS, At45dbSendCmd(), At45dbWaitReady(), _AT45DB_DCB::dcb_devt, _AT45_DEVTAB::devt_offs, DFCMD_BUF1_FLASH, DFCMD_BUF1_WRITE, free(), and malloc().

Referenced by At45dbParamWrite().

Here is the call graph for this function:

uint32_t At45dbPages ( int  dd)

Definition at line 463 of file at45db.c.

References _AT45DB_DCB::dcb_devt, and _AT45_DEVTAB::devt_pages.

unsigned int At45dbPageSize ( int  dd)

Definition at line 468 of file at45db.c.

References _AT45DB_DCB::dcb_devt, and _AT45_DEVTAB::devt_pagsiz.

Referenced by ShowHardwareConfiguration().

int At45dbParamRead ( unsigned int  pos,
void *  data,
unsigned int  len 
)

Load configuration parameters from flash memory.

Parameters:
posStart location within configuration sector.
dataPoints to a buffer that receives the contents.
lenNumber of bytes to read.
Returns:
Always 0.

Definition at line 517 of file at45db.c.

References At45dbPageRead(), At45dbParamPage(), At45dbParamSize(), free(), malloc(), and memcpy().

Referenced by NutNvMemLoad().

Here is the call graph for this function:

int At45dbParamWrite ( unsigned int  pos,
CONST void *  data,
unsigned int  len 
)

Store configuration parameters in flash memory.

Parameters:
posStart location within configuration sector.
dataPoints to a buffer that contains the bytes to store.
lenNumber of bytes to store.
Returns:
0 on success or -1 in case of an error.

Definition at line 543 of file at45db.c.

References At45dbPageRead(), At45dbPageWrite(), At45dbParamPage(), At45dbParamSize(), free(), malloc(), memcmp(), and memcpy().

Referenced by NutNvMemSave().

Here is the call graph for this function: