add tmp112a code

This commit is contained in:
2025-08-18 00:18:21 +08:00
parent 443e9bf8f2
commit b6485c5c39
7 changed files with 135 additions and 52 deletions

View File

@@ -17,7 +17,8 @@
*/
/** @brief 传感器周期上报使能标志 */
extern volatile bool g_sensor_report_enabled;
extern volatile bool g_eddy_current_sensor_report_enabled;
extern volatile bool g_temperature_sensor_report_enabled;
/**
* @section Command_Protocol 协议格式
@@ -62,23 +63,42 @@ extern volatile bool g_sensor_report_enabled;
*/
/**
* @brief 获取传感器周期上报使能状态。
* @brief 获取电涡流传感器周期上报使能状态。
* @return bool 上报状态。
* @retval true 传感器周期上报已启用。
* @retval false 传感器周期上报已禁用。
* @ingroup Command
*/
bool get_sensor_report_enabled(void);
bool get_eddy_sensor_report_enabled(void);
/**
* @brief 设置传感器周期上报使能状态。
* @brief 设置电涡流传感器周期上报使能状态。
* @param enabled 上报使能标志。
* @arg true 启用传感器周期上报。
* @arg false 禁用传感器周期上报。
* @note 推荐通过此函数修改状态,便于后续功能扩展。
* @ingroup Command
*/
void set_sensor_report_status(bool enabled);
void set_eddy_sensor_report_status(bool enabled);
/**
* @brief 获取温度传感器周期上报使能状态。
* @return bool 上报状态。
* @retval true 传感器周期上报已启用。
* @retval false 传感器周期上报已禁用。
* @ingroup Command
*/
bool get_temp_sensor_report_enabled(void);
/**
* @brief 设置温度传感器周期上报使能状态。
* @param enabled 上报使能标志。
* @arg true 启用传感器周期上报。
* @arg false 禁用传感器周期上报。
* @note 推荐通过此函数修改状态,便于后续功能扩展。
* @ingroup Command
*/
void set_temp_sensor_report_status(bool enabled);
/**
* @brief 处理串口环形缓冲区中的命令数据。
@@ -103,4 +123,6 @@ void handle_command(const uint8_t *cmd, uint8_t len);
void eddy_current_report(void);
void temperature_raw_value_report(void);
#endif // COMMAND_H

View File

@@ -14,7 +14,6 @@
#include <stdlib.h>
#include <math.h>
#include "board_config.h"
#include "soft_i2c.h"
#include "i2c.h"
/***************************************************************************/
@@ -32,7 +31,7 @@
/***************************************************************************/
#define LDC1612_ADDR 0x2B
#define LDC1612_ADDR (0x2B)
/************************Register Addr***************************************/

View File

@@ -19,7 +19,7 @@
/******************************************************************************/
/* TMP112A I2C Address */
#define TMP112A_ADDR (0x48) // 7-bit address (ADD0=GND)
#define TMP112A_ADDR (0x49) // 7-bit address (ADD0=GND)
/* Register Addresses */
/******************************************************************************/
@@ -59,7 +59,7 @@
/* Default Configuration */
/******************************************************************************/
#define TMP112A_CONFIG_DEFAULT (TMP112A_RESOLUTION_12BIT | TMP112A_RATE_4HZ)
#define TMP112A_CONFIG_DEFAULT (TMP112A_RESOLUTION_12BIT | TMP112A_RATE_8HZ)
/* Temperature Conversion Constants */
/******************************************************************************/
@@ -111,6 +111,8 @@ tmp112a_status_t tmp112a_config(uint16_t config);
*/
tmp112a_status_t tmp112a_read_temperature(tmp112a_result_t *result);
void tmp112a_get_raw_temperature_value(uint8_t *value);
/*!
\brief 设置温度阈值
\param[in] low_temp: 低温阈值 (°C)