✨ feat(main): 为系统监控和性能监控功能添加宏开关控制
- 新增 ENABLE_SYSTEM_MONITOR 和 ENABLE_PERFORMANCE_MONITOR 宏定义,用于控制监控功能的编译开关 - 在 StartRecording、StopRecording、ProcessAdcData、main 等函数中,使用条件编译包裹所有 SystemMonitor 和 PerformanceMonitor 相关的函数调用 - 在 DebugOutput_PrintSystemStats 和 DebugOutput_PrintPerformanceStats 函数中,使用条件编译包裹整个函数体,确保在宏关闭时不生成调试输出代码 - 在 HAL_GPIO_EXTI_Callback、HAL_SPI_ErrorCallback 和 Error_Handler 等中断和错误处理函数中,同样添加条件编译保护,提高代码的灵活性和可配置性
This commit is contained in:
parent
082ea96e88
commit
4598f8f34f
@ -50,6 +50,10 @@
|
|||||||
// 串口输出控制开关
|
// 串口输出控制开关
|
||||||
#define ENABLE_UART_DEBUG_OUTPUT 1
|
#define ENABLE_UART_DEBUG_OUTPUT 1
|
||||||
#define DEBUG_OUTPUT_INTERVAL_MS 1000 // 调试输出间隔(毫秒)
|
#define DEBUG_OUTPUT_INTERVAL_MS 1000 // 调试输出间隔(毫秒)
|
||||||
|
|
||||||
|
// 监控功能宏开关
|
||||||
|
#define ENABLE_SYSTEM_MONITOR 1 // 系统监控开关
|
||||||
|
#define ENABLE_PERFORMANCE_MONITOR 1 // 性能监控开关
|
||||||
/* USER CODE END PD */
|
/* USER CODE END PD */
|
||||||
|
|
||||||
/* Private macro -------------------------------------------------------------*/
|
/* Private macro -------------------------------------------------------------*/
|
||||||
@ -112,9 +116,13 @@ static void StartRecording(void)
|
|||||||
if (!g_recording_enabled) {
|
if (!g_recording_enabled) {
|
||||||
if (DataStorage_StartRecording(&g_data_storage) == HAL_OK) {
|
if (DataStorage_StartRecording(&g_data_storage) == HAL_OK) {
|
||||||
g_recording_enabled = 1;
|
g_recording_enabled = 1;
|
||||||
|
#if ENABLE_SYSTEM_MONITOR
|
||||||
SystemMonitor_SetState(SYSTEM_STATE_RECORDING);
|
SystemMonitor_SetState(SYSTEM_STATE_RECORDING);
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
|
#if ENABLE_SYSTEM_MONITOR
|
||||||
SystemMonitor_ReportError(SYSTEM_ERROR_STORAGE);
|
SystemMonitor_ReportError(SYSTEM_ERROR_STORAGE);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -128,7 +136,9 @@ static void StopRecording(void)
|
|||||||
if (g_recording_enabled) {
|
if (g_recording_enabled) {
|
||||||
g_recording_enabled = 0;
|
g_recording_enabled = 0;
|
||||||
DataStorage_StopRecording(&g_data_storage);
|
DataStorage_StopRecording(&g_data_storage);
|
||||||
|
#if ENABLE_SYSTEM_MONITOR
|
||||||
SystemMonitor_SetState(SYSTEM_STATE_IDLE);
|
SystemMonitor_SetState(SYSTEM_STATE_IDLE);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,8 +152,12 @@ static void ProcessAdcData(void)
|
|||||||
LTC2508_BufferTypeDef *ready_buffer = NULL;
|
LTC2508_BufferTypeDef *ready_buffer = NULL;
|
||||||
if (LTC2508_GetReadyBuffer(&ready_buffer) == LTC2508_OK && ready_buffer != NULL)
|
if (LTC2508_GetReadyBuffer(&ready_buffer) == LTC2508_OK && ready_buffer != NULL)
|
||||||
{
|
{
|
||||||
|
#if ENABLE_PERFORMANCE_MONITOR
|
||||||
PerformanceMonitor_TaskStart(PERF_TASK_ADC_PROCESSING);
|
PerformanceMonitor_TaskStart(PERF_TASK_ADC_PROCESSING);
|
||||||
|
#endif
|
||||||
|
#if ENABLE_SYSTEM_MONITOR
|
||||||
SystemMonitor_SetState(SYSTEM_STATE_SAMPLING);
|
SystemMonitor_SetState(SYSTEM_STATE_SAMPLING);
|
||||||
|
#endif
|
||||||
g_sample_count++;
|
g_sample_count++;
|
||||||
|
|
||||||
// 1. 从双缓冲区获取数据并合并 (高位16位在前)
|
// 1. 从双缓冲区获取数据并合并 (高位16位在前)
|
||||||
@ -151,13 +165,17 @@ static void ProcessAdcData(void)
|
|||||||
for (uint8_t i = 0; i < NUM_LTC2508; i++) {
|
for (uint8_t i = 0; i < NUM_LTC2508; i++) {
|
||||||
raw_adc[i] = (int32_t)(((uint32_t)ready_buffer->data[i][0] << 16) | ready_buffer->data[i][1]);
|
raw_adc[i] = (int32_t)(((uint32_t)ready_buffer->data[i][0] << 16) | ready_buffer->data[i][1]);
|
||||||
}
|
}
|
||||||
|
#if ENABLE_PERFORMANCE_MONITOR
|
||||||
PerformanceMonitor_TaskEnd(PERF_TASK_ADC_PROCESSING);
|
PerformanceMonitor_TaskEnd(PERF_TASK_ADC_PROCESSING);
|
||||||
|
#endif
|
||||||
|
|
||||||
// 2. 验证数据有效性
|
// 2. 验证数据有效性
|
||||||
uint8_t data_valid = 1;
|
uint8_t data_valid = 1;
|
||||||
for (uint8_t i = 0; i < NUM_LTC2508; i++) {
|
for (uint8_t i = 0; i < NUM_LTC2508; i++) {
|
||||||
if (LTC2508_ValidateData(ready_buffer, i) != LTC2508_OK) {
|
if (LTC2508_ValidateData(ready_buffer, i) != LTC2508_OK) {
|
||||||
|
#if ENABLE_SYSTEM_MONITOR
|
||||||
SystemMonitor_ReportError(SYSTEM_ERROR_ADC);
|
SystemMonitor_ReportError(SYSTEM_ERROR_ADC);
|
||||||
|
#endif
|
||||||
data_valid = 0;
|
data_valid = 0;
|
||||||
break; // 如果有任何通道数据无效,跳过整个样本
|
break; // 如果有任何通道数据无效,跳过整个样本
|
||||||
}
|
}
|
||||||
@ -166,7 +184,9 @@ static void ProcessAdcData(void)
|
|||||||
if (!data_valid) {
|
if (!data_valid) {
|
||||||
// 释放缓冲区并返回
|
// 释放缓冲区并返回
|
||||||
LTC2508_ReleaseBuffer(LTC2508_GetCurrentReadBuffer());
|
LTC2508_ReleaseBuffer(LTC2508_GetCurrentReadBuffer());
|
||||||
|
#if ENABLE_SYSTEM_MONITOR
|
||||||
SystemMonitor_SetState(SYSTEM_STATE_IDLE);
|
SystemMonitor_SetState(SYSTEM_STATE_IDLE);
|
||||||
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,66 +194,104 @@ static void ProcessAdcData(void)
|
|||||||
CorrectionResult_t correction_result;
|
CorrectionResult_t correction_result;
|
||||||
uint8_t correction_applied = 0;
|
uint8_t correction_applied = 0;
|
||||||
|
|
||||||
|
#if ENABLE_PERFORMANCE_MONITOR
|
||||||
PerformanceMonitor_TaskStart(PERF_TASK_CORRECTION);
|
PerformanceMonitor_TaskStart(PERF_TASK_CORRECTION);
|
||||||
|
#endif
|
||||||
if (g_correction_params.params_valid &&
|
if (g_correction_params.params_valid &&
|
||||||
Apply_Correction(raw_adc[0], raw_adc[1], raw_adc[2],
|
Apply_Correction(raw_adc[0], raw_adc[1], raw_adc[2],
|
||||||
&correction_result, &g_correction_params) == HAL_OK) {
|
&correction_result, &g_correction_params) == HAL_OK) {
|
||||||
|
#if ENABLE_PERFORMANCE_MONITOR
|
||||||
PerformanceMonitor_TaskEnd(PERF_TASK_CORRECTION);
|
PerformanceMonitor_TaskEnd(PERF_TASK_CORRECTION);
|
||||||
|
#endif
|
||||||
|
|
||||||
// 4a. 打包校正后的数据
|
// 4a. 打包校正后的数据
|
||||||
|
#if ENABLE_PERFORMANCE_MONITOR
|
||||||
PerformanceMonitor_TaskStart(PERF_TASK_DATA_PACKET);
|
PerformanceMonitor_TaskStart(PERF_TASK_DATA_PACKET);
|
||||||
|
#endif
|
||||||
PackCorrectedData(&g_corrected_packet,
|
PackCorrectedData(&g_corrected_packet,
|
||||||
correction_result.corrected_x,
|
correction_result.corrected_x,
|
||||||
correction_result.corrected_y,
|
correction_result.corrected_y,
|
||||||
correction_result.corrected_z);
|
correction_result.corrected_z);
|
||||||
|
#if ENABLE_PERFORMANCE_MONITOR
|
||||||
PerformanceMonitor_TaskEnd(PERF_TASK_DATA_PACKET);
|
PerformanceMonitor_TaskEnd(PERF_TASK_DATA_PACKET);
|
||||||
|
#endif
|
||||||
correction_applied = 1;
|
correction_applied = 1;
|
||||||
|
|
||||||
// 发送校正后的数据包
|
// 发送校正后的数据包
|
||||||
|
#if ENABLE_PERFORMANCE_MONITOR
|
||||||
PerformanceMonitor_TaskStart(PERF_TASK_RS485_TX);
|
PerformanceMonitor_TaskStart(PERF_TASK_RS485_TX);
|
||||||
|
#endif
|
||||||
if (RS485_SendData((uint8_t*)&g_corrected_packet, sizeof(CorrectedDataPacket_t)) != HAL_OK) {
|
if (RS485_SendData((uint8_t*)&g_corrected_packet, sizeof(CorrectedDataPacket_t)) != HAL_OK) {
|
||||||
|
#if ENABLE_SYSTEM_MONITOR
|
||||||
SystemMonitor_ReportError(SYSTEM_ERROR_COMMUNICATION);
|
SystemMonitor_ReportError(SYSTEM_ERROR_COMMUNICATION);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
#if ENABLE_PERFORMANCE_MONITOR
|
||||||
PerformanceMonitor_TaskEnd(PERF_TASK_RS485_TX);
|
PerformanceMonitor_TaskEnd(PERF_TASK_RS485_TX);
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
|
#if ENABLE_PERFORMANCE_MONITOR
|
||||||
PerformanceMonitor_TaskEnd(PERF_TASK_CORRECTION);
|
PerformanceMonitor_TaskEnd(PERF_TASK_CORRECTION);
|
||||||
|
#endif
|
||||||
|
|
||||||
// 4b. 校正失败或未启用,使用原始数据
|
// 4b. 校正失败或未启用,使用原始数据
|
||||||
|
#if ENABLE_PERFORMANCE_MONITOR
|
||||||
PerformanceMonitor_TaskStart(PERF_TASK_DATA_PACKET);
|
PerformanceMonitor_TaskStart(PERF_TASK_DATA_PACKET);
|
||||||
|
#endif
|
||||||
PackData(&g_data_packet, raw_adc[0], raw_adc[1], raw_adc[2]);
|
PackData(&g_data_packet, raw_adc[0], raw_adc[1], raw_adc[2]);
|
||||||
|
#if ENABLE_PERFORMANCE_MONITOR
|
||||||
PerformanceMonitor_TaskEnd(PERF_TASK_DATA_PACKET);
|
PerformanceMonitor_TaskEnd(PERF_TASK_DATA_PACKET);
|
||||||
|
#endif
|
||||||
|
|
||||||
// 发送原始数据包
|
// 发送原始数据包
|
||||||
|
#if ENABLE_PERFORMANCE_MONITOR
|
||||||
PerformanceMonitor_TaskStart(PERF_TASK_RS485_TX);
|
PerformanceMonitor_TaskStart(PERF_TASK_RS485_TX);
|
||||||
|
#endif
|
||||||
if (RS485_SendData((uint8_t*)&g_data_packet, sizeof(DataPacket_t)) != HAL_OK) {
|
if (RS485_SendData((uint8_t*)&g_data_packet, sizeof(DataPacket_t)) != HAL_OK) {
|
||||||
|
#if ENABLE_SYSTEM_MONITOR
|
||||||
SystemMonitor_ReportError(SYSTEM_ERROR_COMMUNICATION);
|
SystemMonitor_ReportError(SYSTEM_ERROR_COMMUNICATION);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
#if ENABLE_PERFORMANCE_MONITOR
|
||||||
PerformanceMonitor_TaskEnd(PERF_TASK_RS485_TX);
|
PerformanceMonitor_TaskEnd(PERF_TASK_RS485_TX);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// 6. 存储数据到SD卡 (如果启用记录)
|
// 6. 存储数据到SD卡 (如果启用记录)
|
||||||
if (g_recording_enabled) {
|
if (g_recording_enabled) {
|
||||||
|
#if ENABLE_SYSTEM_MONITOR
|
||||||
SystemMonitor_SetState(SYSTEM_STATE_RECORDING);
|
SystemMonitor_SetState(SYSTEM_STATE_RECORDING);
|
||||||
|
#endif
|
||||||
|
#if ENABLE_PERFORMANCE_MONITOR
|
||||||
PerformanceMonitor_TaskStart(PERF_TASK_FATFS_WRITE);
|
PerformanceMonitor_TaskStart(PERF_TASK_FATFS_WRITE);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (correction_applied) {
|
if (correction_applied) {
|
||||||
// 存储校正后的数据
|
// 存储校正后的数据
|
||||||
if (DataStorage_WriteCorrectedData(&g_data_storage, &correction_result) != HAL_OK) {
|
if (DataStorage_WriteCorrectedData(&g_data_storage, &correction_result) != HAL_OK) {
|
||||||
|
#if ENABLE_SYSTEM_MONITOR
|
||||||
SystemMonitor_ReportError(SYSTEM_ERROR_STORAGE);
|
SystemMonitor_ReportError(SYSTEM_ERROR_STORAGE);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 存储原始数据
|
// 存储原始数据
|
||||||
if (DataStorage_WriteData(&g_data_storage, &g_data_packet) != HAL_OK) {
|
if (DataStorage_WriteData(&g_data_storage, &g_data_packet) != HAL_OK) {
|
||||||
|
#if ENABLE_SYSTEM_MONITOR
|
||||||
SystemMonitor_ReportError(SYSTEM_ERROR_STORAGE);
|
SystemMonitor_ReportError(SYSTEM_ERROR_STORAGE);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if ENABLE_PERFORMANCE_MONITOR
|
||||||
PerformanceMonitor_TaskEnd(PERF_TASK_FATFS_WRITE);
|
PerformanceMonitor_TaskEnd(PERF_TASK_FATFS_WRITE);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// 7. 释放已处理的缓冲区
|
// 7. 释放已处理的缓冲区
|
||||||
LTC2508_ReleaseBuffer(LTC2508_GetCurrentReadBuffer());
|
LTC2508_ReleaseBuffer(LTC2508_GetCurrentReadBuffer());
|
||||||
|
|
||||||
|
#if ENABLE_SYSTEM_MONITOR
|
||||||
SystemMonitor_SetState(SYSTEM_STATE_IDLE);
|
SystemMonitor_SetState(SYSTEM_STATE_IDLE);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -269,6 +327,7 @@ static void DebugOutput_SendString(const char* str)
|
|||||||
*/
|
*/
|
||||||
static void DebugOutput_PrintSystemStats(void)
|
static void DebugOutput_PrintSystemStats(void)
|
||||||
{
|
{
|
||||||
|
#if ENABLE_SYSTEM_MONITOR
|
||||||
if (!g_debug_output_enabled) {
|
if (!g_debug_output_enabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -292,6 +351,7 @@ static void DebugOutput_PrintSystemStats(void)
|
|||||||
sys_stats.temperature_celsius);
|
sys_stats.temperature_celsius);
|
||||||
|
|
||||||
DebugOutput_SendString(buffer);
|
DebugOutput_SendString(buffer);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -300,6 +360,7 @@ static void DebugOutput_PrintSystemStats(void)
|
|||||||
*/
|
*/
|
||||||
static void DebugOutput_PrintPerformanceStats(void)
|
static void DebugOutput_PrintPerformanceStats(void)
|
||||||
{
|
{
|
||||||
|
#if ENABLE_PERFORMANCE_MONITOR
|
||||||
if (!g_debug_output_enabled) {
|
if (!g_debug_output_enabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -332,6 +393,7 @@ static void DebugOutput_PrintPerformanceStats(void)
|
|||||||
DebugOutput_SendString(buffer);
|
DebugOutput_SendString(buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/* USER CODE END 0 */
|
/* USER CODE END 0 */
|
||||||
@ -378,18 +440,24 @@ int main(void)
|
|||||||
MX_TIM2_Init();
|
MX_TIM2_Init();
|
||||||
/* USER CODE BEGIN 2 */
|
/* USER CODE BEGIN 2 */
|
||||||
// 初始化系统监控
|
// 初始化系统监控
|
||||||
|
#if ENABLE_SYSTEM_MONITOR
|
||||||
SystemMonitor_Init();
|
SystemMonitor_Init();
|
||||||
SystemMonitor_SetState(SYSTEM_STATE_INIT);
|
SystemMonitor_SetState(SYSTEM_STATE_INIT);
|
||||||
|
#endif
|
||||||
|
|
||||||
// 初始化性能监控
|
// 初始化性能监控
|
||||||
|
#if ENABLE_PERFORMANCE_MONITOR
|
||||||
PerformanceMonitor_Init();
|
PerformanceMonitor_Init();
|
||||||
|
#endif
|
||||||
|
|
||||||
// 初始化调试输出
|
// 初始化调试输出
|
||||||
DebugOutput_Init();
|
DebugOutput_Init();
|
||||||
|
|
||||||
// 初始化LTC2508驱动
|
// 初始化LTC2508驱动
|
||||||
if (LTC2508_Init(&hspi1, &hspi2, &hspi3) != LTC2508_OK) {
|
if (LTC2508_Init(&hspi1, &hspi2, &hspi3) != LTC2508_OK) {
|
||||||
|
#if ENABLE_SYSTEM_MONITOR
|
||||||
SystemMonitor_ReportError(SYSTEM_ERROR_ADC);
|
SystemMonitor_ReportError(SYSTEM_ERROR_ADC);
|
||||||
|
#endif
|
||||||
Error_Handler();
|
Error_Handler();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -402,18 +470,24 @@ int main(void)
|
|||||||
|
|
||||||
// 初始化数据存储
|
// 初始化数据存储
|
||||||
if (DataStorage_Init(&g_data_storage) != HAL_OK) {
|
if (DataStorage_Init(&g_data_storage) != HAL_OK) {
|
||||||
|
#if ENABLE_SYSTEM_MONITOR
|
||||||
SystemMonitor_ReportError(SYSTEM_ERROR_STORAGE);
|
SystemMonitor_ReportError(SYSTEM_ERROR_STORAGE);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// 开始数据记录
|
// 开始数据记录
|
||||||
StartRecording();
|
StartRecording();
|
||||||
|
|
||||||
// 系统初始化完成
|
// 系统初始化完成
|
||||||
|
#if ENABLE_SYSTEM_MONITOR
|
||||||
SystemMonitor_SetState(SYSTEM_STATE_IDLE);
|
SystemMonitor_SetState(SYSTEM_STATE_IDLE);
|
||||||
|
#endif
|
||||||
|
|
||||||
// 启动TIM2定时器用于1ms周期的ADC数据处理
|
// 启动TIM2定时器用于1ms周期的ADC数据处理
|
||||||
if (HAL_TIM_Base_Start_IT(&htim2) != HAL_OK) {
|
if (HAL_TIM_Base_Start_IT(&htim2) != HAL_OK) {
|
||||||
|
#if ENABLE_SYSTEM_MONITOR
|
||||||
SystemMonitor_ReportError(SYSTEM_ERROR_CRITICAL);
|
SystemMonitor_ReportError(SYSTEM_ERROR_CRITICAL);
|
||||||
|
#endif
|
||||||
Error_Handler();
|
Error_Handler();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -432,10 +506,16 @@ int main(void)
|
|||||||
// 系统监控更新 (每100ms更新一次)
|
// 系统监控更新 (每100ms更新一次)
|
||||||
uint32_t current_tick = HAL_GetTick();
|
uint32_t current_tick = HAL_GetTick();
|
||||||
if (current_tick - g_last_monitor_update >= 100) {
|
if (current_tick - g_last_monitor_update >= 100) {
|
||||||
|
#if ENABLE_PERFORMANCE_MONITOR
|
||||||
PerformanceMonitor_TaskStart(PERF_TASK_SYSTEM_MONITOR);
|
PerformanceMonitor_TaskStart(PERF_TASK_SYSTEM_MONITOR);
|
||||||
|
#endif
|
||||||
|
#if ENABLE_SYSTEM_MONITOR
|
||||||
SystemMonitor_Update();
|
SystemMonitor_Update();
|
||||||
|
#endif
|
||||||
|
#if ENABLE_PERFORMANCE_MONITOR
|
||||||
PerformanceMonitor_Update();
|
PerformanceMonitor_Update();
|
||||||
PerformanceMonitor_TaskEnd(PERF_TASK_SYSTEM_MONITOR);
|
PerformanceMonitor_TaskEnd(PERF_TASK_SYSTEM_MONITOR);
|
||||||
|
#endif
|
||||||
g_last_monitor_update = current_tick;
|
g_last_monitor_update = current_tick;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -521,7 +601,9 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
|
|||||||
if (GPIO_Pin == ADC_DRY_Pin) {
|
if (GPIO_Pin == ADC_DRY_Pin) {
|
||||||
// ADC数据就绪,触发DMA读取
|
// ADC数据就绪,触发DMA读取
|
||||||
if (LTC2508_TriggerDmaRead() != LTC2508_OK) {
|
if (LTC2508_TriggerDmaRead() != LTC2508_OK) {
|
||||||
|
#if ENABLE_SYSTEM_MONITOR
|
||||||
SystemMonitor_ReportError(SYSTEM_ERROR_ADC);
|
SystemMonitor_ReportError(SYSTEM_ERROR_ADC);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -552,7 +634,9 @@ void HAL_SPI_ErrorCallback(SPI_HandleTypeDef *hspi)
|
|||||||
{
|
{
|
||||||
// 调用LTC2508驱动的错误回调
|
// 调用LTC2508驱动的错误回调
|
||||||
LTC2508_ErrorCallback(hspi);
|
LTC2508_ErrorCallback(hspi);
|
||||||
|
#if ENABLE_SYSTEM_MONITOR
|
||||||
SystemMonitor_ReportError(SYSTEM_ERROR_ADC);
|
SystemMonitor_ReportError(SYSTEM_ERROR_ADC);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -605,8 +689,10 @@ void Error_Handler(void)
|
|||||||
/* User can add his own implementation to report the HAL error return state */
|
/* User can add his own implementation to report the HAL error return state */
|
||||||
|
|
||||||
// 设置系统状态为错误状态
|
// 设置系统状态为错误状态
|
||||||
|
#if ENABLE_SYSTEM_MONITOR
|
||||||
SystemMonitor_SetState(SYSTEM_STATE_ERROR);
|
SystemMonitor_SetState(SYSTEM_STATE_ERROR);
|
||||||
SystemMonitor_ReportError(SYSTEM_ERROR_CRITICAL);
|
SystemMonitor_ReportError(SYSTEM_ERROR_CRITICAL);
|
||||||
|
#endif
|
||||||
|
|
||||||
// 停止所有DMA传输
|
// 停止所有DMA传输
|
||||||
HAL_SPI_DMAStop(&hspi1);
|
HAL_SPI_DMAStop(&hspi1);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user