Enhanced EEPROM 25LCxxx driver

Dependents:   eeprom_test

Fork of 25LCxxx_SPI by Hendrik Lipka

Embed: (wiki syntax)

« Back to documentation index

Ser25LCxxx Class Reference

Ser25LCxxx Class Reference

A class to read and write all 25* serial SPI eeprom devices from Microchip (from 25xx010 to 25xx1024). More...

#include <Ser25lcxxx.h>

Public Member Functions

 Ser25LCxxx (PinName sck, PinName si, PinName so, PinName enable, int pagenumber, int pagesize)
 Create the handler class.
 ~Ser25LCxxx ()
 Destroy the handler.
unsigned int read (unsigned int startAdr, unsigned int len, unsigned char *buf)
 Read from the eeprom memory.
unsigned int write (unsigned int startAdr, unsigned int len, const unsigned char *data)
 Writes the give buffer into the eeprom memory.
unsigned int clearPage (unsigned int pageNum)
 Fills the given page with EEPROM_CLEAN_BYTE.
unsigned int clearMem ()
 Fills the whole eeprom with EEPROM_CLEAN_BYTE.
bool isWriteInProgress ()
 Return TRUE if a write is performing.
bool isFullyWritable ()
 Return TRUE if the entire eeprom memory is writable.
bool isHalfWritable ()
 Return TRUE if only the first half of the eeprom memory is writable.
bool isNotWritable ()
 Return TRUE if the eeprom memory is not writable.
void setNotWritable ()
 Set the eeprom memory not writable.
void setFullyWritable ()
 Set the eeprom memory fully writable.
void setHalfWritable ()
 Set only the first half of the eeprom memory as writable.

Detailed Description

A class to read and write all 25* serial SPI eeprom devices from Microchip (from 25xx010 to 25xx1024).

One needs to provide total size and page size, since this cannot be read from the devices, and the page size differs even by constant size (look up the data sheet for your part!)

Definition at line 51 of file Ser25lcxxx.h.


Constructor & Destructor Documentation

Ser25LCxxx ( PinName  sck,
PinName  si,
PinName  so,
PinName  enable,
int  pagenumber,
int  pagesize 
)

Create the handler class.

Parameters:
sckclock pin of the spi where the eeprom is connected
siinput pin of the spi where the eeprom is connected
sooutput pin of the spi where the eeprom is connected
enablethe pin name for the port where /CS is connected
pagenumbernumber of pages
pagesizethe size of each page

Definition at line 30 of file Ser25lcxxx.cpp.

~Ser25LCxxx (  )

Destroy the handler.

Definition at line 71 of file Ser25lcxxx.h.


Member Function Documentation

unsigned int clearMem (  )

Fills the whole eeprom with EEPROM_CLEAN_BYTE.

Returns:
the number of written bytes (it should be the eeprom size)

Definition at line 150 of file Ser25lcxxx.cpp.

unsigned int clearPage ( unsigned int  pageNum )

Fills the given page with EEPROM_CLEAN_BYTE.

Parameters:
pageNumthe page to clear
Returns:
the number of written bytes (it should be the page size)

Definition at line 143 of file Ser25lcxxx.cpp.

bool isFullyWritable (  )

Return TRUE if the entire eeprom memory is writable.

Definition at line 121 of file Ser25lcxxx.h.

bool isHalfWritable (  )

Return TRUE if only the first half of the eeprom memory is writable.

Definition at line 128 of file Ser25lcxxx.h.

bool isNotWritable (  )

Return TRUE if the eeprom memory is not writable.

Definition at line 135 of file Ser25lcxxx.h.

bool isWriteInProgress (  )

Return TRUE if a write is performing.

Definition at line 114 of file Ser25lcxxx.h.

unsigned int read ( unsigned int  startAdr,
unsigned int  len,
unsigned char *  buf 
)

Read from the eeprom memory.

Parameters:
startAdrthe adress where to start reading
lenthe number of bytes to read
bufdestination buffer
Returns:
number of read bytes

Definition at line 41 of file Ser25lcxxx.cpp.

void setFullyWritable (  )

Set the eeprom memory fully writable.

Definition at line 149 of file Ser25lcxxx.h.

void setHalfWritable (  )

Set only the first half of the eeprom memory as writable.

Definition at line 156 of file Ser25lcxxx.h.

void setNotWritable (  )

Set the eeprom memory not writable.

Definition at line 142 of file Ser25lcxxx.h.

unsigned int write ( unsigned int  startAdr,
unsigned int  len,
const unsigned char *  data 
)

Writes the give buffer into the eeprom memory.

Parameters:
startAdrthe eeprom adress where to start writing (it doesn't have to match a page boundary)
lennumber of bytes to write
datadata to write
Returns:
the number of written bytes

Definition at line 79 of file Ser25lcxxx.cpp.