#include <defines/ecSlvApiDef.h>
#include <ecSlvESI.h>
#include <ESL_os.h>
#include <ESL_BOARD_config.h>
#include <ESL_vendor.h>
#include <ESL_gpioHelper.h>
#include <ESL_foeDemo.h>
#include <ESL_soeDemo.h>
#include <ESL_eeprom.h>
#include <ESL_cia402Demo.h>
#include <ESL_esiParser.h>
#include <ecSlvApi.h>
#if !(defined MBXMEM)
#define MBXMEM
#endif
#ifdef OSAL_LINUX
#define SITARA_ESI_FILE "sitara.xml"
#define FAULHABER_ESI_FILE "Faulhaber_MC5004_012601_06.xml"
#define WEIDMULLER_ESI_FILE "Weidmueller_UR20_FBC.xml"
#define KUNBUS_ESI_FILE "Gateway_Component_EtherCAT_R02.xml"
#define PILZ_ESI_FILE "KUNBUS-PNOZ_m_ES_EtherCAT_V1_1.xml"
#else
#include "Sitara_Slave_Simple_CiA402.h"
#endif
#define I2C_IOEXP_ADDR 0x60
static void EC_SLV_APP_ESIP_applicationRun(void* pAppCtxt_p);
#if !(defined DPRAM_REMOTE) && !(defined FBTL_REMOTE)
static OSAL_FUNC_UNUSED void EC_SLV_APP_ESIP_boardPhyReset(void* pCtxt_p, uint8_t phyIdx_p, bool reset_p)
{
if (NULL == pApplicationInstance)
{
goto Exit;
}
Exit:
return;
}
#endif
static void EC_SLV_APP_ESIP_appBoardStatusLed(void* pCallContext_p, void* pLedContext_p, bool runLed_p, bool errLed_p)
{
OSALUNREF_PARM(pLedContext_p);
if (NULL == pApplicationInstance)
{
goto Exit;
}
Exit:
return;
}
{
if (!pApplicationInstance)
{
goto Exit;
}
EC_API_SLV_cbRegisterBoardStatusLed(pApplicationInstance->
ptEcSlvApi
,EC_SLV_APP_ESIP_appBoardStatusLed
,pApplicationInstance);
Exit:
return error;
}
{
if (!pAppInstance_p)
{
goto Exit;
}
#if !(defined DPRAM_REMOTE) && !(defined FBTL_REMOTE)
ESL_OS_manualMdioConfig(pAppInstance_p->
ptEcSlvApi);
#else
OSALUNREF_PARM(pAppInstance_p);
#endif
#if !(defined DPRAM_REMOTE) && !(defined FBTL_REMOTE)
#endif
Exit:
return;
}
{
if (!pAppInstance_p)
{
goto Exit;
}
#if !(defined DPRAM_REMOTE) && !(defined FBTL_REMOTE)
#endif
Exit:
return;
}
uint8_t EC_API_SLV_PendingErrorCb(
uint16_t Index,
uint8_t Subindex,
uint32_t length,
uint16_t* pData,
uint8_t bCompleteAccess
)
{
OSALUNREF_PARM(Subindex);
OSALUNREF_PARM(bCompleteAccess);
OSALUNREF_PARM(pData);
if(Index == 0x2000 && length == 2)
{
EC_API_SLV_CiA402_SM_clearErrorCode(pAppInstance_p->
ptEcSlvApi, 0);
}
return 0;
}
{
if (!pAppInstance_p)
{
goto Exit;
}
{
OSAL_error(__func__, __LINE__, OSAL_CONTAINER_NOMEMORY, true, 0);
goto Exit;
}
error = EC_SLV_APP_ESIP_populateBoardFunctions(pAppInstance_p);
{
OSAL_printf("Populate board functions Error code: 0x%08x\n", error);
goto Exit;
}
EC_API_SLV_CiA402_registerSetDictValues (pAppInstance_p->
ptEcSlvApi, EC_SLV_APP_usrApplCia402SetDictValues, pAppInstance_p->
ptEcSlvApi);
EC_API_SLV_CiA402_registerApplication (pAppInstance_p->
ptEcSlvApi, EC_SLV_APP_usrApplCia402Application, pAppInstance_p->
ptEcSlvApi);
EC_API_SLV_CiA402_registerLocalError (pAppInstance_p->
ptEcSlvApi, EC_SLV_APP_ESIP_cia402LocalError, pAppInstance_p->
ptEcSlvApi);
EC_API_SLV_cbRegisterStartInputHandler (pAppInstance_p->
ptEcSlvApi, EC_SLV_APP_ESIP_startInputHandler, pAppInstance_p->
ptEcSlvApi);
EC_API_SLV_PDO_setAssignment(pAppInstance_p->
ptEcSlvApi,
true);
EC_API_SLV_cbRegisterUserApplicationRun(pAppInstance_p->
ptEcSlvApi, EC_SLV_APP_ESIP_applicationRun, &pAppInstance_p);
#ifdef OSAL_LINUX
#else
error = (
EC_API_EError_t)ESL_ESI_parseFileRam(pAppInstance_p->
ptEcSlvApi, (
const uint8_t *)Sitara_Slave_Simple_CiA402_xml, Sitara_Slave_Simple_CiA402_xml_len);
#endif
{
goto Exit;
}
{
OSAL_printf("Slave Init Error Code: 0x%08x\n", error);
goto Exit;
}
#if (defined ENABLE_I2CLEDS) && (ENABLE_I2CLEDS == 1)
#endif
pAppInstance_p->
msec = 0;
pAppInstance_p->
prev = ESL_OS_clockGet();
Exit:
return;
}
static void EC_SLV_APP_ESIP_applicationRun(void* pAppCtxt_p)
{
static uint8_t lastLed = 0;
uint16_t alErrorCode = 0;
pApplicationInstace->
diff = ESL_OS_clockDiff(pApplicationInstace->
prev, NULL);
if (pApplicationInstace->
diff)
{
#if (defined ENABLE_I2CLEDS) && (ENABLE_I2CLEDS == 1)
ESL_OS_ioexp_leds_write(pApplicationInstace->
ioexpLedHandle, ledPDData);
#endif
pApplicationInstace->
prev = ESL_OS_clockGet();
lastLed = lastLed ? lastLed << 1 : 1;
}
EC_API_SLV_getState(pApplicationInstace->
ptEcSlvApi, &state, &alErrorCode);
if (state != pApplicationInstace->
state)
{
pApplicationInstace->
state = state;
}
}
@ EC_API_eERR_INVALID
Definition ecSlvApiDef_error.h:52
@ EC_API_eERR_NONE
Definition ecSlvApiDef_error.h:45
enum EC_API_EError EC_API_EError_t
enum EC_API_SLV_EEsmState EC_API_SLV_EEsmState_t
EC_STATE_T EtherCAT State Machine states.
@ EC_API_SLV_eESM_uninit
Uninitialized State.
Definition ecSlvApi_types.h:70
@ EC_API_SLV_eESM_init
Init State.
Definition ecSlvApi_types.h:71
@ EC_API_SLV_ePHY_IN
Phy index for IN Phy.
Definition ecSlvApi_types.h:120
@ EC_API_SLV_ePHY_OUT
Phy index for OUT Phy.
Definition ecSlvApi_types.h:121
void EC_SLV_APP_ESIP_initBoardFunctions(EC_SLV_APP_Application_t *pAppInstance_p)
Initialize board related functions.
Definition ecSlvESI.c:262
void EC_SLV_APP_ESIP_registerStacklessBoardFunctions(EC_SLV_APP_Application_t *pAppInstance_p)
Register board related functions, which do not use stack handle.
Definition ecSlvESI.c:328
uint8_t state
Definition ecSlvESI.h:79
clock_t diff
Definition ecSlvESI.h:81
void * gpioHandle
Definition ecSlvESI.h:68
int32_t trigger
Definition ecSlvESI.h:77
void * ioexpLedHandle
Definition ecSlvESI.h:70
uint32_t selectedPruInstance
Definition ecSlvESI.h:56
EC_API_SLV_SHandle_t * ptEcSlvApi
Definition ecSlvESI.h:93
int32_t msec
Definition ecSlvESI.h:76
clock_t prev
Definition ecSlvESI.h:81