提供AT24Cxx系列EEPROM芯片的数据读写函数,内含页写自动管理
依赖库:https://github.com/netube99/si2c
#include "eeprom.h"
#include "si2c_port.h"
si2c_t si2c;
si2c_port_t port = {GPIOB, GPIO_PIN_7, GPIOB, GPIO_PIN_6};
Si2c_Init(&si2c, &port);
Eeprom_Init(&si2c);
uint8_t buf[16] = "hello eeprom";
uint8_t rbuf[16];
if (Eeprom_Write(0x0000, buf, sizeof(buf)) == EEPROM_SUCCESS)
{
Eeprom_Read(0x0000, rbuf, sizeof(rbuf));
}| 型号 | 容量 | 页大小 | 寄存器地址 |
|---|---|---|---|
| 24C01 | 128B | 8B | 1字节 |
| 24C02 | 256B | 8B | 1字节 |
| 24C04 | 512B | 16B | 1字节+1位块选 |
| 24C08 | 1KB | 16B | 1字节+2位块选 |
| 24C16 | 2KB | 16B | 1字节+3位块选 |
| 24C32 | 4KB | 32B | 2字节 |
| 24C64 | 8KB | 32B | 2字节 |
| 24C128 | 16KB | 64B | 2字节 |
| 24C256 | 32KB | 64B | 2字节 |