CANopen Slave Documentation
Version 6.16.04
Loading...
Searching...
No Matches
cos_nrl.h File Reference

Detailed Description

This module adds the Network Redundancy Layer (NRL) to the CANopen FD Slave protocol stack. The NRL is an optional add-on module for the CANopen FD Slave protocol stack. The NRL is enabled by setting the symbol COS_NRL_SUPPORT to 1.

The NRL must be started in advance to the CANopen FD Slave protocol stack. The following example depicts the initialization of the NRL:

//----------------------------------------------------------------------------------------------
// Initialise the Network Redundancy Layer
// The DCL is on CAN interface 1, the RCL is on CAN interface 2
//
//----------------------------------------------------------------------------------------------
// Initialise the CANopen slave stack
//
//----------------------------------------------------------------------------------------------
// Start the NRL
//
//---------------------------------------------------------------------------------------------------
// start the CANopen Slave Protocol Stack
//
@ eCP_BITRATE_125K
Definition canpie.h:667
@ eCP_BITRATE_NONE
Definition canpie.h:642
@ eCP_CHANNEL_2
Definition canpie.h:735
@ eCP_CHANNEL_1
Definition canpie.h:732
uint8_t CosMgrInit(uint8_t ubCanIfV, uint16_t uwConfigV)
Initialise the CANopen Slave.
#define COS_CONF_SLAVE
Definition cos_mgr.h:83
uint8_t CosMgrStart(uint8_t ubNodeIdV, int32_t slBitrateNomSelV, int32_t slBitrateDatSelV)
Status_tv CosNrlInit(uint8_t ubNrlChannelV, uint8_t ubPhyIfDclV, uint8_t ubPhyIfRclV, CpNrlDriver_ts *ptsNrlDriverV)
Status_tv CosNrlStart(uint8_t ubNrlChannelV)
CpNrlDriver_ts tsNrlDriverG
@ eCP_NRL_CHANNEL_1
Definition cp_nrl.h:257

The following table shows all additional objects for the CANopen FD Slave protocol stack when NRL is enabled.

Index Description Function / Variable Configuration Symbol
1F62h NRL configuration CosNrl_Idx1F62() COS_NRL_SUPPORT
1F62h NRL monitoring CosNrl_Idx1F63() COS_NRL_SUPPORT
+ Include dependency graph for cos_nrl.h:

Functions

uint8_t CosNrl_Idx1F62 (uint8_t ubSubIndexV, uint8_t ubReqCodeV)
 
uint8_t CosNrl_Idx1F63 (uint8_t ubSubIndexV, uint8_t ubReqCodeV)
 
void CosNrlEventHandler (uint8_t ubNrlStateV)
 
Status_tv CosNrlInit (uint8_t ubNrlChannelV, uint8_t ubPhyIfDclV, uint8_t ubPhyIfRclV, CpNrlDriver_ts *ptsNrlDriverV)
 
Status_tv CosNrlStart (uint8_t ubNrlChannelV)
 
void CosNrlTimerEvent (void)
 

Function Documentation

◆ CosNrl_Idx1F62()

uint8_t CosNrl_Idx1F62 ( uint8_t  ubSubIndexV,
uint8_t  ubReqCodeV 
)

Index 1F62 - Network Redundancy Layer Configuration.

Parameters
ubSubIndexVsub-index
ubReqCodeVread / write access
Returns
SDO response code (enumeration CosSdo_e)

The object allows adjustment of NRL parameters in order to meet the application requirements.

  • Sub-Index 0 Highest Sub-Index supported
  • Sub-Index 1 Counter deviation limit
  • Sub-Index 2 Mailbox timeout

The function returns a SDO response code defined by the CosSdo_e enumeration. The index is only available when the symbol COS_NRL_SUPPORT is set.

◆ CosNrl_Idx1F63()

uint8_t CosNrl_Idx1F63 ( uint8_t  ubSubIndexV,
uint8_t  ubReqCodeV 
)

Index 1F63 - Network Redundancy Layer Monitoring.

Parameters
ubSubIndexVsub-index
ubReqCodeVread / write access
Returns
SDO response code (enumeration CosSdo_e)

This object allows to monitor the transmit and receive counter deviation values of the Network Redundancy Layer.

  • Sub-Index 0 Highest Sub-Index supported
  • Sub-Index 1 NRL state
  • Sub-Index 2 NRL active line
  • Sub-Index 3 CAN error state DCL
  • Sub-Index 4 CAN error state RCL
  • Sub-Index 5 DCL node count
  • Sub-Index 6 DCL cross count
  • Sub-Index 7 RCL node count
  • Sub-Index 8 RCL cross count

The function returns a SDO response code defined by the CosSdo_e enumeration. The index is only available when the symbol COS_NRL_SUPPORT is set.

◆ CosNrlEventHandler()

void CosNrlEventHandler ( uint8_t  ubNrlStateV)
Parameters
[in]ubNrlStateVState of Network Redundancy Layer

This function is called upon the occurrence of a NRL state change event. The function implementation is located in the file cos_user.c. The value of the parameter ubNrlStateV is defined by the enumeration CpNrlState_e, detailed information about the NRL can be obtained by calling CpNrlState().

◆ CosNrlInit()

Status_tv CosNrlInit ( uint8_t  ubNrlChannelV,
uint8_t  ubPhyIfDclV,
uint8_t  ubPhyIfRclV,
CpNrlDriver_ts ptsNrlDriverV 
)
Parameters
[in]ubNrlChannelVChannel of Network Redundancy Layer
[in]ubPhyIfDclVPhysical interface of Default CAN Line
[in]ubPhyIfRclVPhysical interface of Redundant CAN Line
[in]ptsNrlDriverVPointer to NRL driver structure
Returns
Error code defined by the CosErr_e enumeration. If no error occurred, the function will return the value eCOS_ERR_NONE.

This function must be called by the application program prior to any other CANopen FD Slave Stack function if the Network Redundancy Layer shall be supported.

The function returns an error code defined the the enumeration CosErr_e.

◆ CosNrlStart()

Status_tv CosNrlStart ( uint8_t  ubNrlChannelV)
Parameters
[in]ubNrlChannelVChannel of Network Redundancy Layer
Returns
Error code defined by the CosErr_e enumeration. If no error occurred, the function will return the value eCOS_ERR_NONE.

This function must be called by the application program after CosMgrInit(). It is responsible for initialization of the NRL control service.

The function returns an error code defined the the enumeration CosErr_e.

◆ CosNrlTimerEvent()

void CosNrlTimerEvent ( void  )

This function must be called by a timer resource of the target system. It is responsible to call the NRL fault detection and recovery. The period of the timer is defined via the symbol CP_NRL_TIMER_PERIOD.

Example

//-------------------------------------------------------------//
// Timer service routine //
// //
//-------------------------------------------------------------//
void MyTimerService(void)
{
//... timer services of application ...
//--- Call NRL timer function -------------
}
void CosNrlTimerEvent(void)