CANopen Slave Documentation
Version 7.00.00
Loading...
Searching...
No Matches
cos_user.c


//====================================================================================================================//
// File: cos_user.c //
// Description: Example for application specific functions //
// //
// Copyright (C) MicroControl GmbH & Co. KG //
// 53844 Troisdorf - Germany //
// www.microcontrol.net //
// //
//--------------------------------------------------------------------------------------------------------------------//
// The copyright to the computer program(s) herein is the property of MicroControl GmbH & Co. KG, Germany. The //
// program(s) may be used and/or copied only with the written permission of MicroControl GmbH & Co. KG or in //
// accordance with the terms and conditions stipulated in the agreement/contract under which the program(s) have //
// been supplied. //
// //
//====================================================================================================================//
/*--------------------------------------------------------------------------------------------------------------------*\
** IMPORTANT NOTE **
** This file provides a template for all functions that need to be adopted to YOUR hardware. Copy this file to **
** <myfile.c> and make your changes in the new file. **
\*--------------------------------------------------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------------------------------------------------*\
** Include files **
** **
\*--------------------------------------------------------------------------------------------------------------------*/
#include "cos_dict.h" // Object dictionary
#include "cos_mgr.h" // CANopen Slave management functions
#include "cos_mobj.h" // Manufacturer objects
#include "cos_nmt.h" // NMT service
#include "cos_nvm.h" // Parameter storage
#include "cos_emcy.h" // EMCY service
#include "cos_pdo.h" // PDO service
#include "cos_sdo.h" // SDO service
#include "cos_sync.h" // SYNC service
#include "cos_time.h" // TIME service
#include "cos301.h" // Objects from DS-301
#if COS_DS302_NV > 0
#include "cos302.h"
#endif
#if COS_DS401_DI > 0
#include "cos401di.h"
#endif
#if COS_DS401_DO > 0
#include "cos401do.h"
#endif
#if COS_DICT_MAN > 0
#include "cos_mobj.h"
#endif
#if COS_BOOTLOADER_SUPPORT > 0
#include "cos710.h"
#include "mc_iap.h"
#endif
#if COS_SAFETY_SUPPORT == 1
#include "cos_safety.h"
#endif
#if COS_SECURE_CONFIG_SUPPORT > 0
#include <stdlib.h>
#endif
#if COS_SDO_CLIENT > 0
#include "cos_sdo_cln.h"
#endif
/*--------------------------------------------------------------------------------------------------------------------*\
** Variables **
** **
\*--------------------------------------------------------------------------------------------------------------------*/
//------------------------------------------------------------------------------------------------------
// This object holds the device name of the target hardware as visible string
//
#if COS_DICT_OBJ_1008 == 1
uint8_t aubIdx1008_DeviceNameC[] = "CANopen Stack template";
#endif
//------------------------------------------------------------------------------------------------------
// This object holds the version number of the target hardware as visible string
//
#if COS_DICT_OBJ_1009 == 1
uint8_t aubIdx1009_HwVersionC[] = "1.00";
#endif
//------------------------------------------------------------------------------------------------------
// This object holds the version number of the application firmware as visible string
//
#if COS_DICT_OBJ_100A == 1
uint8_t aubIdx100A_SwVersionC[] = "1.00";
#endif
uint8_t ubIdx1018_SubNumberC = 0x04;
uint32_t ulIdx1018_VendorIdC = 0x00000000;
uint32_t ulIdx1018_RevisionNumC = ((uint32_t) COS_VERSION_MAJOR << 24) | ((uint32_t) COS_VERSION_MINOR << 16) | 0x0100;
//------------------------------------------------------------------------------------------------------
// reserve some memory for data of Trm & Rcv PDO
//
#if COS_PDO_RCV_NUMBER > 0
#ifdef __C51__
static uint8_t xdata aubRcvPdoDataT[8];
#else
static uint8_t aubRcvPdoDataT[8];
#endif
#endif
#if COS_PDO_TRM_NUMBER > 0
#ifdef __C51__
static uint8_t xdata aubTrmPdoDataT[8];
#else
static uint8_t aubTrmPdoDataT[8];
#endif
#endif
#if COS_SECURE_CONFIG_SUPPORT > 0
static uint8_t *pubDcfBufferS = 0L;
static uint8_t *pubDcfConfigS = 0L;
#endif
//------------------------------------------------------------------------------------------------------
// Devices with a fixed PDO mapping can have the mapping information in code space. The initialization
// of the structure has to be made here. The initialization code here is ONLY AN EXAMPLE! It has to be
// adopted to the device profile!
//
//----------------------------------------------------------------------------------------------------//
// Receive PDO mapping (fixed) //
// //
//----------------------------------------------------------------------------------------------------//
#if (COS_PDO_RCV_NUMBER > 0) && (COS_PDO_MAPPING == 0)
CosPdoMap_ts atsRcvPdoMapG[] =
{
//--- Index 1600 -----------------------------
{ 0x6200, 0x01, 0x08 },
{ 0x6200, 0x02, 0x08 },
{ 0x6200, 0x03, 0x08 },
{ 0x6200, 0x04, 0x08 },
{ 0x0000, 0x00, 0x00 },
//--- Index 1601 -----------------------------
{ 0x5210, 0x01, 0x10 },
{ 0x5210, 0x02, 0x10 },
{ 0x5210, 0x03, 0x10 },
{ 0x5210, 0x04, 0x10 },
{ 0x0000, 0x00, 0x00 }
};
#endif
//----------------------------------------------------------------------------------------------------//
// Transmit PDO mapping (fixed) //
// //
//----------------------------------------------------------------------------------------------------//
#if (COS_PDO_TRM_NUMBER > 0) && (COS_PDO_MAPPING == 0)
CosPdoMap_ts atsTrmPdoMapG[] =
{
//--- Index 1A00 -----------------------------
{ 0x7130, 0x01, 0x10 },
{ 0x7130, 0x02, 0x10 },
{ 0x7130, 0x03, 0x10 },
{ 0x7130, 0x04, 0x10 },
{ 0x0000, 0x00, 0x00 },
{ 0x0000, 0x00, 0x00 },
{ 0x0000, 0x00, 0x00 },
{ 0x0000, 0x00, 0x00 },
//--- Index 1A01 -----------------------------
{ 0x6000, 0x01, 0x08 },
{ 0x6000, 0x02, 0x08 },
{ 0x0000, 0x00, 0x00 },
{ 0x0000, 0x00, 0x00 },
{ 0x0000, 0x00, 0x00 },
{ 0x0000, 0x00, 0x00 },
{ 0x0000, 0x00, 0x00 },
{ 0x0000, 0x00, 0x00 },
//--- Index 1A02 -----------------------------
{ 0x6030, 0x00, 0x10 },
{ 0x6040, 0x00, 0x10 },
{ 0x0000, 0x00, 0x00 },
{ 0x0000, 0x00, 0x00 },
{ 0x0000, 0x00, 0x00 },
{ 0x0000, 0x00, 0x00 },
{ 0x0000, 0x00, 0x00 },
{ 0x0000, 0x00, 0x00 },
//--- Index 1A03 -----------------------------
{ 0x6030, 0x00, 0x10 },
{ 0x6040, 0x00, 0x10 },
{ 0x0000, 0x00, 0x00 },
{ 0x0000, 0x00, 0x00 },
{ 0x0000, 0x00, 0x00 },
{ 0x0000, 0x00, 0x00 },
{ 0x0000, 0x00, 0x00 },
{ 0x0000, 0x00, 0x00 }
};
#endif
/*--------------------------------------------------------------------------------------------------------------------*\
** Functions **
** **
\*--------------------------------------------------------------------------------------------------------------------*/
#if COS_DS302_NV > 0
//--------------------------------------------------------------------------------------------------------------------//
// Cos302_NetVarPdoRcvHandler() //
// //
//--------------------------------------------------------------------------------------------------------------------//
void Cos302_NetVarPdoRcvHandler(uint32_t ulMapEntryV)
{
uint8_t ubDataIndexT;
//----------------------------------------------------------------
// get data index once
//
ubDataIndexT = (uint8_t)(ulMapEntryV >> 8);
#if COS_PDO_RCV_NUMBER > 0
//----------------------------------------------------------------
// handle UNSIGNED8 output variables
//
if ((ulMapEntryV & 0x0FFF0000) == 0x04C00000)
{
//--------------------------------------------------------
// Now handle received network variable
//
if (tsCos302_NetVarG.aubOut[ubDataIndexT] != 0)
{
}
}
//----------------------------------------------------------------
// handle UNSIGNED16 output variables
//
else if ((ulMapEntryV & 0x0FFF0000) == 0x05800000)
{
//--------------------------------------------------------
// Now handle received network variable
//
if (tsCos302_NetVarG.auwOut[ubDataIndexT] != 0)
{
}
}
//----------------------------------------------------------------
// handle UNSIGNED32 output variables
//
else if ((ulMapEntryV & 0x0FFF0000) == 0x06800000)
{
//--------------------------------------------------------
// Now handle received network variable
//
if (tsCos302_NetVarG.aulOut[ubDataIndexT] != 0)
{
}
}
#endif
}
//--------------------------------------------------------------------------------------------------------------------//
// Cos302_NetVarPdoTrmHandler() //
// //
//--------------------------------------------------------------------------------------------------------------------//
void Cos302_NetVarPdoTrmHandler(uint32_t ulMapEntryV)
{
uint8_t ubDataIndexT;
//----------------------------------------------------------------
// get data index once
//
ubDataIndexT = (uint8_t)(ulMapEntryV >> 8);
#if COS_PDO_TRM_NUMBER > 0
//----------------------------------------------------------------
// handle UNSIGNED8 input variables
//
if ((ulMapEntryV & 0x0FFF0000) == 0x00400000)
{
//--------------------------------------------------------
// Now update transmit network variable
//
tsCos302_NetVarG.aubIn[ubDataIndexT]++;
}
//----------------------------------------------------------------
// handle UNSIGNED16 input variables
//
else if ((ulMapEntryV & 0x0FFF0000) == 0x01000000)
{
//--------------------------------------------------------
// Now update transmit network variable
//
tsCos302_NetVarG.auwIn[ubDataIndexT]++;
}
//----------------------------------------------------------------
// handle UNSIGNED32 input variables
//
else if ((ulMapEntryV & 0x0FFF0000) == 0x02000000)
{
//--------------------------------------------------------
// Now update transmit network variable
//
tsCos302_NetVarG.aulIn[ubDataIndexT]++;
}
#endif
}
#endif
#if COS_PDO_MAPPING > 0
#if COS_PDO_RCV_NUMBER > 0
//--------------------------------------------------------------------------------------------------------------------//
// CosMob_PdoRcvHandler() //
// Demo implementation of PDO receive handler for a mapping entry //
//--------------------------------------------------------------------------------------------------------------------//
void CosMob_PdoRcvHandler(uint32_t ulMapEntryV)
{
//---------------------------------------------------------------------------------------------------
// handle modification event at reception of desired RPDO
//
if (ulMapEntryV == 0x20020008)
{
}
}
#endif
#if COS_PDO_TRM_NUMBER > 0
//--------------------------------------------------------------------------------------------------------------------//
// CosMob_PdoTrmHandler() //
// Demo implementation of PDO transmit handler for mapping entries //
//--------------------------------------------------------------------------------------------------------------------//
void CosMob_PdoTrmHandler(uint32_t ulMapEntryV)
{
if (ulMapEntryV == 0x20040020)
{
// handle ulCosMob_Var2004G before it will copy and sent by TPDO
}
else
{
// handle uqCosMob_Var2005G before it will copy and sent by TPDO
}
}
#endif
#endif
//--------------------------------------------------------------------------------------------------------------------//
// CosBootloaderEvent() //
// //
//--------------------------------------------------------------------------------------------------------------------//
#if COS_BOOTLOADER_SUPPORT > 0
void CosBootloaderEvent(uint8_t ubBootloaderEventV)
{
switch (ubBootloaderEventV)
{
break;
break;
break;
}
}
#endif
//--------------------------------------------------------------------------------------------------------------------//
// CosBootloaderGetSeed() //
// copy random seed to structure //
//--------------------------------------------------------------------------------------------------------------------//
#if COS_BOOTLOADER_SUPPORT > 0
#include <stdlib.h> // for rand() function call
typedef struct MySeed_s {
int32_t slRandom;
uint32_t ulSerial;
} MySeed_ts;
{
//----------------------------------------------------------------------------------------------
// copy a random seed to the structure ptsSeedV
//
MySeed_ts *ptsMySeedT;
ptsMySeedT = (MySeed_ts *) ptsSeedV;
ptsMySeedT->slRandom = rand();
ptsMySeedT->ulSerial = CosMgrGetSerialNumber();
}
#endif
//--------------------------------------------------------------------------------------------------------------------//
// CosBootloaderRequestAppStop() //
// handle request to stop application //
//--------------------------------------------------------------------------------------------------------------------//
#if COS_BOOTLOADER_SUPPORT > 0
{
//---------------------------------------------------------------------------------------------------
// shutdown the application here, e.g.
// - switch active outputs off
// - stop drive
// - store data in memory
//
//---------------------------------------------------------------------------------------------------
// confirm the shutdown request
//
}
#endif
//--------------------------------------------------------------------------------------------------------------------//
// CosBootloaderStart() //
// start the bootloader //
//--------------------------------------------------------------------------------------------------------------------//
#if COS_BOOTLOADER_SUPPORT > 0
{
//---------------------------------------------------------------------------------------------------
// shutdown the CANopen Slave protocol stack
//
//---------------------------------------------------------------------------------------------------
// Jump to bootloader by using the McIapJumpToBoot() function call or any custom specific function
//
}
#endif
//--------------------------------------------------------------------------------------------------------------------//
// CosBootloaderValidateKey() //
// get module bit-rate setting //
//--------------------------------------------------------------------------------------------------------------------//
#if COS_BOOTLOADER_SUPPORT > 0
bool_t CosBootloaderValidateKey(CosBootloaderKey_ts * ptsClientKeyV, CosBootloaderSeed_ts * ptsServerSeedV)
{
bool_t btResultT = false;
if ( (ptsClientKeyV != (CosBootloaderKey_ts *) 0L) && (ptsServerSeedV != (CosBootloaderSeed_ts *) 0L) )
{
//-------------------------------------------------------------------------------------------
// perform check here and set 'btResultT' to true in case the check pass
//
}
return (btResultT);
}
#endif
//--------------------------------------------------------------------------------------------------------------------//
// CosMgrGetNodeId() //
// get module address setting //
//--------------------------------------------------------------------------------------------------------------------//
uint8_t CosMgrGetNodeId(void)
{
uint8_t ubAddrT = 0;
//---------------------------------------------------------------------------------------------------
// Example:
// Read value of DIP-/HEX-switch here
//
ubAddrT = 10;
//---------------------------------------------------------------------------------------------------
// A value of 0 means the address is not defined and we check the value from LSS
//
#if COS_LSS_SUPPORT > 0
if (ubAddrT == 0)
{
McNvmRead(eNVM_305_NODE_ID_U08, &ubAddrT, 1);
}
if (ubAddrT > 127) ubAddrT = 127; // limit in case of error
#else
#endif
return (ubAddrT);
}
//--------------------------------------------------------------------------------------------------------------------//
// CosMgrGetNominalBitrate() //
// get nominal bit rate value //
//--------------------------------------------------------------------------------------------------------------------//
{
return (eCP_BITRATE_500K);
}
//--------------------------------------------------------------------------------------------------------------------//
// CosMgrGetProductCode() //
// get Product Code of module //
//--------------------------------------------------------------------------------------------------------------------//
uint32_t CosMgrGetProductCode(void)
{
#if COS_DICT_OBJ_1010 > 0
Status_tv tvStatusT;
uint16_t uwNvmReadCrcT;
uint16_t uwNvmCalcCrcT;
uint32_t ulValueT;
#endif
uint32_t ulProductCodeT = 0;
//---------------------------------------------------------------------------------------------------
// read value from Non-volatile memory consider the data is valid or not
//
#if COS_DICT_OBJ_1010 > 0
uwNvmCalcCrcT = McNvmBuildChecksum(eNVM_CHECKSUM_START, eNVM_CHECKSUM_END);
tvStatusT = McNvmRead(eNVM_CHECKSUM_U16, (uint8_t *) &uwNvmReadCrcT, 2);
tvStatusT |= McNvmRead(eNVM_301_OBJ_1018_2_U32, (uint8_t *)&ulValueT, 4);
// update value only read was successfull and CRC OK
if (tvStatusT == eNVM_ERR_OK)
{
if (uwNvmCalcCrcT == uwNvmReadCrcT)
{
ulProductCodeT = ulValueT;
}
}
#endif
return (ulProductCodeT);
}
//--------------------------------------------------------------------------------------------------------------------//
// CosMgrGetSerialNumber() //
// get Serial Number of module //
//--------------------------------------------------------------------------------------------------------------------//
uint32_t CosMgrGetSerialNumber(void)
{
#if COS_DICT_OBJ_1010 > 0
Status_tv tvStatusT;
uint16_t uwNvmReadCrcT;
uint16_t uwNvmCalcCrcT;
uint32_t ulValueT;
#endif
uint32_t ulSerialNumberT = 0;
//---------------------------------------------------------------------------------------------------
// read serial number from Non-volatile memory consider the data is valid or not
//
#if COS_DICT_OBJ_1010 > 0
uwNvmCalcCrcT = McNvmBuildChecksum(eNVM_CHECKSUM_START, eNVM_CHECKSUM_END);
tvStatusT = McNvmRead(eNVM_CHECKSUM_U16, (uint8_t *) &uwNvmReadCrcT, 2);
tvStatusT |= McNvmRead(eNVM_301_OBJ_1018_4_U32, (uint8_t *)&ulValueT, 4);
// update value only read was successfull and CRC OK
if (tvStatusT == eNVM_ERR_OK)
{
if (uwNvmCalcCrcT == uwNvmReadCrcT)
{
ulSerialNumberT = ulValueT;
}
}
#endif
return (ulSerialNumberT);
}
//--------------------------------------------------------------------------------------------------------------------//
// CosMgrOnBootUp() //
// Handler for Boot-up event //
//--------------------------------------------------------------------------------------------------------------------//
void CosMgrOnBootUp(void)
{
}
//--------------------------------------------------------------------------------------------------------------------//
// CosMgrOnBusOff() //
// Handler for Bus-Off condition //
//--------------------------------------------------------------------------------------------------------------------//
void CosMgrOnBusOff(void)
{
}
//--------------------------------------------------------------------------------------------------------------------//
// CosMgrOnStart() //
// //
//--------------------------------------------------------------------------------------------------------------------//
void CosMgrOnStart(uint8_t ubCallerResultV)
{
//---------------------------------------------------------------------------------------------------
// Check status of initialization
//
switch (ubCallerResultV)
{
// no error
break;
// failed to initialise CAN interface
break;
// node-ID not valid
break;
// could not load parameters from NVM
break;
default:
break;
}
}
//--------------------------------------------------------------------------------------------------------------------//
// CosMgrProfileUpdate() //
// Handler for SDO Update of a profile //
//--------------------------------------------------------------------------------------------------------------------//
#if COS_DS402 > 0
void CosMgrProfileUpdate(uint16_t uwIndexV, uint8_t ubSubIndexV)
{
}
#endif
//--------------------------------------------------------------------------------------------------------------------//
// CosNmtServiceOnError() //
// Handler for NMT protocol error //
//--------------------------------------------------------------------------------------------------------------------//
{
}
//--------------------------------------------------------------------------------------------------------------------//
// CosNmtServiceOnGuardingEvent() //
// Function handler for Life Guarding Event //
//--------------------------------------------------------------------------------------------------------------------//
{
}
//--------------------------------------------------------------------------------------------------------------------//
// CosNmtServiceOnHeartbeatEvent() //
// Function handler for Heartbeat Event //
//--------------------------------------------------------------------------------------------------------------------//
{
}
//--------------------------------------------------------------------------------------------------------------------//
// CosNmtServiceOnStart() //
// Function handler for NMT Start //
//--------------------------------------------------------------------------------------------------------------------//
{
//---------------------------------------------------------------------------------------------------
// this is an example for NMT start
// it has to be adopted to the device profile / application
//
#if COS_PDO_TRM_NUMBER > 0
CosPdoSend(0);
#endif
#if COS_PDO_TRM_NUMBER > 1
CosPdoSend(1);
#endif
#if COS_PDO_TRM_NUMBER > 2
CosPdoSend(2);
#endif
#if COS_PDO_TRM_NUMBER > 3
CosPdoSend(3);
#endif
}
//--------------------------------------------------------------------------------------------------------------------//
// CosNmtServiceOnStop() //
// Function handler for NMT Stop //
//--------------------------------------------------------------------------------------------------------------------//
{
}
//--------------------------------------------------------------------------------------------------------------------//
// CosNmtServiceOnPreOperational() //
// Function handler for NMT Pre-Operational //
//--------------------------------------------------------------------------------------------------------------------//
{
}
//--------------------------------------------------------------------------------------------------------------------//
// CosPdoComSetup() //
// update receive PDO data //
//--------------------------------------------------------------------------------------------------------------------//
void CosPdoComSetup(void)
{
//---------------------------------------------------------------------------------------------------
// This is an example for changing the default values of a PDO
// communication parameter record.
//
#if COS_PDO_TRM_NUMBER > 0
#endif
#if COS_PDO_TRM_NUMBER > 1
#endif
#if COS_PDO_TRM_NUMBER > 2
#endif
#if COS_PDO_TRM_NUMBER > 3
atsTrmPdoComG[3].ulIdentifier |= 0x80000000; // disable TPDO4
#endif
//---------------------------------------------------------------------------------------------------
// Receive PDO communication parameter
//
#if COS_PDO_RCV_NUMBER > 0
#endif
#if COS_PDO_RCV_NUMBER > 1
#endif
#if COS_PDO_RCV_NUMBER > 2
#endif
#if COS_PDO_RCV_NUMBER > 3
#endif
}
//--------------------------------------------------------------------------------------------------------------------//
// CosPdoRcvDataUpdate() //
// update receive PDO data //
//--------------------------------------------------------------------------------------------------------------------//
#if COS_PDO_RCV_NUMBER > 0
void CosPdoRcvDataUpdate(uint8_t ubPdoNumberV)
{
uint8_t ubDlcT;
//---------------------------------------------------------------------------------------------------
// example for PDO receive update
//
CpCoreBufferGetData(&tsCanPortG, eCosBuf_PDO1_RCV + ubPdoNumberV, &aubRcvPdoDataT[0], 0, 8);
CpCoreBufferGetDlc( &tsCanPortG, eCosBuf_PDO1_RCV + ubPdoNumberV, &ubDlcT);
}
#endif
//--------------------------------------------------------------------------------------------------------------------//
// CosPdoRcvTimeout() //
// handle timeout condition of an RPDO //
//--------------------------------------------------------------------------------------------------------------------//
#if COS_PDO_RCV_NUMBER > 0
void CosPdoRcvTimeout(uint8_t ubPdoNumberV)
{
(void) ubPdoNumberV;
}
#endif
//--------------------------------------------------------------------------------------------------------------------//
// CosPdoTrmDataUpdate() //
// update transmit PDO data //
//--------------------------------------------------------------------------------------------------------------------//
#if COS_PDO_TRM_NUMBER > 0
bool_t CosPdoTrmDataUpdate(uint8_t ubPdoNumberV)
{
//---------------------------------------------------------------------------------------------------
// example for PDO transmit update
//
aubTrmPdoDataT[0] = 0x2F;
aubTrmPdoDataT[1] = 0x01;
aubTrmPdoDataT[2] = 0x20;
aubTrmPdoDataT[3] = 0x00;
aubTrmPdoDataT[4] = 0x01;
aubTrmPdoDataT[5] = 0x00;
aubTrmPdoDataT[6] = 0x00;
aubTrmPdoDataT[7] = 0x00;
CpCoreBufferSetData(&tsCanPortG, eCosBuf_PDO1_TRM + ubPdoNumberV, &aubTrmPdoDataT[0], 0, 8);
CpCoreBufferSetDlc( &tsCanPortG, eCosBuf_PDO1_TRM + ubPdoNumberV, 8);
return (true);
}
#endif
//--------------------------------------------------------------------------------------------------------------------//
// CosSafetySrdoRcvDataUpdate //
// //
//--------------------------------------------------------------------------------------------------------------------//
#if COS_SAFETY_SUPPORT == 1
void CosSafetySrdoRcvDataUpdate(uint8_t ubSrdoNumberV)
{
static uint8_t aubSrdoDataS[8];
CosSafetySrdoGetData(ubSrdoNumberV, &aubSrdoDataS[0]);
}
#endif
//--------------------------------------------------------------------------------------------------------------------//
// CosSafetySrdoTrmDataUpdate //
// //
//--------------------------------------------------------------------------------------------------------------------//
#if COS_SAFETY_SUPPORT == 1
void CosSafetySrdoTrmDataUpdate(uint8_t ubSrdoNumberV)
{
static uint8_t aubSrdoDataS[8] = { 0x00, 0x01, 0x55, 0x55, 0xAA, 0xAA, 0xCC, 0xCC};
CosSafetySrdoSetData(ubSrdoNumberV, &aubSrdoDataS[0]);
aubSrdoDataS[0]++;
}
#endif
//--------------------------------------------------------------------------------------------------------------------//
// CosSdoBlkDownFinal() //
// //
//--------------------------------------------------------------------------------------------------------------------//
#if COS_SDO_BLOCK > 0
uint8_t CosSdoBlkDownFinal(uint16_t uwIndexV, uint8_t ubSubIndexV, uint32_t ulObjectSizeV)
{
(void) uwIndexV;
(void) ubSubIndexV;
(void) ulObjectSizeV;
return (eCosSdo_WRITE_OK);
}
#endif
//--------------------------------------------------------------------------------------------------------------------//
// CosSdoBlkDownObjectSize() //
// //
//--------------------------------------------------------------------------------------------------------------------//
#if COS_SDO_BLOCK > 0
uint8_t CosSdoBlkDownObjectSize(uint16_t uwIndexV, uint8_t ubSubIndexV, uint32_t ulObjectSizeV)
{
(void) uwIndexV;
(void) ubSubIndexV;
(void) ulObjectSizeV;
return (eCosSdo_WRITE_OK);
}
#endif
//--------------------------------------------------------------------------------------------------------------------//
// CosSdoBlkUpObjectSize //
// //
//--------------------------------------------------------------------------------------------------------------------//
#if COS_SDO_BLOCK > 0
uint32_t CosSdoBlkUpObjectSize(uint16_t uwIndexV, uint8_t ubSubIndexV)
{
uint32_t ulObjSizeT = 0;
(void) uwIndexV;
(void) ubSubIndexV;
return (ulObjSizeT);
}
#endif
//--------------------------------------------------------------------------------------------------------------------//
// CosSdoClnEventObjectReady() //
// //
//--------------------------------------------------------------------------------------------------------------------//
#if COS_SDO_CLIENT > 0
void CosSdoClnEventObjectReady( uint8_t ubNodeIdV, CoObject_ts * ptsCoObjV, uint32_t * pulAbortV)
{
}
#endif
//--------------------------------------------------------------------------------------------------------------------//
// CosSdoClnEventTimeout() //
// //
//--------------------------------------------------------------------------------------------------------------------//
#if COS_SDO_CLIENT > 0
void CosSdoClnEventTimeout(uint8_t ubNodeIdV, CoObject_ts * ptsCoObjV)
{
}
#endif
//--------------------------------------------------------------------------------------------------------------------//
// CosSdoSegFinal() //
// //
//--------------------------------------------------------------------------------------------------------------------//
uint8_t CosSdoSegFinal(uint8_t CPP_PARM_UNUSED(ubReqCodeV), uint16_t CPP_PARM_UNUSED(uwIndexV),
uint8_t CPP_PARM_UNUSED(ubSubIndexV))
{
return (eCosSdo_WRITE_OK);
}
//--------------------------------------------------------------------------------------------------------------------//
// CosSecureConfigBufferAllocate() //
// //
//--------------------------------------------------------------------------------------------------------------------//
#if COS_SECURE_CONFIG_SUPPORT > 0
uint8_t * CosSecureConfigBufferAllocate(uint32_t ulSizeV)
{
//---------------------------------------------------------------------------------------------------
// allocate buffer here
//
pubDcfBufferS = (uint8_t *) malloc(ulSizeV);
return (pubDcfBufferS);
}
#endif
//--------------------------------------------------------------------------------------------------------------------//
// CosSecureConfigBufferRelease() //
// //
//--------------------------------------------------------------------------------------------------------------------//
#if COS_SECURE_CONFIG_SUPPORT > 0
void CosSecureConfigBufferRelease(void)
{
//---------------------------------------------------------------------------------------------------
// release buffer here
//
free(pubDcfBufferS);
}
#endif
//--------------------------------------------------------------------------------------------------------------------//
// CosSecureConfigBuildNonce() //
// //
//--------------------------------------------------------------------------------------------------------------------//
#if COS_SECURE_CONFIG_SUPPORT > 0
uint64_t CosSecureConfigBuildNonce(uint64_t uqSeedV)
{
uint64_t uqResultT = uqSeedV;
uqResultT += 1;
return (uqResultT);
}
#endif
//--------------------------------------------------------------------------------------------------------------------//
// CosSecureConfigEvent() //
// //
//--------------------------------------------------------------------------------------------------------------------//
#if COS_SECURE_CONFIG_SUPPORT > 0
void CosSecureConfigEvent(uint8_t ubSecureConfigEventV)
{
switch (ubSecureConfigEventV)
{
break;
break;
break;
break;
break;
}
}
#endif
//--------------------------------------------------------------------------------------------------------------------//
// CosSecureConfigGetDcfBuffer() //
// //
//--------------------------------------------------------------------------------------------------------------------//
#if COS_SECURE_CONFIG_SUPPORT > 0
uint8_t * CosSecureConfigGetDcfBuffer(uint32_t ulSizeV)
{
if (pubDcfConfigS != 0L)
{
free(pubDcfConfigS);
}
//---------------------------------------------------------------------------------------------------
// allocate buffer here
//
pubDcfConfigS = (uint8_t *) malloc(ulSizeV);
return (pubDcfConfigS);
}
#endif
//--------------------------------------------------------------------------------------------------------------------//
// CosSecureConfigGetSeed() //
// //
//--------------------------------------------------------------------------------------------------------------------//
#if COS_SECURE_CONFIG_SUPPORT > 0
uint64_t CosSecureConfigGetSeed(void)
{
static uint64_t uqSeedS = 41;
uqSeedS++;
return (uqSeedS);
}
#endif
//--------------------------------------------------------------------------------------------------------------------//
// CosSyncEventRcvPdo() //
// //
//--------------------------------------------------------------------------------------------------------------------//
{
}
//--------------------------------------------------------------------------------------------------------------------//
// CosTmrTimeStampConsume() //
// //
//--------------------------------------------------------------------------------------------------------------------//
{
//------------------------------------------------------
// handle reception of TIME object
//
if ((ptsTimeStampV->ulMilliseconds) < 86400000)
{
if ((ptsTimeStampV->uwDays) > 0)
{
}
}
}
@ eCP_BITRATE_500K
Definition canpie.h:677
CANopen Slave Stack - CiA 301 objects .
uint8_t aubIdx1008_DeviceNameC[]
Device name string (Index 1008h)
uint32_t ulIdx1018_RevisionNumC
Identity object - revision number (Index 1018h)
uint8_t ubIdx1018_SubNumberC
Identity object (Index 1018h)
uint8_t aubIdx100A_SwVersionC[]
Device software version (Index 100Ah)
uint8_t aubIdx1009_HwVersionC[]
Device hardware version (Index 1009h)
uint32_t ulIdx1018_VendorIdC
Identity object - vendor ID (Index 1018h)
CANopen Slave Stack - CiA 302 Additional application layer functions .
Object Dictionary for CiA 401 (Digital Inputs) .
Object Dictionary for CiA 401 (Digital Outputs) .
CANopen Slave Stack - CiA 710 Generic CANopen bootloader .
void CosBootloaderStart(void)
void CosBootloaderRequestAppStop(void)
void CosBootloaderGetSeed(CosBootloaderSeed_ts *ptsServerSeedV)
void CosBootloaderConfirmAppStop(void)
void CosBootloaderEvent(uint8_t ubBootloaderEventV)
bool_t CosBootloaderValidateKey(CosBootloaderKey_ts *ptsClientKeyV, CosBootloaderSeed_ts *ptsServerSeedV)
@ eCOS_BOOTLOADER_EVENT_APPLICATION_BUSY
Definition cos710.h:93
@ eCOS_BOOTLOADER_EVENT_ACCESS_GRANTED
Definition cos710.h:87
@ eCOS_BOOTLOADER_EVENT_ACCESS_EXPIRED
Definition cos710.h:90
@ eCosSdo_WRITE_OK
Definition cos_defs.h:317
@ eCosBuf_PDO1_RCV
Definition cos_defs.h:212
@ eCosBuf_PDO1_TRM
Definition cos_defs.h:217
@ eCOS_ERR_NONE
Definition cos_defs.h:505
@ eCOS_ERR_PARM_LOAD
Definition cos_defs.h:538
@ eCOS_ERR_VALUE_NODE_ID
Definition cos_defs.h:520
@ eCOS_ERR_CAN_INIT
Definition cos_defs.h:508
CANopen Slave Stack - Dictionary .
CANopen Slave Stack - Emergency functions (EMCY) .
@ eEMCY_301_CAN_LIFEGUARD
Definition cos_emcy.h:384
Status_tv CosEmcyErrorSet(uint8_t ubErrConditionV, uint8_t *pubCustomerCodeV)
CANopen Slave Stack - Management functions .
uint8_t CosMgrRelease(void)
Release the CANopen Slave protocol stack.
uint8_t CosMgrGetNodeId(void)
void CosMgrOnBootUp(void)
void CosMgrOnStart(uint8_t ubCallerResultV)
uint32_t CosMgrGetProductCode(void)
uint32_t CosMgrGetSerialNumber(void)
void CosMgrProfileUpdate(uint16_t uwIndexV, uint8_t ubSubIndexV)
Update parameter of device profile.
int32_t CosMgrGetNominalBitrate(void)
void CosMgrOnBusOff(void)
Handle Bus-Off condition.
CANopen Slave Stack - Manufacturer specific objects .
void CosMob_PdoTrmHandler(uint32_t ulMapEntryV)
Demo implementation of callback handler for a mapping entry.
void CosMob_PdoRcvHandler(uint32_t ulMapEntryV)
Demo implementation of callback handler for a mapping entry.
CANopen Slave Stack - Network management functions (NMT) .
void CosNmtServiceOnHeartbeatEvent(void)
void CosNmtServiceOnError(void)
void CosNmtServiceOnPreOperational(void)
void CosNmtServiceOnStop(void)
void CosNmtServiceOnGuardingEvent(void)
void CosNmtServiceOnStart(void)
CANopen Slave Stack - Non-volatile memory support.
@ eNVM_301_OBJ_1018_2_U32
Definition cos_nvm.h:101
@ eNVM_301_OBJ_1018_4_U32
Definition cos_nvm.h:105
CANopen Slave Stack - Process Data Objects (PDO) .
@ ePDO_TYPE_SYNC_1
Definition cos_pdo.h:160
@ ePDO_TYPE_EVENT_PROFILE
Definition cos_pdo.h:190
void CosPdoComSetup(void)
Setup application specific PDO communication parameter.
void CosPdoRcvDataUpdate(uint8_t ubPdoNumberV)
void CosPdoRcvTimeout(uint8_t ubPdoNumberV)
CosPdoCom_ts atsRcvPdoComG[]
bool_t CosPdoTrmDataUpdate(uint8_t ubPdoNumberV)
CosPdoCom_ts atsTrmPdoComG[]
CANopen Slave Stack - Functional safety .
void CosSafetySrdoRcvDataUpdate(uint8_t ubSrdoNumberV)
enum CosSafetyState_e CosSafetySrdoSetData(uint8_t ubSrdoNumberV, uint8_t *pubSrcDataV)
enum CosSafetyState_e CosSafetySrdoGetData(uint8_t ubSrdoNumberV, uint8_t *pubDestDataV)
void CosSafetySrdoTrmDataUpdate(uint8_t ubSrdoNumberV)
CANopen Slave Stack - Service Data Objects (SDO) .
uint32_t CosSdoBlkUpObjectSize(uint16_t uwIndexV, uint8_t ubSubIndexV)
Retrieve Object Size.
uint8_t CosSdoBlkDownFinal(uint16_t uwIndexV, uint8_t ubSubIndexV, uint32_t ulObjectSizeV)
uint8_t CosSdoSegFinal(uint8_t ubReqCodeV, uint16_t uwIndexV, uint8_t ubSubIndexV)
Handler for segmented SDO write.
uint8_t CosSdoBlkDownObjectSize(uint16_t uwIndexV, uint8_t ubSubIndexV, uint32_t ulObjectSizeV)
CANopen Mini-Master - SDO client .
void CosSdoClnEventObjectReady(uint8_t ubNodeIdV, CoObject_ts *ptsCoObjV, uint32_t *pulAbortV)
void CosSdoClnEventTimeout(uint8_t ubNodeIdV, CoObject_ts *ptsCoObjV)
CANopen Slave Stack - Secure Configuration .
void CosSecureConfigEvent(uint8_t ubSecureConfigEventV)
uint64_t CosSecureConfigGetSeed(void)
uint64_t CosSecureConfigBuildNonce(uint64_t uqSeedV)
@ eCOS_SECURE_CONFIG_EVENT_START_FULL
Definition cos_secure_config.h:103
@ eCOS_SECURE_CONFIG_EVENT_ALLOW_ACCESS
Definition cos_secure_config.h:112
@ eCOS_SECURE_CONFIG_EVENT_DESTROY_NONCE
Definition cos_secure_config.h:109
@ eCOS_SECURE_CONFIG_EVENT_START_PART
Definition cos_secure_config.h:106
@ eCOS_SECURE_CONFIG_EVENT_BLOCK_ACCESS
Definition cos_secure_config.h:115
CANopen Slave Stack - Synchronisation functions (SYNC) .
void CosSyncEventRcvPdo(void)
Handle RPDOs on SYNC reception.
CANopen Slave Stack - Timing functions .
void CosTmrTimeStampConsume(CosTimeOfDay_ts *ptsTimeStampV)
uint16_t CosTmrCalcTicks(uint16_t uwReqTimingV)
CpStatus_tv CpCoreBufferGetData(CpPort_ts *ptsPortV, uint8_t ubBufferIdxV, uint8_t *pubDestDataV, uint8_t ubStartPosV, uint8_t ubSizeV)
Get data from message buffer.
CpStatus_tv CpCoreBufferSetDlc(CpPort_ts *ptsPortV, uint8_t ubBufferIdxV, uint8_t ubDlcV)
Set DLC of specified buffer.
CpStatus_tv CpCoreBufferSetData(CpPort_ts *ptsPortV, uint8_t ubBufferIdxV, uint8_t *pubSrcDataV, uint8_t ubStartPosV, uint8_t ubSizeV)
Set data of message buffer.
CpStatus_tv CpCoreBufferGetDlc(CpPort_ts *ptsPortV, uint8_t ubBufferIdxV, uint8_t *pubDlcV)
Get DLC of specified buffer.
#define COS_VERSION_MINOR
Definition cos_defs.h:101
#define COS_VERSION_MAJOR
Definition cos_defs.h:91
int32_t Status_tv
Data type for status value.
Definition mc_compiler.h:269
#define CPP_PARM_UNUSED(x)
Definition mc_compiler.h:261
MCL - In-Application Programming framework .
void McIapJumpToBoot(void)
uint16_t McNvmBuildChecksum(NvmAddr_tv tvStartAddressV, NvmSize_tv tvDataCountV)
Build Checksum.
Status_tv McNvmRead(NvmAddr_tv tvAddressV, uint8_t *pubDataV, NvmSize_tv tvSizeV)
Read data.
Object structure.
Definition cos_sdo_cln.h:62
Definition cos710.h:117
Definition cos710.h:107
uint16_t uwEventTick
Definition cos_pdo.h:254
uint32_t ulIdentifier
Definition cos_pdo.h:219
uint16_t uwEventTime
Definition cos_pdo.h:248
uint8_t ubTransType
Definition cos_pdo.h:224
PDO mapping parameter (static mapping)
Definition cos_pdo.h:301
Time of day.
Definition cos_time.h:80
uint32_t ulMilliseconds
Definition cos_time.h:84
uint16_t uwDays
Definition cos_time.h:89