更新部分不兼容问题

This commit is contained in:
2026-02-02 10:49:34 +08:00
parent e4d6a186f4
commit efda3469bf
2 changed files with 43 additions and 6 deletions

View File

@@ -27,6 +27,11 @@
// #define EDDY_DRIVE_CURRENT_DETECTION // Eddy Drive Current Detection : Enable // #define EDDY_DRIVE_CURRENT_DETECTION // Eddy Drive Current Detection : Enable
#undef EDDY_DRIVE_CURRENT_DETECTION // Eddy Drive Current Detection : Disable #undef EDDY_DRIVE_CURRENT_DETECTION // Eddy Drive Current Detection : Disable
/* >>>>>>>>>>>>>>>>>>>>[COMMAND DEBUG]<<<<<<<<<<<<<<<<<<<< */
// #define COM_DEBUG // Enable Command Debug Information
#undef COM_DEBUG // Disable Command Debug Information
/* >>>>>>>>>>>>>>>>>>>>>[LDC1612 DEBUG]<<<<<<<<<<<<<<<<<<<< */ /* >>>>>>>>>>>>>>>>>>>>>[LDC1612 DEBUG]<<<<<<<<<<<<<<<<<<<< */
// #define LDC_DEBUG // LDC1612 Driver Debug : Enable // #define LDC_DEBUG // LDC1612 Driver Debug : Enable
@@ -34,12 +39,6 @@
/******************************************************************************/ /******************************************************************************/
#define MCU_CODE 24U
#define FW_VERSION_MAJOR 1
#define FW_VERSION_MINOR 1
#define FW_VERSION_PATCH 3
/* Dynamic USART Configuration Structure */ /* Dynamic USART Configuration Structure */
typedef struct { typedef struct {
uint32_t rcu_usart; uint32_t rcu_usart;

View File

@@ -81,6 +81,14 @@
/** @brief 传感器周期上报使能标志 */ /** @brief 传感器周期上报使能标志 */
volatile bool g_eddy_current_sensor_report_enabled = false; volatile bool g_eddy_current_sensor_report_enabled = false;
/* Debug output control */
#ifdef COM_DEBUG
#include <stdio.h>
#define COMMAND_DEBUG(fmt, ...) printf("[COMMAND] " fmt "\n", ##__VA_ARGS__)
#else
#define COMMAND_DEBUG(fmt, ...)
#endif
/** @name 预设响应数据 /** @name 预设响应数据
* @{ */ * @{ */
static const uint8_t s_report_status_ok[] = { 'o', 'k' }; /**< 成功响应数据 */ static const uint8_t s_report_status_ok[] = { 'o', 'k' }; /**< 成功响应数据 */
@@ -197,6 +205,36 @@ static void send_response(uint8_t type, const uint8_t *payload, uint8_t len)
*/ */
static inline bool is_dec_digit(uint8_t c) { return (c >= '0' && c <= '9'); } static inline bool is_dec_digit(uint8_t c) { return (c >= '0' && c <= '9'); }
/**
* @brief 将一个无符号整数转换为字符串并追加到缓冲区。
* @param value 要转换的数字。
* @param buffer 指向目标缓冲区的指针,转换后的字符串将写入此处。
* @return uint8_t 写入的字符数。
*/
static uint8_t uint_to_str(uint32_t value, char *buffer) {
char temp[10]; // 32位无符号整数最多10位
int i = 0;
if (value == 0) {
buffer[0] = '0';
return 1;
}
// 将数字逆序转换为字符存入临时数组
while (value > 0) {
temp[i++] = (char)((value % 10) + '0');
value /= 10;
}
// 将逆序的字符串反转并存入目标缓冲区
uint8_t len = (uint8_t)i;
for (int j = 0; j < len; j++) {
buffer[j] = temp[--i];
}
return len;
}
/** /**
* @brief 从缓冲区解析十进制无符号整数。 * @brief 从缓冲区解析十进制无符号整数。
* @details 从指定位置开始连续读取十进制数字字符累加构成32位无符号整数。 * @details 从指定位置开始连续读取十进制数字字符累加构成32位无符号整数。