原文地址:http://blog.csdn.net/huangxianxinalice/article/details/9896825
- /
- /**
- \brief This function initialize the EtherCAT Slave Interface.这个函数初始化EtherCAT从站的接口
- *////
- void ECAT_Init(void)
- {
- UINT8 i;
- /*Get Maximum Number of SyncManagers获得SM最大的数目*/
- HW_EscReadByte(nMaxSyncMan, ESC_SM_CHANNELS_OFFSET);
- /* disable all Sync Manager channels 去使能所有的SM通道*/
- for (i = 0; i < nMaxSyncMan; i++)
- HW_DisableSyncManChannel(i);
- /* initialize the mailbox handler 初始化所有的邮箱处理*/
- MBX_Init();
- /* initialize variables 初始化变量*/
- bApplEsmPending = FALSE;
- bEcatWaitForAlControlRes = FALSE;
- bEcatFirstOutputsReceived = FALSE;
- bEcatOutputUpdateRunning = FALSE;
- bEcatInputUpdateRunning = FALSE;
- bWdTrigger = FALSE;
- EcatWdValue = 0;
- Sync0WdCounter = 0;
- Sync0WdValue = 0;
- bDcSyncActive = FALSE;
- bLocalErrorFlag = FALSE;
- u16LocalErrorCode = 0x00;
- u16ALEventMask = 0;
- /* initialize the AL Status register初始化AL状态寄存器 */
- nAlStatus = STATE_INIT;
- SetALStatus(nAlStatus, 0);
- nEcatStateTrans = 0;
- #if LEDS_SUPPORTED || ESC_SUPPORT_ECAT_LED
- u8EcatErrorLed = LED_OFF;
- #endif
- bEscIntEnabled = FALSE;
- #if COE_SUPPORTED
- /* 初始化COE的部分 */
- COE_Init();
- #endif
- }