current_v/Inc/ht24lc02_eeprom.h
2025-12-31 08:21:43 +08:00

104 lines
2.9 KiB
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file : ht24lc02_eeprom.h
* @brief : 数据存储操作
* @version : 1.0
* @changelog : version 1.0 初始版本 2025.11.13
******************************************************************************
* @attention
*
* Copyright (c) 2025 Yuwell Software Danyang.Jiangsu.China
* THIS SOFTWARE is licensed under the Mulan PSL v1.
* can use this software according to the terms and conditions of the Mulan PSL v1.
* You may obtain a copy of Mulan PSL v1 at:
* http://license.coscl.org.cn/MulanPSL
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
* PURPOSE.
* See the Mulan PSL v1 for more details.
*
******************************************************************************
*/
/* USER CODE END Header */
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __HT24LC02_EEPROM_H
#define __HT24LC02_EEPROM_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include "fm33lg0xx_fl.h"
#include "fm33lg0xx_queue.h"
#include "fm33lg0xx_event.h"
/*************** 硬件引脚配置 *******************/
#define EEPROM_24LC02_SDA_GROUP GPIOB
#define EEPROM_24LC02_SDA_PIN FL_GPIO_PIN_3
#define EEPROM_24LC02_SCL_GROUP GPIOB
#define EEPROM_24LC02_SCL_PIN FL_GPIO_PIN_1
#define EEPROM_24LC02_WP_GROUP GPIOB
#define EEPROM_24LC02_WP_PIN FL_GPIO_PIN_0
/*************** 存储芯片配置 *******************/
#define HT24LC02_ADDR 0xA0 // I2C地址包含读写0 读1
#define BLOCK_INDEX_SAVE_ADDR 0x00 // 使用两个地址存储索引
#define HT24LC02_ADDR_MAX 0xFF // 芯片的最大存储地址
#define EEPROM_TOTAL_BYTES 256
#define BLOCK_NUM 64 // 4字节/块共64块
#define BLOCK_SIZE 4 // 每块存储1个uint32_t4字节
#define ADC_BOUNDARY_ELEC_LOW_INDEX (3)
typedef enum
{
INDEX_TOTAL_HOURS = 1,
INDEX_TOTAL_MINUTES,
INDEX_E1_PRESS_LOW,
INDEX_E2_PRESS_HIGH,
INDEX_E4_ELEC_HIGH,
INDEX_E7_220V_LOW,
INDEX_LAST_CLEAN_FILTER_HOURS, // 上次清理滤清器的时间
INDEX_LAST_REPLACE_FILTER_HOURS, // 上次更换滤清器的时间
}EEPROM_SAVED_PARAM_INDEX;
#define EEPROM_E5_NTC_HIGH_VALUE (65) // 摄氏度
#define EEPROM_E3_ELEC_LOW_VALUE (100) // mA
/*************** 导出API函数 *******************/
void eeprom_ht24lc02_init(void);
void eeprom_ht24lc02_save_task(MessageQueue* queue);
void ht24lc02_word_write(uint32_t word, uint8_t addr_index);
#ifdef __cplusplus
}
#endif
#endif /* __HT24LC02_EEPROM_H */
/************************ (C) COPYRIGHT Yuwell *****END OF FILE****/