CANopenNode
CO_Emergency.h File Reference

CANopen Emergency protocol. More...

#include "301/CO_driver.h"
#include "301/CO_ODinterface.h"

Go to the source code of this file.

Data Structures

struct  CO_EM_t
 Emergency object. More...
 

Macros

#define CO_errorReport(em, errorBit, errorCode, infoCode)   CO_error(em, true, errorBit, errorCode, infoCode)
 Report error condition, for description of parameters see CO_error.
 
#define CO_errorReset(em, errorBit, infoCode)   CO_error(em, false, errorBit, CO_EMC_NO_ERROR, infoCode)
 Reset error condition, for description of parameters see CO_error.
 

Enumerations

enum  CO_errorRegister_t {
  CO_ERR_REG_GENERIC_ERR = 0x01U, CO_ERR_REG_CURRENT = 0x02U, CO_ERR_REG_VOLTAGE = 0x04U, CO_ERR_REG_TEMPERATURE = 0x08U,
  CO_ERR_REG_COMMUNICATION = 0x10U, CO_ERR_REG_DEV_PROFILE = 0x20U, CO_ERR_REG_RESERVED = 0x40U, CO_ERR_REG_MANUFACTURER = 0x80U
}
 CANopen Error register. More...
 
enum  CO_EM_errorCode_t {
  CO_EMC_NO_ERROR = 0x0000U, CO_EMC_GENERIC = 0x1000U, CO_EMC_CURRENT = 0x2000U, CO_EMC_CURRENT_INPUT = 0x2100U,
  CO_EMC_CURRENT_INSIDE = 0x2200U, CO_EMC_CURRENT_OUTPUT = 0x2300U, CO_EMC_VOLTAGE = 0x3000U, CO_EMC_VOLTAGE_MAINS = 0x3100U,
  CO_EMC_VOLTAGE_INSIDE = 0x3200U, CO_EMC_VOLTAGE_OUTPUT = 0x3300U, CO_EMC_TEMPERATURE = 0x4000U, CO_EMC_TEMP_AMBIENT = 0x4100U,
  CO_EMC_TEMP_DEVICE = 0x4200U, CO_EMC_HARDWARE = 0x5000U, CO_EMC_SOFTWARE_DEVICE = 0x6000U, CO_EMC_SOFTWARE_INTERNAL = 0x6100U,
  CO_EMC_SOFTWARE_USER = 0x6200U, CO_EMC_DATA_SET = 0x6300U, CO_EMC_ADDITIONAL_MODUL = 0x7000U, CO_EMC_MONITORING = 0x8000U,
  CO_EMC_COMMUNICATION = 0x8100U, CO_EMC_CAN_OVERRUN = 0x8110U, CO_EMC_CAN_PASSIVE = 0x8120U, CO_EMC_HEARTBEAT = 0x8130U,
  CO_EMC_BUS_OFF_RECOVERED = 0x8140U, CO_EMC_CAN_ID_COLLISION = 0x8150U, CO_EMC_PROTOCOL_ERROR = 0x8200U, CO_EMC_PDO_LENGTH = 0x8210U,
  CO_EMC_PDO_LENGTH_EXC = 0x8220U, CO_EMC_DAM_MPDO = 0x8230U, CO_EMC_SYNC_DATA_LENGTH = 0x8240U, CO_EMC_RPDO_TIMEOUT = 0x8250U,
  CO_EMC_TIME_DATA_LENGTH = 0x8260U, CO_EMC_EXTERNAL_ERROR = 0x9000U, CO_EMC_ADDITIONAL_FUNC = 0xF000U, CO_EMC_DEVICE_SPECIFIC = 0xFF00U,
  CO_EMC401_OUT_CUR_HI = 0x2310U, CO_EMC401_OUT_SHORTED = 0x2320U, CO_EMC401_OUT_LOAD_DUMP = 0x2330U, CO_EMC401_IN_VOLT_HI = 0x3110U,
  CO_EMC401_IN_VOLT_LOW = 0x3120U, CO_EMC401_INTERN_VOLT_HI = 0x3210U, CO_EMC401_INTERN_VOLT_LO = 0x3220U, CO_EMC401_OUT_VOLT_HIGH = 0x3310U,
  CO_EMC401_OUT_VOLT_LOW = 0x3320U
}
 CANopen Error code. More...
 
enum  CO_EM_errorStatusBits_t {
  CO_EM_NO_ERROR = 0x00U, CO_EM_CAN_BUS_WARNING = 0x01U, CO_EM_RXMSG_WRONG_LENGTH = 0x02U, CO_EM_RXMSG_OVERFLOW = 0x03U,
  CO_EM_RPDO_WRONG_LENGTH = 0x04U, CO_EM_RPDO_OVERFLOW = 0x05U, CO_EM_CAN_RX_BUS_PASSIVE = 0x06U, CO_EM_CAN_TX_BUS_PASSIVE = 0x07U,
  CO_EM_NMT_WRONG_COMMAND = 0x08U, CO_EM_TIME_TIMEOUT = 0x09U, CO_EM_TIME_LENGTH = 0x0AU, CO_EM_0B_unused = 0x0BU,
  CO_EM_0C_unused = 0x0CU, CO_EM_0D_unused = 0x0DU, CO_EM_0E_unused = 0x0EU, CO_EM_0F_unused = 0x0FU,
  CO_EM_10_unused = 0x10U, CO_EM_11_unused = 0x11U, CO_EM_CAN_TX_BUS_OFF = 0x12U, CO_EM_CAN_RXB_OVERFLOW = 0x13U,
  CO_EM_CAN_TX_OVERFLOW = 0x14U, CO_EM_TPDO_OUTSIDE_WINDOW = 0x15U, CO_EM_16_unused = 0x16U, CO_EM_17_unused = 0x17U,
  CO_EM_SYNC_TIME_OUT = 0x18U, CO_EM_SYNC_LENGTH = 0x19U, CO_EM_PDO_WRONG_MAPPING = 0x1AU, CO_EM_HEARTBEAT_CONSUMER = 0x1BU,
  CO_EM_HB_CONSUMER_REMOTE_RESET = 0x1CU, CO_EM_1D_unused = 0x1DU, CO_EM_1E_unused = 0x1EU, CO_EM_1F_unused = 0x1FU,
  CO_EM_EMERGENCY_BUFFER_FULL = 0x20U, CO_EM_21_unused = 0x21U, CO_EM_MICROCONTROLLER_RESET = 0x22U, CO_EM_23_unused = 0x23U,
  CO_EM_24_unused = 0x24U, CO_EM_25_unused = 0x25U, CO_EM_26_unused = 0x26U, CO_EM_27_unused = 0x27U,
  CO_EM_WRONG_ERROR_REPORT = 0x28U, CO_EM_ISR_TIMER_OVERFLOW = 0x29U, CO_EM_MEMORY_ALLOCATION_ERROR = 0x2AU, CO_EM_GENERIC_ERROR = 0x2BU,
  CO_EM_GENERIC_SOFTWARE_ERROR = 0x2CU, CO_EM_INCONSISTENT_OBJECT_DICT = 0x2DU, CO_EM_CALCULATION_OF_PARAMETERS = 0x2EU, CO_EM_NON_VOLATILE_MEMORY = 0x2FU,
  CO_EM_MANUFACTURER_START = 0x30U, CO_EM_MANUFACTURER_END = CO_CONFIG_EM_ERR_STATUS_BITS_COUNT - 1
}
 Error status bits. More...
 

Functions

CO_ReturnError_t CO_EM_init (CO_EM_t *em, const OD_entry_t *OD_1001_errReg, const OD_entry_t *OD_1014_cobIdEm, CO_CANmodule_t *CANdevTx, uint16_t CANdevTxIdx, const OD_entry_t *OD_1015_InhTime, const OD_entry_t *OD_1003_preDefErr, const OD_entry_t *OD_statusBits, CO_CANmodule_t *CANdevRx, uint16_t CANdevRxIdx, const uint8_t nodeId)
 Initialize Emergency object. More...
 
void CO_EM_initCallbackPre (CO_EM_t *em, void *object, void(*pFunctSignal)(void *object))
 Initialize Emergency callback function. More...
 
void CO_EM_initCallbackRx (CO_EM_t *em, void(*pFunctSignalRx)(const uint16_t ident, const uint16_t errorCode, const uint8_t errorRegister, const uint8_t errorBit, const uint32_t infoCode))
 Initialize Emergency received callback function. More...
 
void CO_EM_process (CO_EM_t *em, bool_t NMTisPreOrOperational, uint32_t timeDifference_us, uint32_t *timerNext_us)
 Process Error control and Emergency object. More...
 
void CO_error (CO_EM_t *em, bool_t setError, const uint8_t errorBit, uint16_t errorCode, uint32_t infoCode)
 Set or reset error condition. More...
 
static bool_t CO_isError (CO_EM_t *em, const uint8_t errorBit)
 Check specific error condition. More...
 
static uint8_t CO_getErrorRegister (CO_EM_t *em)
 Get error register. More...
 

Detailed Description

CANopen Emergency protocol.

Author
Janez Paternoster

This file is part of CANopenNode, an opensource CANopen Stack. Project home page is https://github.com/CANopenNode/CANopenNode. For more information on CANopen see http://www.can-cia.org/.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.