diff --git a/Inc/command.h b/Inc/command.h index f272fac..b9d9c77 100644 --- a/Inc/command.h +++ b/Inc/command.h @@ -16,10 +16,6 @@ * @{ */ -/** @brief 传感器周期上报使能标志 */ -extern volatile bool g_eddy_current_sensor_report_enabled; -extern volatile bool g_temperature_sensor_report_enabled; - /** * @section Command_Protocol 协议格式 * 接收命令帧格式: @@ -62,44 +58,6 @@ extern volatile bool g_temperature_sensor_report_enabled; * @endcode */ -/** - * @brief 获取电涡流传感器周期上报使能状态。 - * @return bool 上报状态。 - * @retval true 传感器周期上报已启用。 - * @retval false 传感器周期上报已禁用。 - * @ingroup Command - */ -bool get_eddy_sensor_report_enabled(void); - -/** - * @brief 设置电涡流传感器周期上报使能状态。 - * @param enabled 上报使能标志。 - * @arg true 启用传感器周期上报。 - * @arg false 禁用传感器周期上报。 - * @note 推荐通过此函数修改状态,便于后续功能扩展。 - * @ingroup Command - */ -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 处理串口环形缓冲区中的命令数据。 * @details 基于状态机的非阻塞协议解析器,处理完整的命令帧并自动响应。 @@ -121,8 +79,4 @@ void handle_command(const uint8_t *cmd, uint8_t len); /** @} */ // end of Command group -void eddy_current_report(void); - -void temperature_raw_value_report(void); - #endif // COMMAND_H diff --git a/Src/command.c b/Src/command.c index d0e34c1..c041765 100644 --- a/Src/command.c +++ b/Src/command.c @@ -17,8 +17,6 @@ #include #include "board_config.h" #include "gd32e23x_usart.h" -#include "ldc1612.h" -#include "tmp112.h" /* ============================================================================ * 协议格式说明 @@ -78,10 +76,6 @@ * 模块内部变量 * ============================================================================ */ -/** @brief 传感器周期上报使能标志 */ -volatile bool g_eddy_current_sensor_report_enabled = false; -volatile bool g_temperature_sensor_report_enabled = false; - /** @name 预设响应数据 * @{ */ static const uint8_t s_report_status_ok[] = { 'o', 'k' }; /**< 成功响应数据 */ @@ -92,50 +86,6 @@ static const uint8_t s_report_status_err[] = { 'e','r','r' }; /**< 错误响应 * 公共接口函数 * ============================================================================ */ -/** - * @brief 查询电涡流传感器是否启用周期性传感器上报。 - * @return true 表示启用;false 表示禁用。 - * @ingroup Command - */ -bool get_eddy_sensor_report_enabled(void) -{ - return g_eddy_current_sensor_report_enabled; -} - -/** - * @brief 设置电涡流传感器是否启用周期性传感器上报标志。 - * @details 本模块内部保存的布尔状态,供其他逻辑决定是否进行周期性数据上报; - * 推荐通过本函数修改而非直接访问全局/静态变量,以便后续扩展(如加锁/回调)。 - * @param status true 启用周期上报;false 禁用。 - * @ingroup Command - */ -void set_eddy_sensor_report_status(bool status) -{ - g_eddy_current_sensor_report_enabled = status; -} - -/** - * @brief 查询温度传感器是否启用周期性传感器上报。 - * @return true 表示启用;false 表示禁用。 - * @ingroup Command - */ -bool get_temp_sensor_report_enabled(void) -{ - return g_temperature_sensor_report_enabled; -} - -/** - * @brief 设置温度传感器是否启用周期性传感器上报标志。 - * @details 本模块内部保存的布尔状态,供其他逻辑决定是否进行周期性数据上报; - * 推荐通过本函数修改而非直接访问全局/静态变量,以便后续扩展(如加锁/回调)。 - * @param status true 启用周期上报;false 禁用。 - * @ingroup Command - */ -void set_temp_sensor_report_status(bool status) -{ - g_temperature_sensor_report_enabled = status; -} - /** * @brief 计算协议包的 8 位累加校验值(Checksum)。 * @details 对输入缓冲区逐字节累加并取低 8 位,累加范围为 data[1] 至 data[len-2], @@ -301,19 +251,19 @@ void handle_command(const uint8_t *frame, uint8_t len) { // 仅基础命令,如 M1, M2, M3 switch (base_cmd) { case 1u: // M1: enable sensor report - set_eddy_sensor_report_status(true); + send_response(RESP_TYPE_OK, s_report_status_ok, sizeof(s_report_status_ok)); return; case 2u: // M2: disable sensor report - set_eddy_sensor_report_status(false); + send_response(RESP_TYPE_OK, s_report_status_ok, sizeof(s_report_status_ok)); return; case 3u: - set_temp_sensor_report_status(true); + send_response(RESP_TYPE_OK, s_report_status_ok, sizeof(s_report_status_ok)); return; case 4u: - set_temp_sensor_report_status(false); + send_response(RESP_TYPE_OK, s_report_status_ok, sizeof(s_report_status_ok)); return; // case 201u: // M201命令 @@ -454,34 +404,4 @@ void command_process(void) { } } } - -void eddy_current_report(void) { - // if (!g_eddy_current_sensor_report_enabled) return; - uint32_t raw_result = ldc1612_get_raw_channel_result(CHANNEL_0); - - uint8_t sensor_data[4]; - sensor_data[0] = (uint8_t)(raw_result >> 24); - sensor_data[1] = (uint8_t)(raw_result >> 16); - sensor_data[2] = (uint8_t)(raw_result >> 8); - sensor_data[3] = (uint8_t)(raw_result & 0xFF); - - send_response(RESP_TYPE_OK, sensor_data, sizeof(sensor_data)); -} - -void temperature_raw_value_report(void) { - // if (!g_temperature_sensor_report_enabled) return; - uint8_t raw_result[4]; - uint8_t value[2] = {0}; - uint32_t raw_value = 0; - - // i2c_read_16bits(TMP112A_ADDR, TMP112A_TEMP_REG, value); - tmp112a_get_raw_temperature_value(value); - raw_value = (uint32_t)((uint16_t) (value[0] << 4) | (value[1]>>4)) * 625; - raw_result[0] = (uint8_t)(raw_value >> 24); - raw_result[1] = (uint8_t)(raw_value >> 16); - raw_result[2] = (uint8_t)(raw_value >> 8); - raw_result[3] = (uint8_t)(raw_value & 0xFF); - - send_response(RESP_TYPE_OK, raw_result, sizeof(raw_result)); -} \ No newline at end of file diff --git a/Src/main.c b/Src/main.c index bb8b36b..c49f112 100644 --- a/Src/main.c +++ b/Src/main.c @@ -40,8 +40,6 @@ OF SUCH DAMAGE. #include #include "i2c.h" #include "board_config.h" -#include "ldc1612.h" -#include "tmp112.h" /*! \brief main function