CiA402 Application implementation.
#include <ecSlvApi.h>
#include <ecSlvApiDef.h>
#include "ecSlvCiA402.h"
#include "ESL_cia402Obd.h"
#include "ESL_cia402Demo.h"
#include "project.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_version.h>
#include <ecSlvApi.h>
#if !(defined MBXMEM)
#define MBXMEM
#endif
#define I2C_IOEXP_ADDR 0x60 // The I2C address for GPIO expander
#define RXPDOMAP_INDEX 0x1600
#define TXPDOMAP_INDEX 0x1A00
#define COE_SM_ERROR_MAX_COUNT 0xFFFF
#define AXIS_ONE 0
#define AXIS_TWO 1
#define AXIS_THREE 2
#if !(defined BIT2BYTE)
#define BIT2BYTE(x) (((x)+7) >> 3)
#endif
static void EC_SLV_APP_applicationRun(void* pAppCtxt_p);
#if (defined GPIO_TEST_PINS) && (1==GPIO_TEST_PINS)
#if (defined GPIO_TEST_PROFILE_SEL) && (GPIO_TEST_PROFILE_2 == GPIO_TEST_PROFILE_SEL)
static void EC_SLV_APP_measurement(void* pMsrmtCtxt_p, uint32_t measureChannel_p, bool channelOn_p);
#endif
#endif
{
if (!pApplicationInstance_p)
{
goto Exit;
}
{
OSAL_printf("%s:%d Error code: 0x%08x\r\n", __func__, __LINE__, error);
goto Exit;
}
{
OSAL_printf("%s:%d Error code: 0x%08x\r\n", __func__, __LINE__, error);
goto Exit;
}
{
OSAL_printf("%s:%d Error code: 0x%08x\r\n", __func__, __LINE__, error);
goto Exit;
}
{
OSAL_printf("%s:%d Error code: 0x%08x\r\n", __func__, __LINE__, error);
goto Exit;
}
{
OSAL_printf("%s:%d Error code: 0x%08x\r\n", __func__, __LINE__, error);
goto Exit;
}
{
OSAL_printf("%s:%d Error code: 0x%08x\r\n", __func__, __LINE__, error);
goto Exit;
}
{
OSAL_printf("%s:%d Error code: 0x%08x\r\n", __func__, __LINE__, error);
goto Exit;
}
{
OSAL_printf("%s:%d Error code: 0x%08x\r\n", __func__, __LINE__, error);
goto Exit;
}
error = ESL_setSWVersion(ptSlave);
{
goto Exit;
}
{
OSAL_printf("%s:%d Error code: 0x%08x\r\n", __func__, __LINE__, error);
goto Exit;
}
{
OSAL_printf("%s:%d Error code: 0x%08x\r\n", __func__, __LINE__, error);
goto Exit;
}
ET1100_BOOT_MBXOUT_START, ET1100_BOOT_MBXOUT_DEF_LENGTH,
ET1100_BOOT_MBXIN_START, ET1100_BOOT_MBXIN_DEF_LENGTH);
{
OSAL_printf("%s:%d Error code: 0x%08x\r\n", __func__, __LINE__, error);
goto Exit;
}
ET1100_MBXOUT_START, ET1100_MBXOUT_DEF_LENGTH,
ET1100_MBXIN_START, ET1100_MBXIN_DEF_LENGTH);
{
OSAL_printf("%s:%d Error code: 0x%08x\r\n", __func__, __LINE__, error);
goto Exit;
}
0, ET1100_MBXOUT_START, ET1100_MBXOUT_DEF_LENGTH,
ET1100_MBXOUT_CONTROLREG, ET1100_MBXOUT_ENABLE);
{
OSAL_printf("%s:%d Error code: 0x%08x\r\n", __func__, __LINE__, error);
goto Exit;
}
1, ET1100_MBXIN_START, ET1100_MBXIN_DEF_LENGTH,
ET1100_MBXIN_CONTROLREG, ET1100_MBXIN_ENABLE);
{
OSAL_printf("%s:%d Error code: 0x%08x\r\n", __func__, __LINE__, error);
goto Exit;
}
2, ET1100_OUTPUT_START, ET1100_OUTPUT_DEF_LENGTH,
ET1100_OUTPUT_CONTROLREG, ET1100_OUTPUT_ENABLE);
{
OSAL_printf("%s:%d Error code: 0x%08x\r\n", __func__, __LINE__, error);
goto Exit;
}
3, ET1100_INPUT_START, ET1100_INPUT_DEF_LENGTH,
ET1100_INPUT_CONTROLREG, ET1100_INPUT_ENABLE);
{
OSAL_printf("%s:%d Error code: 0x%08x\r\n", __func__, __LINE__, error);
goto Exit;
}
error = (
EC_API_EError_t)EC_API_SLV_setSyncManErrLimit(ptSlave, COE_SM_ERROR_MAX_COUNT);
{
OSAL_printf("%s:%d Error code: 0x%08x\r\n", __func__, __LINE__, error);
goto Exit;
}
Exit:
return error;
}
{
if (!pApplicationInstance_p)
{
goto Exit;
}
{
OSAL_printf("%s:%d CiA402 Object Dictionary error code: 0x%08x\r\n", __func__, __LINE__, error);
goto Exit;
}
Exit:
return error;
}
{
uint16_t rxIndex = RXPDOMAP_INDEX + axis_p;
uint16_t curOffset = 0;
if (!pApplicationInstance_p)
{
goto Exit;
}
{
OSAL_printf("%s:%d Create PDO 0x%04x error code: 0x%08x\r\n", __func__, __LINE__, rxIndex, error);
goto Exit;
}
{
OSAL_printf("%s:%d Variable Error code: 0x%08x\r\n", __func__, __LINE__, error);
goto Exit;
}
{
OSAL_printf("%s:%d Variable Error code: 0x%08x\r\n", __func__, __LINE__, error);
goto Exit;
}
{
OSAL_printf("%s:%d Variable Error code: 0x%08x\r\n", __func__, __LINE__, error);
goto Exit;
}
{
OSAL_printf("%s:%d Variable Error code: 0x%08x\r\n", __func__, __LINE__, error);
goto Exit;
}
{
OSAL_printf("%s:%d Variable Error code: 0x%08x\r\n", __func__, __LINE__, error);
goto Exit;
}
{
OSAL_printf("%s:%d Variable Error code: 0x%08x\r\n", __func__, __LINE__, error);
goto Exit;
}
{
OSAL_printf("%s:%d Variable Error code: 0x%08x\r\n", __func__, __LINE__, error);
goto Exit;
}
{
OSAL_printf("%s:%d Variable Error code: 0x%08x\r\n", __func__, __LINE__, error);
goto Exit;
}
{
OSAL_printf("%s:%d Variable Error code: 0x%08x\r\n", __func__, __LINE__, error);
goto Exit;
}
{
OSAL_printf("%s:%d Variable Error code: 0x%08x\r\n", __func__, __LINE__, error);
goto Exit;
}
Exit:
return error;
}
{
uint16_t txIndex = TXPDOMAP_INDEX + axis_p;
uint16_t curOffset = 0;
if (!pApplicationInstance_p)
{
goto Exit;
}
{
OSAL_printf("Create PDO for axis %d error code: 0x%08x\r\n", axis_p);
goto Exit;
}
{
OSAL_printf("%s:%d Variable Error code: 0x%08x\r\n", __func__, __LINE__, error);
goto Exit;
}
{
OSAL_printf("%s:%d Variable Error code: 0x%08x\r\n", __func__, __LINE__, error);
goto Exit;
}
{
OSAL_printf("%s:%d Variable Error code: 0x%08x\r\n", __func__, __LINE__, error);
goto Exit;
}
{
OSAL_printf("PDO 0x1A00 Entry 2 Error code: 0x%08x\r\n", error);
goto Exit;
}
{
OSAL_printf("%s:%d Variable Error code: 0x%08x\r\n", __func__, __LINE__, error);
goto Exit;
}
{
OSAL_printf("PDO 0x1A00 Entry 2 Error code: 0x%08x\r\n", error);
goto Exit;
}
{
OSAL_printf("%s:%d Variable Error code: 0x%08x\r\n", __func__, __LINE__, error);
goto Exit;
}
{
OSAL_printf("PDO 0x1A00 Entry 2 Error code: 0x%08x\r\n", error);
goto Exit;
}
{
OSAL_printf("%s:%d Variable Error code: 0x%08x\r\n", __func__, __LINE__, error);
goto Exit;
}
{
OSAL_printf("PDO 0x1A00 Entry 2 Error code: 0x%08x\r\n", error);
goto Exit;
}
Exit:
return error;
}
#if (defined GPIO_TEST_PINS) && (1==GPIO_TEST_PINS)
#if (defined GPIO_TEST_PROFILE_SEL) && (GPIO_TEST_PROFILE_2 == GPIO_TEST_PROFILE_SEL)
void EC_SLV_APP_measurement(void* pMsrmtCtxt_p, uint32_t measureChannel_p, bool channelOn_p)
{
volatile CSL_GpioBank_registersRegs * pGpioRegBank = NULL;
uint32_t pinMask = 0;
if (pApplicationInstance)
{
switch (measureChannel_p)
{
case 0: pGpioRegBank = ESL_TESTPIN_STATE_REG_BANK; pinMask = ESL_TESTPIN_0_MASK; break;
case 1: pGpioRegBank = ESL_TESTPIN_STATE_REG_BANK; pinMask = ESL_TESTPIN_1_MASK; break;
case 2: pGpioRegBank = ESL_TESTPIN_STATE_REG_BANK; pinMask = ESL_TESTPIN_2_MASK; break;
default:
break;
}
if (channelOn_p)
{
ESL_GPIO_testPins_set(pGpioRegBank, pinMask);
}
else
{
ESL_GPIO_testPins_clear(pGpioRegBank, pinMask);
}
}
}
#endif
#endif
#if !(defined DPRAM_REMOTE) && !(defined FBTL_REMOTE)
static OSAL_FUNC_UNUSED void EC_SLV_APP_boardPhyReset(void* pCtxt_p, uint8_t phyIdx_p, bool reset_p)
{
}
#endif
static void EC_SLV_APP_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_SLV_APP_appBoardStatusLed
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;
}
{
if (!pAppInstance_p)
{
goto Exit;
}
{
OSAL_error(__func__, __LINE__, OSAL_CONTAINER_NOMEMORY, true, 0);
goto Exit;
}
error = EC_SLV_APP_populateBoardFunctions(pAppInstance_p);
{
OSAL_printf("Populate board functions Error code: 0x%08x\r\n", error);
goto Exit;
}
error = EC_SLV_APP_populateSlaveInfo(pAppInstance_p);
{
OSAL_printf("Create Slave Info Error code: 0x%08x\r\n", error);
goto Exit;
}
error = EC_SLV_APP_populateCiA402Functions(pAppInstance_p);
{
OSAL_printf("Create slave information error code: 0x%08x\r\n", error);
return;
}
{
OSAL_printf("Create RxPDO error code: 0x%08x\r\n", error);
return;
}
{
OSAL_printf("Create RxPDO error code: 0x%08x\r\n", error);
return;
}
{
OSAL_printf("Create RxPDO error code: 0x%08x\r\n", error);
return;
}
{
OSAL_printf("Create TxPDO error code: 0x%08x\r\n", error);
return;
}
{
OSAL_printf("Create TxPDO error code: 0x%08x\r\n", error);
return;
}
{
OSAL_printf("Create TxPDO error code: 0x%08x\r\n", error);
return;
}
#if !(defined DPRAM_REMOTE) && !(defined FBTL_REMOTE)
#else
OSAL_SCHED_startTask(EC_SLV_APP_usrAppRunWrapper, pAppInstance_p, OSAL_TASK_ePRIO_Idle
,(uint8_t*)EC_SLV_APP_appRunWrapTaskStack_g, APPRWRAP_TASK_SIZE_BYTE, 0, "AppRun");
#endif
#if (defined GPIO_TEST_PINS) && (1==GPIO_TEST_PINS)
#if (defined GPIO_TEST_PROFILE_SEL) && (GPIO_TEST_PROFILE_2 == GPIO_TEST_PROFILE_SEL)
#endif
#endif
{
OSAL_printf("Slave Init Error Code: 0x%08x\r\n", error);
return;
}
Exit:
return;
}
{
if (pAppInstance_p)
{
}
}
void EC_SLV_APP_applicationRun(void* pAppRunCtxt_p)
{
OSALUNREF_PARM(pAppRunCtxt_p);
#if (defined GPIO_TEST_PINS) && (1==GPIO_TEST_PINS)
#if (defined GPIO_TEST_PROFILE_SEL) && ((GPIO_TEST_PROFILE_1 == GPIO_TEST_PROFILE_SEL) || (GPIO_TEST_PROFILE_2 == GPIO_TEST_PROFILE_SEL))
static bool bToggle = false;
if (bToggle)
{
ESL_GPIO_testPins_set(ESL_TESTPIN_STATE_REG_BANK, ESL_TESTPIN_3_MASK);
}
else
{
ESL_GPIO_testPins_clear(ESL_TESTPIN_STATE_REG_BANK, ESL_TESTPIN_3_MASK);
}
bToggle = !bToggle;
#endif
#endif
}