|
px-fwlib 0.10.0
Cross-platform embedded library and documentation for 8/16/32-bit microcontrollers generated with Doxygen 1.9.2
|
Driver that communicates with an On Semiconductor CAT25M EEPROM using SPI.
File(s):
Reference:
Macros | |
| #define | PX_CAT25M_EEPROM_SIZE_BYTES (PX_CAT25M_PAGES * PX_CAT25M_PAGE_SIZE) |
| EEPROM size (in bytes) More... | |
| #define | PX_CAT25M_ADR_MAX (PX_CAT25M_EEPROM_SIZE_BYTES - 1) |
| Maximum adress. More... | |
| #define | PX_CAT25M_MAX_SPI_CLOCK_HZ 10000000 |
| Maximum SPI Clock rate. More... | |
| #define | PX_CAT25M_SPI_MODE PX_SPI_MODE0 |
| SPI Clock / Data phase. More... | |
| #define | PX_CAT25M_SPI_DATA_ORDER PX_SPI_DATA_ORDER_MSB |
| SPI Data order. More... | |
| #define | PX_CAT25M_CFG_DEVICE PX_CAT25M01 |
| Specify device. More... | |
Typedefs | |
| typedef uint32_t | px_cat25m_adr_t |
| Address size. More... | |
Functions | |
| void | px_cat25m_init (px_spi_handle_t *handle) |
| Initialise driver. More... | |
| void | px_cat25m_rd (void *buf, px_cat25m_adr_t adr, size_t nr_of_bytes) |
| Read data from EEPROM. More... | |
| void | px_cat25m_rd_page (void *buf, uint16_t page) |
| Read a page from EEPROM. More... | |
| void | px_cat25m_rd_page_offset (void *buf, uint16_t page, uint8_t start_byte_in_page, size_t nr_of_bytes) |
| Partial read of data in a page of EEPROM. More... | |
| void | px_cat25m_wr_page (const void *buf, uint16_t page) |
| Write a page from EEPROM. More... | |
| void | px_cat25m_wr_page_offset (const void *buf, uint16_t page, uint8_t start_byte_in_page, size_t nr_of_bytes) |
| Partial write of data in a page of EEPROM. More... | |
| bool | px_cat25m_ready (void) |
| Check if EEPROM is ready for the next read or write access. More... | |
| uint8_t | px_cat25m_status_rd (void) |
| Read the status register of the EEPROM. More... | |
| void | px_cat25m_status_wr (uint8_t status) |
| Write to the status register of the EEPROM. More... | |
| void | px_cat25m_wr_en (void) |
| Enable writing. More... | |
| void | px_cat25m_wr_dis (void) |
| Disable writing. More... | |
List CAT25M devices | |
| #define | PX_CAT25M01 0 |
| #define | PX_CAT25M02 1 |
Status register | |
| #define | PX_CAT25M_STATUS_WPEN 7 |
| Write Protect Enable. More... | |
| #define | PX_CAT25M_STATUS_IPL 6 |
| Identification Page Latch. More... | |
| #define | PX_CAT25M_STATUS_LIP 4 |
| Lock Identification Page. More... | |
| #define | PX_CAT25M_STATUS_BP1 3 |
| Block Protect bit 1. More... | |
| #define | PX_CAT25M_STATUS_BP0 2 |
| Block Protect bit 0. More... | |
| #define | PX_CAT25M_STATUS_WEL 1 |
| Write Enable Latch. More... | |
| #define | PX_CAT25M_STATUS_RDY 0 |
| Ready (inverted) More... | |
| #define PX_CAT25M_EEPROM_SIZE_BYTES (PX_CAT25M_PAGES * PX_CAT25M_PAGE_SIZE) |
EEPROM size (in bytes)
Definition at line 71 of file px_cat25m.h.
| #define PX_CAT25M_ADR_MAX (PX_CAT25M_EEPROM_SIZE_BYTES - 1) |
Maximum adress.
Definition at line 74 of file px_cat25m.h.
| #define PX_CAT25M_STATUS_WPEN 7 |
Write Protect Enable.
Definition at line 78 of file px_cat25m.h.
| #define PX_CAT25M_STATUS_IPL 6 |
Identification Page Latch.
Definition at line 79 of file px_cat25m.h.
| #define PX_CAT25M_STATUS_LIP 4 |
Lock Identification Page.
Definition at line 80 of file px_cat25m.h.
| #define PX_CAT25M_STATUS_BP1 3 |
Block Protect bit 1.
Definition at line 81 of file px_cat25m.h.
| #define PX_CAT25M_STATUS_BP0 2 |
Block Protect bit 0.
Definition at line 82 of file px_cat25m.h.
| #define PX_CAT25M_STATUS_WEL 1 |
Write Enable Latch.
Definition at line 83 of file px_cat25m.h.
| #define PX_CAT25M_STATUS_RDY 0 |
Ready (inverted)
Definition at line 84 of file px_cat25m.h.
| #define PX_CAT25M_MAX_SPI_CLOCK_HZ 10000000 |
Maximum SPI Clock rate.
Definition at line 88 of file px_cat25m.h.
| #define PX_CAT25M_SPI_MODE PX_SPI_MODE0 |
SPI Clock / Data phase.
Definition at line 90 of file px_cat25m.h.
| #define PX_CAT25M_SPI_DATA_ORDER PX_SPI_DATA_ORDER_MSB |
SPI Data order.
Definition at line 92 of file px_cat25m.h.
| #define PX_CAT25M_CFG_DEVICE PX_CAT25M01 |
Specify device.
Definition at line 34 of file px_cat25m_cfg_template.h.
| typedef uint32_t px_cat25m_adr_t |
Address size.
Definition at line 96 of file px_cat25m.h.
| void px_cat25m_init | ( | px_spi_handle_t * | handle | ) |
Initialise driver.
| handle | SPI handle to use for SPI slave device |
Definition at line 48 of file px_cat25m.c.
| void px_cat25m_rd | ( | void * | buf, |
| px_cat25m_adr_t | adr, | ||
| size_t | nr_of_bytes | ||
| ) |
Read data from EEPROM.
This function reads data from EEPROM and stores it in the specified buffer.
| [out] | buf | Buffer to store read data |
| [in] | adr | 0 to PX_CAT25M_ADR_MAX |
| [in] | nr_of_bytes | Number of bytes to read |
Definition at line 56 of file px_cat25m.c.
| void px_cat25m_rd_page | ( | void * | buf, |
| uint16_t | page | ||
| ) |
Read a page from EEPROM.
This function reads a page of data from EEPROM and stores it in the specified buffer. The buffer must be at least PX_CAT25M_PAGE_SIZE bytes in size to accomodate a full page.
The EEPROM has PX_CAT25M_PAGES pages.
| [out] | buf | Buffer to store read data |
| [in] | page | 0 to (PX_CAT25M_PAGES - 1) |
Definition at line 78 of file px_cat25m.c.
| void px_cat25m_rd_page_offset | ( | void * | buf, |
| uint16_t | page, | ||
| uint8_t | start_byte_in_page, | ||
| size_t | nr_of_bytes | ||
| ) |
Partial read of data in a page of EEPROM.
This function reads part of a page of data from EEPROM and stores it in the specified buffer. The buffer must be at least nr_of_bytes in size to the read data.
Only read up to the end of the specified page. If the page boundary is exceeded, the index will wrap to the start of the page, i.e. only the content of the specified page will be read.
| [out] | buf | Buffer to store read data |
| [in] | page | 0 to (PX_CAT25M_PAGES - 1) |
| [in] | start_byte_in_page | Index of first byte to read (0 to PX_CAT25M_PAGE_SIZE - 1) |
| [in] | nr_of_bytes | Number of bytes to read |
Definition at line 96 of file px_cat25m.c.
| void px_cat25m_wr_page | ( | const void * | buf, |
| uint16_t | page | ||
| ) |
Write a page from EEPROM.
This function writes a page of data to EEPROM using the specified buffer as the source. The buffer must contain at least PX_CAT25M_PAGE_SIZE bytes of data.
The EEPROM has PX_CAT25M_PAGES pages.
| [in] | buf | Buffer containing data to be written |
| [in] | page | 0 to (PX_CAT25M_PAGES - 1) |
Definition at line 116 of file px_cat25m.c.
| void px_cat25m_wr_page_offset | ( | const void * | buf, |
| uint16_t | page, | ||
| uint8_t | start_byte_in_page, | ||
| size_t | nr_of_bytes | ||
| ) |
Partial write of data in a page of EEPROM.
This function writes a part of a page of data to EEPROM using the specified buffer as source. The buffer must contain at least nr_of_bytes of data.
Only write up to the end of the specified page. If the page boundary is exceeded, the index will wrap to the start of the page, i.e. only the content of the specified page will be written.
| [in] | buf | Buffer containing data to be written |
| [in] | page | 0 to (PX_CAT25M_PAGES - 1) |
| [in] | start_byte_in_page | Index of first byte to write (0 to PX_CAT25M_PAGE_SIZE - 1) |
| [in] | nr_of_bytes | Number of bytes to write |
Definition at line 138 of file px_cat25m.c.
| bool px_cat25m_ready | ( | void | ) |
Check if EEPROM is ready for the next read or write access.
When data is written to EEPROM, the microcontroller must wait until the operation is finished, before the next one is attempted. This function allows the microcontroller to do something else while waiting for the operation to finish.
| true | EEPROM is ready for next read or write access. |
| false | EEPROM is busy writing. |
Definition at line 162 of file px_cat25m.c.
| uint8_t px_cat25m_status_rd | ( | void | ) |
Read the status register of the EEPROM.
The status register contains flags (e.g. PX_CAT25M_STATUS_RDY). This function can be used to check that a valid and working EEPROM device is connected.
Definition at line 174 of file px_cat25m.c.
| void px_cat25m_status_wr | ( | uint8_t | status | ) |
Write to the status register of the EEPROM.
| status | Value to write to the status register |
Definition at line 187 of file px_cat25m.c.
| void px_cat25m_wr_en | ( | void | ) |
Enable writing.
Definition at line 197 of file px_cat25m.c.
| void px_cat25m_wr_dis | ( | void | ) |
Disable writing.
Definition at line 206 of file px_cat25m.c.