generated from hulk/gd32e23x_template_cmake_vscode
release(golden): 托底线整体替换为生产实装版原样复制(v26.1.0.3)并重编 B 槽固件
- 生产仓库(GitLab ceramixnano_eddy_cmake_vscode dev@151828f,已在机器上实装)原样复制 8 文件:Src/command.c、i2c.c、ldc1612.c、tmp112.c;Inc/command.h、i2c.h、ldc1612.h;CommunicationProtocol.md(copy 后 fc 逐字节核验一致) - 保留 B 槽专属构建(LD 0x0800B000/0x4BF8、VTOR 0xB000、gap-fill 0xFF、BUILD_VARIANT=golden),仅 VERSION_PATCH 2→3 对齐生产 - 与 dev 线从此的功能差异属预期(勿"修复"):LDC1612 驱动电流 GEN(8)(生产 2026-03-23 调参,dev 线仍 GEN(18))、命令集 M1~M4+M999/M9999(无 M5/M6)、M4 无符号温度算法、旧 8 位寄存器地址 i2c 驱动(配套 tmp112/ldc1612 整组生效);IIC 新驱动留待后续 A 线版本 - 保底判定值 v26.1.0.2 → v26.1.0.3;两个版本号均永不再用于 OTA 升级包;dev 线后续 A 版本必须 > V1.0.3(当前 dev 同为 V1.0.3,正式发布前须升版) - 重编译:text+data = 12,036B;向量表校验通过(复位向量 0x0800CC2C 落 B 槽) - FACTORY 工厂镜像(BL EDDY V0.1.0 + B 满槽 + flag,A 擦除态)已打包:Build\golden\CeramixNano-EDDY_FACTORY_B-V1.0.3_2026-10-25.bin,12 项字节校验全过
This commit is contained in:
+10
-92
@@ -74,15 +74,6 @@
|
||||
#define RESP_TYPE_LEN_ERR 0xF4 /**< 长度错误 */
|
||||
/** @} */
|
||||
|
||||
/* 温度补偿参数定义
|
||||
* TEMP_COMP_REF_TEMP_X10000: 参考温度,单位 0.0001°C
|
||||
* TEMP_COMP_COEFF_NUMERATOR / TEMP_COMP_COEFF_DENOMINATOR: 温漂系数,默认表示 counts/°C
|
||||
* 补偿公式: compensated = raw - (temp - ref) * coeff
|
||||
*/
|
||||
#define TEMP_COMP_REF_TEMP_X10000 (250000L)
|
||||
#define TEMP_COMP_COEFF_NUMERATOR (0L)
|
||||
#define TEMP_COMP_COEFF_DENOMINATOR (10000L)
|
||||
|
||||
/* ============================================================================
|
||||
* 模块内部变量
|
||||
* ============================================================================ */
|
||||
@@ -104,9 +95,6 @@ static const uint8_t s_report_status_ok[] = { 'o', 'k' }; /**< 成功响应
|
||||
static const uint8_t s_report_status_err[] = { 'e','r','r' }; /**< 错误响应数据 */
|
||||
/** @} */
|
||||
|
||||
static int32_t tmp112_get_temperature_x10000(void);
|
||||
static int64_t calculate_temperature_compensation_offset(int32_t temperature_x10000);
|
||||
|
||||
/* ============================================================================
|
||||
* 公共接口函数
|
||||
* ============================================================================ */
|
||||
@@ -344,14 +332,6 @@ void handle_command(const uint8_t *frame, uint8_t len) {
|
||||
temperature_raw_value_report();
|
||||
return;
|
||||
|
||||
case 5u:
|
||||
eddy_current_compensated_report();
|
||||
return;
|
||||
|
||||
case 6u:
|
||||
calibration_data_report();
|
||||
return;
|
||||
|
||||
// case 201u: // M201命令
|
||||
// send_response(RESP_TYPE_OK, s_report_status_ok, sizeof(s_report_status_ok));
|
||||
// return;
|
||||
@@ -533,82 +513,20 @@ void eddy_current_report(void) {
|
||||
send_response(RESP_TYPE_OK, sensor_data, sizeof(sensor_data));
|
||||
}
|
||||
|
||||
static int32_t tmp112_get_temperature_x10000(void)
|
||||
{
|
||||
uint8_t value[2] = {0};
|
||||
int16_t temp_raw;
|
||||
|
||||
tmp112a_get_raw_temperature_value(value);
|
||||
|
||||
temp_raw = (int16_t)(((uint16_t)value[0] << 8) | value[1]);
|
||||
temp_raw >>= 4;
|
||||
|
||||
return (int32_t)temp_raw * 625;
|
||||
}
|
||||
|
||||
static int64_t calculate_temperature_compensation_offset(int32_t temperature_x10000)
|
||||
{
|
||||
int32_t delta_temp_x10000 = temperature_x10000 - TEMP_COMP_REF_TEMP_X10000;
|
||||
|
||||
return ((int64_t)delta_temp_x10000 * TEMP_COMP_COEFF_NUMERATOR) /
|
||||
TEMP_COMP_COEFF_DENOMINATOR;
|
||||
}
|
||||
|
||||
void temperature_raw_value_report(void) {
|
||||
// if (!g_temperature_sensor_report_enabled) return;
|
||||
uint8_t raw_result[4];
|
||||
int32_t raw_value = tmp112_get_temperature_x10000();
|
||||
uint8_t value[2] = {0};
|
||||
uint32_t raw_value = 0;
|
||||
|
||||
raw_result[0] = (uint8_t)((uint32_t)raw_value >> 24);
|
||||
raw_result[1] = (uint8_t)((uint32_t)raw_value >> 16);
|
||||
raw_result[2] = (uint8_t)((uint32_t)raw_value >> 8);
|
||||
raw_result[3] = (uint8_t)((uint32_t)raw_value & 0xFF);
|
||||
// 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));
|
||||
}
|
||||
|
||||
void eddy_current_compensated_report(void)
|
||||
{
|
||||
uint8_t sensor_data[4];
|
||||
uint32_t raw_result = ldc1612_get_raw_channel_result(CHANNEL_0);
|
||||
|
||||
if ((raw_result & 0xF0000000u) == 0u) {
|
||||
int32_t temperature_x10000 = tmp112_get_temperature_x10000();
|
||||
int64_t compensated_value = (int64_t)raw_result -
|
||||
calculate_temperature_compensation_offset(temperature_x10000);
|
||||
|
||||
if (compensated_value < 0) {
|
||||
raw_result = 0;
|
||||
} else if (compensated_value > 0x0FFFFFFFLL) {
|
||||
raw_result = 0x0FFFFFFFu;
|
||||
} else {
|
||||
raw_result = (uint32_t)compensated_value;
|
||||
}
|
||||
}
|
||||
|
||||
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 calibration_data_report(void)
|
||||
{
|
||||
uint8_t payload[9];
|
||||
uint32_t eddy_raw_value = ldc1612_get_raw_channel_result(CHANNEL_0);
|
||||
int32_t temperature_raw_value = tmp112_get_temperature_x10000();
|
||||
|
||||
payload[0] = (uint8_t)(eddy_raw_value >> 24);
|
||||
payload[1] = (uint8_t)(eddy_raw_value >> 16);
|
||||
payload[2] = (uint8_t)(eddy_raw_value >> 8);
|
||||
payload[3] = (uint8_t)(eddy_raw_value & 0xFF);
|
||||
payload[4] = 0xFF;
|
||||
payload[5] = (uint8_t)((uint32_t)temperature_raw_value >> 24);
|
||||
payload[6] = (uint8_t)((uint32_t)temperature_raw_value >> 16);
|
||||
payload[7] = (uint8_t)((uint32_t)temperature_raw_value >> 8);
|
||||
payload[8] = (uint8_t)((uint32_t)temperature_raw_value & 0xFF);
|
||||
|
||||
send_response(RESP_TYPE_OK, payload, sizeof(payload));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user