CANopen Master Documentation
Version 6.06.04
Loading...
Searching...
No Matches
com_led.h File Reference

Detailed Description

The LED module supports two types of LEDs: a Module LED and a Network LED. The Module LED displays the state of the hardware, e.g. power supply, driver stage, etc. The Network LED displays the state of the CAN connection and the CANopen NMT state. Both LEDs should be bi-color LEDs. If not, the patterns for the blinking code may need to be adopted.

In the implementation, each LED gets two patterns - one for the red LED and one for the green LED (bi-color LED). Both patterns have a length of 32 bit. With a given default pattern shift rate of 50 ms (defined by the symbol COM_LED_PERIOD) the total pattern length can be 1,6 seconds.

Please note that this implementation is not fully compliant to DR-303-3.

The LED functionality is only compiled when the symbol COM_LED_SUPPORT (see com_conf.h) is set to a value greater 0.

The Network LED is autonomously run by the CANopen stack, i.e. no function has to be called by the user application. The following functions must be adopted to the target hardware for Network LED support:

The Module LED must be driven by the user application, i.e. you have to call the ComLedModuleStatus() function somewhere. The following functions must be adopted to the target hardware for Module LED support:

+ Include dependency graph for com_led.h:

Macros

#define COM_LED_PERIOD   50000
 

Enumerations

enum  ComLedMod_e {
  eCOM_LED_MOD_OK = 0 ,
  eCOM_LED_MOD_FAIL_BAUD ,
  eCOM_LED_MOD_FAIL_ADDR ,
  eCOM_LED_MOD_RECOVER ,
  eCOM_LED_MOD_APP1 ,
  eCOM_LED_MOD_APP2
}
 
enum  ComLedNet_e {
  eCOM_LED_NET_STOPPED = 0 ,
  eCOM_LED_NET_PREOPERATIONAL ,
  eCOM_LED_NET_OPERATIONAL ,
  eCOM_LED_NET_INIT
}
 
enum  ComLedErr_e {
}
 

Functions

void ComLedModRed (uint8_t ubNetV, bool_t btSwitchOnV)
 
void ComLedModGreen (uint8_t ubNetV, bool_t btSwitchOnV)
 
void ComLedNetRed (uint8_t ubNetV, bool_t btSwitchOnV)
 
void ComLedNetGreen (uint8_t ubNetV, bool_t btSwitchOnV)
 
ComStatus_tv ComLedModuleStatus (uint8_t ubNetV, uint8_t ubStatusV)
 
ComStatus_tv ComLedNetworkError (uint8_t ubNetV, uint8_t ubErrorV)
 
ComStatus_tv ComLedNetworkStatus (uint8_t ubNetV, uint8_t ubStatusV)
 

Macro Definition Documentation

◆ COM_LED_PERIOD

#define COM_LED_PERIOD   50000

LED on/off period.

This value defines the shortest on/off period for LED blinking in microseconds.

Enumeration Type Documentation

◆ ComLedErr_e

Network LED - error states.

This enumeration defines the CAN error states for the red network LED. The definitions are used by the function ComLedNetworkError().

Enumerator
eCOM_LED_ERR_BUS_WARN 

CAN Bus is warn error active

eCOM_LED_ERR_BUS_PASSIVE 

CAN Bus is error passive

eCOM_LED_ERR_BUS_OFF 

CAN is Bus-Off

eCOM_LED_ERR_RESERVED 

reserved blinkcode

◆ ComLedMod_e

Module LED states.

This enumeration defines all states for the module LED. The optional module LED displays the state of the hardware, not the network (i.e. CAN) state.

Enumerator
eCOM_LED_MOD_OK 

Module state is OK

eCOM_LED_MOD_FAIL_BAUD 

Hardware failure on baudrate setting

eCOM_LED_MOD_FAIL_ADDR 

Hardware failure on address setting

eCOM_LED_MOD_RECOVER 

Error occured that can be recovered

eCOM_LED_MOD_APP1 

Application / hardware error 1

eCOM_LED_MOD_APP2 

Application / hardware error 2

◆ ComLedNet_e

Network LED - NMT states.

This enumeration defines the NMT states for the green network LED. The definitions are used by the function ComLedNetworkStatus().

Enumerator
eCOM_LED_NET_STOPPED 

Module is in Stopped State

eCOM_LED_NET_PREOPERATIONAL 

Module is in Pre-Operational State

eCOM_LED_NET_OPERATIONAL 

Module is in Operational State

eCOM_LED_NET_INIT 

Module is in Initialization State

Function Documentation

◆ ComLedModGreen()

void ComLedModGreen ( uint8_t  ubNetV,
bool_t  btSwitchOnV 
)

Drive green Module LED.

Parameters
ubNetV- CANopen Network channel
btSwitchOnV- state of the LED

According to the parameter btSwitchOnV the function switches the green Module LED on or off.

  • btSwitchOnV = 0: LED is switched off
  • btSwitchOnV = 1: LED is switched on

This function must be adopted to the target hardware.

◆ ComLedModRed()

void ComLedModRed ( uint8_t  ubNetV,
bool_t  btSwitchOnV 
)

Drive Red Module LED.

Parameters
ubNetV- CANopen Network channel
btSwitchOnV- state of the LED

According to the parameter btSwitchOnV the function switches the red Module LED on or off.

  • btSwitchOnV = 0: LED is switched off
  • btSwitchOnV = 1: LED is switched on

This function must be adopted to the target hardware.

◆ ComLedModuleStatus()

ComStatus_tv ComLedModuleStatus ( uint8_t  ubNetV,
uint8_t  ubStatusV 
)

Module Status LED.

Parameters
ubNetV- CANopen Network channel
ubStatusV- Module Status
Returns
Value of enumeration ComErr_e

This function sets the pattern for the Module Status LED. Valid values for the parameter ubStatusV are given in the enumeration ComLedMod_e.

◆ ComLedNetGreen()

void ComLedNetGreen ( uint8_t  ubNetV,
bool_t  btSwitchOnV 
)

Drive green Network LED.

Parameters
ubNetV- CANopen Network channel
btSwitchOnV- state of the LED

According to the parameter btSwitchOnV the function switches the green Network LED on or off.

  • btSwitchOnV = 0: LED is switched off
  • btSwitchOnV = 1: LED is switched on

This function must be adopted to the target hardware.

◆ ComLedNetRed()

void ComLedNetRed ( uint8_t  ubNetV,
bool_t  btSwitchOnV 
)

Drive red Network LED.

Parameters
ubNetV- CANopen Network channel
btSwitchOnV- state of the LED

According to the parameter btSwitchOnV the function switches the red Network LED on or off.

  • btSwitchOnV = 0: LED is switched off
  • btSwitchOnV = 1: LED is switched on

This function must be adopted to the target hardware.

◆ ComLedNetworkError()

ComStatus_tv ComLedNetworkError ( uint8_t  ubNetV,
uint8_t  ubErrorV 
)

Network Error LED.

Parameters
ubNetV- CANopen Network channel
ubErrorV
Returns
Value of enumeration ComErr_e

This function sets the network error value. Valid values for the parameter ubErrorV are given in the enumeration ComLedErr_e.

◆ ComLedNetworkStatus()

ComStatus_tv ComLedNetworkStatus ( uint8_t  ubNetV,
uint8_t  ubStatusV 
)

Network Status LED.

Parameters
ubNetV- CANopen Network channel
ubStatusV
Returns
Value of enumeration ComErr_e

This function sets the network status value. Valid values for the parameter ubStatusV are given in the enumeration ComLedNet_e.