1 #ifndef __AT24C02_H__ 2 #define __AT24C02_H__ 3 4 5 #include "iic.h" 6 7 #define AT24C02_BASE_ADDR (0x00) 8 9 #define AT24C02_PAGE_SIZE (0x08) 10 11 #define AT24C02_PAGE_NUM (32) 12 13 #define AT24C02_MAX_BYTE_NUM (256) 14 15 #define AT24C02_MAX_MEM_ADDR (0xFF) 16 17 typedef enum 18 { 19 AT24C02_PAGE0 = AT24C02_BASE_ADDR + 0 * AT24C02_PAGE_SIZE, 20 AT24C02_PAGE1 = AT24C02_BASE_ADDR + 1 * AT24C02_PAGE_SIZE, 21 AT24C02_PAGE2 = AT24C02_BASE_ADDR + 2 * AT24C02_PAGE_SIZE, 22 AT24C02_PAGE3 = AT24C02_BASE_ADDR + 3 * AT24C02_PAGE_SIZE, 23 AT24C02_PAGE4 = AT24C02_BASE_ADDR + 4 * AT24C02_PAGE_SIZE, 24 AT24C02_PAGE5 = AT24C02_BASE_ADDR + 5 * AT24C02_PAGE_SIZE, 25 AT24C02_PAGE6 = AT24C02_BASE_ADDR + 6 * AT24C02_PAGE_SIZE, 26 AT24C02_PAGE7 = AT24C02_BASE_ADDR + 7 * AT24C02_PAGE_SIZE, 27 AT24C02_PAGE8 = AT24C02_BASE_ADDR + 8 * AT24C02_PAGE_SIZE, 28 AT24C02_PAGE9 = AT24C02_BASE_ADDR + 9 * AT24C02_PAGE_SIZE, 29 AT24C02_PAGE10 = AT24C02_BASE_ADDR + 10 * AT24C02_PAGE_SIZE, 30 AT24C02_PAGE11 = AT24C02_BASE_ADDR + 11 * AT24C02_PAGE_SIZE, 31 AT24C02_PAGE12 = AT24C02_BASE_ADDR + 12 * AT24C02_PAGE_SIZE, 32 AT24C02_PAGE13 = AT24C02_BASE_ADDR + 13 * AT24C02_PAGE_SIZE, 33 AT24C02_PAGE14 = AT24C02_BASE_ADDR + 14 * AT24C02_PAGE_SIZE, 34 AT24C02_PAGE15 = AT24C02_BASE_ADDR + 15 * AT24C02_PAGE_SIZE, 35 AT24C02_PAGE16 = AT24C02_BASE_ADDR + 16 * AT24C02_PAGE_SIZE, 36 AT24C02_PAGE17 = AT24C02_BASE_ADDR + 17 * AT24C02_PAGE_SIZE, 37 AT24C02_PAGE18 = AT24C02_BASE_ADDR + 18 * AT24C02_PAGE_SIZE, 38 AT24C02_PAGE19 = AT24C02_BASE_ADDR + 19 * AT24C02_PAGE_SIZE, 39 AT24C02_PAGE20 = AT24C02_BASE_ADDR + 20 * AT24C02_PAGE_SIZE, 40 AT24C02_PAGE21 = AT24C02_BASE_ADDR + 21 * AT24C02_PAGE_SIZE, 41 AT24C02_PAGE22 = AT24C02_BASE_ADDR + 22 * AT24C02_PAGE_SIZE, 42 AT24C02_PAGE23 = AT24C02_BASE_ADDR + 23 * AT24C02_PAGE_SIZE, 43 AT24C02_PAGE24 = AT24C02_BASE_ADDR + 24 * AT24C02_PAGE_SIZE, 44 AT24C02_PAGE25 = AT24C02_BASE_ADDR + 25 * AT24C02_PAGE_SIZE, 45 AT24C02_PAGE26 = AT24C02_BASE_ADDR + 26 * AT24C02_PAGE_SIZE, 46 AT24C02_PAGE27 = AT24C02_BASE_ADDR + 27 * AT24C02_PAGE_SIZE, 47 AT24C02_PAGE28 = AT24C02_BASE_ADDR + 28 * AT24C02_PAGE_SIZE, 48 AT24C02_PAGE29 = AT24C02_BASE_ADDR + 29 * AT24C02_PAGE_SIZE, 49 AT24C02_PAGE30 = AT24C02_BASE_ADDR + 30 * AT24C02_PAGE_SIZE, 50 AT24C02_PAGE31 = AT24C02_BASE_ADDR + 31 * AT24C02_PAGE_SIZE, 51 }H_AT24C02_PAGE_T; 52 53 54 55 /** 56 * @brief AT24C02 write data. 57 * @param page, AT24C02 write page. 58 data, Write data buffer. 59 * @retval H_SUCCESS or H_ERROR. 60 */ 61 H_STATUS_T Fn_AT24C02_WriteByte(uint8_t addr, uint8_t data); 62 63 64 /** 65 * @brief AT24C02 write page data. 66 * @param page, AT24C02 write page. 67 pData, Write data buffer. 68 len, Write data length. 69 * @retval H_SUCCESS or H_ERROR. 70 */ 71 H_STATUS_T Fn_AT24C02_WritePage(H_AT24C02_PAGE_T page, uint8_t* pData, uint8_t len); 72 73 74 /** 75 * @brief AT24C02 write serial data. 76 * @param addr, AT24C02 write data memory. 77 pData, Write data buffer. 78 len, Write data length. 79 * @retval H_SUCCESS or H_ERROR. 80 */ 81 H_STATUS_T Fn_AT24C02_WriteData(uint8_t addr, uint8_t* pData, uint16_t len); 82 83 84 /** 85 * @brief AT24C02 read current address data. 86 * @param pData, Read data buffer. 87 * @retval H_SUCCESS or H_ERROR. 88 */ 89 H_STATUS_T Fn_AT24C02_ReadCurrentByte(uint8_t *pData); 90 91 92 /** 93 * @brief AT24C02 read a byte. 94 * @param addr, AT24C02 read data memory. 95 pData, Read data buffer. 96 * @retval H_SUCCESS or H_ERROR. 97 */ 98 H_STATUS_T Fn_AT24C02_ReadByte(uint8_t addr, uint8_t *pData); 99100101 /**102 * @brief AT24C02 read serial data.103 * @param addr, AT24C02 read data memory.104 pData, Read data buffer.105 len, Read data length.106 * @retval H_SUCCESS or H_ERROR.107 */108 H_STATUS_T Fn_AT24C02_ReadData(uint8_t addr, uint8_t *pData, uint16_t len);109110111 /**112 * @brief AT24C02 clear memory data.113 * @param None.114 * @retval H_SUCCESS or H_ERROR.115 */116 H_STATUS_T Fn_AT24C02_ClearMemData(void);117118119 extern uint8_t at24c02_write_buf[AT24C02_MAX_BYTE_NUM];120 extern uint8_t at24c02_read_buf[AT24C02_MAX_BYTE_NUM];121122123 #endif
推荐阅读
- 天玑810跑分多少分_天玑810跑分详情
- 苹果13Pro参数配置_参数详情
- iQOO Z5参数_iQOO Z5参数配置
- ipadmini6参数_ipadmini6配置参数
- iPhone13参数配置_参数详情
- iqooz3的缺点_iqooz3骂声一片
- 暗区突围怎么更换角色
- 阴阳师寻香行御魂用什么
- 一加9r参数_一加9r参数配置详细
- 魅族18x评测_魅族18x体验评测