CANopen Slave Documentation
Version 6.16.04
Loading...
Searching...
No Matches
cos_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 COS_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 COS_LED_SUPPORT (see cos_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 CosLedModuleStatus() function somewhere. The following functions must be adopted to the target hardware for Module LED support:

+ Include dependency graph for cos_led.h:

Enumerations

enum  CosLedMod_e {
  eCosLedMod_OK = 0 ,
  eCosLedMod_FAIL_BAUD ,
  eCosLedMod_FAIL_ADDR ,
  eCosLedMod_RECOVER ,
  eCosLedMod_APP1 ,
  eCosLedMod_APP2
}
 
enum  CosLedNet_e {
  eCosLedNet_STOPPED = 0 ,
  eCosLedNet_PREOPERATIONAL ,
  eCosLedNet_OPERATIONAL ,
  eCosLedNet_INIT
}
 
enum  CosLedErr_e {
}
 

Functions

void CosLedModRed (bool_t btSwitchOnV)
 
void CosLedModGreen (bool_t btSwitchOnV)
 
void CosLedNetRed (bool_t btSwitchOnV)
 
void CosLedNetGreen (bool_t btSwitchOnV)
 
void CosLedModuleStatus (uint8_t ubStatusV)
 
void CosLedNetworkError (uint8_t ubErrorV)
 
void CosLedNetworkPattern (void)
 
void CosLedNetworkStatus (uint8_t ubStatusV)
 

Enumeration Type Documentation

◆ CosLedErr_e

Network LED - error states.

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

Enumerator
eCosLedErr_BUS_WARN 

CAN Bus is warn error active

eCosLedErr_BUS_PASSIVE 

CAN Bus is error passive

eCosLedErr_BUS_OFF 

CAN is Bus-Off

eCosLedErr_RESERVED 

reserved blinkcode

◆ CosLedMod_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
eCosLedMod_OK 

Module state is OK

eCosLedMod_FAIL_BAUD 

Hardware failure on bit-rate setting

eCosLedMod_FAIL_ADDR 

Hardware failure on address setting

eCosLedMod_RECOVER 

Error occurred that can be recovered

eCosLedMod_APP1 

Application / hardware error 1

eCosLedMod_APP2 

Application / hardware error 2

◆ CosLedNet_e

Network LED - NMT states.

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

Enumerator
eCosLedNet_STOPPED 

Module is in Stopped State

eCosLedNet_PREOPERATIONAL 

Module is in Pre-Operational State

eCosLedNet_OPERATIONAL 

Module is in Operational State

eCosLedNet_INIT 

Module is in Initialization State

Function Documentation

◆ CosLedModGreen()

void CosLedModGreen ( bool_t  btSwitchOnV)

Drive green Module LED.

Parameters
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.

◆ CosLedModRed()

void CosLedModRed ( bool_t  btSwitchOnV)

Drive Red Module LED.

Parameters
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.

◆ CosLedModuleStatus()

void CosLedModuleStatus ( uint8_t  ubStatusV)

Module Status LED.

Parameters
ubStatusV- Module Status

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

◆ CosLedNetGreen()

void CosLedNetGreen ( bool_t  btSwitchOnV)

Drive green Network LED.

Parameters
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.

◆ CosLedNetRed()

void CosLedNetRed ( bool_t  btSwitchOnV)

Drive red Network LED.

Parameters
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.

◆ CosLedNetworkError()

void CosLedNetworkError ( uint8_t  ubErrorV)

Network Error LED.

Parameters
ubErrorV- Error condition

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

◆ CosLedNetworkPattern()

void CosLedNetworkPattern ( void  )

Update Network Status LED pattern.

This function sets the pattern for the Network Status LED.

◆ CosLedNetworkStatus()

void CosLedNetworkStatus ( uint8_t  ubStatusV)

Network Status LED.

Parameters
ubStatusV- CAN status

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