✨ feat(system): 优化系统性能并简化监控模块
- 新增VSCode编辑器配置,启用保存时自动格式化 - 新增DMA2_Stream5和USART1中断处理函数,优化SPI传输性能 - 移除TIM1相关配置和性能监控模块,简化系统架构 - 优化GPIO配置,将ADC_SYNC和PA8引脚合并配置 - 简化系统监控模块,仅保留采样计数和数据溢出统计 - 优化SPI配置,使用16位数据宽度并提高DMA优先级 - 提高USART波特率(USART1:2Mbps, USART3:921600bps) - 优化LTC2508驱动,增加初始化状态检查和缓冲区大小 - 修正数据存储模块,使用校正数据包而非校正结果结构体 - 优化RS485驱动,使用中断传输并添加传输完成回调 - 更新IOC配置文件,移除TIM1并调整中断优先级配置 - 新增系统监控简化说明文档,详细记录架构变更
This commit is contained in:
@@ -56,6 +56,9 @@ void MX_DMA_Init(void)
|
||||
/* DMA2_Stream3_IRQn interrupt configuration */
|
||||
HAL_NVIC_SetPriority(DMA2_Stream3_IRQn, 10, 0);
|
||||
HAL_NVIC_EnableIRQ(DMA2_Stream3_IRQn);
|
||||
/* DMA2_Stream5_IRQn interrupt configuration */
|
||||
HAL_NVIC_SetPriority(DMA2_Stream5_IRQn, 0, 0);
|
||||
HAL_NVIC_EnableIRQ(DMA2_Stream5_IRQn);
|
||||
/* DMA2_Stream6_IRQn interrupt configuration */
|
||||
HAL_NVIC_SetPriority(DMA2_Stream6_IRQn, 10, 0);
|
||||
HAL_NVIC_EnableIRQ(DMA2_Stream6_IRQn);
|
||||
|
||||
+4
-4
@@ -52,7 +52,7 @@ void MX_GPIO_Init(void)
|
||||
__HAL_RCC_GPIOD_CLK_ENABLE();
|
||||
|
||||
/*Configure GPIO pin Output Level */
|
||||
HAL_GPIO_WritePin(ADC_SYNC_GPIO_Port, ADC_SYNC_Pin, GPIO_PIN_RESET);
|
||||
HAL_GPIO_WritePin(GPIOA, ADC_SYNC_Pin|GPIO_PIN_8, GPIO_PIN_RESET);
|
||||
|
||||
/*Configure GPIO pin Output Level */
|
||||
HAL_GPIO_WritePin(RS485_CTL_GPIO_Port, RS485_CTL_Pin, GPIO_PIN_RESET);
|
||||
@@ -69,12 +69,12 @@ void MX_GPIO_Init(void)
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
HAL_GPIO_Init(ADC_DRY_GPIO_Port, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pin : ADC_SYNC_Pin */
|
||||
GPIO_InitStruct.Pin = ADC_SYNC_Pin;
|
||||
/*Configure GPIO pins : ADC_SYNC_Pin PA8 */
|
||||
GPIO_InitStruct.Pin = ADC_SYNC_Pin|GPIO_PIN_8;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
HAL_GPIO_Init(ADC_SYNC_GPIO_Port, &GPIO_InitStruct);
|
||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pin : RS485_CTL_Pin */
|
||||
GPIO_InitStruct.Pin = RS485_CTL_Pin;
|
||||
|
||||
+49
-248
@@ -35,7 +35,6 @@
|
||||
#include "correction.h"
|
||||
#include "data_storage.h"
|
||||
#include "system_monitor.h"
|
||||
#include "performance_monitor.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
/* USER CODE END Includes */
|
||||
@@ -53,7 +52,6 @@
|
||||
|
||||
// 监控功能宏开关
|
||||
#define ENABLE_SYSTEM_MONITOR 1 // 系统监控开关
|
||||
#define ENABLE_PERFORMANCE_MONITOR 1 // 性能监控开关
|
||||
/* USER CODE END PD */
|
||||
|
||||
/* Private macro -------------------------------------------------------------*/
|
||||
@@ -80,9 +78,7 @@ CorrectedDataPacket_t g_corrected_packet;
|
||||
// 数据存储句柄
|
||||
DataStorageHandle_t g_data_storage;
|
||||
// 系统状态
|
||||
static uint32_t g_last_monitor_update = 0;
|
||||
static uint8_t g_recording_enabled = 0;
|
||||
static uint32_t g_sample_count = 0;
|
||||
|
||||
// USB连接状态管理
|
||||
static uint8_t g_usb_connected = 0;
|
||||
@@ -92,7 +88,6 @@ static uint32_t g_last_usb_check = 0;
|
||||
// 性能监控和调试输出
|
||||
static uint32_t g_last_debug_output = 0;
|
||||
static uint8_t g_debug_output_enabled = ENABLE_UART_DEBUG_OUTPUT;
|
||||
static SystemPerfStats_t g_perf_stats;
|
||||
|
||||
/* USER CODE END PV */
|
||||
|
||||
@@ -112,7 +107,6 @@ static void UnmountFileSystemForSampling(void);
|
||||
static void DebugOutput_Init(void);
|
||||
static void DebugOutput_SendString(const char* str);
|
||||
static void DebugOutput_PrintSystemStats(void);
|
||||
static void DebugOutput_PrintPerformanceStats(void);
|
||||
/* USER CODE END PFP */
|
||||
|
||||
/* Private user code ---------------------------------------------------------*/
|
||||
@@ -127,13 +121,6 @@ static void StartRecording(void)
|
||||
if (!g_recording_enabled) {
|
||||
if (DataStorage_StartRecording(&g_data_storage) == HAL_OK) {
|
||||
g_recording_enabled = 1;
|
||||
#if ENABLE_SYSTEM_MONITOR
|
||||
SystemMonitor_SetState(SYSTEM_STATE_RECORDING);
|
||||
#endif
|
||||
} else {
|
||||
#if ENABLE_SYSTEM_MONITOR
|
||||
SystemMonitor_ReportError(SYSTEM_ERROR_STORAGE);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -147,9 +134,6 @@ static void StopRecording(void)
|
||||
if (g_recording_enabled) {
|
||||
g_recording_enabled = 0;
|
||||
DataStorage_StopRecording(&g_data_storage);
|
||||
#if ENABLE_SYSTEM_MONITOR
|
||||
SystemMonitor_SetState(SYSTEM_STATE_IDLE);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,145 +147,61 @@ static void ProcessAdcData(void)
|
||||
LTC2508_BufferTypeDef *ready_buffer = NULL;
|
||||
if (LTC2508_GetReadyBuffer(&ready_buffer) == LTC2508_OK && ready_buffer != NULL)
|
||||
{
|
||||
#if ENABLE_PERFORMANCE_MONITOR
|
||||
PerformanceMonitor_TaskStart(PERF_TASK_ADC_PROCESSING);
|
||||
#endif
|
||||
#if ENABLE_SYSTEM_MONITOR
|
||||
SystemMonitor_SetState(SYSTEM_STATE_SAMPLING);
|
||||
SystemMonitor_IncrementSampleCount();
|
||||
#endif
|
||||
g_sample_count++;
|
||||
|
||||
// 1. 从双缓冲区获取数据并合并 (高位16位在前)
|
||||
int32_t raw_adc[NUM_LTC2508];
|
||||
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]);
|
||||
}
|
||||
#if ENABLE_PERFORMANCE_MONITOR
|
||||
PerformanceMonitor_TaskEnd(PERF_TASK_ADC_PROCESSING);
|
||||
#endif
|
||||
|
||||
// 2. 验证数据有效性
|
||||
uint8_t data_valid = 1;
|
||||
for (uint8_t i = 0; i < NUM_LTC2508; i++) {
|
||||
if (LTC2508_ValidateData(ready_buffer, i) != LTC2508_OK) {
|
||||
#if ENABLE_SYSTEM_MONITOR
|
||||
SystemMonitor_ReportError(SYSTEM_ERROR_ADC);
|
||||
#endif
|
||||
data_valid = 0;
|
||||
break; // 如果有任何通道数据无效,跳过整个样本
|
||||
}
|
||||
}
|
||||
|
||||
if (!data_valid) {
|
||||
// 释放缓冲区并返回
|
||||
LTC2508_ReleaseBuffer(LTC2508_GetCurrentReadBuffer());
|
||||
#if ENABLE_SYSTEM_MONITOR
|
||||
SystemMonitor_SetState(SYSTEM_STATE_IDLE);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
// 3. 应用校正算法
|
||||
CorrectionResult_t correction_result;
|
||||
uint8_t correction_applied = 0;
|
||||
|
||||
#if ENABLE_PERFORMANCE_MONITOR
|
||||
PerformanceMonitor_TaskStart(PERF_TASK_CORRECTION);
|
||||
#endif
|
||||
|
||||
if (g_correction_params.params_valid &&
|
||||
Apply_Correction(raw_adc[0], raw_adc[1], raw_adc[2],
|
||||
&correction_result, &g_correction_params) == HAL_OK) {
|
||||
#if ENABLE_PERFORMANCE_MONITOR
|
||||
PerformanceMonitor_TaskEnd(PERF_TASK_CORRECTION);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
// 4a. 打包校正后的数据
|
||||
#if ENABLE_PERFORMANCE_MONITOR
|
||||
PerformanceMonitor_TaskStart(PERF_TASK_DATA_PACKET);
|
||||
#endif
|
||||
PackCorrectedData(&g_corrected_packet,
|
||||
correction_result.corrected_x,
|
||||
correction_result.corrected_y,
|
||||
correction_result.corrected_z);
|
||||
#if ENABLE_PERFORMANCE_MONITOR
|
||||
PerformanceMonitor_TaskEnd(PERF_TASK_DATA_PACKET);
|
||||
#endif
|
||||
|
||||
correction_applied = 1;
|
||||
|
||||
|
||||
// 发送校正后的数据包
|
||||
#if ENABLE_PERFORMANCE_MONITOR
|
||||
PerformanceMonitor_TaskStart(PERF_TASK_RS485_TX);
|
||||
#endif
|
||||
if (RS485_SendData((uint8_t*)&g_corrected_packet, sizeof(CorrectedDataPacket_t)) != HAL_OK) {
|
||||
#if ENABLE_SYSTEM_MONITOR
|
||||
SystemMonitor_ReportError(SYSTEM_ERROR_COMMUNICATION);
|
||||
#endif
|
||||
}
|
||||
#if ENABLE_PERFORMANCE_MONITOR
|
||||
PerformanceMonitor_TaskEnd(PERF_TASK_RS485_TX);
|
||||
#endif
|
||||
} else {
|
||||
#if ENABLE_PERFORMANCE_MONITOR
|
||||
PerformanceMonitor_TaskEnd(PERF_TASK_CORRECTION);
|
||||
#endif
|
||||
RS485_SendData((uint8_t*)&g_corrected_packet, sizeof(CorrectedDataPacket_t));
|
||||
} else {
|
||||
|
||||
// 4b. 校正失败或未启用,使用原始数据
|
||||
#if ENABLE_PERFORMANCE_MONITOR
|
||||
PerformanceMonitor_TaskStart(PERF_TASK_DATA_PACKET);
|
||||
#endif
|
||||
PackData(&g_data_packet, raw_adc[0], raw_adc[1], raw_adc[2]);
|
||||
#if ENABLE_PERFORMANCE_MONITOR
|
||||
PerformanceMonitor_TaskEnd(PERF_TASK_DATA_PACKET);
|
||||
#endif
|
||||
|
||||
|
||||
// 发送原始数据包
|
||||
#if ENABLE_PERFORMANCE_MONITOR
|
||||
PerformanceMonitor_TaskStart(PERF_TASK_RS485_TX);
|
||||
#endif
|
||||
if (RS485_SendData((uint8_t*)&g_data_packet, sizeof(DataPacket_t)) != HAL_OK) {
|
||||
#if ENABLE_SYSTEM_MONITOR
|
||||
SystemMonitor_ReportError(SYSTEM_ERROR_COMMUNICATION);
|
||||
#endif
|
||||
}
|
||||
#if ENABLE_PERFORMANCE_MONITOR
|
||||
PerformanceMonitor_TaskEnd(PERF_TASK_RS485_TX);
|
||||
#endif
|
||||
RS485_SendData((uint8_t*)&g_data_packet, sizeof(DataPacket_t));
|
||||
}
|
||||
|
||||
|
||||
// 6. 存储数据到SD卡 (如果启用记录)
|
||||
if (g_recording_enabled) {
|
||||
#if ENABLE_SYSTEM_MONITOR
|
||||
SystemMonitor_SetState(SYSTEM_STATE_RECORDING);
|
||||
#endif
|
||||
#if ENABLE_PERFORMANCE_MONITOR
|
||||
PerformanceMonitor_TaskStart(PERF_TASK_FATFS_WRITE);
|
||||
#endif
|
||||
|
||||
if (correction_applied) {
|
||||
// 存储校正后的数据
|
||||
if (DataStorage_WriteCorrectedData(&g_data_storage, &correction_result) != HAL_OK) {
|
||||
#if ENABLE_SYSTEM_MONITOR
|
||||
SystemMonitor_ReportError(SYSTEM_ERROR_STORAGE);
|
||||
#endif
|
||||
}
|
||||
DataStorage_WriteCorrectedData(&g_data_storage, &g_corrected_packet);
|
||||
} else {
|
||||
// 存储原始数据
|
||||
if (DataStorage_WriteData(&g_data_storage, &g_data_packet) != HAL_OK) {
|
||||
#if ENABLE_SYSTEM_MONITOR
|
||||
SystemMonitor_ReportError(SYSTEM_ERROR_STORAGE);
|
||||
#endif
|
||||
}
|
||||
DataStorage_WriteData(&g_data_storage, &g_data_packet);
|
||||
}
|
||||
#if ENABLE_PERFORMANCE_MONITOR
|
||||
PerformanceMonitor_TaskEnd(PERF_TASK_FATFS_WRITE);
|
||||
#endif
|
||||
}
|
||||
|
||||
// 7. 释放已处理的缓冲区
|
||||
LTC2508_ReleaseBuffer(LTC2508_GetCurrentReadBuffer());
|
||||
|
||||
} else {
|
||||
// 数据来不及处理
|
||||
#if ENABLE_SYSTEM_MONITOR
|
||||
SystemMonitor_SetState(SYSTEM_STATE_IDLE);
|
||||
SystemMonitor_ReportDataOverflow();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -343,70 +243,21 @@ static void DebugOutput_PrintSystemStats(void)
|
||||
return;
|
||||
}
|
||||
|
||||
char buffer[256];
|
||||
char buffer[128];
|
||||
SystemMonitorStats_t sys_stats;
|
||||
SystemMonitor_GetStats(&sys_stats);
|
||||
|
||||
snprintf(buffer, sizeof(buffer),
|
||||
"\r\n=== System Monitor Stats ===\r\n"
|
||||
"State: %d, Uptime: %lu s\r\n"
|
||||
"Total Samples: %lu, Errors: %lu\r\n"
|
||||
"Memory Usage: %lu bytes\r\n"
|
||||
"CPU Usage: %d%%, Temp: %d°C\r\n",
|
||||
sys_stats.current_state,
|
||||
sys_stats.uptime_seconds,
|
||||
"\r\n=== System Stats ===\r\n"
|
||||
"Total Samples: %lu\r\n"
|
||||
"Data Overflow: %lu\r\n",
|
||||
sys_stats.total_samples,
|
||||
sys_stats.error_count,
|
||||
sys_stats.memory_usage,
|
||||
sys_stats.cpu_usage_percent,
|
||||
sys_stats.temperature_celsius);
|
||||
sys_stats.data_overflow_count);
|
||||
|
||||
DebugOutput_SendString(buffer);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 输出性能监控统计信息
|
||||
* @retval None
|
||||
*/
|
||||
static void DebugOutput_PrintPerformanceStats(void)
|
||||
{
|
||||
#if ENABLE_PERFORMANCE_MONITOR
|
||||
if (!g_debug_output_enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
char buffer[512];
|
||||
PerformanceMonitor_GetStats(&g_perf_stats);
|
||||
|
||||
snprintf(buffer, sizeof(buffer),
|
||||
"\r\n=== Performance Monitor Stats ===\r\n"
|
||||
"Total CPU Usage: %lu%%\r\n"
|
||||
"Free Heap: %lu bytes (Min: %lu)\r\n"
|
||||
"Stack Usage: %lu%%\r\n",
|
||||
g_perf_stats.total_cpu_usage_percent,
|
||||
g_perf_stats.free_heap_size,
|
||||
g_perf_stats.min_free_heap_size,
|
||||
g_perf_stats.stack_usage_percent);
|
||||
|
||||
DebugOutput_SendString(buffer);
|
||||
|
||||
// 输出各任务性能统计
|
||||
for (int i = 0; i < PERF_MON_MAX_TASKS; i++) {
|
||||
if (g_perf_stats.tasks[i].call_count > 0) {
|
||||
snprintf(buffer, sizeof(buffer),
|
||||
"Task[%d]: Calls=%lu, Avg=%lu us, Max=%lu us, CPU=%.1f%%\r\n",
|
||||
i,
|
||||
g_perf_stats.tasks[i].call_count,
|
||||
g_perf_stats.tasks[i].avg_time_us,
|
||||
g_perf_stats.tasks[i].max_time_us,
|
||||
g_perf_stats.tasks[i].cpu_usage_percent);
|
||||
DebugOutput_SendString(buffer);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 检查USB连接状态
|
||||
* @retval 1: USB已连接, 0: USB未连接
|
||||
@@ -444,10 +295,6 @@ static void HandleUSBConnectionChange(void)
|
||||
|
||||
// 卸载用于采样的文件系统
|
||||
UnmountFileSystemForSampling();
|
||||
|
||||
#if ENABLE_SYSTEM_MONITOR
|
||||
SystemMonitor_SetState(SYSTEM_STATE_USB_MODE);
|
||||
#endif
|
||||
} else {
|
||||
// USB断开:重新挂载文件系统,开始数据采集
|
||||
DebugOutput_SendString("USB Disconnected: Starting data acquisition\r\n");
|
||||
@@ -459,10 +306,6 @@ static void HandleUSBConnectionChange(void)
|
||||
StartRecording();
|
||||
}
|
||||
}
|
||||
|
||||
#if ENABLE_SYSTEM_MONITOR
|
||||
SystemMonitor_SetState(SYSTEM_STATE_IDLE);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -578,7 +421,6 @@ int main(void)
|
||||
MX_SPI1_Init();
|
||||
MX_SPI2_Init();
|
||||
MX_SPI3_Init();
|
||||
MX_TIM1_Init();
|
||||
MX_USART1_UART_Init();
|
||||
MX_FATFS_Init();
|
||||
MX_USB_DEVICE_Init();
|
||||
@@ -586,32 +428,18 @@ int main(void)
|
||||
MX_TIM2_Init();
|
||||
/* USER CODE BEGIN 2 */
|
||||
|
||||
// SD_NAND_Init_And_Mount();
|
||||
// SD_NAND_Init_And_Mount();
|
||||
// SD_Test_Write();
|
||||
// SD_Test_Read();
|
||||
|
||||
// 初始化系统监控
|
||||
#if ENABLE_SYSTEM_MONITOR
|
||||
SystemMonitor_Init();
|
||||
SystemMonitor_SetState(SYSTEM_STATE_INIT);
|
||||
#endif
|
||||
|
||||
// 初始化性能监控
|
||||
#if ENABLE_PERFORMANCE_MONITOR
|
||||
PerformanceMonitor_Init();
|
||||
#endif
|
||||
|
||||
// 初始化调试输出
|
||||
DebugOutput_Init();
|
||||
|
||||
// 初始化LTC2508驱动
|
||||
if (LTC2508_Init(&hspi1, &hspi2, &hspi3) != LTC2508_OK) {
|
||||
#if ENABLE_SYSTEM_MONITOR
|
||||
SystemMonitor_ReportError(SYSTEM_ERROR_ADC);
|
||||
#endif
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
// 初始化RS485通信
|
||||
RS485_Init(&huart1, RS485_DE_RE_PORT, RS485_DE_RE_PIN);
|
||||
|
||||
@@ -629,15 +457,7 @@ int main(void)
|
||||
if (DataStorage_Init(&g_data_storage) == HAL_OK) {
|
||||
// 开始数据记录
|
||||
StartRecording();
|
||||
} else {
|
||||
#if ENABLE_SYSTEM_MONITOR
|
||||
SystemMonitor_ReportError(SYSTEM_ERROR_STORAGE);
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
#if ENABLE_SYSTEM_MONITOR
|
||||
SystemMonitor_ReportError(SYSTEM_ERROR_STORAGE);
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
// USB已连接,不进行数据采集
|
||||
@@ -649,22 +469,24 @@ int main(void)
|
||||
}
|
||||
}
|
||||
|
||||
// 系统初始化完成
|
||||
#if ENABLE_SYSTEM_MONITOR
|
||||
SystemMonitor_SetState(SYSTEM_STATE_IDLE);
|
||||
#endif
|
||||
|
||||
// 启动TIM2定时器用于1ms周期的ADC数据处理
|
||||
if (HAL_TIM_Base_Start_IT(&htim2) != HAL_OK) {
|
||||
#if ENABLE_SYSTEM_MONITOR
|
||||
SystemMonitor_ReportError(SYSTEM_ERROR_CRITICAL);
|
||||
#endif
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
// 初始化LTC2508驱动
|
||||
if (LTC2508_Init(&hspi1, &hspi2, &hspi3) != LTC2508_OK) {
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
// 触发信号引脚初始化
|
||||
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_2, GPIO_PIN_SET);
|
||||
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_2, GPIO_PIN_RESET);
|
||||
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_2, GPIO_PIN_SET);
|
||||
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_2, GPIO_PIN_RESET);
|
||||
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_2, GPIO_PIN_SET);
|
||||
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_2, GPIO_PIN_RESET);
|
||||
|
||||
/* USER CODE END 2 */
|
||||
|
||||
/* Infinite loop */
|
||||
@@ -674,21 +496,8 @@ int main(void)
|
||||
/* USER CODE END WHILE */
|
||||
|
||||
/* USER CODE BEGIN 3 */
|
||||
// 系统监控更新 (每100ms更新一次)
|
||||
// 定期任务
|
||||
uint32_t current_tick = HAL_GetTick();
|
||||
if (current_tick - g_last_monitor_update >= 100) {
|
||||
#if ENABLE_PERFORMANCE_MONITOR
|
||||
PerformanceMonitor_TaskStart(PERF_TASK_SYSTEM_MONITOR);
|
||||
#endif
|
||||
#if ENABLE_SYSTEM_MONITOR
|
||||
SystemMonitor_Update();
|
||||
#endif
|
||||
#if ENABLE_PERFORMANCE_MONITOR
|
||||
PerformanceMonitor_Update();
|
||||
PerformanceMonitor_TaskEnd(PERF_TASK_SYSTEM_MONITOR);
|
||||
#endif
|
||||
g_last_monitor_update = current_tick;
|
||||
}
|
||||
|
||||
// USB连接状态检测 (每500ms检测一次)
|
||||
if (current_tick - g_last_usb_check >= 500) {
|
||||
@@ -704,7 +513,6 @@ int main(void)
|
||||
// 定期输出调试信息 (每1秒输出一次)
|
||||
if (g_debug_output_enabled && (current_tick - g_last_debug_output >= DEBUG_OUTPUT_INTERVAL_MS)) {
|
||||
DebugOutput_PrintSystemStats();
|
||||
DebugOutput_PrintPerformanceStats();
|
||||
g_last_debug_output = current_tick;
|
||||
}
|
||||
|
||||
@@ -772,14 +580,19 @@ void SystemClock_Config(void)
|
||||
*/
|
||||
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
|
||||
{
|
||||
if (GPIO_Pin == ADC_DRY_Pin) {
|
||||
// ADC数据就绪,触发DMA读取
|
||||
if (LTC2508_TriggerDmaRead() != LTC2508_OK) {
|
||||
#if ENABLE_SYSTEM_MONITOR
|
||||
SystemMonitor_ReportError(SYSTEM_ERROR_ADC);
|
||||
#endif
|
||||
static uint32_t cnt = 0;
|
||||
if(LTC2508_IsInited() == 0) return;
|
||||
|
||||
cnt ++;
|
||||
// if(cnt % 5 == 0)
|
||||
{
|
||||
// HAL_GPIO_WritePin(GPIOA, GPIO_PIN_8, GPIO_PIN_SET);
|
||||
if (GPIO_Pin == ADC_DRY_Pin) {
|
||||
// ADC数据就绪,触发DMA读取
|
||||
LTC2508_TriggerDmaRead();
|
||||
}
|
||||
}
|
||||
// HAL_GPIO_WritePin(GPIOA, GPIO_PIN_8, GPIO_PIN_RESET);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -808,9 +621,6 @@ void HAL_SPI_ErrorCallback(SPI_HandleTypeDef *hspi)
|
||||
{
|
||||
// 调用LTC2508驱动的错误回调
|
||||
LTC2508_ErrorCallback(hspi);
|
||||
#if ENABLE_SYSTEM_MONITOR
|
||||
SystemMonitor_ReportError(SYSTEM_ERROR_ADC);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -827,13 +637,10 @@ void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
|
||||
const uint8_t max_process_per_interrupt = 8; // 限制每次中断最多处理的数据量,避免中断时间过长
|
||||
|
||||
while (processed_count < max_process_per_interrupt) {
|
||||
LTC2508_BufferTypeDef *ready_buffer = NULL;
|
||||
if (LTC2508_GetReadyBuffer(&ready_buffer) == LTC2508_OK && ready_buffer != NULL) {
|
||||
ProcessAdcData();
|
||||
processed_count++;
|
||||
} else {
|
||||
break; // 没有更多数据可处理
|
||||
}
|
||||
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_8, GPIO_PIN_SET);
|
||||
ProcessAdcData();
|
||||
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_8, GPIO_PIN_RESET);
|
||||
processed_count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -862,12 +669,6 @@ void Error_Handler(void)
|
||||
/* USER CODE BEGIN Error_Handler_Debug */
|
||||
/* User can add his own implementation to report the HAL error return state */
|
||||
|
||||
// 设置系统状态为错误状态
|
||||
#if ENABLE_SYSTEM_MONITOR
|
||||
SystemMonitor_SetState(SYSTEM_STATE_ERROR);
|
||||
SystemMonitor_ReportError(SYSTEM_ERROR_CRITICAL);
|
||||
#endif
|
||||
|
||||
// 停止所有DMA传输
|
||||
HAL_SPI_DMAStop(&hspi1);
|
||||
HAL_SPI_DMAStop(&hspi2);
|
||||
|
||||
+32
-12
@@ -28,6 +28,7 @@ SPI_HandleTypeDef hspi1;
|
||||
SPI_HandleTypeDef hspi2;
|
||||
SPI_HandleTypeDef hspi3;
|
||||
DMA_HandleTypeDef hdma_spi1_rx;
|
||||
DMA_HandleTypeDef hdma_spi1_tx;
|
||||
DMA_HandleTypeDef hdma_spi2_rx;
|
||||
DMA_HandleTypeDef hdma_spi3_rx;
|
||||
|
||||
@@ -45,7 +46,7 @@ void MX_SPI1_Init(void)
|
||||
hspi1.Instance = SPI1;
|
||||
hspi1.Init.Mode = SPI_MODE_MASTER;
|
||||
hspi1.Init.Direction = SPI_DIRECTION_2LINES;
|
||||
hspi1.Init.DataSize = SPI_DATASIZE_8BIT;
|
||||
hspi1.Init.DataSize = SPI_DATASIZE_16BIT;
|
||||
hspi1.Init.CLKPolarity = SPI_POLARITY_LOW;
|
||||
hspi1.Init.CLKPhase = SPI_PHASE_1EDGE;
|
||||
hspi1.Init.NSS = SPI_NSS_SOFT;
|
||||
@@ -77,7 +78,7 @@ void MX_SPI2_Init(void)
|
||||
hspi2.Instance = SPI2;
|
||||
hspi2.Init.Mode = SPI_MODE_SLAVE;
|
||||
hspi2.Init.Direction = SPI_DIRECTION_2LINES_RXONLY;
|
||||
hspi2.Init.DataSize = SPI_DATASIZE_8BIT;
|
||||
hspi2.Init.DataSize = SPI_DATASIZE_16BIT;
|
||||
hspi2.Init.CLKPolarity = SPI_POLARITY_LOW;
|
||||
hspi2.Init.CLKPhase = SPI_PHASE_1EDGE;
|
||||
hspi2.Init.NSS = SPI_NSS_SOFT;
|
||||
@@ -108,7 +109,7 @@ void MX_SPI3_Init(void)
|
||||
hspi3.Instance = SPI3;
|
||||
hspi3.Init.Mode = SPI_MODE_SLAVE;
|
||||
hspi3.Init.Direction = SPI_DIRECTION_2LINES_RXONLY;
|
||||
hspi3.Init.DataSize = SPI_DATASIZE_8BIT;
|
||||
hspi3.Init.DataSize = SPI_DATASIZE_16BIT;
|
||||
hspi3.Init.CLKPolarity = SPI_POLARITY_LOW;
|
||||
hspi3.Init.CLKPhase = SPI_PHASE_1EDGE;
|
||||
hspi3.Init.NSS = SPI_NSS_SOFT;
|
||||
@@ -158,10 +159,10 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef* spiHandle)
|
||||
hdma_spi1_rx.Init.Direction = DMA_PERIPH_TO_MEMORY;
|
||||
hdma_spi1_rx.Init.PeriphInc = DMA_PINC_DISABLE;
|
||||
hdma_spi1_rx.Init.MemInc = DMA_MINC_ENABLE;
|
||||
hdma_spi1_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
|
||||
hdma_spi1_rx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
|
||||
hdma_spi1_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD;
|
||||
hdma_spi1_rx.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD;
|
||||
hdma_spi1_rx.Init.Mode = DMA_NORMAL;
|
||||
hdma_spi1_rx.Init.Priority = DMA_PRIORITY_LOW;
|
||||
hdma_spi1_rx.Init.Priority = DMA_PRIORITY_VERY_HIGH;
|
||||
hdma_spi1_rx.Init.FIFOMode = DMA_FIFOMODE_DISABLE;
|
||||
if (HAL_DMA_Init(&hdma_spi1_rx) != HAL_OK)
|
||||
{
|
||||
@@ -170,6 +171,24 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef* spiHandle)
|
||||
|
||||
__HAL_LINKDMA(spiHandle,hdmarx,hdma_spi1_rx);
|
||||
|
||||
/* SPI1_TX Init */
|
||||
hdma_spi1_tx.Instance = DMA2_Stream5;
|
||||
hdma_spi1_tx.Init.Channel = DMA_CHANNEL_3;
|
||||
hdma_spi1_tx.Init.Direction = DMA_MEMORY_TO_PERIPH;
|
||||
hdma_spi1_tx.Init.PeriphInc = DMA_PINC_DISABLE;
|
||||
hdma_spi1_tx.Init.MemInc = DMA_MINC_ENABLE;
|
||||
hdma_spi1_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD;
|
||||
hdma_spi1_tx.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD;
|
||||
hdma_spi1_tx.Init.Mode = DMA_NORMAL;
|
||||
hdma_spi1_tx.Init.Priority = DMA_PRIORITY_VERY_HIGH;
|
||||
hdma_spi1_tx.Init.FIFOMode = DMA_FIFOMODE_DISABLE;
|
||||
if (HAL_DMA_Init(&hdma_spi1_tx) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
__HAL_LINKDMA(spiHandle,hdmatx,hdma_spi1_tx);
|
||||
|
||||
/* USER CODE BEGIN SPI1_MspInit 1 */
|
||||
|
||||
/* USER CODE END SPI1_MspInit 1 */
|
||||
@@ -201,10 +220,10 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef* spiHandle)
|
||||
hdma_spi2_rx.Init.Direction = DMA_PERIPH_TO_MEMORY;
|
||||
hdma_spi2_rx.Init.PeriphInc = DMA_PINC_DISABLE;
|
||||
hdma_spi2_rx.Init.MemInc = DMA_MINC_ENABLE;
|
||||
hdma_spi2_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
|
||||
hdma_spi2_rx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
|
||||
hdma_spi2_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD;
|
||||
hdma_spi2_rx.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD;
|
||||
hdma_spi2_rx.Init.Mode = DMA_NORMAL;
|
||||
hdma_spi2_rx.Init.Priority = DMA_PRIORITY_LOW;
|
||||
hdma_spi2_rx.Init.Priority = DMA_PRIORITY_VERY_HIGH;
|
||||
hdma_spi2_rx.Init.FIFOMode = DMA_FIFOMODE_DISABLE;
|
||||
if (HAL_DMA_Init(&hdma_spi2_rx) != HAL_OK)
|
||||
{
|
||||
@@ -244,10 +263,10 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef* spiHandle)
|
||||
hdma_spi3_rx.Init.Direction = DMA_PERIPH_TO_MEMORY;
|
||||
hdma_spi3_rx.Init.PeriphInc = DMA_PINC_DISABLE;
|
||||
hdma_spi3_rx.Init.MemInc = DMA_MINC_ENABLE;
|
||||
hdma_spi3_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
|
||||
hdma_spi3_rx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
|
||||
hdma_spi3_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD;
|
||||
hdma_spi3_rx.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD;
|
||||
hdma_spi3_rx.Init.Mode = DMA_NORMAL;
|
||||
hdma_spi3_rx.Init.Priority = DMA_PRIORITY_LOW;
|
||||
hdma_spi3_rx.Init.Priority = DMA_PRIORITY_VERY_HIGH;
|
||||
hdma_spi3_rx.Init.FIFOMode = DMA_FIFOMODE_DISABLE;
|
||||
if (HAL_DMA_Init(&hdma_spi3_rx) != HAL_OK)
|
||||
{
|
||||
@@ -282,6 +301,7 @@ void HAL_SPI_MspDeInit(SPI_HandleTypeDef* spiHandle)
|
||||
|
||||
/* SPI1 DMA DeInit */
|
||||
HAL_DMA_DeInit(spiHandle->hdmarx);
|
||||
HAL_DMA_DeInit(spiHandle->hdmatx);
|
||||
/* USER CODE BEGIN SPI1_MspDeInit 1 */
|
||||
|
||||
/* USER CODE END SPI1_MspDeInit 1 */
|
||||
|
||||
@@ -62,10 +62,12 @@ extern DMA_HandleTypeDef hdma_sdio_rx;
|
||||
extern DMA_HandleTypeDef hdma_sdio_tx;
|
||||
extern SD_HandleTypeDef hsd;
|
||||
extern DMA_HandleTypeDef hdma_spi1_rx;
|
||||
extern DMA_HandleTypeDef hdma_spi1_tx;
|
||||
extern DMA_HandleTypeDef hdma_spi2_rx;
|
||||
extern DMA_HandleTypeDef hdma_spi3_rx;
|
||||
extern TIM_HandleTypeDef htim2;
|
||||
extern DMA_HandleTypeDef hdma_usart1_tx;
|
||||
extern UART_HandleTypeDef huart1;
|
||||
/* USER CODE BEGIN EV */
|
||||
extern SPI_HandleTypeDef hspi1;
|
||||
extern SPI_HandleTypeDef hspi2;
|
||||
@@ -267,6 +269,20 @@ void TIM2_IRQHandler(void)
|
||||
/* USER CODE END TIM2_IRQn 1 */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles USART1 global interrupt.
|
||||
*/
|
||||
void USART1_IRQHandler(void)
|
||||
{
|
||||
/* USER CODE BEGIN USART1_IRQn 0 */
|
||||
|
||||
/* USER CODE END USART1_IRQn 0 */
|
||||
HAL_UART_IRQHandler(&huart1);
|
||||
/* USER CODE BEGIN USART1_IRQn 1 */
|
||||
|
||||
/* USER CODE END USART1_IRQn 1 */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles SDIO global interrupt.
|
||||
*/
|
||||
@@ -323,6 +339,20 @@ void OTG_FS_IRQHandler(void)
|
||||
/* USER CODE END OTG_FS_IRQn 1 */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles DMA2 stream5 global interrupt.
|
||||
*/
|
||||
void DMA2_Stream5_IRQHandler(void)
|
||||
{
|
||||
/* USER CODE BEGIN DMA2_Stream5_IRQn 0 */
|
||||
|
||||
/* USER CODE END DMA2_Stream5_IRQn 0 */
|
||||
HAL_DMA_IRQHandler(&hdma_spi1_tx);
|
||||
/* USER CODE BEGIN DMA2_Stream5_IRQn 1 */
|
||||
|
||||
/* USER CODE END DMA2_Stream5_IRQn 1 */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles DMA2 stream6 global interrupt.
|
||||
*/
|
||||
|
||||
+3
-123
@@ -24,79 +24,8 @@
|
||||
|
||||
/* USER CODE END 0 */
|
||||
|
||||
TIM_HandleTypeDef htim1;
|
||||
TIM_HandleTypeDef htim2;
|
||||
|
||||
/* TIM1 init function */
|
||||
void MX_TIM1_Init(void)
|
||||
{
|
||||
|
||||
/* USER CODE BEGIN TIM1_Init 0 */
|
||||
|
||||
/* USER CODE END TIM1_Init 0 */
|
||||
|
||||
TIM_ClockConfigTypeDef sClockSourceConfig = {0};
|
||||
TIM_MasterConfigTypeDef sMasterConfig = {0};
|
||||
TIM_OC_InitTypeDef sConfigOC = {0};
|
||||
TIM_BreakDeadTimeConfigTypeDef sBreakDeadTimeConfig = {0};
|
||||
|
||||
/* USER CODE BEGIN TIM1_Init 1 */
|
||||
|
||||
/* USER CODE END TIM1_Init 1 */
|
||||
htim1.Instance = TIM1;
|
||||
htim1.Init.Prescaler = 0;
|
||||
htim1.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||
htim1.Init.Period = 83;
|
||||
htim1.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
|
||||
htim1.Init.RepetitionCounter = 0;
|
||||
htim1.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
|
||||
if (HAL_TIM_Base_Init(&htim1) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
|
||||
if (HAL_TIM_ConfigClockSource(&htim1, &sClockSourceConfig) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
if (HAL_TIM_PWM_Init(&htim1) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
|
||||
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
|
||||
if (HAL_TIMEx_MasterConfigSynchronization(&htim1, &sMasterConfig) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
sConfigOC.OCMode = TIM_OCMODE_PWM1;
|
||||
sConfigOC.Pulse = 0;
|
||||
sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;
|
||||
sConfigOC.OCNPolarity = TIM_OCNPOLARITY_HIGH;
|
||||
sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
|
||||
sConfigOC.OCIdleState = TIM_OCIDLESTATE_RESET;
|
||||
sConfigOC.OCNIdleState = TIM_OCNIDLESTATE_RESET;
|
||||
if (HAL_TIM_PWM_ConfigChannel(&htim1, &sConfigOC, TIM_CHANNEL_1) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
sBreakDeadTimeConfig.OffStateRunMode = TIM_OSSR_DISABLE;
|
||||
sBreakDeadTimeConfig.OffStateIDLEMode = TIM_OSSI_DISABLE;
|
||||
sBreakDeadTimeConfig.LockLevel = TIM_LOCKLEVEL_OFF;
|
||||
sBreakDeadTimeConfig.DeadTime = 0;
|
||||
sBreakDeadTimeConfig.BreakState = TIM_BREAK_DISABLE;
|
||||
sBreakDeadTimeConfig.BreakPolarity = TIM_BREAKPOLARITY_HIGH;
|
||||
sBreakDeadTimeConfig.AutomaticOutput = TIM_AUTOMATICOUTPUT_DISABLE;
|
||||
if (HAL_TIMEx_ConfigBreakDeadTime(&htim1, &sBreakDeadTimeConfig) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
/* USER CODE BEGIN TIM1_Init 2 */
|
||||
|
||||
/* USER CODE END TIM1_Init 2 */
|
||||
HAL_TIM_MspPostInit(&htim1);
|
||||
|
||||
}
|
||||
/* TIM2 init function */
|
||||
void MX_TIM2_Init(void)
|
||||
{
|
||||
@@ -141,18 +70,7 @@ void MX_TIM2_Init(void)
|
||||
void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* tim_baseHandle)
|
||||
{
|
||||
|
||||
if(tim_baseHandle->Instance==TIM1)
|
||||
{
|
||||
/* USER CODE BEGIN TIM1_MspInit 0 */
|
||||
|
||||
/* USER CODE END TIM1_MspInit 0 */
|
||||
/* TIM1 clock enable */
|
||||
__HAL_RCC_TIM1_CLK_ENABLE();
|
||||
/* USER CODE BEGIN TIM1_MspInit 1 */
|
||||
|
||||
/* USER CODE END TIM1_MspInit 1 */
|
||||
}
|
||||
else if(tim_baseHandle->Instance==TIM2)
|
||||
if(tim_baseHandle->Instance==TIM2)
|
||||
{
|
||||
/* USER CODE BEGIN TIM2_MspInit 0 */
|
||||
|
||||
@@ -161,56 +79,18 @@ void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* tim_baseHandle)
|
||||
__HAL_RCC_TIM2_CLK_ENABLE();
|
||||
|
||||
/* TIM2 interrupt Init */
|
||||
HAL_NVIC_SetPriority(TIM2_IRQn, 3, 0);
|
||||
HAL_NVIC_SetPriority(TIM2_IRQn, 12, 0);
|
||||
HAL_NVIC_EnableIRQ(TIM2_IRQn);
|
||||
/* USER CODE BEGIN TIM2_MspInit 1 */
|
||||
|
||||
/* USER CODE END TIM2_MspInit 1 */
|
||||
}
|
||||
}
|
||||
void HAL_TIM_MspPostInit(TIM_HandleTypeDef* timHandle)
|
||||
{
|
||||
|
||||
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||||
if(timHandle->Instance==TIM1)
|
||||
{
|
||||
/* USER CODE BEGIN TIM1_MspPostInit 0 */
|
||||
|
||||
/* USER CODE END TIM1_MspPostInit 0 */
|
||||
|
||||
__HAL_RCC_GPIOA_CLK_ENABLE();
|
||||
/**TIM1 GPIO Configuration
|
||||
PA8 ------> TIM1_CH1
|
||||
*/
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_8;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
GPIO_InitStruct.Alternate = GPIO_AF1_TIM1;
|
||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||
|
||||
/* USER CODE BEGIN TIM1_MspPostInit 1 */
|
||||
|
||||
/* USER CODE END TIM1_MspPostInit 1 */
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* tim_baseHandle)
|
||||
{
|
||||
|
||||
if(tim_baseHandle->Instance==TIM1)
|
||||
{
|
||||
/* USER CODE BEGIN TIM1_MspDeInit 0 */
|
||||
|
||||
/* USER CODE END TIM1_MspDeInit 0 */
|
||||
/* Peripheral clock disable */
|
||||
__HAL_RCC_TIM1_CLK_DISABLE();
|
||||
/* USER CODE BEGIN TIM1_MspDeInit 1 */
|
||||
|
||||
/* USER CODE END TIM1_MspDeInit 1 */
|
||||
}
|
||||
else if(tim_baseHandle->Instance==TIM2)
|
||||
if(tim_baseHandle->Instance==TIM2)
|
||||
{
|
||||
/* USER CODE BEGIN TIM2_MspDeInit 0 */
|
||||
|
||||
|
||||
+8
-2
@@ -41,7 +41,7 @@ void MX_USART1_UART_Init(void)
|
||||
|
||||
/* USER CODE END USART1_Init 1 */
|
||||
huart1.Instance = USART1;
|
||||
huart1.Init.BaudRate = 115200;
|
||||
huart1.Init.BaudRate = 2000000;
|
||||
huart1.Init.WordLength = UART_WORDLENGTH_8B;
|
||||
huart1.Init.StopBits = UART_STOPBITS_1;
|
||||
huart1.Init.Parity = UART_PARITY_NONE;
|
||||
@@ -70,7 +70,7 @@ void MX_USART3_UART_Init(void)
|
||||
|
||||
/* USER CODE END USART3_Init 1 */
|
||||
huart3.Instance = USART3;
|
||||
huart3.Init.BaudRate = 115200;
|
||||
huart3.Init.BaudRate = 921600;
|
||||
huart3.Init.WordLength = UART_WORDLENGTH_8B;
|
||||
huart3.Init.StopBits = UART_STOPBITS_1;
|
||||
huart3.Init.Parity = UART_PARITY_NONE;
|
||||
@@ -130,6 +130,9 @@ void HAL_UART_MspInit(UART_HandleTypeDef* uartHandle)
|
||||
|
||||
__HAL_LINKDMA(uartHandle,hdmatx,hdma_usart1_tx);
|
||||
|
||||
/* USART1 interrupt Init */
|
||||
HAL_NVIC_SetPriority(USART1_IRQn, 6, 0);
|
||||
HAL_NVIC_EnableIRQ(USART1_IRQn);
|
||||
/* USER CODE BEGIN USART1_MspInit 1 */
|
||||
|
||||
/* USER CODE END USART1_MspInit 1 */
|
||||
@@ -179,6 +182,9 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef* uartHandle)
|
||||
|
||||
/* USART1 DMA DeInit */
|
||||
HAL_DMA_DeInit(uartHandle->hdmatx);
|
||||
|
||||
/* USART1 interrupt Deinit */
|
||||
HAL_NVIC_DisableIRQ(USART1_IRQn);
|
||||
/* USER CODE BEGIN USART1_MspDeInit 1 */
|
||||
|
||||
/* USER CODE END USART1_MspDeInit 1 */
|
||||
|
||||
Reference in New Issue
Block a user