LED indicators
CANopen_303

## Files

file | CO_LEDs.h
| CANopen Indicator specification (CiA 303-3 v1.4.0)

## Data Structures

struct | CO_LEDs_t
| LEDs object, initialized by CO_LEDs_init() More...

## Macros

#define | CO_LED_RED(LEDs, BITFIELD) (((LEDs)->LEDred & BITFIELD) ? 1 : 0)
| Get on/off state for green led for specified bitfield.
#define | CO_LED_GREEN(LEDs, BITFIELD) (((LEDs)->LEDgreen & BITFIELD) ? 1 : 0)
| Get on/off state for green led for specified bitfield.

## Enumerations

enum | CO_LED_BITFIELD_t { CO_LED_flicker = 0x01, CO_LED_blink = 0x02, CO_LED_flash_1 = 0x04, CO_LED_flash_2 = 0x08, CO_LED_flash_3 = 0x10, CO_LED_flash_4 = 0x20, CO_LED_CANopen = 0x80 }
| Bitfield for combining with red or green led. More...

## Functions

CO_ReturnError_t | CO_LEDs_init (CO_LEDs_t *LEDs)
| Initialize LEDs object. More...
void | CO_LEDs_process (CO_LEDs_t *LEDs, uint32_t timeDifference_us, CO_NMT_internalState_t NMTstate, bool_t LSSconfig, bool_t ErrCANbusOff, bool_t ErrCANbusWarn, bool_t ErrRpdo, bool_t ErrSync, bool_t ErrHbCons, bool_t ErrOther, bool_t firmwareDownload, uint32_t *timerNext_us)
| Process indicator states. More...

## Detailed Description

CIA 303-3 standard specifies indicator LED diodes, which reflects state of the CANopen device. Green and red leds or bi-color led can be used.

CANopen green led - run led:

- flickering: LSS configuration state is active
- blinking: device is in NMT pre-operational state
- single flash: device is in NMT stopped state
- triple flash: a software download is running in the device
- on: device is in NMT operational state

CANopen red led - error led:

- off: no error
- flickering: LSS node id is not configured, CANopen is not initialized
- blinking: invalid configuration, general error
- single flash: CAN warning limit reached
- double flash: heartbeat consumer - error in remote monitored node
- triple flash: sync message reception timeout
- quadruple flash: PDO has not been received before the event timer elapsed
- on: CAN bus off

To apply on/off state to led diode, use CO_LED_RED and CO_LED_GREEN macros. For CANopen leds use CO_LED_BITFIELD_t CO_LED_CANopen. Other bitfields are available for implementing custom leds.

## Enumeration Type Documentation

## CO_LED_BITFIELD_t

enum CO_LED_BITFIELD_t

Bitfield for combining with red or green led.

Enumerator
CO_LED_flicker | LED flickering 10Hz.
CO_LED_blink | LED blinking 2,5Hz.
CO_LED_flash_1 | LED single flash.
CO_LED_flash_2 | LED double flash.
CO_LED_flash_3 | LED triple flash.
CO_LED_flash_4 | LED quadruple flash.
CO_LED_CANopen | LED CANopen according to CiA 303-3.

## Function Documentation

## CO_LEDs_init()

CO_ReturnError_t CO_LEDs_init | ( | CO_LEDs_t * | LEDs | ) |

Initialize LEDs object.

Function must be called in the communication reset section.

Parameters

  LEDs | This object will be initialized.

Returns
  CO_ReturnError_t CO_ERROR_NO or CO_ERROR_ILLEGAL_ARGUMENT.

## CO_LEDs_process()

void CO_LEDs_process | ( | CO_LEDs_t * | LEDs,
|  | uint32_t | timeDifference_us,
|  | CO_NMT_internalState_t | NMTstate,
|  | bool_t | LSSconfig,
|  | bool_t | ErrCANbusOff,
|  | bool_t | ErrCANbusWarn,
|  | bool_t | ErrRpdo,
|  | bool_t | ErrSync,
|  | bool_t | ErrHbCons,
|  | bool_t | ErrOther,
|  | bool_t | firmwareDownload,
|  | uint32_t * | timerNext_us
| ) |  |

Process indicator states.

Function must be called cyclically.

Parameters

  | LEDs | This object.
  | timeDifference_us | Time difference from previous function call in [microseconds].
  | NMTstate | NMT operating state.
  | LSSconfig | Node is in LSS configuration state indication.
  | ErrCANbusOff | CAN bus off indication (highest priority).
  | ErrCANbusWarn | CAN error warning limit reached indication.
  | ErrRpdo | RPDO event timer timeout indication.
  | ErrSync | Sync receive timeout indication.
  | ErrHbCons | Heartbeat consumer error (remote node) indication.
  | ErrOther | Other error indication (lowest priority).
  | firmwareDownload | Firmware download is in progress indication.
  [out] | timerNext_us | info to OS - see CO_process().