61 lines
2.0 KiB
C
61 lines
2.0 KiB
C
#ifndef AT24CM02_H_
|
|
#define AT24CM02_H_
|
|
|
|
#include <stdint.h>
|
|
|
|
#include "FreeRTOS.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#define AT24CM02_CAPACITY_BYTES 262144UL
|
|
#define AT24CM02_PAGE_SIZE_BYTES 256U
|
|
#define AT24CM02_PAGE_COUNT 1024U
|
|
#define AT24CM02_DEFAULT_ADDRESS 0x50U
|
|
|
|
typedef enum
|
|
{
|
|
EEPROM_STATUS_SUCCESS = 0,
|
|
EEPROM_STATUS_NOT_INITIALIZED,
|
|
EEPROM_STATUS_INVALID_ARGUMENT,
|
|
EEPROM_STATUS_OUT_OF_RANGE,
|
|
EEPROM_STATUS_NO_MEMORY,
|
|
EEPROM_STATUS_MUTEX_TIMEOUT,
|
|
EEPROM_STATUS_BUS_BUSY,
|
|
EEPROM_STATUS_TIMEOUT,
|
|
EEPROM_STATUS_NO_ACK,
|
|
EEPROM_STATUS_ARBITRATION_LOST
|
|
} EEPROM_Status;
|
|
|
|
// Configure GPIO91/GPIO92 and I2CA for 400-kHz operation. Call this once
|
|
// after Device_init() and Device_initGPIO(), before starting the scheduler.
|
|
EEPROM_Status EEPROM_init(void);
|
|
|
|
// Read or write an arbitrary byte range. A write that crosses a 256-byte page
|
|
// boundary is automatically split into multiple page-write transactions.
|
|
EEPROM_Status EEPROM_read(uint16_t *data, uint32_t address,
|
|
uint16_t deviceAddress, uint32_t byteCount,
|
|
TickType_t timeoutTicks);
|
|
EEPROM_Status EEPROM_write(const uint16_t *data, uint32_t address,
|
|
uint16_t deviceAddress, uint32_t byteCount,
|
|
TickType_t timeoutTicks);
|
|
|
|
// Page numbers are one-based (1 through 1024), matching the original driver.
|
|
EEPROM_Status EEPROM_pageNumberToAddress(uint16_t pageNumber,
|
|
uint32_t *pageAddress);
|
|
EEPROM_Status EEPROM_readPage(uint16_t *data, uint16_t deviceAddress,
|
|
uint16_t pageNumber, uint16_t byteCount,
|
|
TickType_t timeoutTicks);
|
|
EEPROM_Status EEPROM_writePage(const uint16_t *data, uint16_t deviceAddress,
|
|
uint16_t pageNumber, uint16_t byteCount,
|
|
TickType_t timeoutTicks);
|
|
|
|
const char *EEPROM_statusString(EEPROM_Status status);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif // AT24CM02_H_
|