- 添加CAN反馈和ID快照SPI命令文件 - 移除EXMC组件依赖,精简项目配置 - 添加RAM函数段链接脚本,优化Flash等待周期抖动 - 实现EscExmcBus类,提供16位并行总线访问LAN9252 - 实现EscLan9252驱动,支持寄存器和PDI内存访问 - 实现EthercatSlave类,采用三缓冲机制进行PDO数据交换 - 实现EthercatSync同步管理,支持SYNC0/SYNC1中断和定时器模式 - 添加ISR执行时间统计和诊断功能 - 分离周期路径和事件路径通知机制,避免RMW竞态
64 lines
2.0 KiB
C++
64 lines
2.0 KiB
C++
/**
|
|
* @file initial.cpp
|
|
* @brief 应用启动初始化实现。
|
|
*/
|
|
|
|
#include "sys/initial.h"
|
|
|
|
#include "device/canfd.h"
|
|
#include "device/temp_sensor.h"
|
|
#include "device/usart0.h"
|
|
#include "device/timer.h"
|
|
#include "device/adc.h"
|
|
#include "device/watchdog.h"
|
|
#include "device/spi/app_spi_command.h"
|
|
#include "sys/systick.h"
|
|
#include "sys/ota_boot_request.h"
|
|
#include "sys/task_manager.h"
|
|
#include "sys/config.h"
|
|
#include "comm/ethercat_slave.h"
|
|
#include "comm/ethercat_sync.h"
|
|
|
|
/**
|
|
* @brief 执行应用级外设与调度初始化。
|
|
* @param[in] 无。
|
|
* @param[out] 无。
|
|
* @retval 无返回值。
|
|
* @note 依次完成 SysTick、USART0、ADC/温度采样、CANFD、任务管理器与调度定时器的启动。
|
|
*/
|
|
void AppInitializer::init()
|
|
{
|
|
/* 必须最先设置 NVIC 优先级分组:确保后续 CanFd/SPI0 等外设 init 中
|
|
* 编码抢占/子优先级字节时使用正确的分组(PRE4_SUB0),避免在错误分组
|
|
* 下编码后被重新解释。EtherCAT 实时架构整改 Task3。 */
|
|
nvic_priority_group_set(CONFIG_NVIC_PRIORITY_GROUP);
|
|
printf("[APP] init: SysTick...\r\n");
|
|
SysTickTimer::initMs();
|
|
printf("[APP] init: USART0...\r\n");
|
|
Usart0::configurePins();
|
|
Usart0::init();
|
|
printf("[APP] init: TempSensor...\r\n");
|
|
TempSensor::init();
|
|
printf("[APP] init: CANFD...\r\n");
|
|
CanFd::init();
|
|
printf("[APP] init: OtaBootRequest...\r\n");
|
|
OtaBootRequest::init();
|
|
printf("[APP] init: AppSpiCommand...\r\n");
|
|
AppSpiCommandBus.init();
|
|
printf("[APP] init: TaskManager...\r\n");
|
|
TaskManager::init();
|
|
printf("[APP] init: SchedulerTimer...\r\n");
|
|
SchedulerTimer::init();
|
|
printf("[APP] init: EthercatSlave...\r\n");
|
|
EthercatSlave::init();
|
|
if (EthercatSlave::isEscReady()) {
|
|
printf("[APP] init: EthercatSync...\r\n");
|
|
EthercatSync::init();
|
|
} else {
|
|
printf("[APP] init: EthercatSync SKIPPED (ESC not ready)\r\n");
|
|
}
|
|
printf("[APP] init: Watchdog...\r\n");
|
|
Watchdog::init();
|
|
printf("[APP] init: all done\r\n");
|
|
}
|