/* * @Author: wujunchao wujunchao@wuxismart.com * @Date: 2024-08-30 13:18:55 * @LastEditors: wujunchao wujunchao@wuxismart.com * @LastEditTime: 2025-03-28 09:07:40 * @FilePath: \acdt\board\Inc\eeprom.h * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE */ #ifndef __EEPROM_H #define __EEPROM_H #include "provalctrl.h" #define EE_MODEL_NAME "M24C64" #define EE_DEV_ADDR 0xA0 /* 设备地址 */ #define EE_PAGE_SIZE 32 /* 页面大小(字节) */ #define EE_SIZE (8*1024) /* 总容量(字节) */ #define EE_ADDR_BYTES 2 /* 地址字节个数 */ #define EEPROM_WriteAddress1 0x00 #define EEPROM_ReadAddress1 0x00 #define BufferSize1 sizeof(Tx1_Buffer) #define PRO1_ADDR EEPROM_WriteAddress1 + 32 #define PRO2_ADDR PRO1_ADDR + 12 #define AO_0_SAVE_ADDR 0x0064 #define AO_1_SAVE_ADDR 0x00C8 #define AO_2_SAVE_ADDR 0x012C extern uint8_t Tx1_Buffer[]; extern uint8_t Rx1_Buffer[]; #define I2C_WR 0 #define I2C_RD 1 // 定义I2C总线连接的GPIO端口, 用户只需要修改下面3行代码即可任意改变SCL和SDA的引脚 #define GPIO_PORT_I2C GPIOB // GPIO端口 #define I2C_SCL_PIN GPIO_PIN_6 // 连接到SCL时钟线的GPIO #define I2C_SDA_PIN GPIO_PIN_7 // 连接到SDA数据线的GPIO /* 定义读写SCL和SDA的宏 */ #define I2C_SCL_1() GPIO_PORT_I2C->BSRR = I2C_SCL_PIN // SCL = 1 #define I2C_SCL_0() GPIO_PORT_I2C->BSRR = (uint32_t)I2C_SCL_PIN << 16U // SCL = 0 #define I2C_SDA_1() GPIO_PORT_I2C->BSRR = I2C_SDA_PIN // SDA = 1 #define I2C_SDA_0() GPIO_PORT_I2C->BSRR = (uint32_t)I2C_SDA_PIN << 16U // SDA = 0 #define I2C_SDA_READ() (GPIO_PORT_I2C->IDR & I2C_SDA_PIN) // 读SDA口线状态 #define I2C_SCL_READ() (GPIO_PORT_I2C->IDR & I2C_SCL_PIN) // 读SCL口线状态 void ee_io_init(void); uint8_t ee_writebytes(uint8_t *_pWriteBuf, uint16_t _usAddress, uint16_t _usSize); uint8_t ee_readbytes(uint8_t *_pReadBuf, uint16_t _usAddress, uint16_t _usSize); void ee_writefloats(uint16_t _usAddress, float *wr_data); void ee_readfloats(uint16_t _usAddress, float *rd_data); #endif /*! end of the file */