Contiki-NG

The Xmem API module contains functionality to use external flash memories of NOR or NAND type. More...

Functions

void xmem_init (void)
 Initialize the external memory.
 
int xmem_pread (void *buf, int nbytes, unsigned long offset)
 Read a number of bytes from an offset in the external memory. More...
 
int xmem_pwrite (const void *buf, int nbytes, unsigned long offset)
 
int xmem_erase (long nbytes, unsigned long offset)
 Erase a sector in the flash memory. More...
 

Detailed Description

The Xmem API module contains functionality to use external flash memories of NOR or NAND type.

It us typically used as a back-end for the CFS module.

Function Documentation

◆ xmem_erase()

int xmem_erase ( long  nbytes,
unsigned long  offset 
)

Erase a sector in the flash memory.

Parameters
nbytesThe number of bytes to erase.
offsetThe offset in the flash memory at which to start erasing.
Returns
The number of bytes that got erased, or -1 if the operation failed.

Both parameters may have to be a multiple of a value that depends on the particular flash memory used.

Definition at line 128 of file xmem.c.

References addr.

◆ xmem_pread()

int xmem_pread ( void *  buf,
int  nbytes,
unsigned long  offset 
)

Read a number of bytes from an offset in the external memory.

Parameters
bufThe buffer where the read data is stored.
nbytesThe number of bytes to read.
offsetThe offset to read from in the flash memory.
Returns
The number of read bytes, or -1 if the operation failed.

Definition at line 64 of file xmem.c.

◆ xmem_pwrite()

int xmem_pwrite ( const void *  buf,
int  nbytes,
unsigned long  offset 
)
Parameters
bufThe buffer that contains the data to write.
nbytesThe number of bytes to write.
offsetThe offset to write to in the flash memory.
Returns
The number of written bytes, or -1 if the operation failed.

Definition at line 94 of file xmem.c.