AT24C02.h的源代码
c
/**
******************************************************************************
* @file at24c02.h
* @brief AT24C02 EEPROM驱动程序头文件
******************************************************************************
*/
#ifndef __AT24C02_H
#define __AT24C02_H
#ifdef __cplusplus
extern "C" {
#endif
/* 包含头文件 */
#include "main.h"
#include "i2c.h"
/* AT24C02参数定义 */
#define AT24C02_ADDRESS 0xA0 // AT24C02地址(写),读地址为0xA1
#define AT24C02_PAGE_SIZE 8 // 页大小(字节)
#define AT24C02_SIZE 256 // 总容量(字节)
/* 函数声明 */
uint8_t AT24C02_Init(void);
uint8_t AT24C02_ReadByte(uint16_t addr);
uint8_t AT24C02_WriteByte(uint16_t addr, uint8_t data);
uint8_t AT24C02_ReadBytes(uint16_t addr, uint8_t *data, uint16_t len);
uint8_t AT24C02_WriteBytes(uint16_t addr, uint8_t *data, uint16_t len);
uint8_t AT24C02_IsConnected(void);
#ifdef __cplusplus
}
#endif
#endif /* __AT24C02_H */