添加EXMC 16-bit并行总线驱动实现,用于LAN9252 ESC通信。 在cproject.yml中添加device_exmc组和相关源文件,包括 gd32e50x_exmc.c/h文件,并更新头文件搜索路径。 由于GigaDevice DFP未将EXMC注册为CMSIS组件,需要本地编入 RTE/Device目录下的EXMC源文件以支持LAN9252并行总线功能。 fix(canfd): 优化CANFD驱动中的条件编译和DLC处理逻辑 将CANFD相关的配置项从硬编码改为使用sys/config.h中的配置。 添加对DLC=0情况的支持(表示无数据负载的远程帧), 修正了数据长度检查逻辑,确保DLC为0时不需要提供数据指针。 同时重构了调试代码的条件编译,使用CONFIG_CAN_STARTUP_DIAG_VERBOSE 等配置开关控制调试输出函数的编译。 refactor(ethercat): 统一配置项管理,移除硬编码常量 将EtherCAT相关配置项从硬编码改为统一的sys/config.h配置, 提升代码可维护性。 docs(spi): 更新SPI命令响应缓冲区大小说明 更新CAN桥接和ID快照命令的响应payload大小计算说明, 统一使用AppSpiCommand::kTxBufSize - V2_OVERHEAD作为上限。
67 lines
2.3 KiB
C++
67 lines
2.3 KiB
C++
/**
|
|
* @file initial.cpp
|
|
* @brief 应用启动初始化实现。
|
|
*/
|
|
|
|
#include "sys/initial.h"
|
|
|
|
#include "device/canfd.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();
|
|
/* ESP32 EN/RESET (PC9) 直接配置为推挽输出高电平,保持 ESP32 正常运行 */
|
|
rcu_periph_clock_enable(RCU_GPIOC);
|
|
gpio_bit_set(CONFIG_ESP32_RESET_PORT, CONFIG_ESP32_RESET_PIN);
|
|
gpio_init(CONFIG_ESP32_RESET_PORT, GPIO_MODE_OUT_PP, GPIO_OSPEED_50MHZ, CONFIG_ESP32_RESET_PIN);
|
|
printf("[APP] init: USART0...\r\n");
|
|
Usart0::configurePins();
|
|
Usart0::init();
|
|
printf("[APP] init: ADC...\r\n");
|
|
Adc::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");
|
|
}
|