feat(cproject): 重构项目文件结构并添加EtherCAT通信支持
- 将设备相关文件重新组织为device/spi和comm分组 - 添加EtherCAT从站通信模块(esc_exmc_bus、esc_lan9252、ethercat_slave等) - 添加EXMC外设组件支持 - 统一文件命名规范为小写 refactor(canfd): 优化CANFD模块中断安全性和配置方式 - 替换自定义临界区函数为RT_CRITICAL_SAVE/RESTORE宏 - 使用配置常量CONFIG_IRQ_PREEMPT_CAN替代硬编码值 - 简化邮箱满时的处理逻辑,移除不必要的SysTick等待 - 移除废弃的中断保存头文件引用 refactor(timer): 更新定时器配置以使用配置常量 - 修复头文件包含路径大小写问题 - 使用CONFIG_NVIC_PRIORITY_GROUP配置项替代硬编码值
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/**
|
||||
* @file task_runner.cpp
|
||||
* @brief 任务执行器实现。
|
||||
*/
|
||||
@@ -6,13 +6,16 @@
|
||||
#include "main.h"
|
||||
#include "device/adc.h"
|
||||
#include "device/watchdog.h"
|
||||
#include "device/app_spi_command.h"
|
||||
#include "device/spi/app_spi_command.h"
|
||||
#include "device/canfd.h"
|
||||
#include "device/temp_sensor.h"
|
||||
#include "sys/config.h"
|
||||
#include "sys/ota_boot_request.h"
|
||||
#include "sys/task_manager.h"
|
||||
#include "sys/task_runner.h"
|
||||
#if CONFIG_ETHERCAT_ENABLE
|
||||
#include "comm/ethercat_slave.h"
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
constexpr uint32_t kAdcFilterWindow = CONFIG_ADC_FILTER_SIZE + 1U;
|
||||
@@ -265,6 +268,34 @@ void TaskRunner::taskDiagnosticPrint()
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 执行 SPI CS release 后推迟的命令解析(从 ISR 移出)。
|
||||
* @param[in] 无。
|
||||
* @param[out] 无。
|
||||
* @retval 无返回值。
|
||||
* @note ISR 瘦身:onCsRelease() 仅置位 TASK_SPI_CMD_PROCESS,实际解析在此执行。
|
||||
*/
|
||||
void TaskRunner::taskSpiCmdProcess()
|
||||
{
|
||||
AppSpiCommandBus.processPendingCommand();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 执行 EtherCAT 周期/事件处理(非实时应用层 PDO 映射)。
|
||||
* @param[in] 无。
|
||||
* @param[out] 无。
|
||||
* @retval 无返回值。
|
||||
* @note 由周期 ISR(EXTI0 SYNC0)或 ESC 事件 ISR(EXTI1 IRQ)置位 TASK_ETHERCAT_PROCESS。
|
||||
*/
|
||||
void TaskRunner::taskEthercatProcess()
|
||||
{
|
||||
#if CONFIG_ETHERCAT_ENABLE
|
||||
EthercatSlave::process();
|
||||
#else
|
||||
/* 未使能 EtherCAT 时此分支不应被置位;保留空操作以避免链接错误。 */
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 初始化任务执行器运行时上下文。
|
||||
* @param[in] 无。
|
||||
@@ -309,4 +340,6 @@ void TaskRunner::runPending()
|
||||
if(pending & (1UL << TASK_HEARTBEAT)) taskHeartbeat();
|
||||
if(pending & (1UL << TASK_DIAGNOSTIC_PRINT)) taskDiagnosticPrint();
|
||||
if(pending & (1UL << TASK_SPI_LOG)) AppSpiCommandBus.poll();
|
||||
if(pending & (1UL << TASK_SPI_CMD_PROCESS)) taskSpiCmdProcess();
|
||||
if(pending & (1UL << TASK_ETHERCAT_PROCESS)) taskEthercatProcess();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user