/* * bsp_EEPROM.h * * Created on: Oct 26, 2023 * Author: shiya */ #ifndef INC_BSP_EEPROM_H_ #define INC_BSP_EEPROM_H_ #include "../../BASE/Inc/BSP/bsp_include.h" #include "bsp_CV.pb.h" #include "bsp_PV.pb.h" #include "bsp_IAP.pb.h" #define EEPROM_WP_Pin GPIO_PIN_11 #define EEPROM_WP_GPIO_Port GPIOE #define EEPROM_SCL_Pin GPIO_PIN_12 #define EEPROM_SCL_GPIO_Port GPIOE #define EEPROM_SDA_Pin GPIO_PIN_13 #define EEPROM_SDA_GPIO_Port GPIOE #define AT24C512 #ifdef AT24C512 #define EE_MODEL_NAME "AT24C512" #define EE_DEV_ADDR 0xA0 /* 设备地址 */ #define EE_PAGE_SIZE 128 /* 页面大小(字节) */ #define EE_SIZE (512*128) /* 总容量(字节) */ // not used in this progrm #define EE_ADDR_BYTES 2 /* 地址字节个数 */ #endif #define I2C_WR 0 /* 写控制bit */ #define I2C_RD 1 /* 读控制bit */ ////////////////////////////////////////////////////////////////// //there are 12M eeprom in total, and the code download Address is App_Download_EEPROM_Addr //512 Pages x 128 Bytes = 65536 Bytes = 512 kbits #define GF_BSP_EEPROM_CV_struct_define_Start_Address 0 #define IAP_struct_define_Start_Address 512 extern uint16_t App_Download_EEPROM_Addr; //返回值::1-正常;0-错误 uint8_t GF_BSP_EEPROM_Init(void); uint8_t GF_BSP_EEPROM_CheckOK(void); uint8_t GF_BSP_EEPROM_ReadBytes(uint8_t *_pReadBuf, uint16_t _usAddress, uint16_t _usSize); uint8_t GF_BSP_EEPROM_WriteBytes(uint8_t *_pWriteBuf, uint16_t _usAddress, uint16_t _usSize); CV_struct_define GF_BSP_EEPROM_Get_CV(void); uint8_t GF_BSP_EEPROM_Set_CV(CV_struct_define cv); IAP_struct_define GF_BSP_EEPROM_Get_IAP(void); uint8_t GF_BSP_EEPROM_Set_IAP(IAP_struct_define iap); PV_struct_define GF_BSP_EEPROM_Get_PV(void); uint8_t GF_BSP_EEPROM_Set_PV(PV_struct_define pv); #endif /* INC_BSP_EEPROM_H_ */