Go to the documentation of this file.
26 #ifndef CO_EMERGENCY_H
27 #define CO_EMERGENCY_H
34 #define CO_CONFIG_EM (CO_CONFIG_EM_PRODUCER | \
37 #ifndef CO_CONFIG_EM_ERR_STATUS_BITS_COUNT
38 #define CO_CONFIG_EM_ERR_STATUS_BITS_COUNT (10*8)
40 #ifndef CO_CONFIG_EM_BUFFER_SIZE
41 #define CO_CONFIG_EM_BUFFER_SIZE 16
43 #ifndef CO_CONFIG_ERR_CONDITION_GENERIC
44 #define CO_CONFIG_ERR_CONDITION_GENERIC (em->errorStatusBits[5] != 0)
46 #ifndef CO_CONFIG_ERR_CONDITION_COMMUNICATION
47 #define CO_CONFIG_ERR_CONDITION_COMMUNICATION (em->errorStatusBits[2] \
48 || em->errorStatusBits[3])
50 #ifndef CO_CONFIG_ERR_CONDITION_MANUFACTURER
51 #define CO_CONFIG_ERR_CONDITION_MANUFACTURER (em->errorStatusBits[8] \
52 || em->errorStatusBits[9])
377 #if ((CO_CONFIG_EM) & (CO_CONFIG_EM_PRODUCER | CO_CONFIG_EM_HISTORY)) \
378 || defined CO_DOXYGEN
383 #if ((CO_CONFIG_EM) & CO_CONFIG_EM_PRODUCER) || defined CO_DOXYGEN
401 #if ((CO_CONFIG_EM) & CO_CONFIG_EM_PRODUCER) || defined CO_DOXYGEN
410 #if ((CO_CONFIG_EM) & CO_CONFIG_EM_PROD_CONFIGURABLE) || defined CO_DOXYGEN
416 #if ((CO_CONFIG_EM) & CO_CONFIG_EM_PROD_INHIBIT) || defined CO_DOXYGEN
424 #if ((CO_CONFIG_EM) & CO_CONFIG_EM_CONSUMER) || defined CO_DOXYGEN
433 #if ((CO_CONFIG_EM) & CO_CONFIG_FLAG_CALLBACK_PRE) || defined CO_DOXYGEN
435 void (*pFunctSignalPre)(
void *object);
472 #
if ((
CO_CONFIG_EM) & CO_CONFIG_EM_PRODUCER) || defined CO_DOXYGEN
476 #
if ((
CO_CONFIG_EM) & CO_CONFIG_EM_PROD_INHIBIT) || defined CO_DOXYGEN
480 #
if ((
CO_CONFIG_EM) & CO_CONFIG_EM_HISTORY) || defined CO_DOXYGEN
483 #
if ((
CO_CONFIG_EM) & CO_CONFIG_EM_STATUS_BITS) || defined CO_DOXYGEN
486 #
if ((
CO_CONFIG_EM) & CO_CONFIG_EM_CONSUMER) || defined CO_DOXYGEN
493 #if ((CO_CONFIG_EM) & CO_CONFIG_FLAG_CALLBACK_PRE) || defined CO_DOXYGEN
510 void (*pFunctSignal)(
void *
object));
514 #if ((CO_CONFIG_EM) & CO_CONFIG_EM_CONSUMER) || defined CO_DOXYGEN
531 void (*pFunctSignalRx)(
const uint16_t ident,
554 bool_t NMTisPreOrOperational,
584 #define CO_errorReport(em, errorBit, errorCode, infoCode) \
585 CO_error(em, true, errorBit, errorCode, infoCode)
591 #define CO_errorReset(em, errorBit, infoCode) \
592 CO_error(em, false, errorBit, CO_EMC_NO_ERROR, infoCode)
607 uint8_t bitmask = 1 << (errorBit & 0x7);
unsigned long int uint32_t
UNSIGNED32 in CANopen (0007h), 32-bit unsigned integer.
Definition: CO_driver.h:155
@ CO_EM_CALCULATION_OF_PARAMETERS
0x2E, generic, critical, Error in calculation of device parameters
Definition: CO_Emergency.h:349
uint16_t producerCanId
COB ID of emergency message, from Object dictionary.
Definition: CO_Emergency.h:412
#define CO_CONFIG_EM_ERR_STATUS_BITS_COUNT
Maximum number of CO_EM_errorStatusBits_t.
Definition: CO_config.h:214
Interface between CAN hardware and CANopenNode.
@ CO_EMC_HEARTBEAT
0x8130, Life Guard Error or Heartbeat Error
Definition: CO_Emergency.h:184
@ CO_EM_CAN_RX_BUS_PASSIVE
0x06, communication, info, CAN receive bus is passive
Definition: CO_Emergency.h:263
@ CO_EM_21_unused
0x21, generic, info, (unused)
Definition: CO_Emergency.h:322
@ CO_EMC_MONITORING
0x80xx, Monitoring
Definition: CO_Emergency.h:176
CO_EM_errorStatusBits_t
Error status bits.
Definition: CO_Emergency.h:247
@ CO_EM_GENERIC_ERROR
0x2B, generic, critical, Generic error, test usage
Definition: CO_Emergency.h:343
@ CO_EMC401_OUT_LOAD_DUMP
0x2330, DS401, Load dump at outputs
Definition: CO_Emergency.h:215
@ CO_ERR_REG_VOLTAGE
bit 2, voltage
Definition: CO_Emergency.h:122
#define true
Logical true, for general use.
Definition: CO_driver.h:137
@ CO_EM_24_unused
0x24, generic, info, (unused)
Definition: CO_Emergency.h:328
@ CO_EMC_ADDITIONAL_FUNC
0xF0xx, Additional Functions
Definition: CO_Emergency.h:206
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.
Definition: CO_Emergency.c:686
unsigned int uint16_t
UNSIGNED16 in CANopen (0006h), 16-bit unsigned integer.
Definition: CO_driver.h:153
@ CO_EM_TPDO_OUTSIDE_WINDOW
0x15, communication, critical, TPDO is outside SYNC window
Definition: CO_Emergency.h:295
uint16_t CANdevTxIdx
From CO_EM_init()
Definition: CO_Emergency.h:414
uint16_t CANerrorStatusOld
Old CAN error status bitfield.
Definition: CO_Emergency.h:375
bool_t producerEnabled
True, if emergency producer is enabled, from Object dictionary.
Definition: CO_Emergency.h:403
@ CO_EMC_CAN_ID_COLLISION
0x8150, CAN-ID collision
Definition: CO_Emergency.h:188
CO_CANtx_t * CANtxBuff
CAN transmit buffer.
Definition: CO_Emergency.h:409
CO_ReturnError_t
Return values of some CANopen functions.
Definition: CO_driver.h:488
@ CO_EMC_GENERIC
0x10xx, Generic Error
Definition: CO_Emergency.h:140
@ CO_EM_RXMSG_WRONG_LENGTH
0x02, communication, info, Wrong data length of the received CAN message
Definition: CO_Emergency.h:254
@ CO_EM_SYNC_TIME_OUT
0x18, communication, critical, SYNC message timeout
Definition: CO_Emergency.h:301
@ CO_ERR_REG_COMMUNICATION
bit 4, communication error
Definition: CO_Emergency.h:124
@ CO_EMC401_INTERN_VOLT_HI
0x3210, DS401, Internal voltage too high
Definition: CO_Emergency.h:221
@ CO_EMC_COMMUNICATION
0x81xx, Communication
Definition: CO_Emergency.h:178
unsigned char bool_t
Boolean data type for general use.
Definition: CO_driver.h:141
@ CO_ERR_REG_RESERVED
bit 6, reserved (always 0)
Definition: CO_Emergency.h:126
@ CO_EMC_PDO_LENGTH
0x8210, PDO not processed due to length error
Definition: CO_Emergency.h:192
@ CO_ERR_REG_GENERIC_ERR
bit 0, generic error
Definition: CO_Emergency.h:120
@ CO_EM_0F_unused
0x0F, communication, info, (unused)
Definition: CO_Emergency.h:281
@ CO_EM_1D_unused
0x1D, communication, critical, (unused)
Definition: CO_Emergency.h:312
@ CO_EMC_DAM_MPDO
0x8230, DAM MPDO not processed, destination object not available
Definition: CO_Emergency.h:196
@ CO_EM_MICROCONTROLLER_RESET
0x22, generic, info, Microcontroller has just started
Definition: CO_Emergency.h:324
@ CO_ERR_REG_CURRENT
bit 1, current
Definition: CO_Emergency.h:121
@ CO_EMC_ADDITIONAL_MODUL
0x70xx, Additional Modules
Definition: CO_Emergency.h:174
@ CO_EM_WRONG_ERROR_REPORT
0x28, generic, critical, Wrong parameters to CO_errorReport() function
Definition: CO_Emergency.h:337
@ CO_EMC_PROTOCOL_ERROR
0x82xx, Protocol Error
Definition: CO_Emergency.h:190
@ CO_EM_27_unused
0x27, generic, info, (unused)
Definition: CO_Emergency.h:334
@ CO_EMC_BUS_OFF_RECOVERED
0x8140, recovered from bus off
Definition: CO_Emergency.h:186
@ CO_EM_NON_VOLATILE_MEMORY
0x2F, generic, critical, Error with access to non volatile device memory
Definition: CO_Emergency.h:352
@ CO_EM_SYNC_LENGTH
0x19, communication, critical, Unexpected SYNC data length
Definition: CO_Emergency.h:303
@ CO_EM_GENERIC_SOFTWARE_ERROR
0x2C, generic, critical, Software error
Definition: CO_Emergency.h:345
@ CO_ERR_REG_DEV_PROFILE
bit 5, device profile specific
Definition: CO_Emergency.h:125
@ CO_EM_10_unused
0x10, communication, critical, (unused)
Definition: CO_Emergency.h:284
@ CO_EM_EMERGENCY_BUFFER_FULL
0x20, generic, info, Emergency buffer is full, Emergency message wasn't sent
Definition: CO_Emergency.h:320
@ CO_EMC_DATA_SET
0x63xx, Data Set
Definition: CO_Emergency.h:172
@ CO_EM_0B_unused
0x0B, communication, info, (unused)
Definition: CO_Emergency.h:273
@ CO_EMC401_OUT_CUR_HI
0x2310, DS401, Current at outputs too high (overload)
Definition: CO_Emergency.h:211
@ CO_EMC_SOFTWARE_INTERNAL
0x61xx, Internal Software
Definition: CO_Emergency.h:168
@ CO_EM_MANUFACTURER_END
(CO_CONFIG_EM_ERR_STATUS_BITS_COUNT - 1), largest value of the Error status bit.
Definition: CO_Emergency.h:362
@ CO_EMC_CURRENT
0x20xx, Current
Definition: CO_Emergency.h:142
@ CO_EM_1E_unused
0x1E, communication, critical, (unused)
Definition: CO_Emergency.h:314
@ CO_EM_CAN_RXB_OVERFLOW
0x13, communication, critical, CAN module receive buffer has overflowed
Definition: CO_Emergency.h:291
@ CO_EMC_SOFTWARE_DEVICE
0x60xx, Device Software
Definition: CO_Emergency.h:166
@ CO_EM_NMT_WRONG_COMMAND
0x08, communication, info, Wrong NMT command received
Definition: CO_Emergency.h:267
@ CO_EM_INCONSISTENT_OBJECT_DICT
0x2D, generic, critical, Object dictionary does not match the software
Definition: CO_Emergency.h:347
@ CO_EMC401_OUT_SHORTED
0x2320, DS401, Short circuit at outputs
Definition: CO_Emergency.h:213
@ CO_EMC_CURRENT_OUTPUT
0x23xx, Current, device output side
Definition: CO_Emergency.h:148
@ CO_EMC_VOLTAGE_OUTPUT
0x33xx, Output Voltage
Definition: CO_Emergency.h:156
CO_CANmodule_t * CANdevTx
From CO_EM_init()
Definition: CO_Emergency.h:407
@ CO_EM_CAN_TX_BUS_PASSIVE
0x07, communication, info, CAN transmit bus is passive
Definition: CO_Emergency.h:265
@ CO_EM_CAN_TX_BUS_OFF
0x12, communication, critical, CAN transmit bus is off
Definition: CO_Emergency.h:288
@ CO_EM_CAN_TX_OVERFLOW
0x14, communication, critical, CAN transmit buffer has overflowed
Definition: CO_Emergency.h:293
@ CO_EM_MANUFACTURER_START
0x30+, manufacturer, info or critical, Error status buts, free to use by manufacturer.
Definition: CO_Emergency.h:359
@ CO_EM_RPDO_OVERFLOW
0x05, communication, info, Previous received PDO wasn't processed yet
Definition: CO_Emergency.h:261
@ CO_EMC_DEVICE_SPECIFIC
0xFFxx, Device specific
Definition: CO_Emergency.h:208
@ CO_EMC401_OUT_VOLT_LOW
0x3320, DS401, Output voltage too low
Definition: CO_Emergency.h:227
CO_EM_errorCode_t
CANopen Error code.
Definition: CO_Emergency.h:136
@ CO_EMC_VOLTAGE_INSIDE
0x32xx, Voltage inside the device
Definition: CO_Emergency.h:154
@ CO_EMC401_INTERN_VOLT_LO
0x3220, DS401, Internal voltage too low
Definition: CO_Emergency.h:223
@ CO_EMC_HARDWARE
0x50xx, Device Hardware
Definition: CO_Emergency.h:164
uint8_t nodeId
Copy of CANopen node ID, from CO_EM_init()
Definition: CO_Emergency.h:405
uint8_t fifoCount
Count of emergency messages in fifo, used for OD object 0x1003.
Definition: CO_Emergency.h:398
@ CO_EM_NO_ERROR
0x00, Error Reset or No Error
Definition: CO_Emergency.h:249
#define CO_CONFIG_EM_BUFFER_SIZE
Size of the internal buffer, where emergencies are stored after error indication with CO_error() func...
Definition: CO_config.h:228
CO_errorRegister_t
CANopen Error register.
Definition: CO_Emergency.h:119
@ CO_EM_HB_CONSUMER_REMOTE_RESET
0x1C, communication, critical, Heartbeat consumer detected remote node reset
Definition: CO_Emergency.h:310
uint8_t * errorRegister
Pointer to error register in object dictionary at 0x1001,00.
Definition: CO_Emergency.h:373
void CO_EM_initCallbackPre(CO_EM_t *em, void *object, void(*pFunctSignal)(void *object))
Initialize Emergency callback function.
uint8_t fifoOverflow
Indication of overflow - messages in buffer are not post-processed.
Definition: CO_Emergency.h:396
@ CO_EM_HEARTBEAT_CONSUMER
0x1B, communication, critical, Heartbeat consumer timeout
Definition: CO_Emergency.h:307
@ CO_EMC_TEMP_AMBIENT
0x41xx, Ambient Temperature
Definition: CO_Emergency.h:160
@ CO_EM_CAN_BUS_WARNING
0x01, communication, info, CAN bus warning limit reached
Definition: CO_Emergency.h:251
static uint8_t CO_getErrorRegister(CO_EM_t *em)
Get error register.
Definition: CO_Emergency.h:620
uint8_t fifoPpPtr
Pointer for the fifo, where next emergency message has to be post-processed by CO_EM_process() functi...
Definition: CO_Emergency.h:394
@ CO_EM_11_unused
0x11, communication, critical, (unused)
Definition: CO_Emergency.h:286
Emergency object.
Definition: CO_Emergency.h:369
@ CO_EM_23_unused
0x23, generic, info, (unused)
Definition: CO_Emergency.h:326
@ CO_EMC401_IN_VOLT_HI
0x3110, DS401, Input voltage too high
Definition: CO_Emergency.h:217
uint8_t fifoWrPtr
Pointer for the fifo buffer, where next emergency message will be written by CO_error() function.
Definition: CO_Emergency.h:390
#define CO_CONFIG_EM
Configuration of Emergency.
Definition: CO_config.h:197
@ CO_EMC_CAN_PASSIVE
0x8120, CAN in Error Passive Mode
Definition: CO_Emergency.h:182
@ CO_EM_1F_unused
0x1F, communication, critical, (unused)
Definition: CO_Emergency.h:316
@ CO_EMC_SYNC_DATA_LENGTH
0x8240, Unexpected SYNC data length
Definition: CO_Emergency.h:198
uint8_t errorStatusBits[CO_CONFIG_EM_ERR_STATUS_BITS_COUNT/8]
Bitfield for the internal indication of the error condition.
Definition: CO_Emergency.h:371
CANopen Object Dictionary interface.
void * functSignalObjectPre
From CO_EM_initCallbackPre() or NULL.
Definition: CO_Emergency.h:437
@ CO_EM_25_unused
0x25, generic, info, (unused)
Definition: CO_Emergency.h:330
@ CO_EMC_TIME_DATA_LENGTH
0x8260, Unexpected TIME data length
Definition: CO_Emergency.h:202
@ CO_EMC_PDO_LENGTH_EXC
0x8220, PDO length exceeded
Definition: CO_Emergency.h:194
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.
@ CO_EMC_EXTERNAL_ERROR
0x90xx, External Error
Definition: CO_Emergency.h:204
@ CO_EM_0C_unused
0x0C, communication, info, (unused)
Definition: CO_Emergency.h:275
@ CO_EM_TIME_LENGTH
0x0A, communication, info, Unexpected TIME data length
Definition: CO_Emergency.h:271
@ CO_EMC401_OUT_VOLT_HIGH
0x3310, DS401, Output voltage too high
Definition: CO_Emergency.h:225
@ CO_EMC_VOLTAGE_MAINS
0x31xx, Mains Voltage
Definition: CO_Emergency.h:152
@ CO_EM_17_unused
0x17, communication, critical, (unused)
Definition: CO_Emergency.h:299
@ CO_EMC_TEMP_DEVICE
0x42xx, Device Temperature
Definition: CO_Emergency.h:162
@ CO_EM_0E_unused
0x0E, communication, info, (unused)
Definition: CO_Emergency.h:279
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.
static bool_t CO_isError(CO_EM_t *em, const uint8_t errorBit)
Check specific error condition.
Definition: CO_Emergency.h:605
@ CO_EM_0D_unused
0x0D, communication, info, (unused)
Definition: CO_Emergency.h:277
@ CO_ERR_REG_MANUFACTURER
bit 7, manufacturer specific
Definition: CO_Emergency.h:127
@ CO_EMC_RPDO_TIMEOUT
0x8250, RPDO timeout
Definition: CO_Emergency.h:200
#define NULL
NULL, for general usage.
Definition: CO_driver.h:135
@ CO_EM_RXMSG_OVERFLOW
0x03, communication, info, Previous received CAN message wasn't processed yet
Definition: CO_Emergency.h:257
@ CO_EMC_CAN_OVERRUN
0x8110, CAN Overrun (Objects lost)
Definition: CO_Emergency.h:180
Complete CAN module object.
Definition: CO_driver.h:319
@ CO_EM_ISR_TIMER_OVERFLOW
0x29, generic, critical, Timer task has overflowed
Definition: CO_Emergency.h:339
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.
Definition: CO_Emergency.c:538
@ CO_EMC401_IN_VOLT_LOW
0x3120, DS401, Input voltage too low
Definition: CO_Emergency.h:219
@ CO_EM_TIME_TIMEOUT
0x09, communication, info, TIME message timeout
Definition: CO_Emergency.h:269
Object Dictionary entry for one OD object.
Definition: CO_ODinterface.h:336
@ CO_EMC_SOFTWARE_USER
0x62xx, User Software
Definition: CO_Emergency.h:170
@ CO_EM_MEMORY_ALLOCATION_ERROR
0x2A, generic, critical, Unable to allocate memory for objects
Definition: CO_Emergency.h:341
@ CO_EMC_VOLTAGE
0x30xx, Voltage
Definition: CO_Emergency.h:150
@ CO_EM_16_unused
0x16, communication, critical, (unused)
Definition: CO_Emergency.h:297
@ CO_EM_PDO_WRONG_MAPPING
0x1A, communication, critical, Error with PDO mapping
Definition: CO_Emergency.h:305
@ CO_EMC_TEMPERATURE
0x40xx, Temperature
Definition: CO_Emergency.h:158
@ CO_ERR_REG_TEMPERATURE
bit 3, temperature
Definition: CO_Emergency.h:123
@ CO_EMC_CURRENT_INSIDE
0x22xx, Current inside the device
Definition: CO_Emergency.h:146
@ CO_EMC_CURRENT_INPUT
0x21xx, Current, device input side
Definition: CO_Emergency.h:144
Configuration object for CAN transmit message for specific CANopenNode Object.
Definition: CO_driver.h:299
@ CO_EMC_NO_ERROR
0x00xx, error Reset or No Error
Definition: CO_Emergency.h:138
uint32_t inhibitEmTime_us
Inhibit time for emergency message, from Object dictionary.
Definition: CO_Emergency.h:418
@ CO_EM_26_unused
0x26, generic, info, (unused)
Definition: CO_Emergency.h:332
unsigned char uint8_t
UNSIGNED8 in CANopen (0005h), 8-bit unsigned integer.
Definition: CO_driver.h:151
@ CO_EM_RPDO_WRONG_LENGTH
0x04, communication, info, Wrong data length of received PDO
Definition: CO_Emergency.h:259