倍福EtherCAT从站协议栈代码SSC移植到ARM Cortex-M3

软件组织架构:

./Startup 存放启动文件(后缀名s的文件)

./Application 存放main函数

./System 存放跟CM3有关的文件

./SSC  存放跟EtherCAT从站协议栈有关的文件

从站协议栈架构,可以参考以下文章:

Beckoff的EtherCAT从站代码架构解析 https://blog.csdn.net/kobesdu/article/details/42169293

 【note】EtherCAT从站代码配置 https://blog.csdn.net/kobesdu/article/details/41869995

基于EtherCAT协议的从站分析 http://www.xhuojia.com/hardware/800350357.html

 倍福提供的EtherCAT从站代码包解析 https://blog.csdn.net/xkzju2010/article/details/46482213?locationNum=11&fps=1

【note】Slave STack Code Tool之各类参数配置 https://blog.csdn.net/kobesdu/article/details/38440415?locationNum=6&fps=1

EtherCAT从站开发方案介绍--含ET9300对比 https://wenku.baidu.com/view/e576093add3383c4bb4cd2ac.html

EtherCAT从站代码注释(部分) https://blog.csdn.net/xkzju2010/article/details/46482229

基于EtherCAT协议的从站分析 http://www.xhuojia.com/hardware/800350357.html
-------------------------------------------------------------------

HW_Init(void)函数,定义了PDI接口。ESC的PDI(过程数据接口)有这几种情况:

1. Up to 32 bit digital I/O——32位数字量I/O

2. Serial Peripheral Interface ——SPI总线

3.  8/16-bit synchronous/asynchronous Microcontroller Interface ——MCI接口

4. With FPGA, specific on-board-bus——带FPGA的,特定的on-board-bus

过程数据和参数是通过ESC上的DPRAM来交互的。为了保证数据的一致性,ESC硬件上会有一些 机制,比如同步管理器等。

HW_Init函数的解读也可以参考 https://blog.csdn.net/qq_15157841/article/details/51789250

UINT16 HW_Init(void)
{
    
    #if DBG_INFO_ENABLE
        DBG_INFO = 0x0101;
    #endif
    UINT32 intMask = 0;
    pEsc = (unsigned short *)ESC100StartAddress;//(unsigned short)MAKE_PTR_TO_ESC;定义指针pEsc,指向ESC物理内存起始地址    
    UINT16 u16PdiCtrl = 0;

    do
    {
        HW_EscReadWord(u16PdiCtrl,ESC_PDI_CONTROL_OFFSET);//ESC_PDI_CONTROL_OFFSET==0x0140
    } while (((u16PdiCtrl & 0xFF) < 0x8) || ((u16PdiCtrl & 0xFF) > 0xD) );


    #if AL_EVENT_ENABLED
        HW_EscWriteDWord(intMask, ESC_AL_EVENTMASK_OFFSET);//ESC_AL_EVENTMASK_OFFSET==0x0204  AL Event masking of the AL Event Request register Events for mapping to PDI IRQ signal

    /* enable the ESC-interrupt microcontroller specific,
        the macro ENABLE_ESC_INT should be defined in ecat_def.h */
    //------------ENABLE_ESC_INT();
    #else
        /* initialize the AL_Event Mask Register */
        HW_EscWriteDWord(intMask, ESC_AL_EVENTMASK_OFFSET);
    #endif
    return 0;
}

猜你喜欢

转载自blog.csdn.net/wofreeo/article/details/82378343