27#define PX_CAT25M_CMD_WREN 0x06
28#define PX_CAT25M_CMD_WRDI 0x04
29#define PX_CAT25M_CMD_RDSR 0x05
30#define PX_CAT25M_CMD_WRSR 0x01
31#define PX_CAT25M_CMD_READ 0x03
32#define PX_CAT25M_CMD_WRITE 0x02
40static bool px_cat25m_ready_flag;
51 px_cat25m_ready_flag =
true;
53 px_cat25m_spi_handle = handle;
59 uint8_t *bufffer_u8 = (uint8_t *)buf;
69 spi_data[0] = PX_CAT25M_CMD_READ;
81 uint8_t * bufffer_u8 = (uint8_t *)buf;
87 spi_data[0] = PX_CAT25M_CMD_READ;
98 uint8_t start_byte_in_page,
101 uint8_t * bufffer_u8 = (uint8_t *)buf;
107 spi_data[0] = PX_CAT25M_CMD_READ;
110 spi_data[3] = start_byte_in_page;
119 uint8_t * bufffer_u8 = (uint8_t *)buf;
127 spi_data[0] = PX_CAT25M_CMD_WRITE;
135 px_cat25m_ready_flag =
false;
140 uint8_t start_byte_in_page,
143 uint8_t * bufffer_u8 = (uint8_t *)buf;
151 spi_data[0] = PX_CAT25M_CMD_WRITE;
154 spi_data[3] = start_byte_in_page;
159 px_cat25m_ready_flag =
false;
179 spi_data[0] = PX_CAT25M_CMD_RDSR;
192 spi_data[0] = PX_CAT25M_CMD_WRSR;
193 spi_data[1] = status;
202 spi_data[0] = PX_CAT25M_CMD_WREN;
211 spi_data[0] = PX_CAT25M_CMD_WRDI;
void px_cat25m_rd_page(void *buf, uint16_t page)
Read a page from EEPROM.
void px_cat25m_wr_page(const void *buf, uint16_t page)
Write a page from EEPROM.
bool px_cat25m_ready(void)
Check if EEPROM is ready for the next read or write access.
void px_cat25m_rd(void *buf, px_cat25m_adr_t adr, size_t nr_of_bytes)
Read data from EEPROM.
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.
uint8_t px_cat25m_status_rd(void)
Read the status register of the EEPROM.
#define PX_CAT25M_STATUS_RDY
Ready (inverted)
void px_cat25m_wr_en(void)
Enable writing.
uint32_t px_cat25m_adr_t
Address size.
void px_cat25m_status_wr(uint8_t status)
Write to the status register of the EEPROM.
void px_cat25m_wr_dis(void)
Disable writing.
void px_cat25m_init(px_spi_handle_t *handle)
Initialise driver.
#define PX_CAT25M_ADR_MAX
Maximum adress.
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.
#define PX_U16_HI8(data)
Extract the high 8 bits of a 16-bit value (Most Significant Byte)
#define PX_U32_LO8(data)
Extract the low 8 bits (bits 7..0) of a 32-bit value.
#define PX_U32_MH8(data)
Extract the middle high 8 bits (bits 23..16) of a 32-bit value.
#define PX_U32_ML8(data)
Extract the middle low 8 bits (bits 15..8) of a 32-bit value.
#define PX_U16_LO8(data)
Extract the low 8 bits of a 16-bit value (Least Significant Byte)
#define PX_SPI_FLAG_START_AND_STOP
Begin and finish SPI transaction.
#define PX_SPI_FLAG_START
Begin SPI transaction (take SPI slave's Chip Select line low)
void px_spi_wr(px_spi_handle_t *handle, const void *data, size_t nr_of_bytes, uint8_t flags)
Perform an SPI write transaction with an SPI slave.
void px_spi_rd(px_spi_handle_t *handle, void *data, size_t nr_of_bytes, uint8_t flags)
Perform an SPI read transaction with an SPI slave.
#define PX_SPI_FLAG_STOP
Finish SPI transaction (take SPI slave's Chip Select line high)