Library to use 25LCxxx chips
Fork of 25LCxxx_SPI by
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 (SPI *spi, PinName enable, uint32_t bytes, uint32_t pagesize) | |
create the handler class | |
~Ser25LCxxx () | |
destroys the handler, and frees the /CS pin | |
uint8_t * | read (uint32_t startAdr, uint32_t len) |
read a part of the eeproms memory. | |
bool | write (uint32_t startAdr, uint32_t len, const uint8_t *data) |
writes the give buffer into the memory. | |
bool | clearPage (uint32_t pageNum) |
fills the given page with 0xFF | |
void | clearMem () |
fills the while eeprom with 0xFF |
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 35 of file Ser25lcxxx.h.
Constructor & Destructor Documentation
Ser25LCxxx | ( | SPI * | spi, |
PinName | enable, | ||
uint32_t | bytes, | ||
uint32_t | pagesize | ||
) |
create the handler class
- Parameters:
-
spi the SPI port where the eeprom is connected. Must be set to format(8,3), and with a speed matching the one of your device (up to 5MHz should work) enable the pin name for the port where /CS is connected bytes the size of you eeprom in bytes (NOT bits, eg. a 25LC010 has 128 bytes) pagesize the size of a single page, to provide overruns
Definition at line 30 of file Ser25lcxxx.cpp.
~Ser25LCxxx | ( | ) |
destroys the handler, and frees the /CS pin
Definition at line 38 of file Ser25lcxxx.cpp.
Member Function Documentation
void clearMem | ( | ) |
fills the while eeprom with 0xFF
Definition at line 155 of file Ser25lcxxx.cpp.
bool clearPage | ( | uint32_t | pageNum ) |
fills the given page with 0xFF
- Parameters:
-
pageNum the page number to clear
- Returns:
- if the pageNum is out of range
Definition at line 131 of file Ser25lcxxx.cpp.
uint8_t * read | ( | uint32_t | startAdr, |
uint32_t | len | ||
) |
read a part of the eeproms memory.
The buffer will be allocated here, and must be freed by the user
- Parameters:
-
startAdr the adress where to start reading. Doesn't need to match a page boundary len the number of bytes to read (must not exceed the end of memory)
- Returns:
- NULL if the adresses are out of range, the pointer to the data otherwise
Definition at line 42 of file Ser25lcxxx.cpp.
bool write | ( | uint32_t | startAdr, |
uint32_t | len, | ||
const uint8_t * | data | ||
) |
writes the give buffer into the memory.
This function handles dividing the write into pages, and waites until the phyiscal write has finished
- Parameters:
-
startAdr the adress where to start writing. Doesn't need to match a page boundary len the number of bytes to read (must not exceed the end of memory)
- Returns:
- false if the adresses are out of range
Definition at line 75 of file Ser25lcxxx.cpp.
Generated on Tue Aug 9 2022 16:22:07 by 1.7.2