static analysis: refactoring changed enum with define to be able to use bitwise operators
This commit is contained in:
parent
6e009c0893
commit
7855d35bae
9 changed files with 166 additions and 266 deletions
|
|
@ -564,33 +564,33 @@ void CO_EM_process(CO_EM_t *em,
|
|||
uint16_t CANerrStChanged = CANerrSt ^ em->CANerrorStatusOld;
|
||||
em->CANerrorStatusOld = CANerrSt;
|
||||
|
||||
if (CANerrStChanged & ((uint16_t)CO_CAN_ERRTX_WARNING | (uint16_t)CO_CAN_ERRRX_WARNING)) {
|
||||
if (CANerrStChanged & (CO_CAN_ERRTX_WARNING | CO_CAN_ERRRX_WARNING)) {
|
||||
CO_error(em,
|
||||
(CANerrSt & ((uint16_t)CO_CAN_ERRTX_WARNING | (uint16_t)CO_CAN_ERRRX_WARNING)) != 0U,
|
||||
(CANerrSt & (CO_CAN_ERRTX_WARNING | CO_CAN_ERRRX_WARNING)) != 0U,
|
||||
CO_EM_CAN_BUS_WARNING, CO_EMC_NO_ERROR, 0);
|
||||
}
|
||||
if (CANerrStChanged & (uint16_t)CO_CAN_ERRTX_PASSIVE) {
|
||||
CO_error(em, (CANerrSt & (uint16_t)CO_CAN_ERRTX_PASSIVE) != 0U,
|
||||
if (CANerrStChanged & CO_CAN_ERRTX_PASSIVE) {
|
||||
CO_error(em, (CANerrSt & CO_CAN_ERRTX_PASSIVE) != 0U,
|
||||
CO_EM_CAN_TX_BUS_PASSIVE, CO_EMC_CAN_PASSIVE, 0);
|
||||
}
|
||||
if (CANerrStChanged & (uint16_t)CO_CAN_ERRTX_BUS_OFF) {
|
||||
CO_error(em, (CANerrSt & (uint16_t)CO_CAN_ERRTX_BUS_OFF) != 0U,
|
||||
if (CANerrStChanged & CO_CAN_ERRTX_BUS_OFF) {
|
||||
CO_error(em, (CANerrSt & CO_CAN_ERRTX_BUS_OFF) != 0U,
|
||||
CO_EM_CAN_TX_BUS_OFF, CO_EMC_BUS_OFF_RECOVERED, 0);
|
||||
}
|
||||
if (CANerrStChanged & (uint16_t)CO_CAN_ERRTX_OVERFLOW) {
|
||||
CO_error(em, (CANerrSt & (uint16_t)CO_CAN_ERRTX_OVERFLOW) != 0U,
|
||||
if (CANerrStChanged & CO_CAN_ERRTX_OVERFLOW) {
|
||||
CO_error(em, (CANerrSt & CO_CAN_ERRTX_OVERFLOW) != 0U,
|
||||
CO_EM_CAN_TX_OVERFLOW, CO_EMC_CAN_OVERRUN, 0);
|
||||
}
|
||||
if (CANerrStChanged & (uint16_t)CO_CAN_ERRTX_PDO_LATE) {
|
||||
CO_error(em, (CANerrSt & (uint16_t)CO_CAN_ERRTX_PDO_LATE) != 0U,
|
||||
if (CANerrStChanged & CO_CAN_ERRTX_PDO_LATE) {
|
||||
CO_error(em, (CANerrSt & CO_CAN_ERRTX_PDO_LATE) != 0U,
|
||||
CO_EM_TPDO_OUTSIDE_WINDOW, CO_EMC_COMMUNICATION, 0);
|
||||
}
|
||||
if (CANerrStChanged & (uint16_t)CO_CAN_ERRRX_PASSIVE) {
|
||||
CO_error(em, (CANerrSt & (uint16_t)CO_CAN_ERRRX_PASSIVE) != 0U,
|
||||
if (CANerrStChanged & CO_CAN_ERRRX_PASSIVE) {
|
||||
CO_error(em, (CANerrSt & CO_CAN_ERRRX_PASSIVE) != 0U,
|
||||
CO_EM_CAN_RX_BUS_PASSIVE, CO_EMC_CAN_PASSIVE, 0);
|
||||
}
|
||||
if (CANerrStChanged & (uint16_t)CO_CAN_ERRRX_OVERFLOW) {
|
||||
CO_error(em, (CANerrSt & (uint16_t)CO_CAN_ERRRX_OVERFLOW) != 0U,
|
||||
if (CANerrStChanged & CO_CAN_ERRRX_OVERFLOW) {
|
||||
CO_error(em, (CANerrSt & CO_CAN_ERRRX_OVERFLOW) != 0U,
|
||||
CO_EM_CAN_RXB_OVERFLOW, CO_EMC_CAN_OVERRUN, 0);
|
||||
}
|
||||
}
|
||||
|
|
@ -681,7 +681,7 @@ void CO_EM_process(CO_EM_t *em,
|
|||
}
|
||||
else if ((em->fifoOverflow == 2U) && (em->fifoPpPtr == em->fifoWrPtr)) {
|
||||
em->fifoOverflow = 0;
|
||||
CO_errorReset(em, (uint8_t)CO_EM_EMERGENCY_BUFFER_FULL, 0);
|
||||
CO_errorReset(em, CO_EM_EMERGENCY_BUFFER_FULL, 0);
|
||||
}
|
||||
else { /* MISRA C 2004 14.10 */ }
|
||||
}
|
||||
|
|
@ -719,7 +719,7 @@ void CO_EM_process(CO_EM_t *em,
|
|||
|
||||
|
||||
/******************************************************************************/
|
||||
void CO_error(CO_EM_t *em, bool_t setError, const CO_EM_errorStatusBits_t errorBit,
|
||||
void CO_error(CO_EM_t *em, bool_t setError, const uint8_t errorBit,
|
||||
uint16_t errorCode, uint32_t infoCode)
|
||||
{
|
||||
if (em == NULL) { return; }
|
||||
|
|
|
|||
|
|
@ -103,7 +103,8 @@ extern "C" {
|
|||
|
||||
|
||||
/**
|
||||
* CANopen Error register.
|
||||
* @defgroup CO_errorRegister_t CANopen Error register
|
||||
* @{
|
||||
*
|
||||
* Mandatory for CANopen, resides in object dictionary, index 0x1001.
|
||||
*
|
||||
|
|
@ -114,118 +115,75 @@ extern "C" {
|
|||
* Internal errors may prevent device to stay in NMT Operational state and
|
||||
* changes may switch between the states. See @ref CO_NMT_control_t for details.
|
||||
*/
|
||||
typedef enum {
|
||||
CO_ERR_REG_GENERIC_ERR = 0x01U, /**< bit 0, generic error */
|
||||
CO_ERR_REG_CURRENT = 0x02U, /**< bit 1, current */
|
||||
CO_ERR_REG_VOLTAGE = 0x04U, /**< bit 2, voltage */
|
||||
CO_ERR_REG_TEMPERATURE = 0x08U, /**< bit 3, temperature */
|
||||
CO_ERR_REG_COMMUNICATION = 0x10U, /**< bit 4, communication error */
|
||||
CO_ERR_REG_DEV_PROFILE = 0x20U, /**< bit 5, device profile specific */
|
||||
CO_ERR_REG_RESERVED = 0x40U, /**< bit 6, reserved (always 0) */
|
||||
CO_ERR_REG_MANUFACTURER = 0x80U /**< bit 7, manufacturer specific */
|
||||
} CO_errorRegister_t;
|
||||
#define CO_ERR_REG_GENERIC_ERR 0x01U /**< bit 0, generic error */
|
||||
#define CO_ERR_REG_CURRENT 0x02U /**< bit 1, current */
|
||||
#define CO_ERR_REG_VOLTAGE 0x04U /**< bit 2, voltage */
|
||||
#define CO_ERR_REG_TEMPERATURE 0x08U /**< bit 3, temperature */
|
||||
#define CO_ERR_REG_COMMUNICATION 0x10U /**< bit 4, communication error */
|
||||
#define CO_ERR_REG_DEV_PROFILE 0x20U /**< bit 5, device profile specific */
|
||||
#define CO_ERR_REG_RESERVED 0x40U /**< bit 6, reserved (always 0) */
|
||||
#define CO_ERR_REG_MANUFACTURER 0x80U /**< bit 7, manufacturer specific */
|
||||
|
||||
/** @} */ /* CO_errorRegister_t */
|
||||
|
||||
/**
|
||||
* CANopen Error code
|
||||
* @defgroup CO_EM_errorCode_t CANopen Error code
|
||||
* @{
|
||||
*
|
||||
* Standard error codes according to CiA DS-301 and DS-401.
|
||||
*/
|
||||
typedef enum {
|
||||
/** 0x00xx, error Reset or No Error */
|
||||
CO_EMC_NO_ERROR = 0x0000U,
|
||||
/** 0x10xx, Generic Error */
|
||||
CO_EMC_GENERIC = 0x1000U,
|
||||
/** 0x20xx, Current */
|
||||
CO_EMC_CURRENT = 0x2000U,
|
||||
/** 0x21xx, Current, device input side */
|
||||
CO_EMC_CURRENT_INPUT = 0x2100U,
|
||||
/** 0x22xx, Current inside the device */
|
||||
CO_EMC_CURRENT_INSIDE = 0x2200U,
|
||||
/** 0x23xx, Current, device output side */
|
||||
CO_EMC_CURRENT_OUTPUT = 0x2300U,
|
||||
/** 0x30xx, Voltage */
|
||||
CO_EMC_VOLTAGE = 0x3000U,
|
||||
/** 0x31xx, Mains Voltage */
|
||||
CO_EMC_VOLTAGE_MAINS = 0x3100U,
|
||||
/** 0x32xx, Voltage inside the device */
|
||||
CO_EMC_VOLTAGE_INSIDE = 0x3200U,
|
||||
/** 0x33xx, Output Voltage */
|
||||
CO_EMC_VOLTAGE_OUTPUT = 0x3300U,
|
||||
/** 0x40xx, Temperature */
|
||||
CO_EMC_TEMPERATURE = 0x4000U,
|
||||
/** 0x41xx, Ambient Temperature */
|
||||
CO_EMC_TEMP_AMBIENT = 0x4100U,
|
||||
/** 0x42xx, Device Temperature */
|
||||
CO_EMC_TEMP_DEVICE = 0x4200U,
|
||||
/** 0x50xx, Device Hardware */
|
||||
CO_EMC_HARDWARE = 0x5000U,
|
||||
/** 0x60xx, Device Software */
|
||||
CO_EMC_SOFTWARE_DEVICE = 0x6000U,
|
||||
/** 0x61xx, Internal Software */
|
||||
CO_EMC_SOFTWARE_INTERNAL = 0x6100U,
|
||||
/** 0x62xx, User Software */
|
||||
CO_EMC_SOFTWARE_USER = 0x6200U,
|
||||
/** 0x63xx, Data Set */
|
||||
CO_EMC_DATA_SET = 0x6300U,
|
||||
/** 0x70xx, Additional Modules */
|
||||
CO_EMC_ADDITIONAL_MODUL = 0x7000U,
|
||||
/** 0x80xx, Monitoring */
|
||||
CO_EMC_MONITORING = 0x8000U,
|
||||
/** 0x81xx, Communication */
|
||||
CO_EMC_COMMUNICATION = 0x8100U,
|
||||
/** 0x8110, CAN Overrun (Objects lost) */
|
||||
CO_EMC_CAN_OVERRUN = 0x8110U,
|
||||
/** 0x8120, CAN in Error Passive Mode */
|
||||
CO_EMC_CAN_PASSIVE = 0x8120U,
|
||||
/** 0x8130, Life Guard Error or Heartbeat Error */
|
||||
CO_EMC_HEARTBEAT = 0x8130U,
|
||||
/** 0x8140, recovered from bus off */
|
||||
CO_EMC_BUS_OFF_RECOVERED = 0x8140U,
|
||||
/** 0x8150, CAN-ID collision */
|
||||
CO_EMC_CAN_ID_COLLISION = 0x8150U,
|
||||
/** 0x82xx, Protocol Error */
|
||||
CO_EMC_PROTOCOL_ERROR = 0x8200U,
|
||||
/** 0x8210, PDO not processed due to length error */
|
||||
CO_EMC_PDO_LENGTH = 0x8210U,
|
||||
/** 0x8220, PDO length exceeded */
|
||||
CO_EMC_PDO_LENGTH_EXC = 0x8220U,
|
||||
/** 0x8230, DAM MPDO not processed, destination object not available */
|
||||
CO_EMC_DAM_MPDO = 0x8230U,
|
||||
/** 0x8240, Unexpected SYNC data length */
|
||||
CO_EMC_SYNC_DATA_LENGTH = 0x8240U,
|
||||
/** 0x8250, RPDO timeout */
|
||||
CO_EMC_RPDO_TIMEOUT = 0x8250U,
|
||||
/** 0x90xx, External Error */
|
||||
CO_EMC_EXTERNAL_ERROR = 0x9000U,
|
||||
/** 0xF0xx, Additional Functions */
|
||||
CO_EMC_ADDITIONAL_FUNC = 0xF000U,
|
||||
/** 0xFFxx, Device specific */
|
||||
CO_EMC_DEVICE_SPECIFIC = 0xFF00U,
|
||||
#define CO_EMC_NO_ERROR 0x0000U /** 0x00xx error Reset or No Error */
|
||||
#define CO_EMC_GENERIC 0x1000U /** 0x10xx Generic Error */
|
||||
#define CO_EMC_CURRENT 0x2000U /** 0x20xx Current */
|
||||
#define CO_EMC_CURRENT_INPUT 0x2100U /** 0x21xx Current device input side */
|
||||
#define CO_EMC_CURRENT_INSIDE 0x2200U /** 0x22xx Current inside the device */
|
||||
#define CO_EMC_CURRENT_OUTPUT 0x2300U /** 0x23xx Current device output side */
|
||||
#define CO_EMC_VOLTAGE 0x3000U /** 0x30xx Voltage */
|
||||
#define CO_EMC_VOLTAGE_MAINS 0x3100U /** 0x31xx Mains Voltage */
|
||||
#define CO_EMC_VOLTAGE_INSIDE 0x3200U /** 0x32xx Voltage inside the device */
|
||||
#define CO_EMC_VOLTAGE_OUTPUT 0x3300U /** 0x33xx Output Voltage */
|
||||
#define CO_EMC_TEMPERATURE 0x4000U /** 0x40xx Temperature */
|
||||
#define CO_EMC_TEMP_AMBIENT 0x4100U /** 0x41xx Ambient Temperature */
|
||||
#define CO_EMC_TEMP_DEVICE 0x4200U /** 0x42xx Device Temperature */
|
||||
#define CO_EMC_HARDWARE 0x5000U /** 0x50xx Device Hardware */
|
||||
#define CO_EMC_SOFTWARE_DEVICE 0x6000U /** 0x60xx Device Software */
|
||||
#define CO_EMC_SOFTWARE_INTERNAL 0x6100U /** 0x61xx Internal Software */
|
||||
#define CO_EMC_SOFTWARE_USER 0x6200U /** 0x62xx User Software */
|
||||
#define CO_EMC_DATA_SET 0x6300U /** 0x63xx Data Set */
|
||||
#define CO_EMC_ADDITIONAL_MODUL 0x7000U /** 0x70xx Additional Modules */
|
||||
#define CO_EMC_MONITORING 0x8000U /** 0x80xx Monitoring */
|
||||
#define CO_EMC_COMMUNICATION 0x8100U /** 0x81xx Communication */
|
||||
#define CO_EMC_CAN_OVERRUN 0x8110U /** 0x8110 CAN Overrun (Objects lost) */
|
||||
#define CO_EMC_CAN_PASSIVE 0x8120U /** 0x8120 CAN in Error Passive Mode */
|
||||
#define CO_EMC_HEARTBEAT 0x8130U /** 0x8130 Life Guard Error or Heartbeat Error */
|
||||
#define CO_EMC_BUS_OFF_RECOVERED 0x8140U /** 0x8140 recovered from bus off */
|
||||
#define CO_EMC_CAN_ID_COLLISION 0x8150U /** 0x8150 CAN-ID collision */
|
||||
#define CO_EMC_PROTOCOL_ERROR 0x8200U /** 0x82xx Protocol Error */
|
||||
#define CO_EMC_PDO_LENGTH 0x8210U /** 0x8210 PDO not processed due to length error */
|
||||
#define CO_EMC_PDO_LENGTH_EXC 0x8220U /** 0x8220 PDO length exceeded */
|
||||
#define CO_EMC_DAM_MPDO 0x8230U /** 0x8230 DAM MPDO not processed destination object not available */
|
||||
#define CO_EMC_SYNC_DATA_LENGTH 0x8240U /** 0x8240 Unexpected SYNC data length */
|
||||
#define CO_EMC_RPDO_TIMEOUT 0x8250U /** 0x8250 RPDO timeout */
|
||||
#define CO_EMC_EXTERNAL_ERROR 0x9000U /** 0x90xx External Error */
|
||||
#define CO_EMC_ADDITIONAL_FUNC 0xF000U /** 0xF0xx Additional Functions */
|
||||
#define CO_EMC_DEVICE_SPECIFIC 0xFF00U /** 0xFFxx Device specific */
|
||||
|
||||
/** 0x2310, DS401, Current at outputs too high (overload) */
|
||||
CO_EMC401_OUT_CUR_HI = 0x2310U,
|
||||
/** 0x2320, DS401, Short circuit at outputs */
|
||||
CO_EMC401_OUT_SHORTED = 0x2320U,
|
||||
/** 0x2330, DS401, Load dump at outputs */
|
||||
CO_EMC401_OUT_LOAD_DUMP = 0x2330U,
|
||||
/** 0x3110, DS401, Input voltage too high */
|
||||
CO_EMC401_IN_VOLT_HI = 0x3110U,
|
||||
/** 0x3120, DS401, Input voltage too low */
|
||||
CO_EMC401_IN_VOLT_LOW = 0x3120U,
|
||||
/** 0x3210, DS401, Internal voltage too high */
|
||||
CO_EMC401_INTERN_VOLT_HI = 0x3210U,
|
||||
/** 0x3220, DS401, Internal voltage too low */
|
||||
CO_EMC401_INTERN_VOLT_LO = 0x3220U,
|
||||
/** 0x3310, DS401, Output voltage too high */
|
||||
CO_EMC401_OUT_VOLT_HIGH = 0x3310U,
|
||||
/** 0x3320, DS401, Output voltage too low */
|
||||
CO_EMC401_OUT_VOLT_LOW = 0x3320U,
|
||||
} CO_EM_errorCode_t;
|
||||
#define CO_EMC401_OUT_CUR_HI 0x2310U /** 0x2310 DS401 Current at outputs too high (overload) */
|
||||
#define CO_EMC401_OUT_SHORTED 0x2320U /** 0x2320 DS401 Short circuit at outputs */
|
||||
#define CO_EMC401_OUT_LOAD_DUMP 0x2330U /** 0x2330 DS401 Load dump at outputs */
|
||||
#define CO_EMC401_IN_VOLT_HI 0x3110U /** 0x3110 DS401 Input voltage too high */
|
||||
#define CO_EMC401_IN_VOLT_LOW 0x3120U /** 0x3120 DS401 Input voltage too low */
|
||||
#define CO_EMC401_INTERN_VOLT_HI 0x3210U /** 0x3210 DS401 Internal voltage too high */
|
||||
#define CO_EMC401_INTERN_VOLT_LO 0x3220U /** 0x3220 DS401 Internal voltage too low */
|
||||
#define CO_EMC401_OUT_VOLT_HIGH 0x3310U /** 0x3310 DS401 Output voltage too high */
|
||||
#define CO_EMC401_OUT_VOLT_LOW 0x3320U /** 0x3320 DS401 Output voltage too low */
|
||||
|
||||
/** @} */ /* CO_EM_errorCode_t */
|
||||
|
||||
|
||||
/**
|
||||
* Error status bits
|
||||
* @defgroup CO_EM_errorStatusBits_t Error status bits
|
||||
* @{
|
||||
*
|
||||
* Bits for internal indication of the error condition. Each error condition is
|
||||
* specified by unique index from 0x00 up to 0xFF.
|
||||
|
|
@ -240,123 +198,68 @@ typedef enum {
|
|||
* uses first 6 bytes. Additional 4 bytes are pre-defined for manufacturer
|
||||
* or device specific error indications, by default.
|
||||
*/
|
||||
typedef enum {
|
||||
/** 0x00, Error Reset or No Error */
|
||||
CO_EM_NO_ERROR = 0x00U,
|
||||
/** 0x01, communication, info, CAN bus warning limit reached */
|
||||
CO_EM_CAN_BUS_WARNING = 0x01U,
|
||||
/** 0x02, communication, info, Wrong data length of the received CAN
|
||||
* message */
|
||||
CO_EM_RXMSG_WRONG_LENGTH = 0x02U,
|
||||
/** 0x03, communication, info, Previous received CAN message wasn't
|
||||
* processed yet */
|
||||
CO_EM_RXMSG_OVERFLOW = 0x03U,
|
||||
/** 0x04, communication, info, Wrong data length of received PDO */
|
||||
CO_EM_RPDO_WRONG_LENGTH = 0x04U,
|
||||
/** 0x05, communication, info, Previous received PDO wasn't processed yet */
|
||||
CO_EM_RPDO_OVERFLOW = 0x05U,
|
||||
/** 0x06, communication, info, CAN receive bus is passive */
|
||||
CO_EM_CAN_RX_BUS_PASSIVE = 0x06U,
|
||||
/** 0x07, communication, info, CAN transmit bus is passive */
|
||||
CO_EM_CAN_TX_BUS_PASSIVE = 0x07U,
|
||||
/** 0x08, communication, info, Wrong NMT command received */
|
||||
CO_EM_NMT_WRONG_COMMAND = 0x08U,
|
||||
/** 0x09, communication, info, TIME message timeout */
|
||||
CO_EM_TIME_TIMEOUT = 0x09U,
|
||||
/** 0x0A, communication, info, (unused) */
|
||||
CO_EM_0A_unused = 0x0AU,
|
||||
/** 0x0B, communication, info, (unused) */
|
||||
CO_EM_0B_unused = 0x0BU,
|
||||
/** 0x0C, communication, info, (unused) */
|
||||
CO_EM_0C_unused = 0x0CU,
|
||||
/** 0x0D, communication, info, (unused) */
|
||||
CO_EM_0D_unused = 0x0DU,
|
||||
/** 0x0E, communication, info, (unused) */
|
||||
CO_EM_0E_unused = 0x0EU,
|
||||
/** 0x0F, communication, info, (unused) */
|
||||
CO_EM_0F_unused = 0x0FU,
|
||||
#define CO_EM_NO_ERROR 0x00U /** 0x00 Error Reset or No Error */
|
||||
#define CO_EM_CAN_BUS_WARNING 0x01U /** 0x01 communication info CAN bus warning limit reached */
|
||||
#define CO_EM_RXMSG_WRONG_LENGTH 0x02U /** 0x02 communication info Wrong data length of the received CAN message */
|
||||
#define CO_EM_RXMSG_OVERFLOW 0x03U /** 0x03 communication info Previous received CAN message wasn't processed yet */
|
||||
#define CO_EM_RPDO_WRONG_LENGTH 0x04U /** 0x04 communication info Wrong data length of received PDO */
|
||||
#define CO_EM_RPDO_OVERFLOW 0x05U /** 0x05 communication info Previous received PDO wasn't processed yet */
|
||||
#define CO_EM_CAN_RX_BUS_PASSIVE 0x06U /** 0x06 communication info CAN receive bus is passive */
|
||||
#define CO_EM_CAN_TX_BUS_PASSIVE 0x07U /** 0x07 communication info CAN transmit bus is passive */
|
||||
#define CO_EM_NMT_WRONG_COMMAND 0x08U /** 0x08 communication info Wrong NMT command received */
|
||||
#define CO_EM_TIME_TIMEOUT 0x09U /** 0x09 communication info TIME message timeout */
|
||||
#define CO_EM_0A_unused 0x0AU /** 0x0A communication info (unused) */
|
||||
#define CO_EM_0B_unused 0x0BU /** 0x0B communication info (unused) */
|
||||
#define CO_EM_0C_unused 0x0CU /** 0x0C communication info (unused) */
|
||||
#define CO_EM_0D_unused 0x0DU /** 0x0D communication info (unused) */
|
||||
#define CO_EM_0E_unused 0x0EU /** 0x0E communication info (unused) */
|
||||
#define CO_EM_0F_unused 0x0FU /** 0x0F communication info (unused) */
|
||||
|
||||
/** 0x10, communication, critical, (unused) */
|
||||
CO_EM_10_unused = 0x10U,
|
||||
/** 0x11, communication, critical, (unused) */
|
||||
CO_EM_11_unused = 0x11U,
|
||||
/** 0x12, communication, critical, CAN transmit bus is off */
|
||||
CO_EM_CAN_TX_BUS_OFF = 0x12U,
|
||||
/** 0x13, communication, critical, CAN module receive buffer has
|
||||
* overflowed */
|
||||
CO_EM_CAN_RXB_OVERFLOW = 0x13U,
|
||||
/** 0x14, communication, critical, CAN transmit buffer has overflowed */
|
||||
CO_EM_CAN_TX_OVERFLOW = 0x14U,
|
||||
/** 0x15, communication, critical, TPDO is outside SYNC window */
|
||||
CO_EM_TPDO_OUTSIDE_WINDOW = 0x15U,
|
||||
/** 0x16, communication, critical, (unused) */
|
||||
CO_EM_16_unused = 0x16U,
|
||||
/** 0x17, communication, critical, RPDO message timeout */
|
||||
CO_EM_RPDO_TIME_OUT = 0x17U,
|
||||
/** 0x18, communication, critical, SYNC message timeout */
|
||||
CO_EM_SYNC_TIME_OUT = 0x18U,
|
||||
/** 0x19, communication, critical, Unexpected SYNC data length */
|
||||
CO_EM_SYNC_LENGTH = 0x19U,
|
||||
/** 0x1A, communication, critical, Error with PDO mapping */
|
||||
CO_EM_PDO_WRONG_MAPPING = 0x1AU,
|
||||
/** 0x1B, communication, critical, Heartbeat consumer timeout */
|
||||
CO_EM_HEARTBEAT_CONSUMER = 0x1BU,
|
||||
/** 0x1C, communication, critical, Heartbeat consumer detected remote node
|
||||
* reset */
|
||||
CO_EM_HB_CONSUMER_REMOTE_RESET = 0x1CU,
|
||||
/** 0x1D, communication, critical, Error in SRDO configuration parameters. */
|
||||
CO_EM_SRDO_CONFIGURATION = 0x1DU,
|
||||
/** 0x1E, communication, critical, (unused) */
|
||||
CO_EM_1E_unused = 0x1EU,
|
||||
/** 0x1F, communication, critical, (unused) */
|
||||
CO_EM_1F_unused = 0x1FU,
|
||||
#define CO_EM_10_unused 0x10U /** 0x10 communication critical (unused) */
|
||||
#define CO_EM_11_unused 0x11U /** 0x11 communication critical (unused) */
|
||||
#define CO_EM_CAN_TX_BUS_OFF 0x12U /** 0x12 communication critical CAN transmit bus is off */
|
||||
#define CO_EM_CAN_RXB_OVERFLOW 0x13U /** 0x13 communication critical CAN module receive buffer has overflowed */
|
||||
#define CO_EM_CAN_TX_OVERFLOW 0x14U /** 0x14 communication critical CAN transmit buffer has overflowed */
|
||||
#define CO_EM_TPDO_OUTSIDE_WINDOW 0x15U /** 0x15 communication critical TPDO is outside SYNC window */
|
||||
#define CO_EM_16_unused 0x16U /** 0x16 communication critical (unused) */
|
||||
#define CO_EM_RPDO_TIME_OUT 0x17U /** 0x17 communication critical RPDO message timeout */
|
||||
#define CO_EM_SYNC_TIME_OUT 0x18U /** 0x18 communication critical SYNC message timeout */
|
||||
#define CO_EM_SYNC_LENGTH 0x19U /** 0x19 communication critical Unexpected SYNC data length */
|
||||
#define CO_EM_PDO_WRONG_MAPPING 0x1AU /** 0x1A communication critical Error with PDO mapping */
|
||||
#define CO_EM_HEARTBEAT_CONSUMER 0x1BU /** 0x1B communication critical Heartbeat consumer timeout */
|
||||
#define CO_EM_HB_CONSUMER_REMOTE_RESET 0x1CU /** 0x1C communication critical Heartbeat consumer detected remote node reset */
|
||||
#define CO_EM_SRDO_CONFIGURATION 0x1DU /** 0x1D communication critical Error in SRDO configuration parameters. */
|
||||
#define CO_EM_1E_unused 0x1EU /** 0x1E communication critical (unused) */
|
||||
#define CO_EM_1F_unused 0x1FU /** 0x1F communication critical (unused) */
|
||||
|
||||
/** 0x20, generic, info, Emergency buffer is full, Emergency message wasn't
|
||||
* sent */
|
||||
CO_EM_EMERGENCY_BUFFER_FULL = 0x20U,
|
||||
/** 0x21, generic, info, (unused) */
|
||||
CO_EM_21_unused = 0x21U,
|
||||
/** 0x22, generic, info, Microcontroller has just started */
|
||||
CO_EM_MICROCONTROLLER_RESET = 0x22U,
|
||||
/** 0x23, generic, info, (unused) */
|
||||
CO_EM_23_unused = 0x23U,
|
||||
/** 0x24, generic, info, (unused) */
|
||||
CO_EM_24_unused = 0x24U,
|
||||
/** 0x25, generic, info, (unused) */
|
||||
CO_EM_25_unused = 0x25U,
|
||||
/** 0x26, generic, info, (unused) */
|
||||
CO_EM_26_unused = 0x26U,
|
||||
/** 0x27, generic, info, Automatic store to non-volatile memory failed */
|
||||
CO_EM_NON_VOLATILE_AUTO_SAVE = 0x27U,
|
||||
#define CO_EM_EMERGENCY_BUFFER_FULL 0x20U /** 0x20 generic info Emergency buffer is full Emergency message wasn't sent */
|
||||
#define CO_EM_21_unused 0x21U /** 0x21 generic info (unused) */
|
||||
#define CO_EM_MICROCONTROLLER_RESET 0x22U /** 0x22 generic info Microcontroller has just started */
|
||||
#define CO_EM_23_unused 0x23U /** 0x23 generic info (unused) */
|
||||
#define CO_EM_24_unused 0x24U /** 0x24 generic info (unused) */
|
||||
#define CO_EM_25_unused 0x25U /** 0x25 generic info (unused) */
|
||||
#define CO_EM_26_unused 0x26U /** 0x26 generic info (unused) */
|
||||
#define CO_EM_NON_VOLATILE_AUTO_SAVE 0x27U /** 0x27 generic info Automatic store to non-volatile memory failed */
|
||||
|
||||
/** 0x28, generic, critical, Wrong parameters to CO_errorReport() function*/
|
||||
CO_EM_WRONG_ERROR_REPORT = 0x28U,
|
||||
/** 0x29, generic, critical, Timer task has overflowed */
|
||||
CO_EM_ISR_TIMER_OVERFLOW = 0x29U,
|
||||
/** 0x2A, generic, critical, Unable to allocate memory for objects */
|
||||
CO_EM_MEMORY_ALLOCATION_ERROR = 0x2AU,
|
||||
/** 0x2B, generic, critical, Generic error, test usage */
|
||||
CO_EM_GENERIC_ERROR = 0x2BU,
|
||||
/** 0x2C, generic, critical, Software error */
|
||||
CO_EM_GENERIC_SOFTWARE_ERROR = 0x2CU,
|
||||
/** 0x2D, generic, critical, Object dictionary does not match the software*/
|
||||
CO_EM_INCONSISTENT_OBJECT_DICT = 0x2DU,
|
||||
/** 0x2E, generic, critical, Error in calculation of device parameters */
|
||||
CO_EM_CALCULATION_OF_PARAMETERS = 0x2EU,
|
||||
/** 0x2F, generic, critical, Error with access to non volatile device memory
|
||||
*/
|
||||
CO_EM_NON_VOLATILE_MEMORY = 0x2FU,
|
||||
#define CO_EM_WRONG_ERROR_REPORT 0x28U /** 0x28 generic critical Wrong parameters to CO_errorReport() function*/
|
||||
#define CO_EM_ISR_TIMER_OVERFLOW 0x29U /** 0x29 generic critical Timer task has overflowed */
|
||||
#define CO_EM_MEMORY_ALLOCATION_ERROR 0x2AU /** 0x2A generic critical Unable to allocate memory for objects */
|
||||
#define CO_EM_GENERIC_ERROR 0x2BU /** 0x2B generic critical Generic error test usage */
|
||||
#define CO_EM_GENERIC_SOFTWARE_ERROR 0x2CU /** 0x2C generic critical Software error */
|
||||
#define CO_EM_INCONSISTENT_OBJECT_DICT 0x2DU /** 0x2D generic critical Object dictionary does not match the software*/
|
||||
#define CO_EM_CALCULATION_OF_PARAMETERS 0x2EU /** 0x2E generic critical Error in calculation of device parameters */
|
||||
#define CO_EM_NON_VOLATILE_MEMORY 0x2FU /** 0x2F generic critical Error with access to non volatile device memory */
|
||||
|
||||
/** 0x30+, manufacturer, info or critical, Error status buts, free to use by
|
||||
* manufacturer. By default bits 0x30..0x3F are set as informational and
|
||||
* bits 0x40..0x4F are set as critical. Manufacturer critical bits sets the
|
||||
* error register, as specified by @ref CO_CONFIG_ERR_CONDITION_MANUFACTURER
|
||||
*/
|
||||
CO_EM_MANUFACTURER_START = 0x30U,
|
||||
/** (@ref CO_CONFIG_EM_ERR_STATUS_BITS_COUNT - 1), largest value of the
|
||||
* Error status bit. */
|
||||
CO_EM_MANUFACTURER_END = CO_CONFIG_EM_ERR_STATUS_BITS_COUNT - 1
|
||||
} CO_EM_errorStatusBits_t;
|
||||
/** 0x30+ manufacturer info or critical Error status buts free to use by
|
||||
* manufacturer. By default bits 0x30..0x3F are set as informational and
|
||||
* bits 0x40..0x4F are set as critical. Manufacturer critical bits sets the
|
||||
* error register as specified by @ref CO_CONFIG_ERR_CONDITION_MANUFACTURER
|
||||
*/
|
||||
#define CO_EM_MANUFACTURER_START 0x30U
|
||||
/** (@ref CO_CONFIG_EM_ERR_STATUS_BITS_COUNT - 1) largest value of the Error status bit. */
|
||||
#define CO_EM_MANUFACTURER_END (CO_CONFIG_EM_ERR_STATUS_BITS_COUNT - 1)
|
||||
|
||||
/** @} */ /* CO_EM_errorStatusBits_t */
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -388,7 +388,7 @@ void CO_HBconsumer_process(
|
|||
#endif
|
||||
if (monitoredNode->HBstate == CO_HBconsumer_ACTIVE) {
|
||||
CO_errorReport(HBcons->em,
|
||||
(uint8_t)CO_EM_HB_CONSUMER_REMOTE_RESET,
|
||||
CO_EM_HB_CONSUMER_REMOTE_RESET,
|
||||
CO_EMC_HEARTBEAT, i);
|
||||
}
|
||||
monitoredNode->HBstate = CO_HBconsumer_UNKNOWN;
|
||||
|
|
@ -425,7 +425,7 @@ void CO_HBconsumer_process(
|
|||
monitoredNode->functSignalObjectTimeout);
|
||||
}
|
||||
#endif
|
||||
CO_errorReport(HBcons->em, (uint8_t)CO_EM_HEARTBEAT_CONSUMER,
|
||||
CO_errorReport(HBcons->em, CO_EM_HEARTBEAT_CONSUMER,
|
||||
CO_EMC_HEARTBEAT, i);
|
||||
monitoredNode->NMTstate = CO_NMT_UNKNOWN;
|
||||
monitoredNode->HBstate = CO_HBconsumer_TIMEOUT;
|
||||
|
|
@ -492,8 +492,8 @@ void CO_HBconsumer_process(
|
|||
/* Clear emergencies when all monitored nodes becomes active.
|
||||
* We only have one emergency index for all monitored nodes! */
|
||||
if (!HBcons->allMonitoredActive && allMonitoredActiveCurrent) {
|
||||
CO_errorReset(HBcons->em, (uint8_t)CO_EM_HEARTBEAT_CONSUMER, 0);
|
||||
CO_errorReset(HBcons->em, (uint8_t)CO_EM_HB_CONSUMER_REMOTE_RESET, 0);
|
||||
CO_errorReset(HBcons->em, CO_EM_HEARTBEAT_CONSUMER, 0);
|
||||
CO_errorReset(HBcons->em, CO_EM_HB_CONSUMER_REMOTE_RESET, 0);
|
||||
}
|
||||
|
||||
HBcons->allMonitoredActive = allMonitoredActiveCurrent;
|
||||
|
|
|
|||
|
|
@ -229,7 +229,7 @@ void CO_nodeGuardingSlave_process(CO_nodeGuardingSlave_t *ngs,
|
|||
|
||||
if (ngs->lifeTimeTimeout) {
|
||||
/* error bit is shared with HB consumer */
|
||||
CO_errorReset(ngs->em, (uint8_t)CO_EM_HEARTBEAT_CONSUMER, 0);
|
||||
CO_errorReset(ngs->em, CO_EM_HEARTBEAT_CONSUMER, 0);
|
||||
ngs->lifeTimeTimeout = false;
|
||||
}
|
||||
|
||||
|
|
@ -252,7 +252,7 @@ void CO_nodeGuardingSlave_process(CO_nodeGuardingSlave_t *ngs,
|
|||
ngs->lifeTimeTimeout = true;
|
||||
|
||||
/* error bit is shared with HB consumer */
|
||||
CO_errorReport(ngs->em, (uint8_t)CO_EM_HEARTBEAT_CONSUMER,
|
||||
CO_errorReport(ngs->em, CO_EM_HEARTBEAT_CONSUMER,
|
||||
CO_EMC_HEARTBEAT, 0);
|
||||
}
|
||||
}
|
||||
|
|
@ -415,12 +415,12 @@ void CO_nodeGuardingMaster_process(CO_nodeGuardingMaster_t *ngm,
|
|||
if (!node->responseRecived) {
|
||||
node->monitoringActive = false;
|
||||
/* error bit is shared with HB consumer */
|
||||
CO_errorReport(ngm->em, (uint8_t)CO_EM_HEARTBEAT_CONSUMER,
|
||||
CO_errorReport(ngm->em, CO_EM_HEARTBEAT_CONSUMER,
|
||||
CO_EMC_HEARTBEAT, node->ident & 0x7F);
|
||||
}
|
||||
else if (node->NMTstate != CO_NMT_UNKNOWN) {
|
||||
node->monitoringActive = true;
|
||||
CO_errorReset(ngm->em, (uint8_t)CO_EM_HEARTBEAT_CONSUMER,
|
||||
CO_errorReset(ngm->em, CO_EM_HEARTBEAT_CONSUMER,
|
||||
node->ident & 0x7F);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -692,7 +692,7 @@ CO_ReturnError_t CO_RPDO_init(CO_RPDO_t *RPDO,
|
|||
|
||||
if (erroneousMap != 0U) {
|
||||
CO_errorReport(PDO->em,
|
||||
(uint8_t)CO_EM_PDO_WRONG_MAPPING, CO_EMC_PROTOCOL_ERROR,
|
||||
CO_EM_PDO_WRONG_MAPPING, CO_EMC_PROTOCOL_ERROR,
|
||||
(erroneousMap != 1U) ? erroneousMap : COB_ID);
|
||||
}
|
||||
if (!valid) {
|
||||
|
|
@ -888,7 +888,7 @@ void CO_RPDO_process(CO_RPDO_t *RPDO,
|
|||
if (RPDO->timeoutTime_us > 0U) {
|
||||
if (rpdoReceived) {
|
||||
if (RPDO->timeoutTimer > RPDO->timeoutTime_us) {
|
||||
CO_errorReset(PDO->em, (uint8_t)CO_EM_RPDO_TIME_OUT,
|
||||
CO_errorReset(PDO->em, CO_EM_RPDO_TIME_OUT,
|
||||
RPDO->timeoutTimer);
|
||||
}
|
||||
/* enable monitoring */
|
||||
|
|
@ -900,7 +900,7 @@ void CO_RPDO_process(CO_RPDO_t *RPDO,
|
|||
RPDO->timeoutTimer += timeDifference_us;
|
||||
|
||||
if (RPDO->timeoutTimer > RPDO->timeoutTime_us) {
|
||||
CO_errorReport(PDO->em, (uint8_t)CO_EM_RPDO_TIME_OUT,
|
||||
CO_errorReport(PDO->em, CO_EM_RPDO_TIME_OUT,
|
||||
CO_EMC_RPDO_TIMEOUT, RPDO->timeoutTimer);
|
||||
}
|
||||
}
|
||||
|
|
@ -1156,7 +1156,7 @@ CO_ReturnError_t CO_TPDO_init(CO_TPDO_t *TPDO,
|
|||
|
||||
if (erroneousMap != 0U) {
|
||||
CO_errorReport(PDO->em,
|
||||
(uint8_t)CO_EM_PDO_WRONG_MAPPING, CO_EMC_PROTOCOL_ERROR,
|
||||
CO_EM_PDO_WRONG_MAPPING, CO_EMC_PROTOCOL_ERROR,
|
||||
(erroneousMap != 1U) ? erroneousMap : COB_ID);
|
||||
}
|
||||
if (!valid) {
|
||||
|
|
|
|||
|
|
@ -417,7 +417,7 @@ CO_SYNC_status_t CO_SYNC_process(CO_SYNC_t *SYNC,
|
|||
}
|
||||
|
||||
if (SYNC->timer > periodTimeout) {
|
||||
CO_errorReport(SYNC->em, (uint8_t)CO_EM_SYNC_TIME_OUT,
|
||||
CO_errorReport(SYNC->em, CO_EM_SYNC_TIME_OUT,
|
||||
CO_EMC_COMMUNICATION, SYNC->timer);
|
||||
SYNC->timeoutError = 2;
|
||||
}
|
||||
|
|
@ -448,7 +448,7 @@ CO_SYNC_status_t CO_SYNC_process(CO_SYNC_t *SYNC,
|
|||
|
||||
/* verify error from receive function */
|
||||
if (SYNC->receiveError != 0U) {
|
||||
CO_errorReport(SYNC->em, (uint8_t)CO_EM_SYNC_LENGTH,
|
||||
CO_errorReport(SYNC->em, CO_EM_SYNC_LENGTH,
|
||||
CO_EMC_SYNC_DATA_LENGTH, SYNC->receiveError);
|
||||
SYNC->receiveError = 0;
|
||||
}
|
||||
|
|
@ -462,7 +462,7 @@ CO_SYNC_status_t CO_SYNC_process(CO_SYNC_t *SYNC,
|
|||
|
||||
if (syncStatus == CO_SYNC_RX_TX) {
|
||||
if (SYNC->timeoutError == 2U) {
|
||||
CO_errorReset(SYNC->em, (uint8_t)CO_EM_SYNC_TIME_OUT, 0);
|
||||
CO_errorReset(SYNC->em, CO_EM_SYNC_TIME_OUT, 0);
|
||||
}
|
||||
SYNC->timeoutError = 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -516,28 +516,25 @@ typedef enum {
|
|||
|
||||
|
||||
/**
|
||||
* CAN error status bitmasks.
|
||||
* @defgroup CO_CAN_ERR_status_t CAN error status bitmasks
|
||||
* @{
|
||||
*
|
||||
* CAN warning level is reached, if CAN transmit or receive error counter is
|
||||
* more or equal to 96. CAN passive level is reached, if counters are more or
|
||||
* equal to 128. Transmitter goes in error state 'bus off' if transmit error
|
||||
* counter is more or equal to 256.
|
||||
*/
|
||||
typedef enum {
|
||||
CO_CAN_ERRTX_WARNING = 0x0001U, /**< 0x0001, CAN transmitter warning */
|
||||
CO_CAN_ERRTX_PASSIVE = 0x0002U, /**< 0x0002, CAN transmitter passive */
|
||||
CO_CAN_ERRTX_BUS_OFF = 0x0004U, /**< 0x0004, CAN transmitter bus off */
|
||||
CO_CAN_ERRTX_OVERFLOW = 0x0008U, /**< 0x0008, CAN transmitter overflow */
|
||||
|
||||
CO_CAN_ERRTX_PDO_LATE = 0x0080U, /**< 0x0080, TPDO is outside sync window */
|
||||
|
||||
CO_CAN_ERRRX_WARNING = 0x0100U, /**< 0x0100, CAN receiver warning */
|
||||
CO_CAN_ERRRX_PASSIVE = 0x0200U, /**< 0x0200, CAN receiver passive */
|
||||
CO_CAN_ERRRX_OVERFLOW = 0x0800U, /**< 0x0800, CAN receiver overflow */
|
||||
|
||||
CO_CAN_ERR_WARN_PASSIVE = 0x0303U/**< 0x0303, combination */
|
||||
} CO_CAN_ERR_status_t;
|
||||
#define CO_CAN_ERRTX_WARNING 0x0001U /**< 0x0001 CAN transmitter warning */
|
||||
#define CO_CAN_ERRTX_PASSIVE 0x0002U /**< 0x0002 CAN transmitter passive */
|
||||
#define CO_CAN_ERRTX_BUS_OFF 0x0004U /**< 0x0004 CAN transmitter bus off */
|
||||
#define CO_CAN_ERRTX_OVERFLOW 0x0008U /**< 0x0008 CAN transmitter overflow */
|
||||
#define CO_CAN_ERRTX_PDO_LATE 0x0080U /**< 0x0080 TPDO is outside sync window */
|
||||
#define CO_CAN_ERRRX_WARNING 0x0100U /**< 0x0100 CAN receiver warning */
|
||||
#define CO_CAN_ERRRX_PASSIVE 0x0200U /**< 0x0200 CAN receiver passive */
|
||||
#define CO_CAN_ERRRX_OVERFLOW 0x0800U /**< 0x0800 CAN receiver overflow */
|
||||
#define CO_CAN_ERR_WARN_PASSIVE 0x0303U /**< 0x0303 combination */
|
||||
|
||||
/** @} */ /* CO_CAN_ERR_status_t */
|
||||
|
||||
/**
|
||||
* Return values of some CANopen functions. If function was executed
|
||||
|
|
|
|||
|
|
@ -704,7 +704,7 @@ CO_SRDO_init(CO_SRDO_t* SRDO, uint8_t SRDO_Index, CO_SRDOGuard_t* SRDOGuard, OD_
|
|||
}
|
||||
else {
|
||||
if (ret == CO_ERROR_NO) {
|
||||
CO_errorReport(em, (uint8_t)CO_EM_SRDO_CONFIGURATION, CO_EMC_DATA_SET, err);
|
||||
CO_errorReport(em, CO_EM_SRDO_CONFIGURATION, CO_EMC_DATA_SET, err);
|
||||
configurationValidUnset(SRDO->SRDOGuard);
|
||||
}
|
||||
}
|
||||
|
|
@ -869,7 +869,7 @@ CO_SRDO_process(CO_SRDO_t* SRDO, uint32_t timeDifference_us, uint32_t* timerNext
|
|||
else { /* CO_SRDO_RX */
|
||||
/* verify error from receive function */
|
||||
if (SRDO->rxSrdoShort) {
|
||||
CO_errorReport(SRDO->em, (uint8_t)CO_EM_RPDO_WRONG_LENGTH, CO_EMC_PDO_LENGTH, 0);
|
||||
CO_errorReport(SRDO->em, CO_EM_RPDO_WRONG_LENGTH, CO_EMC_PDO_LENGTH, 0);
|
||||
SRDO->internalState = CO_SRDO_state_error_rxShort;
|
||||
}
|
||||
else if (CO_FLAG_READ(SRDO->CANrxNew[SRDO->nextIsNormal ? 0 : 1])) {
|
||||
|
|
|
|||
|
|
@ -1443,8 +1443,8 @@ CO_NMT_reset_cmd_t CO_process(CO_t *co,
|
|||
timeDifference_us,
|
||||
unc ? CO_NMT_INITIALIZING : NMTstate,
|
||||
LSSslave_configuration,
|
||||
(CANerrorStatus & (uint16_t)CO_CAN_ERRTX_BUS_OFF) != 0U,
|
||||
(CANerrorStatus & (uint16_t)CO_CAN_ERR_WARN_PASSIVE) != 0U,
|
||||
(CANerrorStatus & CO_CAN_ERRTX_BUS_OFF) != 0U,
|
||||
(CANerrorStatus & CO_CAN_ERR_WARN_PASSIVE) != 0U,
|
||||
false, /* RPDO event timer timeout */
|
||||
unc ? false : CO_isError(co->em, CO_EM_SYNC_TIME_OUT),
|
||||
unc ? false : (CO_isError(co->em, CO_EM_HEARTBEAT_CONSUMER)
|
||||
|
|
|
|||
Loading…
Reference in a new issue