Files
GD32E50X_BOOT/GD32E50X_BOOT/comm/ecat/applInterface.h
T
cbb 46adcb790c feat(boot): BOOT 常驻原生 EtherCAT 刷 APP,跳转前按 HBI 使用情况补发 ESC 复位
把 BOOT 侧已上板跑通的 SSC/HBI 移植层一次性入库(comm/ecat + gd32e50x_exmc),
并修掉「刷完首启 APP 报 EXMC 总线未就绪、断电重上即好」这条实测链:

- v1.1.0.13:jumpToApplication 前补一发 LAN9252 RST#。BOOT 侧 HBI 全是索引两步事务,
  bootEcatDeinit 末尾的 writeReg32 把 HBI_IDX_0 留在 0x0054,而 APP 起板探针判
  IDX_0==0x1234(DS 9.5.4.2 复位默认值),带着残值跳进去就直接报总线未就绪。
- v1.1.0.14:那一发不能无条件下发。path=jump_latest_now(上电 3ms 直跳、这轮 ESC 从没
  起过)也在电源刚稳的窗口里拉了 RST#,释放点距上电仅约 15ms,板上表现为每次上电都停
  在 BOOT 里(串口停在 [J5-HEX];microlib + putChar 逐字符阻塞等 TBE,故日志停在半截
  = CPU 真停在那儿,不是尾巴没刷出来)。现由 s_escBusUp 门控(bootEcatBringup 里
  exmcInit 成功才置位);脉宽从 delay_1us(按 4cycle/迭代标定,实测 30ms 只走出 8ms)
  换成 DWT CYCCNT 真 30ms + 释放后 2ms;跳转前打 [J6] boot v<ver> handoff。
  delay_1ms 在这里不可用:本函数跑在 __disable_irq() 之后,SysTick 中断不递减就是永久
  死等,而 BOOT 没开 IWDG —— 那会变成刷完直接静默变砖。

v1.1.0.12 的两条一并入库:10s OTA 窗口的活性判据并上 ecatSessionActive(防半截灌写被
当合法 APP 跳进去、HardFault→复位→留守 10s 形成活锁);0x100A 上报真版本串
(DEVICE_SW_VERSION_LEN 0x3→0x10,acSoftwareversion 显式给 LEN+1 防越界读)。

板上实测:v1.1.0.14 上电直跳恢复正常,APP v1.6.34 起板,自检 ethercat 不再降级。
2026-09-15 00:19:33 +08:00

126 lines
4.7 KiB
C

/**
\addtogroup EcatAppl EtherCAT application
@{
*/
/**
\file applInterface.c
\author EthercatSSC@beckhoff.com
\brief Definition of the application interface functions
\version 5.11
<br>Changes to version - :<br>
V5.10.1 : Start file change log
*/
/*-----------------------------------------------------------------------------------------
------
------ Includes
------
-----------------------------------------------------------------------------------------*/
#ifndef _APPL_INTERFACE_H_
#define _APPL_INTERFACE_H_
#include "ecat_def.h"
#include <stdlib.h>
#include <string.h>
#include "esc.h"
#include "ecatslv.h"
#include "objdef.h"
#include "ecatappl.h"
#endif /*#ifndef _APPL_INTERFACE_H_*/
#if defined(_APPL_INTERFACE_) && (_APPL_INTERFACE_ == 1)
#define PROTO
#else
#define PROTO extern
#endif
/*-----------------------------------------------------------------------------------------
------
------ Function pointer which are used to call optional functions from the application
------
-----------------------------------------------------------------------------------------*/
/////////////////////////////////////////////////////////////////////////////////////////
/**
\return 0 if successful or greater 0 in case of an error
\param wordaddr Word address of the EEPROM data to be read
\brief This function shall copy EEPROM data to the ESC EEPROM data register (0x508:0x50F/0x50B).
\brief The EEPROM data starting at the specified word address and the length specified with "EEPROM_READ_SIZE".
\brief The data shall be copied to the ESC EEPROM buffer (ESC offset 0x508)
*////////////////////////////////////////////////////////////////////////////////////////
PROTO UINT16 (* pAPPL_EEPROM_Read)(UINT32 wordaddr);
/////////////////////////////////////////////////////////////////////////////////////////
/**
\return 0 if successful or greater 0 in case of an error
\param wordaddr Word address of the EEPROM data to be written
\brief This function shall copy data from the ESC EEPROM data register (0x508:0x50F/0x50B) to the EEPROM memory.
\brief The EEPROM data starting at the specified word address and the length specified with "EEPROM_WRITE_SIZE".
*////////////////////////////////////////////////////////////////////////////////////////
PROTO UINT16(*pAPPL_EEPROM_Write)(UINT32 wordaddr);
/////////////////////////////////////////////////////////////////////////////////////////
/**
\return 0 if successful or greater 0 in case of an error
\brief This function shall copy the EEPROM reload information to the ESC EEPROM data register (0x508:0x50F/0x50B).
\brief Read the ESC data sheet for the reload information (e.g. Beckhoff IPCore ESC Datasheet section II, clause 3.45.1)
*////////////////////////////////////////////////////////////////////////////////////////
PROTO UINT16(*pAPPL_EEPROM_Reload)(void);
/*-----------------------------------------------------------------------------------------
------
------ Functions provided by the SSC to be called from the application
------
-----------------------------------------------------------------------------------------*/
/////////////////////////////////////////////////////////////////////////////////////////
/**
\return 0 if successful or greater 0 in case of an error
\brief Initialize the generic slave stack.
\brief This function should be called after the platform including operating system and
\brief ESC is ready to use.
*////////////////////////////////////////////////////////////////////////////////////////
PROTO UINT16 MainInit(void);
/////////////////////////////////////////////////////////////////////////////////////////
/**
\brief This function handles the low priority function like EtherCAT state machine
\brief handling, mailbox protocols and if no synchronization is enabled also the
\brief application.
\brief This function shall be called cyclically from the application.
*////////////////////////////////////////////////////////////////////////////////////////
PROTO void MainLoop(void);
/////////////////////////////////////////////////////////////////////////////////////////
/**
\param alStatus requested AL Status
\param alStatusCode requested AL Status Code
\brief This function shall be called by the application to trigger state transition in case
\brief of an application error or to complete a pending transition.
\brief If the function was called due to an error it shall be again if the error is gone.
\brief NOTE: state requests to a higher state than the current state are not allowed.
*////////////////////////////////////////////////////////////////////////////////////////
PROTO void ECAT_StateChange(UINT8 alStatus, UINT16 alStatusCode);
#undef PROTO