feat(ethercat): 添加EtherCAT从站功能支持并优化同步机制
- 添加CAN反馈和ID快照SPI命令文件 - 移除EXMC组件依赖,精简项目配置 - 添加RAM函数段链接脚本,优化Flash等待周期抖动 - 实现EscExmcBus类,提供16位并行总线访问LAN9252 - 实现EscLan9252驱动,支持寄存器和PDI内存访问 - 实现EthercatSlave类,采用三缓冲机制进行PDO数据交换 - 实现EthercatSync同步管理,支持SYNC0/SYNC1中断和定时器模式 - 添加ISR执行时间统计和诊断功能 - 分离周期路径和事件路径通知机制,避免RMW竞态
This commit is contained in:
@@ -5,8 +5,6 @@
|
||||
#include "comm/esc_exmc_bus.h"
|
||||
#include "sys/config.h"
|
||||
|
||||
#if CONFIG_ETHERCAT_ENABLE
|
||||
|
||||
extern "C" {
|
||||
#include "gd32e50x_rcu.h"
|
||||
#include "gd32e50x_gpio.h"
|
||||
@@ -68,32 +66,18 @@ void EscExmcBus::init()
|
||||
exmc_norsram_init(&norsram_init);
|
||||
exmc_norsram_enable(CONFIG_ESC_EXMC_BANK_NOR_SRAM_REGION1);
|
||||
#else
|
||||
/* EXMC 外设库未安装:仅占位,CONFIG_ETHERCAT_ENABLE=1 时需先安装 EXMC 组件。 */
|
||||
/* EXMC 外设库未安装:仅占位,启用 EtherCAT 时需先安装 EXMC 组件。 */
|
||||
#endif
|
||||
}
|
||||
|
||||
__attribute__((section(".ramfunc"), noinline))
|
||||
uint16_t EscExmcBus::read16(uint32_t offset)
|
||||
{
|
||||
return ESC_EXMC_REG16(offset);
|
||||
}
|
||||
|
||||
__attribute__((section(".ramfunc"), noinline))
|
||||
void EscExmcBus::write16(uint32_t offset, uint16_t data)
|
||||
{
|
||||
ESC_EXMC_REG16(offset) = data;
|
||||
}
|
||||
|
||||
void EscExmcBus::readBlock(uint32_t offset, uint16_t *buf, size_t count)
|
||||
{
|
||||
for (size_t i = 0U; i < count; ++i) {
|
||||
buf[i] = ESC_EXMC_REG16(offset + (uint32_t)(i * 2U));
|
||||
}
|
||||
}
|
||||
|
||||
void EscExmcBus::writeBlock(uint32_t offset, const uint16_t *buf, size_t count)
|
||||
{
|
||||
for (size_t i = 0U; i < count; ++i) {
|
||||
ESC_EXMC_REG16(offset + (uint32_t)(i * 2U)) = buf[i];
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* CONFIG_ETHERCAT_ENABLE */
|
||||
|
||||
Reference in New Issue
Block a user