diff --git a/301/CO_Emergency.h b/301/CO_Emergency.h index 9fec904..80791b1 100644 --- a/301/CO_Emergency.h +++ b/301/CO_Emergency.h @@ -26,24 +26,21 @@ /* default configuration, see CO_config.h */ #ifndef CO_CONFIG_EM -#define CO_CONFIG_EM (CO_CONFIG_EM_PRODUCER | \ - CO_CONFIG_EM_HISTORY | \ - CO_CONFIG_GLOBAL_FLAG_CALLBACK_PRE | \ - CO_CONFIG_GLOBAL_FLAG_TIMERNEXT) +#define CO_CONFIG_EM \ + (CO_CONFIG_EM_PRODUCER | CO_CONFIG_EM_HISTORY | CO_CONFIG_GLOBAL_FLAG_CALLBACK_PRE \ + | CO_CONFIG_GLOBAL_FLAG_TIMERNEXT) #endif #ifndef CO_CONFIG_EM_ERR_STATUS_BITS_COUNT -#define CO_CONFIG_EM_ERR_STATUS_BITS_COUNT (10U*8U) +#define CO_CONFIG_EM_ERR_STATUS_BITS_COUNT (10U * 8U) #endif #ifndef CO_CONFIG_ERR_CONDITION_GENERIC #define CO_CONFIG_ERR_CONDITION_GENERIC (em->errorStatusBits[5] != 0U) #endif #ifndef CO_CONFIG_ERR_CONDITION_COMMUNICATION -#define CO_CONFIG_ERR_CONDITION_COMMUNICATION ((em->errorStatusBits[2] != 0U) \ - || (em->errorStatusBits[3] != 0U)) +#define CO_CONFIG_ERR_CONDITION_COMMUNICATION ((em->errorStatusBits[2] != 0U) || (em->errorStatusBits[3] != 0U)) #endif #ifndef CO_CONFIG_ERR_CONDITION_MANUFACTURER -#define CO_CONFIG_ERR_CONDITION_MANUFACTURER (( em->errorStatusBits[8] != 0U) \ - || (em->errorStatusBits[9] != 0U)) +#define CO_CONFIG_ERR_CONDITION_MANUFACTURER ((em->errorStatusBits[8] != 0U) || (em->errorStatusBits[9] != 0U)) #endif #ifdef __cplusplus @@ -96,7 +93,6 @@ extern "C" { * registered by @ref CO_EM_initCallbackRx() function. */ - /** * @defgroup CO_errorRegister_t CANopen Error register * @{ @@ -110,14 +106,14 @@ 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. */ -#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 */ +#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 */ @@ -127,55 +123,54 @@ extern "C" { * * Standard error codes according to CiA DS-301 and DS-401. */ -#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 */ +#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 */ -#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 */ +#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 */ - /** * @defgroup CO_EM_errorStatusBits_t Error status bits * @{ @@ -193,85 +188,88 @@ extern "C" { * uses first 6 bytes. Additional 4 bytes are pre-defined for manufacturer * or device specific error indications, by default. */ -#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) */ +#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) */ -#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) */ +#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) */ -#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 */ +#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 */ -#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 */ +#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 */ -#define CO_EM_MANUFACTURER_START 0x30U +#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 - 1U) +#define CO_EM_MANUFACTURER_END (CO_CONFIG_EM_ERR_STATUS_BITS_COUNT - 1U) /** @} */ /* CO_EM_errorStatusBits_t */ - - -#if (((CO_CONFIG_EM) & (CO_CONFIG_EM_PRODUCER | CO_CONFIG_EM_HISTORY)) != 0) \ - || defined CO_DOXYGEN +#if (((CO_CONFIG_EM) & (CO_CONFIG_EM_PRODUCER | CO_CONFIG_EM_HISTORY)) != 0) || defined CO_DOXYGEN /** * Fifo buffer for emergency producer and error history */ typedef struct { uint32_t msg; -#if (((CO_CONFIG_EM) & CO_CONFIG_EM_PRODUCER) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_EM)&CO_CONFIG_EM_PRODUCER) != 0) || defined CO_DOXYGEN uint32_t info; #endif } CO_EM_fifo_t; #endif - /** * Emergency object. */ @@ -279,21 +277,20 @@ typedef struct { /** Bitfield for the internal indication of the error condition. */ uint8_t errorStatusBits[CO_CONFIG_EM_ERR_STATUS_BITS_COUNT / 8U]; /** Pointer to error register in object dictionary at 0x1001,00. */ - uint8_t *errorRegister; + uint8_t* errorRegister; /** Old CAN error status bitfield */ uint16_t CANerrorStatusOld; /** From CO_EM_init() */ - CO_CANmodule_t *CANdevTx; + CO_CANmodule_t* CANdevTx; -#if (((CO_CONFIG_EM) & (CO_CONFIG_EM_PRODUCER | CO_CONFIG_EM_HISTORY)) != 0) \ - || defined CO_DOXYGEN +#if (((CO_CONFIG_EM) & (CO_CONFIG_EM_PRODUCER | CO_CONFIG_EM_HISTORY)) != 0) || defined CO_DOXYGEN /** Internal circular FIFO buffer for storing pre-processed emergency * messages. Messages are added by @ref CO_error() function. All messages * are later post-processed by @ref CO_EM_process() function. In case of * overflow, error is indicated but emergency message is not sent. Fifo is * also used for error history, OD object 0x1003, "Pre-defined error field". * Buffer is defined by @ref CO_EM_init(). */ - CO_EM_fifo_t *fifo; + CO_EM_fifo_t* fifo; /** Size of the above buffer, specified by @ref CO_EM_init(). */ uint8_t fifoSize; /** Pointer for the fifo buffer, where next emergency message will be @@ -309,59 +306,55 @@ typedef struct { uint8_t fifoCount; #endif /* (CO_CONFIG_EM) & (CO_CONFIG_EM_PRODUCER | CO_CONFIG_EM_HISTORY) */ -#if (((CO_CONFIG_EM) & CO_CONFIG_EM_PRODUCER) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_EM)&CO_CONFIG_EM_PRODUCER) != 0) || defined CO_DOXYGEN /** True, if emergency producer is enabled, from Object dictionary */ bool_t producerEnabled; /** Copy of CANopen node ID, from CO_EM_init() */ uint8_t nodeId; /** CAN transmit buffer */ - CO_CANtx_t *CANtxBuff; + CO_CANtx_t* CANtxBuff; /** Extension for OD object */ OD_extension_t OD_1014_extension; - #if (((CO_CONFIG_EM) & CO_CONFIG_EM_PROD_CONFIGURABLE) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_EM)&CO_CONFIG_EM_PROD_CONFIGURABLE) != 0) || defined CO_DOXYGEN /** COB ID of emergency message, from Object dictionary */ uint16_t producerCanId; /** From CO_EM_init() */ uint16_t CANdevTxIdx; - #endif - #if (((CO_CONFIG_EM) & CO_CONFIG_EM_PROD_INHIBIT) != 0) || defined CO_DOXYGEN - /** Inhibit time for emergency message, from Object dictionary */ +#endif +#if (((CO_CONFIG_EM)&CO_CONFIG_EM_PROD_INHIBIT) != 0) || defined CO_DOXYGEN + /** Inhibit time for emergency message, from Object dictionary */ uint32_t inhibitEmTime_us; /**< Internal timer for inhibit time */ uint32_t inhibitEmTimer; /** Extension for OD object */ OD_extension_t OD_1015_extension; - #endif +#endif #endif /* (CO_CONFIG_EM) & CO_CONFIG_EM_PRODUCER */ -#if (((CO_CONFIG_EM) & CO_CONFIG_EM_HISTORY) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_EM)&CO_CONFIG_EM_HISTORY) != 0) || defined CO_DOXYGEN /** Extension for OD object */ OD_extension_t OD_1003_extension; #endif -#if (((CO_CONFIG_EM) & CO_CONFIG_EM_STATUS_BITS) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_EM)&CO_CONFIG_EM_STATUS_BITS) != 0) || defined CO_DOXYGEN /** Extension for OD object */ OD_extension_t OD_statusBits_extension; #endif -#if (((CO_CONFIG_EM) & CO_CONFIG_EM_CONSUMER) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_EM)&CO_CONFIG_EM_CONSUMER) != 0) || defined CO_DOXYGEN /** From CO_EM_initCallbackRx() or NULL */ - void (*pFunctSignalRx)(const uint16_t ident, - const uint16_t errorCode, - const uint8_t errorRegister, - const uint8_t errorBit, - const uint32_t infoCode); + void (*pFunctSignalRx)(const uint16_t ident, const uint16_t errorCode, const uint8_t errorRegister, + const uint8_t errorBit, const uint32_t infoCode); #endif -#if (((CO_CONFIG_EM) & CO_CONFIG_FLAG_CALLBACK_PRE) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_EM)&CO_CONFIG_FLAG_CALLBACK_PRE) != 0) || defined CO_DOXYGEN /** From CO_EM_initCallbackPre() or NULL */ - void (*pFunctSignalPre)(void *object); + void (*pFunctSignalPre)(void* object); /** From CO_EM_initCallbackPre() or NULL */ - void *functSignalObjectPre; + void* functSignalObjectPre; #endif } CO_EM_t; - /** * Initialize Emergency object. * @@ -396,36 +389,28 @@ typedef struct { * * @return @ref CO_ReturnError_t CO_ERROR_NO in case of success. */ -CO_ReturnError_t CO_EM_init(CO_EM_t *em, - CO_CANmodule_t *CANdevTx, - const OD_entry_t *OD_1001_errReg, -#if (((CO_CONFIG_EM) & (CO_CONFIG_EM_PRODUCER | CO_CONFIG_EM_HISTORY)) != 0) \ - || defined CO_DOXYGEN - CO_EM_fifo_t *fifo, - uint8_t fifoSize, +CO_ReturnError_t CO_EM_init(CO_EM_t* em, CO_CANmodule_t* CANdevTx, const OD_entry_t* OD_1001_errReg, +#if (((CO_CONFIG_EM) & (CO_CONFIG_EM_PRODUCER | CO_CONFIG_EM_HISTORY)) != 0) || defined CO_DOXYGEN + CO_EM_fifo_t* fifo, uint8_t fifoSize, #endif -#if (((CO_CONFIG_EM) & CO_CONFIG_EM_PRODUCER) != 0) || defined CO_DOXYGEN - OD_entry_t *OD_1014_cobIdEm, - uint16_t CANdevTxIdx, - #if (((CO_CONFIG_EM) & CO_CONFIG_EM_PROD_INHIBIT) != 0) || defined CO_DOXYGEN - OD_entry_t *OD_1015_InhTime, - #endif +#if (((CO_CONFIG_EM)&CO_CONFIG_EM_PRODUCER) != 0) || defined CO_DOXYGEN + OD_entry_t* OD_1014_cobIdEm, uint16_t CANdevTxIdx, +#if (((CO_CONFIG_EM)&CO_CONFIG_EM_PROD_INHIBIT) != 0) || defined CO_DOXYGEN + OD_entry_t* OD_1015_InhTime, #endif -#if (((CO_CONFIG_EM) & CO_CONFIG_EM_HISTORY) != 0) || defined CO_DOXYGEN - OD_entry_t *OD_1003_preDefErr, #endif -#if (((CO_CONFIG_EM) & CO_CONFIG_EM_STATUS_BITS) != 0) || defined CO_DOXYGEN - OD_entry_t *OD_statusBits, +#if (((CO_CONFIG_EM)&CO_CONFIG_EM_HISTORY) != 0) || defined CO_DOXYGEN + OD_entry_t* OD_1003_preDefErr, #endif -#if (((CO_CONFIG_EM) & CO_CONFIG_EM_CONSUMER) != 0) || defined CO_DOXYGEN - CO_CANmodule_t *CANdevRx, - uint16_t CANdevRxIdx, +#if (((CO_CONFIG_EM)&CO_CONFIG_EM_STATUS_BITS) != 0) || defined CO_DOXYGEN + OD_entry_t* OD_statusBits, #endif - const uint8_t nodeId, - uint32_t *errInfo); +#if (((CO_CONFIG_EM)&CO_CONFIG_EM_CONSUMER) != 0) || defined CO_DOXYGEN + CO_CANmodule_t* CANdevRx, uint16_t CANdevRxIdx, +#endif + const uint8_t nodeId, uint32_t* errInfo); - -#if (((CO_CONFIG_EM) & CO_CONFIG_FLAG_CALLBACK_PRE) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_EM)&CO_CONFIG_FLAG_CALLBACK_PRE) != 0) || defined CO_DOXYGEN /** * Initialize Emergency callback function. * @@ -440,13 +425,10 @@ CO_ReturnError_t CO_EM_init(CO_EM_t *em, * be NULL * @param pFunctSignal Pointer to the callback function. Not called if NULL. */ -void CO_EM_initCallbackPre(CO_EM_t *em, - void *object, - void (*pFunctSignal)(void *object)); +void CO_EM_initCallbackPre(CO_EM_t* em, void* object, void (*pFunctSignal)(void* object)); #endif - -#if (((CO_CONFIG_EM) & CO_CONFIG_EM_CONSUMER) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_EM)&CO_CONFIG_EM_CONSUMER) != 0) || defined CO_DOXYGEN /** * Initialize Emergency received callback function. * @@ -462,15 +444,11 @@ void CO_EM_initCallbackPre(CO_EM_t *em, * @param em This object. * @param pFunctSignalRx Pointer to the callback function. Not called if NULL. */ -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)); +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)); #endif - /** * Process Error control and Emergency object. * @@ -485,11 +463,7 @@ void CO_EM_initCallbackRx(CO_EM_t *em, * [microseconds]. * @param [out] timerNext_us info to OS - see CO_process(). */ -void CO_EM_process(CO_EM_t *em, - bool_t NMTisPreOrOperational, - uint32_t timeDifference_us, - uint32_t *timerNext_us); - +void CO_EM_process(CO_EM_t* em, bool_t NMTisPreOrOperational, uint32_t timeDifference_us, uint32_t* timerNext_us); /** * Set or reset error condition. @@ -509,23 +483,17 @@ void CO_EM_process(CO_EM_t *em, * @param infoCode 32 bit value is passed to bytes 4...7 of the Emergency * message. It contains optional additional information. */ -void CO_error(CO_EM_t *em, bool_t setError, const uint8_t errorBit, - uint16_t errorCode, uint32_t infoCode); - +void CO_error(CO_EM_t* em, bool_t setError, const uint8_t errorBit, uint16_t errorCode, uint32_t infoCode); /** * Report error condition, for description of parameters see @ref CO_error. */ -#define CO_errorReport(em, errorBit, errorCode, infoCode) \ - CO_error(em, true, errorBit, errorCode, infoCode) - +#define CO_errorReport(em, errorBit, errorCode, infoCode) CO_error(em, true, errorBit, errorCode, infoCode) /** * Reset error condition, for description of parameters see @ref CO_error. */ -#define CO_errorReset(em, errorBit, infoCode) \ - CO_error(em, false, errorBit, CO_EMC_NO_ERROR, infoCode) - +#define CO_errorReset(em, errorBit, infoCode) CO_error(em, false, errorBit, CO_EMC_NO_ERROR, infoCode) /** * Check specific error condition. @@ -537,12 +505,15 @@ void CO_error(CO_EM_t *em, bool_t setError, const uint8_t errorBit, * * @return true if Error is present. */ -static inline bool_t CO_isError(CO_EM_t *em, const uint8_t errorBit) { +static inline bool_t +CO_isError(CO_EM_t* em, const uint8_t errorBit) { uint8_t index = errorBit >> 3; uint8_t bitmask = 1 << (errorBit & 0x7); return (em == NULL || index >= (CO_CONFIG_EM_ERR_STATUS_BITS_COUNT / 8U) - || (em->errorStatusBits[index] & bitmask) != 0) ? true : false; + || (em->errorStatusBits[index] & bitmask) != 0) + ? true + : false; } /** @@ -552,7 +523,8 @@ static inline bool_t CO_isError(CO_EM_t *em, const uint8_t errorBit) { * * @return Error register or 0 if doesn't exist. */ -static inline uint8_t CO_getErrorRegister(CO_EM_t *em) { +static inline uint8_t +CO_getErrorRegister(CO_EM_t* em) { return (em == NULL || em->errorRegister == NULL) ? 0 : *em->errorRegister; } diff --git a/301/CO_HBconsumer.h b/301/CO_HBconsumer.h index 38232f5..b3d1273 100644 --- a/301/CO_HBconsumer.h +++ b/301/CO_HBconsumer.h @@ -28,13 +28,12 @@ /* default configuration, see CO_config.h */ #ifndef CO_CONFIG_HB_CONS -#define CO_CONFIG_HB_CONS (CO_CONFIG_HB_CONS_ENABLE | \ - CO_CONFIG_GLOBAL_FLAG_CALLBACK_PRE | \ - CO_CONFIG_GLOBAL_FLAG_TIMERNEXT | \ - CO_CONFIG_GLOBAL_FLAG_OD_DYNAMIC) +#define CO_CONFIG_HB_CONS \ + (CO_CONFIG_HB_CONS_ENABLE | CO_CONFIG_GLOBAL_FLAG_CALLBACK_PRE | CO_CONFIG_GLOBAL_FLAG_TIMERNEXT \ + | CO_CONFIG_GLOBAL_FLAG_OD_DYNAMIC) #endif -#if (((CO_CONFIG_HB_CONS) & CO_CONFIG_HB_CONS_ENABLE) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_HB_CONS)&CO_CONFIG_HB_CONS_ENABLE) != 0) || defined CO_DOXYGEN #ifdef __cplusplus extern "C" { @@ -63,13 +62,12 @@ extern "C" { * Heartbeat state of a node */ typedef enum { - CO_HBconsumer_UNCONFIGURED = 0x00U, /**< Consumer entry inactive */ - CO_HBconsumer_UNKNOWN = 0x01U, /**< Consumer enabled, but no heartbeat received yet */ - CO_HBconsumer_ACTIVE = 0x02U, /**< Heartbeat received within set time */ - CO_HBconsumer_TIMEOUT = 0x03U, /**< No heatbeat received for set time */ + CO_HBconsumer_UNCONFIGURED = 0x00U, /**< Consumer entry inactive */ + CO_HBconsumer_UNKNOWN = 0x01U, /**< Consumer enabled, but no heartbeat received yet */ + CO_HBconsumer_ACTIVE = 0x02U, /**< Heartbeat received within set time */ + CO_HBconsumer_TIMEOUT = 0x03U, /**< No heatbeat received for set time */ } CO_HBconsumer_state_t; - /** * One monitored node inside CO_HBconsumer_t. */ @@ -85,46 +83,42 @@ typedef struct { /** Consumer heartbeat time from OD */ uint32_t time_us; /** Indication if new Heartbeat message received from the CAN bus */ - volatile void *CANrxNew; -#if (((CO_CONFIG_HB_CONS) & CO_CONFIG_FLAG_CALLBACK_PRE) != 0) || defined CO_DOXYGEN + volatile void* CANrxNew; +#if (((CO_CONFIG_HB_CONS)&CO_CONFIG_FLAG_CALLBACK_PRE) != 0) || defined CO_DOXYGEN /** From CO_HBconsumer_initCallbackPre() or NULL */ - void (*pFunctSignalPre)(void *object); + void (*pFunctSignalPre)(void* object); /** From CO_HBconsumer_initCallbackPre() or NULL */ - void *functSignalObjectPre; + void* functSignalObjectPre; #endif -#if (((CO_CONFIG_HB_CONS) & CO_CONFIG_HB_CONS_CALLBACK_CHANGE) != 0) \ - || (((CO_CONFIG_HB_CONS) & CO_CONFIG_HB_CONS_CALLBACK_MULTI) != 0) \ - || defined CO_DOXYGEN +#if (((CO_CONFIG_HB_CONS)&CO_CONFIG_HB_CONS_CALLBACK_CHANGE) != 0) \ + || (((CO_CONFIG_HB_CONS)&CO_CONFIG_HB_CONS_CALLBACK_MULTI) != 0) || defined CO_DOXYGEN /** Previous value of the remote node (Heartbeat payload) */ CO_NMT_internalState_t NMTstatePrev; #endif -#if (((CO_CONFIG_HB_CONS) & CO_CONFIG_HB_CONS_CALLBACK_MULTI) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_HB_CONS)&CO_CONFIG_HB_CONS_CALLBACK_MULTI) != 0) || defined CO_DOXYGEN /** Callback for remote NMT changed event. * From CO_HBconsumer_initCallbackNmtChanged() or NULL. */ - void (*pFunctSignalNmtChanged)(uint8_t nodeId, uint8_t idx, - CO_NMT_internalState_t NMTstate, - void *object); + void (*pFunctSignalNmtChanged)(uint8_t nodeId, uint8_t idx, CO_NMT_internalState_t NMTstate, void* object); /** Pointer to object */ - void *pFunctSignalObjectNmtChanged; + void* pFunctSignalObjectNmtChanged; /** Callback for heartbeat state change to active event. * From CO_HBconsumer_initCallbackHeartbeatStarted() or NULL. */ - void (*pFunctSignalHbStarted)(uint8_t nodeId, uint8_t idx, void *object); + void (*pFunctSignalHbStarted)(uint8_t nodeId, uint8_t idx, void* object); /** Pointer to object */ - void *functSignalObjectHbStarted; + void* functSignalObjectHbStarted; /** Callback for consumer timeout event. * From CO_HBconsumer_initCallbackTimeout() or NULL. */ - void (*pFunctSignalTimeout)(uint8_t nodeId, uint8_t idx, void *object); + void (*pFunctSignalTimeout)(uint8_t nodeId, uint8_t idx, void* object); /** Pointer to object */ - void *functSignalObjectTimeout; + void* functSignalObjectTimeout; /** Callback for remote reset event. * From CO_HBconsumer_initCallbackRemoteReset() or NULL. */ - void (*pFunctSignalRemoteReset)(uint8_t nodeId, uint8_t idx, void *object); + void (*pFunctSignalRemoteReset)(uint8_t nodeId, uint8_t idx, void* object); /** Pointer to object */ - void *functSignalObjectRemoteReset; + void* functSignalObjectRemoteReset; #endif } CO_HBconsNode_t; - /** * Heartbeat consumer object. * @@ -133,9 +127,9 @@ typedef struct { */ typedef struct { /** From CO_HBconsumer_init() */ - CO_EM_t *em; + CO_EM_t* em; /** Array of monitored nodes, from CO_HBconsumer_init() */ - CO_HBconsNode_t *monitoredNodes; + CO_HBconsNode_t* monitoredNodes; /** Actual number of monitored nodes, size-of-the-above-array or * number-of-array-elements-in-OD-0x1016, whichever is smaller. */ uint8_t numberOfMonitoredNodes; @@ -148,25 +142,22 @@ typedef struct { /** previous state of the variable */ bool_t NMTisPreOrOperationalPrev; /** From CO_HBconsumer_init() */ - CO_CANmodule_t *CANdevRx; + CO_CANmodule_t* CANdevRx; /** From CO_HBconsumer_init() */ uint16_t CANdevRxIdxStart; -#if (((CO_CONFIG_HB_CONS) & CO_CONFIG_FLAG_OD_DYNAMIC) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_HB_CONS)&CO_CONFIG_FLAG_OD_DYNAMIC) != 0) || defined CO_DOXYGEN /** Extension for OD object */ OD_extension_t OD_1016_extension; #endif -#if (((CO_CONFIG_HB_CONS) & CO_CONFIG_HB_CONS_CALLBACK_CHANGE) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_HB_CONS)&CO_CONFIG_HB_CONS_CALLBACK_CHANGE) != 0) || defined CO_DOXYGEN /** Callback for remote NMT changed event. * From CO_HBconsumer_initCallbackNmtChanged() or NULL. */ - void (*pFunctSignalNmtChanged)(uint8_t nodeId, uint8_t idx, - CO_NMT_internalState_t NMTstate, - void *object); + void (*pFunctSignalNmtChanged)(uint8_t nodeId, uint8_t idx, CO_NMT_internalState_t NMTstate, void* object); /** Pointer to object */ - void *pFunctSignalObjectNmtChanged; + void* pFunctSignalObjectNmtChanged; #endif } CO_HBconsumer_t; - /** * Initialize Heartbeat consumer object. * @@ -186,17 +177,11 @@ typedef struct { * * @return @ref CO_ReturnError_t CO_ERROR_NO in case of success. */ -CO_ReturnError_t CO_HBconsumer_init(CO_HBconsumer_t *HBcons, - CO_EM_t *em, - CO_HBconsNode_t *monitoredNodes, - uint8_t monitoredNodesCount, - OD_entry_t *OD_1016_HBcons, - CO_CANmodule_t *CANdevRx, - uint16_t CANdevRxIdxStart, - uint32_t *errInfo); +CO_ReturnError_t CO_HBconsumer_init(CO_HBconsumer_t* HBcons, CO_EM_t* em, CO_HBconsNode_t* monitoredNodes, + uint8_t monitoredNodesCount, OD_entry_t* OD_1016_HBcons, CO_CANmodule_t* CANdevRx, + uint16_t CANdevRxIdxStart, uint32_t* errInfo); - -#if (((CO_CONFIG_HB_CONS) & CO_CONFIG_FLAG_CALLBACK_PRE) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_HB_CONS)&CO_CONFIG_FLAG_CALLBACK_PRE) != 0) || defined CO_DOXYGEN /** * Initialize Heartbeat consumer callback function. * @@ -208,15 +193,11 @@ CO_ReturnError_t CO_HBconsumer_init(CO_HBconsumer_t *HBcons, * @param object Pointer to object, which will be passed to pFunctSignal(). Can be NULL * @param pFunctSignal Pointer to the callback function. Not called if NULL. */ -void CO_HBconsumer_initCallbackPre( - CO_HBconsumer_t *HBcons, - void *object, - void (*pFunctSignal)(void *object)); +void CO_HBconsumer_initCallbackPre(CO_HBconsumer_t* HBcons, void* object, void (*pFunctSignal)(void* object)); #endif -#if (((CO_CONFIG_HB_CONS) & CO_CONFIG_HB_CONS_CALLBACK_CHANGE) != 0) \ - || (((CO_CONFIG_HB_CONS) & CO_CONFIG_HB_CONS_CALLBACK_MULTI) != 0) \ - || defined CO_DOXYGEN +#if (((CO_CONFIG_HB_CONS)&CO_CONFIG_HB_CONS_CALLBACK_CHANGE) != 0) \ + || (((CO_CONFIG_HB_CONS)&CO_CONFIG_HB_CONS_CALLBACK_MULTI) != 0) || defined CO_DOXYGEN /** * Initialize Heartbeat consumer NMT changed callback function. * @@ -230,16 +211,12 @@ void CO_HBconsumer_initCallbackPre( * Can be NULL. * @param pFunctSignal Pointer to the callback function. Not called if NULL. */ -void CO_HBconsumer_initCallbackNmtChanged( - CO_HBconsumer_t *HBcons, - uint8_t idx, - void *object, - void (*pFunctSignal)(uint8_t nodeId, uint8_t idx, - CO_NMT_internalState_t NMTstate, - void *object)); +void CO_HBconsumer_initCallbackNmtChanged(CO_HBconsumer_t* HBcons, uint8_t idx, void* object, + void (*pFunctSignal)(uint8_t nodeId, uint8_t idx, + CO_NMT_internalState_t NMTstate, void* object)); #endif -#if (((CO_CONFIG_HB_CONS) & CO_CONFIG_HB_CONS_CALLBACK_MULTI) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_HB_CONS)&CO_CONFIG_HB_CONS_CALLBACK_MULTI) != 0) || defined CO_DOXYGEN /** * Initialize Heartbeat consumer started callback function. * @@ -252,11 +229,8 @@ void CO_HBconsumer_initCallbackNmtChanged( * @param object Pointer to object, which will be passed to pFunctSignal(). Can be NULL * @param pFunctSignal Pointer to the callback function. Not called if NULL. */ -void CO_HBconsumer_initCallbackHeartbeatStarted( - CO_HBconsumer_t *HBcons, - uint8_t idx, - void *object, - void (*pFunctSignal)(uint8_t nodeId, uint8_t idx, void *object)); +void CO_HBconsumer_initCallbackHeartbeatStarted(CO_HBconsumer_t* HBcons, uint8_t idx, void* object, + void (*pFunctSignal)(uint8_t nodeId, uint8_t idx, void* object)); /** * Initialize Heartbeat consumer timeout callback function. @@ -270,11 +244,8 @@ void CO_HBconsumer_initCallbackHeartbeatStarted( * @param object Pointer to object, which will be passed to pFunctSignal(). Can be NULL * @param pFunctSignal Pointer to the callback function. Not called if NULL. */ -void CO_HBconsumer_initCallbackTimeout( - CO_HBconsumer_t *HBcons, - uint8_t idx, - void *object, - void (*pFunctSignal)(uint8_t nodeId, uint8_t idx, void *object)); +void CO_HBconsumer_initCallbackTimeout(CO_HBconsumer_t* HBcons, uint8_t idx, void* object, + void (*pFunctSignal)(uint8_t nodeId, uint8_t idx, void* object)); /** * Initialize Heartbeat consumer remote reset detected callback function. @@ -288,11 +259,8 @@ void CO_HBconsumer_initCallbackTimeout( * @param object Pointer to object, which will be passed to pFunctSignal(). Can be NULL * @param pFunctSignal Pointer to the callback function. Not called if NULL. */ -void CO_HBconsumer_initCallbackRemoteReset( - CO_HBconsumer_t *HBcons, - uint8_t idx, - void *object, - void (*pFunctSignal)(uint8_t nodeId, uint8_t idx, void *object)); +void CO_HBconsumer_initCallbackRemoteReset(CO_HBconsumer_t* HBcons, uint8_t idx, void* object, + void (*pFunctSignal)(uint8_t nodeId, uint8_t idx, void* object)); #endif /* (CO_CONFIG_HB_CONS) & CO_CONFIG_HB_CONS_CALLBACK_MULTI */ /** @@ -305,14 +273,10 @@ void CO_HBconsumer_initCallbackRemoteReset( * @param timeDifference_us Time difference from previous function call in [microseconds]. * @param [out] timerNext_us info to OS - see CO_process(). */ -void CO_HBconsumer_process( - CO_HBconsumer_t *HBcons, - bool_t NMTisPreOrOperational, - uint32_t timeDifference_us, - uint32_t *timerNext_us); +void CO_HBconsumer_process(CO_HBconsumer_t* HBcons, bool_t NMTisPreOrOperational, uint32_t timeDifference_us, + uint32_t* timerNext_us); - -#if (((CO_CONFIG_HB_CONS) & CO_CONFIG_HB_CONS_QUERY_FUNCT) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_HB_CONS)&CO_CONFIG_HB_CONS_QUERY_FUNCT) != 0) || defined CO_DOXYGEN /** * Get the heartbeat producer object index by node ID * @@ -320,9 +284,7 @@ void CO_HBconsumer_process( * @param nodeId producer node ID * @return index. -1 if not found */ -int8_t CO_HBconsumer_getIdxByNodeId( - CO_HBconsumer_t *HBcons, - uint8_t nodeId); +int8_t CO_HBconsumer_getIdxByNodeId(CO_HBconsumer_t* HBcons, uint8_t nodeId); /** * Get the current state of a heartbeat producer by the index in OD 0x1016 @@ -331,9 +293,7 @@ int8_t CO_HBconsumer_getIdxByNodeId( * @param idx object sub index * @return #CO_HBconsumer_state_t */ -CO_HBconsumer_state_t CO_HBconsumer_getState( - CO_HBconsumer_t *HBcons, - uint8_t idx); +CO_HBconsumer_state_t CO_HBconsumer_getState(CO_HBconsumer_t* HBcons, uint8_t idx); /** * Get the current NMT state of a heartbeat producer by the index in OD 0x1016 @@ -346,10 +306,7 @@ CO_HBconsumer_state_t CO_HBconsumer_getState( * @retval 0 NMT state has been received and is valid * @retval -1 not valid */ -int8_t CO_HBconsumer_getNmtState( - CO_HBconsumer_t *HBcons, - uint8_t idx, - CO_NMT_internalState_t *nmtState); +int8_t CO_HBconsumer_getNmtState(CO_HBconsumer_t* HBcons, uint8_t idx, CO_NMT_internalState_t* nmtState); #endif /* (CO_CONFIG_HB_CONS) & CO_CONFIG_HB_CONS_QUERY_FUNCT */ diff --git a/301/CO_NMT_Heartbeat.h b/301/CO_NMT_Heartbeat.h index 0bd3937..c95d9c5 100644 --- a/301/CO_NMT_Heartbeat.h +++ b/301/CO_NMT_Heartbeat.h @@ -27,8 +27,7 @@ /* default configuration, see CO_config.h */ #ifndef CO_CONFIG_NMT -#define CO_CONFIG_NMT (CO_CONFIG_GLOBAL_FLAG_CALLBACK_PRE | \ - CO_CONFIG_GLOBAL_FLAG_TIMERNEXT) +#define CO_CONFIG_NMT (CO_CONFIG_GLOBAL_FLAG_CALLBACK_PRE | CO_CONFIG_GLOBAL_FLAG_TIMERNEXT) #endif #ifdef __cplusplus @@ -82,7 +81,6 @@ typedef enum { CO_NMT_STOPPED = 4 } CO_NMT_internalState_t; - /** * Commands from NMT master. */ @@ -101,7 +99,6 @@ typedef enum { CO_NMT_RESET_COMMUNICATION = 130 } CO_NMT_command_t; - /** * Return code from CO_NMT_process() that tells application code what to * reset. @@ -118,7 +115,6 @@ typedef enum { CO_RESET_QUIT = 3 } CO_NMT_reset_cmd_t; - /** * @defgroup CO_NMT_control_t NMT control bitfield for NMT internal state. * @{ @@ -134,28 +130,27 @@ typedef enum { /** First 8 bits can be used to specify bitmask for the * @ref CO_errorRegister_t to get relevant bits for the calculation. */ -#define CO_NMT_ERR_REG_MASK 0x00FFU +#define CO_NMT_ERR_REG_MASK 0x00FFU /** If bit is set then device enters NMT operational state after the * initialization phase otherwise it enters NMT pre-operational state. */ #define CO_NMT_STARTUP_TO_OPERATIONAL 0x0100U /** If bit is set and device is operational it enters NMT pre-operational * or stopped state if CAN bus is off or heartbeat consumer timeout is * detected. */ -#define CO_NMT_ERR_ON_BUSOFF_HB 0x1000U +#define CO_NMT_ERR_ON_BUSOFF_HB 0x1000U /** If bit is set and device is operational it enters NMT pre-operational * or stopped state if masked CANopen error register is different than * zero. */ -#define CO_NMT_ERR_ON_ERR_REG 0x2000U +#define CO_NMT_ERR_ON_ERR_REG 0x2000U /** If bit is set and CO_NMT_ERR_ON_xx condition is met then device will * enter NMT stopped state otherwise it will enter NMT pre-op state. */ -#define CO_NMT_ERR_TO_STOPPED 0x4000U +#define CO_NMT_ERR_TO_STOPPED 0x4000U /** If bit is set and device is pre-operational it enters NMT operational * state automatically if conditions from CO_NMT_ERR_ON_xx are all false.*/ -#define CO_NMT_ERR_FREE_TO_OPERATIONAL 0x8000U +#define CO_NMT_ERR_FREE_TO_OPERATIONAL 0x8000U /** @} */ /* CO_NMT_control_t */ - /** * NMT consumer and Heartbeat producer object */ @@ -178,30 +173,29 @@ typedef struct { /** Extension for OD object */ OD_extension_t OD_1017_extension; /** From CO_NMT_init() */ - CO_EM_t *em; -#if (((CO_CONFIG_NMT) & CO_CONFIG_NMT_MASTER) != 0) || defined CO_DOXYGEN + CO_EM_t* em; +#if (((CO_CONFIG_NMT)&CO_CONFIG_NMT_MASTER) != 0) || defined CO_DOXYGEN /** From CO_NMT_init() */ - CO_CANmodule_t *NMT_CANdevTx; + CO_CANmodule_t* NMT_CANdevTx; /** CAN transmit buffer for NMT master message */ - CO_CANtx_t *NMT_TXbuff; + CO_CANtx_t* NMT_TXbuff; #endif /** From CO_NMT_init() */ - CO_CANmodule_t *HB_CANdevTx; + CO_CANmodule_t* HB_CANdevTx; /** CAN transmit buffer for heartbeat message */ - CO_CANtx_t *HB_TXbuff; -#if (((CO_CONFIG_NMT) & CO_CONFIG_FLAG_CALLBACK_PRE) != 0) || defined CO_DOXYGEN + CO_CANtx_t* HB_TXbuff; +#if (((CO_CONFIG_NMT)&CO_CONFIG_FLAG_CALLBACK_PRE) != 0) || defined CO_DOXYGEN /** From CO_NMT_initCallbackPre() or NULL */ - void (*pFunctSignalPre)(void *object); + void (*pFunctSignalPre)(void* object); /** From CO_NMT_initCallbackPre() or NULL */ - void *functSignalObjectPre; + void* functSignalObjectPre; #endif -#if (((CO_CONFIG_NMT) & CO_CONFIG_NMT_CALLBACK_CHANGE) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_NMT)&CO_CONFIG_NMT_CALLBACK_CHANGE) != 0) || defined CO_DOXYGEN /** From CO_NMT_initCallbackChanged() or NULL */ void (*pFunctNMT)(CO_NMT_internalState_t state); #endif } CO_NMT_t; - /** * Initialize NMT and Heartbeat producer object. * @@ -231,27 +225,15 @@ typedef struct { * * @return #CO_ReturnError_t CO_ERROR_NO on success. */ -CO_ReturnError_t CO_NMT_init(CO_NMT_t *NMT, - OD_entry_t *OD_1017_ProducerHbTime, - CO_EM_t *em, - uint8_t nodeId, - uint16_t NMTcontrol, - uint16_t firstHBTime_ms, - CO_CANmodule_t *NMT_CANdevRx, - uint16_t NMT_rxIdx, - uint16_t CANidRxNMT, -#if (((CO_CONFIG_NMT) & CO_CONFIG_NMT_MASTER) != 0) || defined CO_DOXYGEN - CO_CANmodule_t *NMT_CANdevTx, - uint16_t NMT_txIdx, - uint16_t CANidTxNMT, +CO_ReturnError_t CO_NMT_init(CO_NMT_t* NMT, OD_entry_t* OD_1017_ProducerHbTime, CO_EM_t* em, uint8_t nodeId, + uint16_t NMTcontrol, uint16_t firstHBTime_ms, CO_CANmodule_t* NMT_CANdevRx, + uint16_t NMT_rxIdx, uint16_t CANidRxNMT, +#if (((CO_CONFIG_NMT)&CO_CONFIG_NMT_MASTER) != 0) || defined CO_DOXYGEN + CO_CANmodule_t* NMT_CANdevTx, uint16_t NMT_txIdx, uint16_t CANidTxNMT, #endif - CO_CANmodule_t *HB_CANdevTx, - uint16_t HB_txIdx, - uint16_t CANidTxHB, - uint32_t *errInfo); + CO_CANmodule_t* HB_CANdevTx, uint16_t HB_txIdx, uint16_t CANidTxHB, uint32_t* errInfo); - -#if (((CO_CONFIG_NMT) & CO_CONFIG_FLAG_CALLBACK_PRE) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_NMT)&CO_CONFIG_FLAG_CALLBACK_PRE) != 0) || defined CO_DOXYGEN /** * Initialize NMT callback function after message preprocessed. * @@ -264,13 +246,10 @@ CO_ReturnError_t CO_NMT_init(CO_NMT_t *NMT, * Can be NULL * @param pFunctSignal Pointer to the callback function. Not called if NULL. */ -void CO_NMT_initCallbackPre(CO_NMT_t *NMT, - void *object, - void (*pFunctSignal)(void *object)); +void CO_NMT_initCallbackPre(CO_NMT_t* NMT, void* object, void (*pFunctSignal)(void* object)); #endif - -#if (((CO_CONFIG_NMT) & CO_CONFIG_NMT_CALLBACK_CHANGE) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_NMT)&CO_CONFIG_NMT_CALLBACK_CHANGE) != 0) || defined CO_DOXYGEN /** * Initialize NMT callback function. * @@ -282,11 +261,9 @@ void CO_NMT_initCallbackPre(CO_NMT_t *NMT, * @param NMT This object. * @param pFunctNMT Pointer to the callback function. Not called if NULL. */ -void CO_NMT_initCallbackChanged(CO_NMT_t *NMT, - void (*pFunctNMT)(CO_NMT_internalState_t state)); +void CO_NMT_initCallbackChanged(CO_NMT_t* NMT, void (*pFunctNMT)(CO_NMT_internalState_t state)); #endif - /** * Process received NMT and produce Heartbeat messages. * @@ -300,11 +277,8 @@ void CO_NMT_initCallbackChanged(CO_NMT_t *NMT, * * @return #CO_NMT_reset_cmd_t */ -CO_NMT_reset_cmd_t CO_NMT_process(CO_NMT_t *NMT, - CO_NMT_internalState_t *NMTstate, - uint32_t timeDifference_us, - uint32_t *timerNext_us); - +CO_NMT_reset_cmd_t CO_NMT_process(CO_NMT_t* NMT, CO_NMT_internalState_t* NMTstate, uint32_t timeDifference_us, + uint32_t* timerNext_us); /** * Query current NMT state @@ -313,11 +287,11 @@ CO_NMT_reset_cmd_t CO_NMT_process(CO_NMT_t *NMT, * * @return @ref CO_NMT_internalState_t */ -static inline CO_NMT_internalState_t CO_NMT_getInternalState(CO_NMT_t *NMT) { +static inline CO_NMT_internalState_t +CO_NMT_getInternalState(CO_NMT_t* NMT) { return (NMT == NULL) ? CO_NMT_INITIALIZING : NMT->operatingState; } - /** * Send NMT command to self, without sending NMT message * @@ -326,14 +300,14 @@ static inline CO_NMT_internalState_t CO_NMT_getInternalState(CO_NMT_t *NMT) { * @param NMT This object. * @param command NMT command */ -static inline void CO_NMT_sendInternalCommand(CO_NMT_t *NMT, - CO_NMT_command_t command) -{ - if (NMT != NULL) { NMT->internalCommand = command; } +static inline void +CO_NMT_sendInternalCommand(CO_NMT_t* NMT, CO_NMT_command_t command) { + if (NMT != NULL) { + NMT->internalCommand = command; + } } - -#if ((CO_CONFIG_NMT) & CO_CONFIG_NMT_MASTER) || defined CO_DOXYGEN +#if ((CO_CONFIG_NMT)&CO_CONFIG_NMT_MASTER) || defined CO_DOXYGEN /** * Send NMT master command. * @@ -349,9 +323,7 @@ static inline void CO_NMT_sendInternalCommand(CO_NMT_t *NMT, * * @return CO_ERROR_NO on success or CO_ReturnError_t from CO_CANsend(). */ -CO_ReturnError_t CO_NMT_sendCommand(CO_NMT_t *NMT, - CO_NMT_command_t command, - uint8_t nodeID); +CO_ReturnError_t CO_NMT_sendCommand(CO_NMT_t* NMT, CO_NMT_command_t command, uint8_t nodeID); #endif /* (CO_CONFIG_NMT) & CO_CONFIG_NMT_MASTER */ diff --git a/301/CO_Node_Guarding.h b/301/CO_Node_Guarding.h index 35596f2..1f7eba5 100644 --- a/301/CO_Node_Guarding.h +++ b/301/CO_Node_Guarding.h @@ -34,7 +34,7 @@ #define CO_CONFIG_NODE_GUARDING_MASTER_COUNT 0x7F #endif -#if (((CO_CONFIG_NODE_GUARDING) & CO_CONFIG_NODE_GUARDING_SLAVE_ENABLE) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_NODE_GUARDING)&CO_CONFIG_NODE_GUARDING_SLAVE_ENABLE) != 0) || defined CO_DOXYGEN #ifdef __cplusplus extern "C" { @@ -77,9 +77,9 @@ extern "C" { */ typedef struct { /** From CO_nodeGuardingSlave_init() */ - CO_EM_t *em; + CO_EM_t* em; /** Indicates, if new rtr message received from CAN bus */ - volatile void *CANrxNew; + volatile void* CANrxNew; /** Guard time in microseconds, calculated from OD_0x100C */ uint32_t guardTime_us; /** Life time in microseconds, calculated from guardTime_us * lifeTimeFactor */ @@ -97,12 +97,11 @@ typedef struct { /** Extension for OD object */ OD_extension_t OD_100D_extension; /** From CO_nodeGuardingSlave_init() */ - CO_CANmodule_t *CANdevTx; + CO_CANmodule_t* CANdevTx; /** CAN transmit buffer for the message */ - CO_CANtx_t *CANtxBuff; + CO_CANtx_t* CANtxBuff; } CO_nodeGuardingSlave_t; - /** * Initialize Node Guarding slave object. * @@ -124,17 +123,10 @@ typedef struct { * * @return #CO_ReturnError_t CO_ERROR_NO on success. */ -CO_ReturnError_t CO_nodeGuardingSlave_init(CO_nodeGuardingSlave_t *ngs, - OD_entry_t *OD_100C_GuardTime, - OD_entry_t *OD_100D_LifeTimeFactor, - CO_EM_t *em, - uint16_t CANidNodeGuarding, - CO_CANmodule_t *CANdevRx, - uint16_t CANdevRxIdx, - CO_CANmodule_t *CANdevTx, - uint16_t CANdevTxIdx, - uint32_t *errInfo); - +CO_ReturnError_t CO_nodeGuardingSlave_init(CO_nodeGuardingSlave_t* ngs, OD_entry_t* OD_100C_GuardTime, + OD_entry_t* OD_100D_LifeTimeFactor, CO_EM_t* em, uint16_t CANidNodeGuarding, + CO_CANmodule_t* CANdevRx, uint16_t CANdevRxIdx, CO_CANmodule_t* CANdevTx, + uint16_t CANdevTxIdx, uint32_t* errInfo); /** * Process Node Guarding slave. @@ -148,12 +140,8 @@ CO_ReturnError_t CO_nodeGuardingSlave_init(CO_nodeGuardingSlave_t *ngs, * microseconds. * @param [out] timerNext_us info to OS - see CO_process(). */ -void CO_nodeGuardingSlave_process(CO_nodeGuardingSlave_t *ngs, - CO_NMT_internalState_t NMTstate, - bool_t slaveDisable, - uint32_t timeDifference_us, - uint32_t *timerNext_us); - +void CO_nodeGuardingSlave_process(CO_nodeGuardingSlave_t* ngs, CO_NMT_internalState_t NMTstate, bool_t slaveDisable, + uint32_t timeDifference_us, uint32_t* timerNext_us); /** * Inquire, if Node guarding slave detected life time timeout @@ -164,12 +152,11 @@ void CO_nodeGuardingSlave_process(CO_nodeGuardingSlave_t *ngs, * * @return true, if life time timeout was detected. */ -static inline bool_t CO_nodeGuardingSlave_isTimeout(CO_nodeGuardingSlave_t *ngs) -{ +static inline bool_t +CO_nodeGuardingSlave_isTimeout(CO_nodeGuardingSlave_t* ngs) { return (ngs == NULL) || ngs->lifeTimeTimeout; } - /** @} */ /* CO_Node_Guarding */ #ifdef __cplusplus @@ -178,10 +165,7 @@ static inline bool_t CO_nodeGuardingSlave_isTimeout(CO_nodeGuardingSlave_t *ngs) #endif /* (CO_CONFIG_NODE_GUARDING) & CO_CONFIG_NODE_GUARDING_SLAVE_ENABLE */ - - - -#if (((CO_CONFIG_NODE_GUARDING) & CO_CONFIG_NODE_GUARDING_MASTER_ENABLE) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_NODE_GUARDING)&CO_CONFIG_NODE_GUARDING_MASTER_ENABLE) != 0) || defined CO_DOXYGEN #if CO_CONFIG_NODE_GUARDING_MASTER_COUNT < 1 || CO_CONFIG_NODE_GUARDING_MASTER_COUNT > 127 #error CO_CONFIG_NODE_GUARDING_MASTER_COUNT value is wrong! @@ -223,13 +207,13 @@ typedef struct { */ typedef struct { /** From CO_nodeGuardingMaster_init() */ - CO_EM_t *em; + CO_EM_t* em; /** From CO_nodeGuardingMaster_init() */ - CO_CANmodule_t *CANdevTx; + CO_CANmodule_t* CANdevTx; /** From CO_nodeGuardingMaster_init() */ uint16_t CANdevTxIdx; /** CAN transmit buffer for the message */ - CO_CANtx_t *CANtxBuff; + CO_CANtx_t* CANtxBuff; /** True, if all monitored nodes are active or no node is monitored. Can be * read by the application */ bool_t allMonitoredActive; @@ -254,12 +238,8 @@ typedef struct { * * @return #CO_ReturnError_t CO_ERROR_NO on success. */ -CO_ReturnError_t CO_nodeGuardingMaster_init(CO_nodeGuardingMaster_t *ngm, - CO_EM_t *em, - CO_CANmodule_t *CANdevRx, - uint16_t CANdevRxIdx, - CO_CANmodule_t *CANdevTx, - uint16_t CANdevTxIdx); +CO_ReturnError_t CO_nodeGuardingMaster_init(CO_nodeGuardingMaster_t* ngm, CO_EM_t* em, CO_CANmodule_t* CANdevRx, + uint16_t CANdevRxIdx, CO_CANmodule_t* CANdevTx, uint16_t CANdevTxIdx); /** * Initialize node inside Node Guarding master object. @@ -275,9 +255,7 @@ CO_ReturnError_t CO_nodeGuardingMaster_init(CO_nodeGuardingMaster_t *ngm, * * @return #CO_ReturnError_t CO_ERROR_NO on success. */ -CO_ReturnError_t CO_nodeGuardingMaster_initNode(CO_nodeGuardingMaster_t *ngm, - uint8_t index, - uint8_t nodeId, +CO_ReturnError_t CO_nodeGuardingMaster_initNode(CO_nodeGuardingMaster_t* ngm, uint8_t index, uint8_t nodeId, uint16_t guardTime_ms); /** @@ -290,9 +268,7 @@ CO_ReturnError_t CO_nodeGuardingMaster_initNode(CO_nodeGuardingMaster_t *ngm, * microseconds. * @param [out] timerNext_us info to OS - see CO_process(). */ -void CO_nodeGuardingMaster_process(CO_nodeGuardingMaster_t *ngm, - uint32_t timeDifference_us, - uint32_t *timerNext_us); +void CO_nodeGuardingMaster_process(CO_nodeGuardingMaster_t* ngm, uint32_t timeDifference_us, uint32_t* timerNext_us); /** @} */ /* @addtogroup CO_Node_Guarding */ diff --git a/301/CO_ODinterface.h b/301/CO_ODinterface.h index b7d3b86..d9034fb 100644 --- a/301/CO_ODinterface.h +++ b/301/CO_ODinterface.h @@ -54,88 +54,85 @@ typedef uint8_t OD_attr_t; #define CO_PROGMEM const #endif - /** * Common DS301 object dictionary entries. */ typedef enum { - OD_H1000_DEV_TYPE = 0x1000U,/**< Device type */ - OD_H1001_ERR_REG = 0x1001U,/**< Error register */ - OD_H1002_MANUF_STATUS_REG = 0x1002U,/**< Manufacturer status register */ - OD_H1003_PREDEF_ERR_FIELD = 0x1003U,/**< Predefined error field */ - OD_H1004_RSV = 0x1004U,/**< Reserved */ - OD_H1005_COBID_SYNC = 0x1005U,/**< Sync message cob-id */ - OD_H1006_COMM_CYCL_PERIOD = 0x1006U,/**< Communication cycle period */ - OD_H1007_SYNC_WINDOW_LEN = 0x1007U,/**< Sync windows length */ - OD_H1008_MANUF_DEV_NAME = 0x1008U,/**< Manufacturer device name */ - OD_H1009_MANUF_HW_VERSION = 0x1009U,/**< Manufacturer hardware version */ - OD_H100A_MANUF_SW_VERSION = 0x100AU,/**< Manufacturer software version */ - OD_H100B_RSV = 0x100BU,/**< Reserved */ - OD_H100C_GUARD_TIME = 0x100CU,/**< Guard time */ - OD_H100D_LIFETIME_FACTOR = 0x100DU,/**< Life time factor */ - OD_H100E_RSV = 0x100EU,/**< Reserved */ - OD_H100F_RSV = 0x100FU,/**< Reserved */ - OD_H1010_STORE_PARAMETERS = 0x1010U,/**< Store params in persistent mem.*/ - OD_H1011_RESTORE_DEFAULT = 0x1011U,/**< Restore default parameters */ - OD_H1012_COBID_TIME = 0x1012U,/**< Timestamp message cob-id */ - OD_H1013_HIGH_RES_TIMESTAMP = 0x1013U,/**< High resolution timestamp */ - OD_H1014_COBID_EMERGENCY = 0x1014U,/**< Emergency message cob-id */ - OD_H1015_INHIBIT_TIME_EMCY = 0x1015U,/**< Inhibit time emergency message */ - OD_H1016_CONSUMER_HB_TIME = 0x1016U,/**< Consumer heartbeat time */ - OD_H1017_PRODUCER_HB_TIME = 0x1017U,/**< Producer heartbeat time */ - OD_H1018_IDENTITY_OBJECT = 0x1018U,/**< Identity object */ - OD_H1019_SYNC_CNT_OVERFLOW = 0x1019U,/**< Sync counter overflow value */ - OD_H1020_VERIFY_CONFIG = 0x1020U,/**< Verify configuration */ - OD_H1021_STORE_EDS = 0x1021U,/**< Store EDS */ - OD_H1022_STORE_FORMAT = 0x1022U,/**< Store format */ - OD_H1023_OS_CMD = 0x1023U,/**< OS command */ - OD_H1024_OS_CMD_MODE = 0x1024U,/**< OS command mode */ - OD_H1025_OS_DBG_INTERFACE = 0x1025U,/**< OS debug interface */ - OD_H1026_OS_PROMPT = 0x1026U,/**< OS prompt */ - OD_H1027_MODULE_LIST = 0x1027U,/**< Module list */ - OD_H1028_EMCY_CONSUMER = 0x1028U,/**< Emergency consumer object */ - OD_H1029_ERR_BEHAVIOR = 0x1029U,/**< Error behaviour */ - OD_H1200_SDO_SERVER_1_PARAM = 0x1200U,/**< SDO server parameter */ - OD_H1280_SDO_CLIENT_1_PARAM = 0x1280U,/**< SDO client parameter */ - OD_H1300_GFC_PARAM = 0x1300U,/**< Global fail-safe command param */ - OD_H1301_SRDO_1_PARAM = 0x1301U,/**< SRDO communication parameter */ - OD_H1381_SRDO_1_MAPPING = 0x1381U,/**< SRDO mapping parameter */ - OD_H13FE_SRDO_VALID = 0x13FEU,/**< SRDO Configuration valid */ - OD_H13FF_SRDO_CHECKSUM = 0x13FFU,/**< SRDO configuration checksum */ - OD_H1400_RXPDO_1_PARAM = 0x1400U,/**< RXPDO communication parameter */ - OD_H1600_RXPDO_1_MAPPING = 0x1600U,/**< RXPDO mapping parameters */ - OD_H1800_TXPDO_1_PARAM = 0x1800U,/**< TXPDO communication parameter */ - OD_H1A00_TXPDO_1_MAPPING = 0x1A00U,/**< TXPDO mapping parameters */ + OD_H1000_DEV_TYPE = 0x1000U, /**< Device type */ + OD_H1001_ERR_REG = 0x1001U, /**< Error register */ + OD_H1002_MANUF_STATUS_REG = 0x1002U, /**< Manufacturer status register */ + OD_H1003_PREDEF_ERR_FIELD = 0x1003U, /**< Predefined error field */ + OD_H1004_RSV = 0x1004U, /**< Reserved */ + OD_H1005_COBID_SYNC = 0x1005U, /**< Sync message cob-id */ + OD_H1006_COMM_CYCL_PERIOD = 0x1006U, /**< Communication cycle period */ + OD_H1007_SYNC_WINDOW_LEN = 0x1007U, /**< Sync windows length */ + OD_H1008_MANUF_DEV_NAME = 0x1008U, /**< Manufacturer device name */ + OD_H1009_MANUF_HW_VERSION = 0x1009U, /**< Manufacturer hardware version */ + OD_H100A_MANUF_SW_VERSION = 0x100AU, /**< Manufacturer software version */ + OD_H100B_RSV = 0x100BU, /**< Reserved */ + OD_H100C_GUARD_TIME = 0x100CU, /**< Guard time */ + OD_H100D_LIFETIME_FACTOR = 0x100DU, /**< Life time factor */ + OD_H100E_RSV = 0x100EU, /**< Reserved */ + OD_H100F_RSV = 0x100FU, /**< Reserved */ + OD_H1010_STORE_PARAMETERS = 0x1010U, /**< Store params in persistent mem.*/ + OD_H1011_RESTORE_DEFAULT = 0x1011U, /**< Restore default parameters */ + OD_H1012_COBID_TIME = 0x1012U, /**< Timestamp message cob-id */ + OD_H1013_HIGH_RES_TIMESTAMP = 0x1013U, /**< High resolution timestamp */ + OD_H1014_COBID_EMERGENCY = 0x1014U, /**< Emergency message cob-id */ + OD_H1015_INHIBIT_TIME_EMCY = 0x1015U, /**< Inhibit time emergency message */ + OD_H1016_CONSUMER_HB_TIME = 0x1016U, /**< Consumer heartbeat time */ + OD_H1017_PRODUCER_HB_TIME = 0x1017U, /**< Producer heartbeat time */ + OD_H1018_IDENTITY_OBJECT = 0x1018U, /**< Identity object */ + OD_H1019_SYNC_CNT_OVERFLOW = 0x1019U, /**< Sync counter overflow value */ + OD_H1020_VERIFY_CONFIG = 0x1020U, /**< Verify configuration */ + OD_H1021_STORE_EDS = 0x1021U, /**< Store EDS */ + OD_H1022_STORE_FORMAT = 0x1022U, /**< Store format */ + OD_H1023_OS_CMD = 0x1023U, /**< OS command */ + OD_H1024_OS_CMD_MODE = 0x1024U, /**< OS command mode */ + OD_H1025_OS_DBG_INTERFACE = 0x1025U, /**< OS debug interface */ + OD_H1026_OS_PROMPT = 0x1026U, /**< OS prompt */ + OD_H1027_MODULE_LIST = 0x1027U, /**< Module list */ + OD_H1028_EMCY_CONSUMER = 0x1028U, /**< Emergency consumer object */ + OD_H1029_ERR_BEHAVIOR = 0x1029U, /**< Error behaviour */ + OD_H1200_SDO_SERVER_1_PARAM = 0x1200U, /**< SDO server parameter */ + OD_H1280_SDO_CLIENT_1_PARAM = 0x1280U, /**< SDO client parameter */ + OD_H1300_GFC_PARAM = 0x1300U, /**< Global fail-safe command param */ + OD_H1301_SRDO_1_PARAM = 0x1301U, /**< SRDO communication parameter */ + OD_H1381_SRDO_1_MAPPING = 0x1381U, /**< SRDO mapping parameter */ + OD_H13FE_SRDO_VALID = 0x13FEU, /**< SRDO Configuration valid */ + OD_H13FF_SRDO_CHECKSUM = 0x13FFU, /**< SRDO configuration checksum */ + OD_H1400_RXPDO_1_PARAM = 0x1400U, /**< RXPDO communication parameter */ + OD_H1600_RXPDO_1_MAPPING = 0x1600U, /**< RXPDO mapping parameters */ + OD_H1800_TXPDO_1_PARAM = 0x1800U, /**< TXPDO communication parameter */ + OD_H1A00_TXPDO_1_MAPPING = 0x1A00U, /**< TXPDO mapping parameters */ } OD_ObjDicId_30x_t; - /** * Attributes (bit masks) for OD sub-object. */ typedef enum { - ODA_SDO_R = 0x01U, /**< SDO server may read from the variable */ - ODA_SDO_W = 0x02U, /**< SDO server may write to the variable */ + ODA_SDO_R = 0x01U, /**< SDO server may read from the variable */ + ODA_SDO_W = 0x02U, /**< SDO server may write to the variable */ ODA_SDO_RW = 0x03U, /**< SDO server may read from or write to the variable */ - ODA_TPDO = 0x04U, /**< Variable is mappable into TPDO (can be read) */ - ODA_RPDO = 0x08U, /**< Variable is mappable into RPDO (can be written) */ - ODA_TRPDO = 0x0CU, /**< Variable is mappable into TPDO or RPDO */ - ODA_TSRDO = 0x10U, /**< Variable is mappable into transmitting SRDO */ - ODA_RSRDO = 0x20U, /**< Variable is mappable into receiving SRDO */ + ODA_TPDO = 0x04U, /**< Variable is mappable into TPDO (can be read) */ + ODA_RPDO = 0x08U, /**< Variable is mappable into RPDO (can be written) */ + ODA_TRPDO = 0x0CU, /**< Variable is mappable into TPDO or RPDO */ + ODA_TSRDO = 0x10U, /**< Variable is mappable into transmitting SRDO */ + ODA_RSRDO = 0x20U, /**< Variable is mappable into receiving SRDO */ ODA_TRSRDO = 0x30U, /**< Variable is mappable into tx or rx SRDO */ - ODA_MB = 0x40U, /**< Variable is multi-byte ((u)int16_t to (u)int64_t) */ - ODA_STR = 0x80U /**< Shorter value, than specified variable size, may be + ODA_MB = 0x40U, /**< Variable is multi-byte ((u)int16_t to (u)int64_t) */ + ODA_STR = 0x80U /**< Shorter value, than specified variable size, may be written to the variable. SDO write will fill remaining memory with zeroes. Attribute is used for VISIBLE_STRING and UNICODE_STRING. */ } OD_attributes_t; - /** * Return codes from OD access functions. * * @ref OD_getSDOabCode() can be used to retrieve corresponding SDO abort code. */ typedef enum { -/* !!!! WARNING !!!! + /* !!!! WARNING !!!! * If changing these values, change also OD_getSDOabCode() function! */ /** Read/write is only partial, make more calls */ @@ -196,7 +193,6 @@ typedef enum { ODR_COUNT = 26 } ODR_t; - /** * IO stream structure, used for read/write access to OD variable, part of * @ref OD_IO_t. @@ -206,11 +202,11 @@ typedef struct { * read/write functions operate on it. If memory for data object is not * specified by Object Dictionary, then dataOrig is NULL. */ - void *dataOrig; + void* dataOrig; /** Pointer to object, passed by @ref OD_extension_init(). Can be used * inside read / write functions from IO extension. */ - void *object; + void* object; /** Data length in bytes or 0, if length is not specified */ OD_size_t dataLength; /** In case of large data, dataOffset indicates position of already @@ -224,7 +220,6 @@ typedef struct { uint8_t subIndex; } OD_stream_t; - /** * Structure for input / output on the OD variable. It is initialized with * @ref OD_getSub() function. Access principle to OD variable is via read/write @@ -265,8 +260,7 @@ typedef struct { * * @return Value from @ref ODR_t, "ODR_OK" in case of success. */ - ODR_t (*read)(OD_stream_t *stream, void *buf, - OD_size_t count, OD_size_t *countRead); + ODR_t (*read)(OD_stream_t* stream, void* buf, OD_size_t count, OD_size_t* countRead); /** * Function pointer for writing value into specified variable inside Object * Dictionary. If OD variable is larger than buf, then this function must @@ -295,28 +289,24 @@ typedef struct { * * @return Value from @ref ODR_t, "ODR_OK" in case of success. */ - ODR_t (*write)(OD_stream_t *stream, const void *buf, - OD_size_t count, OD_size_t *countWritten); + ODR_t (*write)(OD_stream_t* stream, const void* buf, OD_size_t count, OD_size_t* countWritten); } OD_IO_t; - /** * Extension of OD object, which can optionally be specified by application in * initialization phase with @ref OD_extension_init() function. */ typedef struct { /** Object on which read and write will operate, part of @ref OD_stream_t */ - void *object; + void* object; /** Application specified read function pointer. If NULL, then read will be * disabled. @ref OD_readOriginal can be used here to keep the original read * function. For function description see @ref OD_IO_t. */ - ODR_t (*read)(OD_stream_t *stream, void *buf, - OD_size_t count, OD_size_t *countRead); + ODR_t (*read)(OD_stream_t* stream, void* buf, OD_size_t count, OD_size_t* countRead); /** Application specified write function pointer. If NULL, then write will * be disabled. @ref OD_writeOriginal can be used here to keep the original * write function. For function description see @ref OD_IO_t. */ - ODR_t (*write)(OD_stream_t *stream, const void *buf, - OD_size_t count, OD_size_t *countWritten); + ODR_t (*write)(OD_stream_t* stream, const void* buf, OD_size_t count, OD_size_t* countWritten); #if OD_FLAGS_PDO_SIZE > 0 /**PDO flags bit-field provides one bit for each OD variable, which exist * inside OD object at specific sub index. If application clears that bit, @@ -332,7 +322,6 @@ typedef struct { #endif } OD_extension_t; - /** * Object Dictionary entry for one OD object. * @@ -350,12 +339,11 @@ typedef struct { uint8_t odObjectType; /** OD object of type indicated by odObjectType, from which @ref OD_getSub() * fetches the information */ - CO_PROGMEM void *odObject; + CO_PROGMEM void* odObject; /** Extension to OD, specified by application */ - OD_extension_t *extension; + OD_extension_t* extension; } OD_entry_t; - /** * Object Dictionary */ @@ -363,10 +351,9 @@ typedef struct { /** Number of elements in the list, without last element, which is blank */ uint16_t size; /** List OD entries (table of contents), ordered by index */ - OD_entry_t *list; + OD_entry_t* list; } OD_t; - /** * Read value from original OD location * @@ -376,9 +363,7 @@ typedef struct { * io->read returned by @ref OD_getSub() equals to this function. See * also @ref OD_IO_t. */ -ODR_t OD_readOriginal(OD_stream_t *stream, void *buf, - OD_size_t count, OD_size_t *countRead); - +ODR_t OD_readOriginal(OD_stream_t* stream, void* buf, OD_size_t count, OD_size_t* countRead); /** * Write value to original OD location @@ -389,9 +374,7 @@ ODR_t OD_readOriginal(OD_stream_t *stream, void *buf, * io->write returned by @ref OD_getSub() equals to this function. See * also @ref OD_IO_t. */ -ODR_t OD_writeOriginal(OD_stream_t *stream, const void *buf, - OD_size_t count, OD_size_t *countWritten); - +ODR_t OD_writeOriginal(OD_stream_t* stream, const void* buf, OD_size_t count, OD_size_t* countWritten); /** * Find OD entry in Object Dictionary @@ -401,8 +384,7 @@ ODR_t OD_writeOriginal(OD_stream_t *stream, const void *buf, * * @return Pointer to OD entry or NULL if not found */ -OD_entry_t *OD_find(OD_t *od, uint16_t index); - +OD_entry_t* OD_find(OD_t* od, uint16_t index); /** * Find sub-object with specified sub-index on OD entry returned by OD_find. @@ -420,9 +402,7 @@ OD_entry_t *OD_find(OD_t *od, uint16_t index); * * @return Value from @ref ODR_t, "ODR_OK" in case of success. */ -ODR_t OD_getSub(const OD_entry_t *entry, uint8_t subIndex, - OD_IO_t *io, bool_t odOrig); - +ODR_t OD_getSub(const OD_entry_t* entry, uint8_t subIndex, OD_IO_t* io, bool_t odOrig); /** * Return index from OD entry @@ -431,11 +411,11 @@ ODR_t OD_getSub(const OD_entry_t *entry, uint8_t subIndex, * * @return OD index */ -static inline uint16_t OD_getIndex(const OD_entry_t *entry) { +static inline uint16_t +OD_getIndex(const OD_entry_t* entry) { return (entry != NULL) ? entry->index : 0U; } - /** * Check, if OD variable is mappable to PDO or SRDO. * @@ -446,12 +426,11 @@ static inline uint16_t OD_getIndex(const OD_entry_t *entry) { * * @return true, if OD variable is mappable. */ -static inline bool_t OD_mappable(OD_stream_t *stream) { - return (stream != NULL) - ? ((stream->attribute & ((OD_attr_t)ODA_TRPDO | (OD_attr_t)ODA_TRSRDO)) != 0U) : false; +static inline bool_t +OD_mappable(OD_stream_t* stream) { + return (stream != NULL) ? ((stream->attribute & ((OD_attr_t)ODA_TRPDO | (OD_attr_t)ODA_TRSRDO)) != 0U) : false; } - /** * Restart read or write operation on OD variable * @@ -461,11 +440,13 @@ static inline bool_t OD_mappable(OD_stream_t *stream) { * * @param stream Object Dictionary stream object. */ -static inline void OD_rwRestart(OD_stream_t *stream) { - if (stream != NULL) { stream->dataOffset = 0U; } +static inline void +OD_rwRestart(OD_stream_t* stream) { + if (stream != NULL) { + stream->dataOffset = 0U; + } } - /** * Get TPDO request flags for OD entry. * @@ -475,7 +456,8 @@ static inline void OD_rwRestart(OD_stream_t *stream) { * * @return pointer to flagsPDO */ -static inline uint8_t *OD_getFlagsPDO(OD_entry_t *entry) { +static inline uint8_t* +OD_getFlagsPDO(OD_entry_t* entry) { #if OD_FLAGS_PDO_SIZE > 0 if ((entry != NULL) && (entry->extension != NULL)) { return &entry->extension->flagsPDO[0]; @@ -484,7 +466,6 @@ static inline uint8_t *OD_getFlagsPDO(OD_entry_t *entry) { return NULL; } - /** * Request TPDO, to which OD variable is mapped * @@ -502,7 +483,8 @@ static inline uint8_t *OD_getFlagsPDO(OD_entry_t *entry) { * @param flagsPDO TPDO request flags returned by @ref OD_getFlagsPDO. * @param subIndex subIndex of the OD variable. */ -static inline void OD_requestTPDO(uint8_t *flagsPDO, uint8_t subIndex) { +static inline void +OD_requestTPDO(uint8_t* flagsPDO, uint8_t subIndex) { #if OD_FLAGS_PDO_SIZE > 0 if ((flagsPDO != NULL) && (subIndex < (OD_FLAGS_PDO_SIZE * 8U))) { /* clear subIndex-th bit */ @@ -512,7 +494,6 @@ static inline void OD_requestTPDO(uint8_t *flagsPDO, uint8_t subIndex) { #endif } - /** * Check if requested TPDO was transmitted * @@ -524,7 +505,8 @@ static inline void OD_requestTPDO(uint8_t *flagsPDO, uint8_t subIndex) { * @ref OD_requestTPDO call. If there was no @ref OD_requestTPDO call yet and * TPDO was transmitted by other event, function also returns true. */ -static inline bool_t OD_TPDOtransmitted(uint8_t *flagsPDO, uint8_t subIndex) { +static inline bool_t +OD_TPDOtransmitted(uint8_t* flagsPDO, uint8_t subIndex) { #if OD_FLAGS_PDO_SIZE > 0 if ((flagsPDO != NULL) && (subIndex < (OD_FLAGS_PDO_SIZE * 8U))) { /* return true, if subIndex-th bit is set */ @@ -537,7 +519,6 @@ static inline bool_t OD_TPDOtransmitted(uint8_t *flagsPDO, uint8_t subIndex) { return false; } - /** * Get SDO abort code from returnCode * @@ -547,7 +528,6 @@ static inline bool_t OD_TPDOtransmitted(uint8_t *flagsPDO, uint8_t subIndex) { */ uint32_t OD_getSDOabCode(ODR_t returnCode); - /** * Extend OD object with own read/write functions and/or flagsPDO * @@ -580,15 +560,15 @@ uint32_t OD_getSDOabCode(ODR_t returnCode); * * @return "ODR_OK" on success, "ODR_IDX_NOT_EXIST" if OD object doesn't exist. */ -static inline ODR_t OD_extension_init(OD_entry_t *entry, - OD_extension_t *extension) -{ - if (entry == NULL) { return ODR_IDX_NOT_EXIST; } +static inline ODR_t +OD_extension_init(OD_entry_t* entry, OD_extension_t* extension) { + if (entry == NULL) { + return ODR_IDX_NOT_EXIST; + } entry->extension = extension; return ODR_OK; } - /** * @defgroup CO_ODgetSetters Getters and setters * @{ @@ -610,76 +590,65 @@ static inline ODR_t OD_extension_init(OD_entry_t *entry, * variable does not exist in object dictionary or it does not have the correct * length or other reason. */ -ODR_t OD_get_value(const OD_entry_t *entry, uint8_t subIndex, - void *val, OD_size_t len, bool_t odOrig); +ODR_t OD_get_value(const OD_entry_t* entry, uint8_t subIndex, void* val, OD_size_t len, bool_t odOrig); /** Get int8_t variable from Object Dictionary, see @ref OD_get_value */ -static inline ODR_t OD_get_i8(const OD_entry_t *entry, uint8_t subIndex, - int8_t *val, bool_t odOrig) -{ +static inline ODR_t +OD_get_i8(const OD_entry_t* entry, uint8_t subIndex, int8_t* val, bool_t odOrig) { return OD_get_value(entry, subIndex, val, sizeof(*val), odOrig); } /** Get int16_t variable from Object Dictionary, see @ref OD_get_value */ -static inline ODR_t OD_get_i16(const OD_entry_t *entry, uint8_t subIndex, - int16_t *val, bool_t odOrig) -{ +static inline ODR_t +OD_get_i16(const OD_entry_t* entry, uint8_t subIndex, int16_t* val, bool_t odOrig) { return OD_get_value(entry, subIndex, val, sizeof(*val), odOrig); } /** Get int32_t variable from Object Dictionary, see @ref OD_get_value */ -static inline ODR_t OD_get_i32(const OD_entry_t *entry, uint8_t subIndex, - int32_t *val, bool_t odOrig) -{ +static inline ODR_t +OD_get_i32(const OD_entry_t* entry, uint8_t subIndex, int32_t* val, bool_t odOrig) { return OD_get_value(entry, subIndex, val, sizeof(*val), odOrig); } /** Get int64_t variable from Object Dictionary, see @ref OD_get_value */ -static inline ODR_t OD_get_i64(const OD_entry_t *entry, uint8_t subIndex, - int64_t *val, bool_t odOrig) -{ +static inline ODR_t +OD_get_i64(const OD_entry_t* entry, uint8_t subIndex, int64_t* val, bool_t odOrig) { return OD_get_value(entry, subIndex, val, sizeof(*val), odOrig); } /** Get uint8_t variable from Object Dictionary, see @ref OD_get_value */ -static inline ODR_t OD_get_u8(const OD_entry_t *entry, uint8_t subIndex, - uint8_t *val, bool_t odOrig) -{ +static inline ODR_t +OD_get_u8(const OD_entry_t* entry, uint8_t subIndex, uint8_t* val, bool_t odOrig) { return OD_get_value(entry, subIndex, val, sizeof(*val), odOrig); } /** Get uint16_t variable from Object Dictionary, see @ref OD_get_value */ -static inline ODR_t OD_get_u16(const OD_entry_t *entry, uint8_t subIndex, - uint16_t *val, bool_t odOrig) -{ +static inline ODR_t +OD_get_u16(const OD_entry_t* entry, uint8_t subIndex, uint16_t* val, bool_t odOrig) { return OD_get_value(entry, subIndex, val, sizeof(*val), odOrig); } /** Get uint32_t variable from Object Dictionary, see @ref OD_get_value */ -static inline ODR_t OD_get_u32(const OD_entry_t *entry, uint8_t subIndex, - uint32_t *val, bool_t odOrig) -{ +static inline ODR_t +OD_get_u32(const OD_entry_t* entry, uint8_t subIndex, uint32_t* val, bool_t odOrig) { return OD_get_value(entry, subIndex, val, sizeof(*val), odOrig); } /** Get uint64_t variable from Object Dictionary, see @ref OD_get_value */ -static inline ODR_t OD_get_u64(const OD_entry_t *entry, uint8_t subIndex, - uint64_t *val, bool_t odOrig) -{ +static inline ODR_t +OD_get_u64(const OD_entry_t* entry, uint8_t subIndex, uint64_t* val, bool_t odOrig) { return OD_get_value(entry, subIndex, val, sizeof(*val), odOrig); } /** Get float32_t variable from Object Dictionary, see @ref OD_get_value */ -static inline ODR_t OD_get_f32(const OD_entry_t *entry, uint8_t subIndex, - float32_t *val, bool_t odOrig) -{ +static inline ODR_t +OD_get_f32(const OD_entry_t* entry, uint8_t subIndex, float32_t* val, bool_t odOrig) { return OD_get_value(entry, subIndex, val, sizeof(*val), odOrig); } /** Get float64_t variable from Object Dictionary, see @ref OD_get_value */ -static inline ODR_t OD_get_f64(const OD_entry_t *entry, uint8_t subIndex, - float64_t *val, bool_t odOrig) -{ +static inline ODR_t +OD_get_f64(const OD_entry_t* entry, uint8_t subIndex, float64_t* val, bool_t odOrig) { return OD_get_value(entry, subIndex, val, sizeof(*val), odOrig); } @@ -697,76 +666,65 @@ static inline ODR_t OD_get_f64(const OD_entry_t *entry, uint8_t subIndex, * variable does not exist in object dictionary or it does not have the correct * length or other reason. */ -ODR_t OD_set_value(const OD_entry_t *entry, uint8_t subIndex, void *val, - OD_size_t len, bool_t odOrig); +ODR_t OD_set_value(const OD_entry_t* entry, uint8_t subIndex, void* val, OD_size_t len, bool_t odOrig); /** Set int8_t variable in Object Dictionary, see @ref OD_set_value */ -static inline ODR_t OD_set_i8(const OD_entry_t *entry, uint8_t subIndex, - int8_t val, bool_t odOrig) -{ +static inline ODR_t +OD_set_i8(const OD_entry_t* entry, uint8_t subIndex, int8_t val, bool_t odOrig) { return OD_set_value(entry, subIndex, &val, sizeof(val), odOrig); } /** Set int16_t variable in Object Dictionary, see @ref OD_set_value */ -static inline ODR_t OD_set_i16(const OD_entry_t *entry, uint8_t subIndex, - int16_t val, bool_t odOrig) -{ +static inline ODR_t +OD_set_i16(const OD_entry_t* entry, uint8_t subIndex, int16_t val, bool_t odOrig) { return OD_set_value(entry, subIndex, &val, sizeof(val), odOrig); } /** Set int32_t variable in Object Dictionary, see @ref OD_set_value */ -static inline ODR_t OD_set_i32(const OD_entry_t *entry, uint8_t subIndex, - int32_t val, bool_t odOrig) -{ +static inline ODR_t +OD_set_i32(const OD_entry_t* entry, uint8_t subIndex, int32_t val, bool_t odOrig) { return OD_set_value(entry, subIndex, &val, sizeof(val), odOrig); } /** Set int32_t variable in Object Dictionary, see @ref OD_set_value */ -static inline ODR_t OD_set_i64(const OD_entry_t *entry, uint8_t subIndex, - int64_t val, bool_t odOrig) -{ +static inline ODR_t +OD_set_i64(const OD_entry_t* entry, uint8_t subIndex, int64_t val, bool_t odOrig) { return OD_set_value(entry, subIndex, &val, sizeof(val), odOrig); } /** Set uint8_t variable in Object Dictionary, see @ref OD_set_value */ -static inline ODR_t OD_set_u8(const OD_entry_t *entry, uint8_t subIndex, - uint8_t val, bool_t odOrig) -{ +static inline ODR_t +OD_set_u8(const OD_entry_t* entry, uint8_t subIndex, uint8_t val, bool_t odOrig) { return OD_set_value(entry, subIndex, &val, sizeof(val), odOrig); } /** Set uint16_t variable in Object Dictionary, see @ref OD_set_value */ -static inline ODR_t OD_set_u16(const OD_entry_t *entry, uint8_t subIndex, - uint16_t val, bool_t odOrig) -{ +static inline ODR_t +OD_set_u16(const OD_entry_t* entry, uint8_t subIndex, uint16_t val, bool_t odOrig) { return OD_set_value(entry, subIndex, &val, sizeof(val), odOrig); } /** Set uint32_t variable in Object Dictionary, see @ref OD_set_value */ -static inline ODR_t OD_set_u32(const OD_entry_t *entry, uint8_t subIndex, - uint32_t val, bool_t odOrig) -{ +static inline ODR_t +OD_set_u32(const OD_entry_t* entry, uint8_t subIndex, uint32_t val, bool_t odOrig) { return OD_set_value(entry, subIndex, &val, sizeof(val), odOrig); } /** Set uint64_t variable in Object Dictionary, see @ref OD_set_value */ -static inline ODR_t OD_set_u64(const OD_entry_t *entry, uint8_t subIndex, - uint64_t val, bool_t odOrig) -{ +static inline ODR_t +OD_set_u64(const OD_entry_t* entry, uint8_t subIndex, uint64_t val, bool_t odOrig) { return OD_set_value(entry, subIndex, &val, sizeof(val), odOrig); } /** Set float32_t variable in Object Dictionary, see @ref OD_set_value */ -static inline ODR_t OD_set_f32(const OD_entry_t *entry, uint8_t subIndex, - float32_t val, bool_t odOrig) -{ +static inline ODR_t +OD_set_f32(const OD_entry_t* entry, uint8_t subIndex, float32_t val, bool_t odOrig) { return OD_set_value(entry, subIndex, &val, sizeof(val), odOrig); } /** Set float64_t variable in Object Dictionary, see @ref OD_set_value */ -static inline ODR_t OD_set_f64(const OD_entry_t *entry, uint8_t subIndex, - float64_t val, bool_t odOrig) -{ +static inline ODR_t +OD_set_f64(const OD_entry_t* entry, uint8_t subIndex, float64_t val, bool_t odOrig) { return OD_set_value(entry, subIndex, &val, sizeof(val), odOrig); } @@ -785,11 +743,9 @@ static inline ODR_t OD_set_f64(const OD_entry_t *entry, uint8_t subIndex, * * @return Pointer to variable in Object Dictionary or NULL in case of error. */ -void *OD_getPtr(const OD_entry_t *entry, uint8_t subIndex, OD_size_t len, - ODR_t *err); +void* OD_getPtr(const OD_entry_t* entry, uint8_t subIndex, OD_size_t len, ODR_t* err); /** @} */ /* CO_ODgetSetters */ - #if defined OD_DEFINITION || defined CO_DOXYGEN /** * @defgroup CO_ODdefinition OD definition objects @@ -827,8 +783,8 @@ typedef enum { * Object for single OD variable, used for "VAR" type OD objects */ typedef struct { - void *dataOrig; /**< Pointer to data */ - OD_attr_t attribute; /**< Attribute bitfield, see @ref OD_attributes_t */ + void* dataOrig; /**< Pointer to data */ + OD_attr_t attribute; /**< Attribute bitfield, see @ref OD_attributes_t */ OD_size_t dataLength; /**< Data length in bytes */ } OD_obj_var_t; @@ -836,11 +792,11 @@ typedef struct { * Object for OD array of variables, used for "ARRAY" type OD objects */ typedef struct { - uint8_t *dataOrig0; /**< Pointer to data for sub-index 0 */ - void *dataOrig; /**< Pointer to array of data */ - OD_attr_t attribute0; /**< Attribute bitfield for sub-index 0, see + uint8_t* dataOrig0; /**< Pointer to data for sub-index 0 */ + void* dataOrig; /**< Pointer to array of data */ + OD_attr_t attribute0; /**< Attribute bitfield for sub-index 0, see @ref OD_attributes_t */ - OD_attr_t attribute; /**< Attribute bitfield for array elements */ + OD_attr_t attribute; /**< Attribute bitfield for array elements */ OD_size_t dataElementLength; /**< Data length of array elements in bytes */ OD_size_t dataElementSizeof; /**< Sizeof one array element in bytes */ } OD_obj_array_t; @@ -849,9 +805,9 @@ typedef struct { * Object for OD sub-elements, used in "RECORD" type OD objects */ typedef struct { - void *dataOrig; /**< Pointer to data */ - uint8_t subIndex; /**< Sub index of element. */ - OD_attr_t attribute; /**< Attribute bitfield, see @ref OD_attributes_t */ + void* dataOrig; /**< Pointer to data */ + uint8_t subIndex; /**< Sub index of element. */ + OD_attr_t attribute; /**< Attribute bitfield, see @ref OD_attributes_t */ OD_size_t dataLength; /**< Data length in bytes */ } OD_obj_record_t; diff --git a/301/CO_PDO.h b/301/CO_PDO.h index ff73845..55d1ad4 100644 --- a/301/CO_PDO.h +++ b/301/CO_PDO.h @@ -27,15 +27,10 @@ /* default configuration, see CO_config.h */ #ifndef CO_CONFIG_PDO -#define CO_CONFIG_PDO (CO_CONFIG_RPDO_ENABLE | \ - CO_CONFIG_TPDO_ENABLE | \ - CO_CONFIG_RPDO_TIMERS_ENABLE | \ - CO_CONFIG_TPDO_TIMERS_ENABLE | \ - CO_CONFIG_PDO_SYNC_ENABLE | \ - CO_CONFIG_PDO_OD_IO_ACCESS | \ - CO_CONFIG_GLOBAL_RT_FLAG_CALLBACK_PRE | \ - CO_CONFIG_GLOBAL_FLAG_TIMERNEXT | \ - CO_CONFIG_GLOBAL_FLAG_OD_DYNAMIC) +#define CO_CONFIG_PDO \ + (CO_CONFIG_RPDO_ENABLE | CO_CONFIG_TPDO_ENABLE | CO_CONFIG_RPDO_TIMERS_ENABLE | CO_CONFIG_TPDO_TIMERS_ENABLE \ + | CO_CONFIG_PDO_SYNC_ENABLE | CO_CONFIG_PDO_OD_IO_ACCESS | CO_CONFIG_GLOBAL_RT_FLAG_CALLBACK_PRE \ + | CO_CONFIG_GLOBAL_FLAG_TIMERNEXT | CO_CONFIG_GLOBAL_FLAG_OD_DYNAMIC) #endif #if (((CO_CONFIG_PDO) & (CO_CONFIG_RPDO_ENABLE | CO_CONFIG_TPDO_ENABLE)) != 0) || defined CO_DOXYGEN @@ -168,13 +163,13 @@ typedef uint8_t CO_PDO_size_t; * PDO transmission Types */ typedef enum { - CO_PDO_TRANSM_TYPE_SYNC_ACYCLIC = 0U, /**< synchronous (acyclic) */ - CO_PDO_TRANSM_TYPE_SYNC_1 = 1U, /**< synchronous (cyclic every sync) */ - CO_PDO_TRANSM_TYPE_SYNC_240 = 0xF0U, /**< synchronous (cyclic every 240-th + CO_PDO_TRANSM_TYPE_SYNC_ACYCLIC = 0U, /**< synchronous (acyclic) */ + CO_PDO_TRANSM_TYPE_SYNC_1 = 1U, /**< synchronous (cyclic every sync) */ + CO_PDO_TRANSM_TYPE_SYNC_240 = 0xF0U, /**< synchronous (cyclic every 240-th sync) */ CO_PDO_TRANSM_TYPE_SYNC_EVENT_LO = 0xFEU, /**< event-driven, lower value (manufacturer specific), */ - CO_PDO_TRANSM_TYPE_SYNC_EVENT_HI = 0xFFU /**< event-driven, higher value + CO_PDO_TRANSM_TYPE_SYNC_EVENT_HI = 0xFFU /**< event-driven, higher value (device profile and application profile specific) */ } CO_PDO_transmissionTypes_t; @@ -183,16 +178,16 @@ typedef enum { */ typedef struct { /** From CO_xPDO_init() */ - CO_EM_t *em; + CO_EM_t* em; /** From CO_xPDO_init() */ - CO_CANmodule_t *CANdev; + CO_CANmodule_t* CANdev; /** True, if PDO is enabled and valid */ bool_t valid; /** Data length of the received PDO message. Calculated from mapping */ CO_PDO_size_t dataLength; /** Number of mapped objects in PDO */ uint8_t mappedObjectsCount; -#if (((CO_CONFIG_PDO) & CO_CONFIG_PDO_OD_IO_ACCESS) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_PDO)&CO_CONFIG_PDO_OD_IO_ACCESS) != 0) || defined CO_DOXYGEN /** Object dictionary interface for all mapped entries. OD_IO.dataOffset has * special usage with PDO. It stores information about mappedLength of * the variable. mappedLength can be less or equal to the OD_IO.dataLength. @@ -200,25 +195,25 @@ typedef struct { * OD_IO.dataOffset is set to 0 before read/write function call and after * the call OD_IO.dataOffset is set back to mappedLength. */ OD_IO_t OD_IO[CO_PDO_MAX_MAPPED_ENTRIES]; - #if OD_FLAGS_PDO_SIZE > 0 +#if OD_FLAGS_PDO_SIZE > 0 /** Pointer to byte, which contains PDO flag bit from @ref OD_extension_t */ - uint8_t *flagPDObyte[CO_PDO_MAX_MAPPED_ENTRIES]; + uint8_t* flagPDObyte[CO_PDO_MAX_MAPPED_ENTRIES]; /** Bitmask for the flagPDObyte */ uint8_t flagPDObitmask[CO_PDO_MAX_MAPPED_ENTRIES]; - #endif +#endif #else /* Pointers to data objects inside OD, where PDO will be copied */ - uint8_t *mapPointer[CO_PDO_MAX_SIZE]; - #if OD_FLAGS_PDO_SIZE > 0 - uint8_t *flagPDObyte[CO_PDO_MAX_SIZE]; + uint8_t* mapPointer[CO_PDO_MAX_SIZE]; +#if OD_FLAGS_PDO_SIZE > 0 + uint8_t* flagPDObyte[CO_PDO_MAX_SIZE]; uint8_t flagPDObitmask[CO_PDO_MAX_SIZE]; - #endif #endif -#if (((CO_CONFIG_PDO) & CO_CONFIG_FLAG_OD_DYNAMIC) != 0) || defined CO_DOXYGEN +#endif +#if (((CO_CONFIG_PDO)&CO_CONFIG_FLAG_OD_DYNAMIC) != 0) || defined CO_DOXYGEN /** True for RPDO, false for TPDO */ bool_t isRPDO; /** From CO_xPDO_init() */ - OD_t *OD; + OD_t* OD; /** From CO_xPDO_init() */ uint16_t CANdevIdx; /** From CO_xPDO_init() */ @@ -232,21 +227,19 @@ typedef struct { #endif } CO_PDO_common_t; - /******************************************************************************* * R P D O ******************************************************************************/ -#if (((CO_CONFIG_PDO) & CO_CONFIG_RPDO_ENABLE) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_PDO)&CO_CONFIG_RPDO_ENABLE) != 0) || defined CO_DOXYGEN /** * Number of buffers for received CAN message for RPDO */ -#if (((CO_CONFIG_PDO) & CO_CONFIG_PDO_SYNC_ENABLE) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_PDO)&CO_CONFIG_PDO_SYNC_ENABLE) != 0) || defined CO_DOXYGEN #define CO_RPDO_CAN_BUFFERS_COUNT 2 #else #define CO_RPDO_CAN_BUFFERS_COUNT 1 #endif - /** * RPDO object. */ @@ -254,33 +247,32 @@ typedef struct { /** PDO common properties, must be first element in this object */ CO_PDO_common_t PDO_common; /** Variable indicates, if new PDO message received from CAN bus. */ - volatile void *CANrxNew[CO_RPDO_CAN_BUFFERS_COUNT]; + volatile void* CANrxNew[CO_RPDO_CAN_BUFFERS_COUNT]; /** CO_PDO_MAX_SIZE data bytes of the received message. */ uint8_t CANrxData[CO_RPDO_CAN_BUFFERS_COUNT][CO_PDO_MAX_SIZE]; /** Indication of RPDO length errors, use with CO_PDO_receiveErrors_t */ uint8_t receiveError; -#if (((CO_CONFIG_PDO) & CO_CONFIG_PDO_SYNC_ENABLE) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_PDO)&CO_CONFIG_PDO_SYNC_ENABLE) != 0) || defined CO_DOXYGEN /** From CO_RPDO_init() */ - CO_SYNC_t *SYNC; + CO_SYNC_t* SYNC; /** True if transmissionType <= 240 */ bool_t synchronous; #endif -#if (((CO_CONFIG_PDO) & CO_CONFIG_RPDO_TIMERS_ENABLE) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_PDO)&CO_CONFIG_RPDO_TIMERS_ENABLE) != 0) || defined CO_DOXYGEN /** Maximum timeout time between received PDOs in microseconds. Configurable * by OD variable RPDO communication parameter, event-timer. */ uint32_t timeoutTime_us; /** Timeout timer variable in microseconds */ uint32_t timeoutTimer; #endif -#if (((CO_CONFIG_PDO) & CO_CONFIG_FLAG_CALLBACK_PRE) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_PDO)&CO_CONFIG_FLAG_CALLBACK_PRE) != 0) || defined CO_DOXYGEN /** From CO_RPDO_initCallbackPre() or NULL */ - void (*pFunctSignalPre)(void *object); + void (*pFunctSignalPre)(void* object); /** From CO_RPDO_initCallbackPre() or NULL */ - void *functSignalObjectPre; + void* functSignalObjectPre; #endif } CO_RPDO_t; - /** * Initialize RPDO object. * @@ -304,21 +296,14 @@ typedef struct { * * @return #CO_ReturnError_t CO_ERROR_NO on success. */ -CO_ReturnError_t CO_RPDO_init(CO_RPDO_t *RPDO, - OD_t *OD, - CO_EM_t *em, -#if (((CO_CONFIG_PDO) & CO_CONFIG_PDO_SYNC_ENABLE) != 0) || defined CO_DOXYGEN - CO_SYNC_t *SYNC, +CO_ReturnError_t CO_RPDO_init(CO_RPDO_t* RPDO, OD_t* OD, CO_EM_t* em, +#if (((CO_CONFIG_PDO)&CO_CONFIG_PDO_SYNC_ENABLE) != 0) || defined CO_DOXYGEN + CO_SYNC_t* SYNC, #endif - uint16_t preDefinedCanId, - OD_entry_t *OD_14xx_RPDOCommPar, - OD_entry_t *OD_16xx_RPDOMapPar, - CO_CANmodule_t *CANdevRx, - uint16_t CANdevRxIdx, - uint32_t *errInfo); + uint16_t preDefinedCanId, OD_entry_t* OD_14xx_RPDOCommPar, OD_entry_t* OD_16xx_RPDOMapPar, + CO_CANmodule_t* CANdevRx, uint16_t CANdevRxIdx, uint32_t* errInfo); - -#if (((CO_CONFIG_PDO) & CO_CONFIG_FLAG_CALLBACK_PRE) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_PDO)&CO_CONFIG_FLAG_CALLBACK_PRE) != 0) || defined CO_DOXYGEN /** * Initialize RPDO callback function. * @@ -330,12 +315,9 @@ CO_ReturnError_t CO_RPDO_init(CO_RPDO_t *RPDO, * @param object Pointer to object, which will be passed to pFunctSignalPre(). * @param pFunctSignalPre Pointer to the callback function. Not called if NULL. */ -void CO_RPDO_initCallbackPre(CO_RPDO_t *RPDO, - void *object, - void (*pFunctSignalPre)(void *object)); +void CO_RPDO_initCallbackPre(CO_RPDO_t* RPDO, void* object, void (*pFunctSignalPre)(void* object)); #endif - /** * Process received PDO messages. * @@ -351,20 +333,17 @@ void CO_RPDO_initCallbackPre(CO_RPDO_t *RPDO, * @param syncWas True, if CANopen SYNC message was just received or * transmitted. */ -void CO_RPDO_process(CO_RPDO_t *RPDO, -#if (((CO_CONFIG_PDO) & CO_CONFIG_RPDO_TIMERS_ENABLE) != 0) || defined CO_DOXYGEN - uint32_t timeDifference_us, - uint32_t *timerNext_us, +void CO_RPDO_process(CO_RPDO_t* RPDO, +#if (((CO_CONFIG_PDO)&CO_CONFIG_RPDO_TIMERS_ENABLE) != 0) || defined CO_DOXYGEN + uint32_t timeDifference_us, uint32_t* timerNext_us, #endif - bool_t NMTisOperational, - bool_t syncWas); + bool_t NMTisOperational, bool_t syncWas); #endif /* (CO_CONFIG_PDO) & CO_CONFIG_RPDO_ENABLE */ - /******************************************************************************* * T P D O ******************************************************************************/ -#if (((CO_CONFIG_PDO) & CO_CONFIG_TPDO_ENABLE) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_PDO)&CO_CONFIG_TPDO_ENABLE) != 0) || defined CO_DOXYGEN /** * TPDO object. */ @@ -372,21 +351,21 @@ typedef struct { /** PDO common properties, must be first element in this object */ CO_PDO_common_t PDO_common; /** CAN transmit buffer inside CANdev */ - CO_CANtx_t *CANtxBuff; + CO_CANtx_t* CANtxBuff; /** Copy of the variable from object dictionary */ uint8_t transmissionType; /** If this flag is set and TPDO is event driven (transmission type is 0, * 254 or 255), then PDO will be sent by CO_TPDO_process(). */ bool_t sendRequest; -#if (((CO_CONFIG_PDO) & CO_CONFIG_PDO_SYNC_ENABLE) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_PDO)&CO_CONFIG_PDO_SYNC_ENABLE) != 0) || defined CO_DOXYGEN /** From CO_TPDO_init() */ - CO_SYNC_t *SYNC; + CO_SYNC_t* SYNC; /** Copy of the variable from object dictionary */ uint8_t syncStartValue; /** SYNC counter used for PDO sending */ uint8_t syncCounter; #endif -#if (((CO_CONFIG_PDO) & CO_CONFIG_TPDO_TIMERS_ENABLE) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_PDO)&CO_CONFIG_TPDO_TIMERS_ENABLE) != 0) || defined CO_DOXYGEN /** Inhibit time from object dictionary translated to microseconds */ uint32_t inhibitTime_us; /** Event time from object dictionary translated to microseconds */ @@ -398,7 +377,6 @@ typedef struct { #endif } CO_TPDO_t; - /** * Initialize TPDO object. * @@ -422,19 +400,12 @@ typedef struct { * * @return #CO_ReturnError_t CO_ERROR_NO on success. */ -CO_ReturnError_t CO_TPDO_init(CO_TPDO_t *TPDO, - OD_t *OD, - CO_EM_t *em, -#if (((CO_CONFIG_PDO) & CO_CONFIG_PDO_SYNC_ENABLE) != 0) || defined CO_DOXYGEN - CO_SYNC_t *SYNC, +CO_ReturnError_t CO_TPDO_init(CO_TPDO_t* TPDO, OD_t* OD, CO_EM_t* em, +#if (((CO_CONFIG_PDO)&CO_CONFIG_PDO_SYNC_ENABLE) != 0) || defined CO_DOXYGEN + CO_SYNC_t* SYNC, #endif - uint16_t preDefinedCanId, - OD_entry_t *OD_18xx_TPDOCommPar, - OD_entry_t *OD_1Axx_TPDOMapPar, - CO_CANmodule_t *CANdevTx, - uint16_t CANdevTxIdx, - uint32_t *errInfo); - + uint16_t preDefinedCanId, OD_entry_t* OD_18xx_TPDOCommPar, OD_entry_t* OD_1Axx_TPDOMapPar, + CO_CANmodule_t* CANdevTx, uint16_t CANdevTxIdx, uint32_t* errInfo); /** * Request transmission of TPDO message. @@ -445,11 +416,13 @@ CO_ReturnError_t CO_TPDO_init(CO_TPDO_t *TPDO, * * @param TPDO TPDO object. */ -static inline void CO_TPDOsendRequest(CO_TPDO_t *TPDO) { - if (TPDO != NULL) { TPDO->sendRequest = true; } +static inline void +CO_TPDOsendRequest(CO_TPDO_t* TPDO) { + if (TPDO != NULL) { + TPDO->sendRequest = true; + } } - /** * Process transmitting PDO messages. * @@ -463,13 +436,11 @@ static inline void CO_TPDOsendRequest(CO_TPDO_t *TPDO) { * @param syncWas True, if CANopen SYNC message was just received or * transmitted. */ -void CO_TPDO_process(CO_TPDO_t *TPDO, -#if (((CO_CONFIG_PDO) & CO_CONFIG_TPDO_TIMERS_ENABLE) != 0) || defined CO_DOXYGEN - uint32_t timeDifference_us, - uint32_t *timerNext_us, +void CO_TPDO_process(CO_TPDO_t* TPDO, +#if (((CO_CONFIG_PDO)&CO_CONFIG_TPDO_TIMERS_ENABLE) != 0) || defined CO_DOXYGEN + uint32_t timeDifference_us, uint32_t* timerNext_us, #endif - bool_t NMTisOperational, - bool_t syncWas); + bool_t NMTisOperational, bool_t syncWas); #endif /* (CO_CONFIG_PDO) & CO_CONFIG_TPDO_ENABLE */ /** @} */ /* CO_PDO */ diff --git a/301/CO_SDOclient.h b/301/CO_SDOclient.h index f4cac5c..df096cd 100644 --- a/301/CO_SDOclient.h +++ b/301/CO_SDOclient.h @@ -32,14 +32,14 @@ #define CO_CONFIG_SDO_CLI (0) #endif #ifndef CO_CONFIG_SDO_CLI_BUFFER_SIZE - #if ((CO_CONFIG_SDO_CLI) & CO_CONFIG_SDO_CLI_BLOCK) != 0 - #define CO_CONFIG_SDO_CLI_BUFFER_SIZE 1000U - #else - #define CO_CONFIG_SDO_CLI_BUFFER_SIZE 32U - #endif +#if ((CO_CONFIG_SDO_CLI)&CO_CONFIG_SDO_CLI_BLOCK) != 0 +#define CO_CONFIG_SDO_CLI_BUFFER_SIZE 1000U +#else +#define CO_CONFIG_SDO_CLI_BUFFER_SIZE 32U +#endif #endif -#if (((CO_CONFIG_SDO_CLI) & CO_CONFIG_SDO_CLI_ENABLE) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_SDO_CLI)&CO_CONFIG_SDO_CLI_ENABLE) != 0) || defined CO_DOXYGEN #ifdef __cplusplus extern "C" { @@ -164,30 +164,29 @@ CO_SDO_abortCode_t write_SDO(CO_SDOclient_t *SDO_C, uint8_t nodeId, * @see @ref CO_SDOserver */ - /** * SDO client object */ typedef struct { -#if (((CO_CONFIG_SDO_CLI) & CO_CONFIG_SDO_CLI_LOCAL) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_SDO_CLI)&CO_CONFIG_SDO_CLI_LOCAL) != 0) || defined CO_DOXYGEN /** From CO_SDOclient_init() */ - OD_t *OD; + OD_t* OD; /** From CO_SDOclient_init() */ uint8_t nodeId; /** Object dictionary interface for locally transferred object */ OD_IO_t OD_IO; #endif /** From CO_SDOclient_init() */ - CO_CANmodule_t *CANdevRx; + CO_CANmodule_t* CANdevRx; /** From CO_SDOclient_init() */ uint16_t CANdevRxIdx; /** From CO_SDOclient_init() */ - CO_CANmodule_t *CANdevTx; + CO_CANmodule_t* CANdevTx; /** From CO_SDOclient_init() */ uint16_t CANdevTxIdx; /** CAN transmit buffer inside CANdevTx for CAN tx message */ - CO_CANtx_t *CANtxBuff; -#if (((CO_CONFIG_SDO_CLI) & CO_CONFIG_FLAG_OD_DYNAMIC) != 0) || defined CO_DOXYGEN + CO_CANtx_t* CANtxBuff; +#if (((CO_CONFIG_SDO_CLI)&CO_CONFIG_FLAG_OD_DYNAMIC) != 0) || defined CO_DOXYGEN /** Copy of CANopen COB_ID Client -> Server, meaning of the specific bits: - Bit 0...10: 11-bit CAN identifier. - Bit 11..30: reserved, must be 0. @@ -226,20 +225,20 @@ typedef struct { uint8_t buf[CO_CONFIG_SDO_CLI_BUFFER_SIZE + 1U]; /** Indicates, if new SDO message received from CAN bus. It is not cleared, * until received message is completely processed. */ - volatile void *CANrxNew; + volatile void* CANrxNew; /** 8 data bytes of the received message */ uint8_t CANrxData[8]; -#if (((CO_CONFIG_SDO_CLI) & CO_CONFIG_FLAG_CALLBACK_PRE) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_SDO_CLI)&CO_CONFIG_FLAG_CALLBACK_PRE) != 0) || defined CO_DOXYGEN /** From CO_SDOclient_initCallbackPre() or NULL */ - void (*pFunctSignal)(void *object); + void (*pFunctSignal)(void* object); /** From CO_SDOclient_initCallbackPre() or NULL */ - void *functSignalObject; + void* functSignalObject; #endif -#if (((CO_CONFIG_SDO_CLI) & CO_CONFIG_SDO_CLI_SEGMENTED) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_SDO_CLI)&CO_CONFIG_SDO_CLI_SEGMENTED) != 0) || defined CO_DOXYGEN /** Toggle bit toggled in each segment in segmented transfer */ uint8_t toggle; #endif -#if (((CO_CONFIG_SDO_CLI) & CO_CONFIG_SDO_CLI_BLOCK) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_SDO_CLI)&CO_CONFIG_SDO_CLI_BLOCK) != 0) || defined CO_DOXYGEN /** Timeout time for SDO sub-block upload, half of #SDOtimeoutTime_us */ uint32_t block_SDOtimeoutTime_us; /** Timeout timer for SDO sub-block upload */ @@ -259,7 +258,6 @@ typedef struct { #endif } CO_SDOclient_t; - /** * Initialize SDO client object. * @@ -281,18 +279,11 @@ typedef struct { * * @return #CO_ReturnError_t: CO_ERROR_NO or CO_ERROR_ILLEGAL_ARGUMENT. */ -CO_ReturnError_t CO_SDOclient_init(CO_SDOclient_t *SDO_C, - OD_t *OD, - OD_entry_t *OD_1280_SDOcliPar, - uint8_t nodeId, - CO_CANmodule_t *CANdevRx, - uint16_t CANdevRxIdx, - CO_CANmodule_t *CANdevTx, - uint16_t CANdevTxIdx, - uint32_t *errInfo); +CO_ReturnError_t CO_SDOclient_init(CO_SDOclient_t* SDO_C, OD_t* OD, OD_entry_t* OD_1280_SDOcliPar, uint8_t nodeId, + CO_CANmodule_t* CANdevRx, uint16_t CANdevRxIdx, CO_CANmodule_t* CANdevTx, + uint16_t CANdevTxIdx, uint32_t* errInfo); - -#if (((CO_CONFIG_SDO_CLI) & CO_CONFIG_FLAG_CALLBACK_PRE) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_SDO_CLI)&CO_CONFIG_FLAG_CALLBACK_PRE) != 0) || defined CO_DOXYGEN /** * Initialize SDOclient callback function. * @@ -307,12 +298,9 @@ CO_ReturnError_t CO_SDOclient_init(CO_SDOclient_t *SDO_C, * be NULL. * @param pFunctSignal Pointer to the callback function. Not called if NULL. */ -void CO_SDOclient_initCallbackPre(CO_SDOclient_t *SDOclient, - void *object, - void (*pFunctSignal)(void *object)); +void CO_SDOclient_initCallbackPre(CO_SDOclient_t* SDOclient, void* object, void (*pFunctSignal)(void* object)); #endif - /** * Setup SDO client object. * @@ -331,12 +319,9 @@ void CO_SDOclient_initCallbackPre(CO_SDOclient_t *SDOclient, * @return #CO_SDO_return_t, CO_SDO_RT_ok_communicationEnd or * CO_SDO_RT_wrongArguments */ -CO_SDO_return_t CO_SDOclient_setup(CO_SDOclient_t *SDO_C, - uint32_t COB_IDClientToServer, - uint32_t COB_IDServerToClient, +CO_SDO_return_t CO_SDOclient_setup(CO_SDOclient_t* SDO_C, uint32_t COB_IDClientToServer, uint32_t COB_IDServerToClient, uint8_t nodeIDOfTheSDOServer); - /** * Initiate SDO download communication. * @@ -361,13 +346,8 @@ CO_SDO_return_t CO_SDOclient_setup(CO_SDOclient_t *SDO_C, * * @return #CO_SDO_return_t */ -CO_SDO_return_t CO_SDOclientDownloadInitiate(CO_SDOclient_t *SDO_C, - uint16_t index, - uint8_t subIndex, - size_t sizeIndicated, - uint16_t SDOtimeoutTime_ms, - bool_t blockEnable); - +CO_SDO_return_t CO_SDOclientDownloadInitiate(CO_SDOclient_t* SDO_C, uint16_t index, uint8_t subIndex, + size_t sizeIndicated, uint16_t SDOtimeoutTime_ms, bool_t blockEnable); /** * Initiate SDO download communication - update size. @@ -380,9 +360,7 @@ CO_SDO_return_t CO_SDOclientDownloadInitiate(CO_SDOclient_t *SDO_C, * @param SDO_C This object. * @param sizeIndicated Same as in CO_SDOclientDownloadInitiate(). */ -void CO_SDOclientDownloadInitSize(CO_SDOclient_t *SDO_C, - size_t sizeIndicated); - +void CO_SDOclientDownloadInitSize(CO_SDOclient_t* SDO_C, size_t sizeIndicated); /** * Write data into SDO client buffer @@ -403,10 +381,7 @@ void CO_SDOclientDownloadInitSize(CO_SDOclient_t *SDO_C, * * @return number of bytes actually written. */ -size_t CO_SDOclientDownloadBufWrite(CO_SDOclient_t *SDO_C, - const uint8_t *buf, - size_t count); - +size_t CO_SDOclientDownloadBufWrite(CO_SDOclient_t* SDO_C, const uint8_t* buf, size_t count); /** * Process SDO download communication. @@ -436,14 +411,9 @@ size_t CO_SDOclientDownloadBufWrite(CO_SDOclient_t *SDO_C, * ends successfully and state becomes idle. If greater than 0, then * communication is in progress. */ -CO_SDO_return_t CO_SDOclientDownload(CO_SDOclient_t *SDO_C, - uint32_t timeDifference_us, - bool_t send_abort, - bool_t bufferPartial, - CO_SDO_abortCode_t *SDOabortCode, - size_t *sizeTransferred, - uint32_t *timerNext_us); - +CO_SDO_return_t CO_SDOclientDownload(CO_SDOclient_t* SDO_C, uint32_t timeDifference_us, bool_t send_abort, + bool_t bufferPartial, CO_SDO_abortCode_t* SDOabortCode, size_t* sizeTransferred, + uint32_t* timerNext_us); /** * Initiate SDO upload communication. @@ -460,12 +430,8 @@ CO_SDO_return_t CO_SDOclientDownload(CO_SDOclient_t *SDO_C, * * @return #CO_SDO_return_t */ -CO_SDO_return_t CO_SDOclientUploadInitiate(CO_SDOclient_t *SDO_C, - uint16_t index, - uint8_t subIndex, - uint16_t SDOtimeoutTime_ms, - bool_t blockEnable); - +CO_SDO_return_t CO_SDOclientUploadInitiate(CO_SDOclient_t* SDO_C, uint16_t index, uint8_t subIndex, + uint16_t SDOtimeoutTime_ms, bool_t blockEnable); /** * Process SDO upload communication. @@ -497,14 +463,9 @@ CO_SDO_return_t CO_SDOclientUploadInitiate(CO_SDOclient_t *SDO_C, * ends successfully and state becomes idle. If greater than 0, then * communication is in progress. */ -CO_SDO_return_t CO_SDOclientUpload(CO_SDOclient_t *SDO_C, - uint32_t timeDifference_us, - bool_t send_abort, - CO_SDO_abortCode_t *SDOabortCode, - size_t *sizeIndicated, - size_t *sizeTransferred, - uint32_t *timerNext_us); - +CO_SDO_return_t CO_SDOclientUpload(CO_SDOclient_t* SDO_C, uint32_t timeDifference_us, bool_t send_abort, + CO_SDO_abortCode_t* SDOabortCode, size_t* sizeIndicated, size_t* sizeTransferred, + uint32_t* timerNext_us); /** * Read data from SDO client buffer. @@ -526,10 +487,7 @@ CO_SDO_return_t CO_SDOclientUpload(CO_SDOclient_t *SDO_C, * * @return number of bytes actually read. */ -size_t CO_SDOclientUploadBufRead(CO_SDOclient_t *SDO_C, - uint8_t *buf, - size_t count); - +size_t CO_SDOclientUploadBufRead(CO_SDOclient_t* SDO_C, uint8_t* buf, size_t count); /** * Close SDO communication temporary. @@ -540,7 +498,7 @@ size_t CO_SDOclientUploadBufRead(CO_SDOclient_t *SDO_C, * * @param SDO_C This object. */ -void CO_SDOclientClose(CO_SDOclient_t *SDO_C); +void CO_SDOclientClose(CO_SDOclient_t* SDO_C); /** @} */ /* CO_SDOclient */ diff --git a/301/CO_SDOserver.h b/301/CO_SDOserver.h index ed78609..3e29a9e 100644 --- a/301/CO_SDOserver.h +++ b/301/CO_SDOserver.h @@ -26,10 +26,9 @@ /* default configuration, see CO_config.h */ #ifndef CO_CONFIG_SDO_SRV -#define CO_CONFIG_SDO_SRV (CO_CONFIG_SDO_SRV_SEGMENTED | \ - CO_CONFIG_GLOBAL_FLAG_CALLBACK_PRE | \ - CO_CONFIG_GLOBAL_FLAG_TIMERNEXT | \ - CO_CONFIG_GLOBAL_FLAG_OD_DYNAMIC) +#define CO_CONFIG_SDO_SRV \ + (CO_CONFIG_SDO_SRV_SEGMENTED | CO_CONFIG_GLOBAL_FLAG_CALLBACK_PRE | CO_CONFIG_GLOBAL_FLAG_TIMERNEXT \ + | CO_CONFIG_GLOBAL_FLAG_OD_DYNAMIC) #endif #ifndef CO_CONFIG_SDO_SRV_BUFFER_SIZE #define CO_CONFIG_SDO_SRV_BUFFER_SIZE 32U @@ -76,16 +75,15 @@ extern "C" { * Access to Object dictionary is specified in @ref CO_ODinterface. */ - /** * Internal state flags indicate type of transfer * * These flags correspond to the upper nibble of the SDO state machine states * and can be used to determine the type of state an SDO object is in. */ -#define CO_SDO_ST_FLAG_DOWNLOAD 0x10U -#define CO_SDO_ST_FLAG_UPLOAD 0x20U -#define CO_SDO_ST_FLAG_BLOCK 0x40U +#define CO_SDO_ST_FLAG_DOWNLOAD 0x10U +#define CO_SDO_ST_FLAG_UPLOAD 0x20U +#define CO_SDO_ST_FLAG_BLOCK 0x40U /** * Internal states of the SDO state machine. @@ -98,26 +96,26 @@ extern "C" { * Note: CANopen has little endian byte order. */ typedef enum { -/** + /** * - SDO client may start new download to or upload from specified node, * specified index and specified subindex. It can start normal or block * communication. * - SDO server is waiting for client request. */ -CO_SDO_ST_IDLE = 0x00U, -/** + CO_SDO_ST_IDLE = 0x00U, + /** * - SDO client or server may send SDO abort message in case of error: * - byte 0: @b 10000000 binary. * - byte 1..3: Object index and subIndex. * - byte 4..7: #CO_SDO_abortCode_t. */ -CO_SDO_ST_ABORT = 0x01U, + CO_SDO_ST_ABORT = 0x01U, -/** + /** * - SDO client: Node-ID of the SDO server is the same as node-ID of this node, * SDO client is the same device as SDO server. Transfer data directly without * communication on CAN. * - SDO server does not use this state. */ -CO_SDO_ST_DOWNLOAD_LOCAL_TRANSFER = 0x10U, -/** + CO_SDO_ST_DOWNLOAD_LOCAL_TRANSFER = 0x10U, + /** * - SDO client initiates SDO download: * - byte 0: @b 0010nnes binary: (nn: if e=s=1, number of data bytes, that do * @b not contain data; e=1 for expedited transfer; s=1 if data size is @@ -126,45 +124,45 @@ CO_SDO_ST_DOWNLOAD_LOCAL_TRANSFER = 0x10U, * - byte 4..7: If e=1, expedited data are here. If e=0 s=1, size of data for * segmented transfer is indicated here. * - SDO server is in #CO_SDO_ST_IDLE state and waits for client request. */ -CO_SDO_ST_DOWNLOAD_INITIATE_REQ = 0x11U, -/** + CO_SDO_ST_DOWNLOAD_INITIATE_REQ = 0x11U, + /** * - SDO client waits for response. * - SDO server responses: * - byte 0: @b 01100000 binary. * - byte 1..3: Object index and subIndex. * - byte 4..7: Reserved. * - In case of expedited transfer communication ends here. */ -CO_SDO_ST_DOWNLOAD_INITIATE_RSP = 0x12U, -/** + CO_SDO_ST_DOWNLOAD_INITIATE_RSP = 0x12U, + /** * - SDO client sends SDO segment: * - byte 0: @b 000tnnnc binary: (t: toggle bit, set to 0 in first segment; * nnn: number of data bytes, that do @b not contain data; c=1 if this is the * last segment). * - byte 1..7: Data segment. * - SDO server waits for segment. */ -CO_SDO_ST_DOWNLOAD_SEGMENT_REQ = 0x13U, -/** + CO_SDO_ST_DOWNLOAD_SEGMENT_REQ = 0x13U, + /** * - SDO client waits for response. * - SDO server responses: * - byte 0: @b 001t0000 binary: (t: toggle bit, set to 0 in first segment). * - byte 1..7: Reserved. * - If c was set to 1, then communication ends here. */ -CO_SDO_ST_DOWNLOAD_SEGMENT_RSP = 0x14U, + CO_SDO_ST_DOWNLOAD_SEGMENT_RSP = 0x14U, -/** + /** * - SDO client: Node-ID of the SDO server is the same as node-ID of this node, * SDO client is the same device as SDO server. Transfer data directly without * communication on CAN. * - SDO server does not use this state. */ -CO_SDO_ST_UPLOAD_LOCAL_TRANSFER = 0x20U, -/** + CO_SDO_ST_UPLOAD_LOCAL_TRANSFER = 0x20U, + /** * - SDO client initiates SDO upload: * - byte 0: @b 01000000 binary. * - byte 1..3: Object index and subIndex. * - byte 4..7: Reserved. * - SDO server is in #CO_SDO_ST_IDLE state and waits for client request. */ -CO_SDO_ST_UPLOAD_INITIATE_REQ = 0x21U, -/** + CO_SDO_ST_UPLOAD_INITIATE_REQ = 0x21U, + /** * - SDO client waits for response. * - SDO server responses: * - byte 0: @b 0100nnes binary: (nn: if e=s=1, number of data bytes, that do @@ -174,14 +172,14 @@ CO_SDO_ST_UPLOAD_INITIATE_REQ = 0x21U, * - byte 4..7: If e=1, expedited data are here. If e=0 s=1, size of data for * segmented transfer is indicated here. * - In case of expedited transfer communication ends here. */ -CO_SDO_ST_UPLOAD_INITIATE_RSP = 0x22U, -/** + CO_SDO_ST_UPLOAD_INITIATE_RSP = 0x22U, + /** * - SDO client requests SDO segment: * - byte 0: @b 011t0000 binary: (t: toggle bit, set to 0 in first segment). * - byte 1..7: Reserved. * - SDO server waits for segment request. */ -CO_SDO_ST_UPLOAD_SEGMENT_REQ = 0x23U, -/** + CO_SDO_ST_UPLOAD_SEGMENT_REQ = 0x23U, + /** * - SDO client waits for response. * - SDO server responses with data: * - byte 0: @b 000tnnnc binary: (t: toggle bit, set to 0 in first segment; @@ -189,17 +187,17 @@ CO_SDO_ST_UPLOAD_SEGMENT_REQ = 0x23U, * last segment). * - byte 1..7: Data segment. * - If c is set to 1, then communication ends here. */ -CO_SDO_ST_UPLOAD_SEGMENT_RSP = 0x24U, + CO_SDO_ST_UPLOAD_SEGMENT_RSP = 0x24U, -/** + /** * - SDO client initiates SDO block download: * - byte 0: @b 11000rs0 binary: (r=1 if client supports generating CRC on * data; s=1 if data size is indicated.) * - byte 1..3: Object index and subIndex. * - byte 4..7: If s=1, then size of data for block download is indicated here. * - SDO server is in #CO_SDO_ST_IDLE state and waits for client request. */ -CO_SDO_ST_DOWNLOAD_BLK_INITIATE_REQ = 0x51U, -/** + CO_SDO_ST_DOWNLOAD_BLK_INITIATE_REQ = 0x51U, + /** * - SDO client waits for response. * - SDO server responses: * - byte 0: @b 10100r00 binary: (r=1 if server supports generating CRC on @@ -208,16 +206,16 @@ CO_SDO_ST_DOWNLOAD_BLK_INITIATE_REQ = 0x51U, * - byte 4: blksize: Number of segments per block that shall be used by the * client for the following block download with 0 < blksize < 128. * - byte 5..7: Reserved. */ -CO_SDO_ST_DOWNLOAD_BLK_INITIATE_RSP = 0x52U, -/** + CO_SDO_ST_DOWNLOAD_BLK_INITIATE_RSP = 0x52U, + /** * - SDO client sends 'blksize' segments of data in sequence: * - byte 0: @b cnnnnnnn binary: (c=1 if no more segments to be downloaded, * enter SDO block download end phase; nnnnnnn is sequence number of segment, * 1..127. * - byte 1..7: At most 7 bytes of segment data to be downloaded. * - SDO server reads sequence of 'blksize' blocks. */ -CO_SDO_ST_DOWNLOAD_BLK_SUBBLOCK_REQ = 0x53U, -/** + CO_SDO_ST_DOWNLOAD_BLK_SUBBLOCK_REQ = 0x53U, + /** * - SDO client waits for response. * - SDO server responses: * - byte 0: @b 10100010 binary. @@ -231,25 +229,25 @@ CO_SDO_ST_DOWNLOAD_BLK_SUBBLOCK_REQ = 0x53U, * - byte 3..7: Reserved. * - If c was set to 1, then communication enters SDO block download end phase. */ -CO_SDO_ST_DOWNLOAD_BLK_SUBBLOCK_RSP = 0x54U, -/** + CO_SDO_ST_DOWNLOAD_BLK_SUBBLOCK_RSP = 0x54U, + /** * - SDO client sends SDO block download end: * - byte 0: @b 110nnn01 binary: (nnn: number of data bytes, that do @b not * contain data) * - byte 1..2: 16 bit CRC for the data set, if enabled by client and server. * - byte 3..7: Reserved. * - SDO server waits for client request. */ -CO_SDO_ST_DOWNLOAD_BLK_END_REQ = 0x55U, -/** + CO_SDO_ST_DOWNLOAD_BLK_END_REQ = 0x55U, + /** * - SDO client waits for response. * - SDO server responses: * - byte 0: @b 10100001 binary. * - byte 1..7: Reserved. * - Block download successfully ends here. */ -CO_SDO_ST_DOWNLOAD_BLK_END_RSP = 0x56U, + CO_SDO_ST_DOWNLOAD_BLK_END_RSP = 0x56U, -/** + /** * - SDO client initiates SDO block upload: * - byte 0: @b 10100r00 binary: (r=1 if client supports generating CRC on * data.) @@ -260,8 +258,8 @@ CO_SDO_ST_DOWNLOAD_BLK_END_RSP = 0x56U, * upload protocol #CO_SDO_ST_UPLOAD_INITIATE_RSP. * - byte 6..7: Reserved. * - SDO server is in #CO_SDO_ST_IDLE state and waits for client request. */ -CO_SDO_ST_UPLOAD_BLK_INITIATE_REQ = 0x61U, -/** + CO_SDO_ST_UPLOAD_BLK_INITIATE_REQ = 0x61U, + /** * - SDO client waits for response. * - SDO server responses: * - byte 0: @b 11000rs0 binary: (r=1 if server supports generating CRC on @@ -270,22 +268,22 @@ CO_SDO_ST_UPLOAD_BLK_INITIATE_REQ = 0x61U, * - byte 4..7: If s=1, then size of data for block upload is indicated here. * - If enabled by pst, then server may alternatively response with * #CO_SDO_ST_UPLOAD_INITIATE_RSP */ -CO_SDO_ST_UPLOAD_BLK_INITIATE_RSP = 0x62U, -/** + CO_SDO_ST_UPLOAD_BLK_INITIATE_RSP = 0x62U, + /** * - SDO client sends second initiate for SDO block upload: * - byte 0: @b 10100011 binary. * - byte 1..7: Reserved. * - SDO server waits for client request. */ -CO_SDO_ST_UPLOAD_BLK_INITIATE_REQ2 = 0x63U, -/** + CO_SDO_ST_UPLOAD_BLK_INITIATE_REQ2 = 0x63U, + /** * - SDO client reads sequence of 'blksize' blocks. * - SDO server sends 'blksize' segments of data in sequence: * - byte 0: @b cnnnnnnn binary: (c=1 if no more segments to be uploaded, * enter SDO block upload end phase; nnnnnnn is sequence number of segment, * 1..127. * - byte 1..7: At most 7 bytes of segment data to be uploaded. */ -CO_SDO_ST_UPLOAD_BLK_SUBBLOCK_SREQ = 0x64U, -/** + CO_SDO_ST_UPLOAD_BLK_SUBBLOCK_SREQ = 0x64U, + /** * - SDO client responses: * - byte 0: @b 10100010 binary. * - byte 1: ackseq: sequence number of last segment that was received @@ -299,16 +297,16 @@ CO_SDO_ST_UPLOAD_BLK_SUBBLOCK_SREQ = 0x64U, * - SDO server waits for response. * - If c was set to 1 and all segments were successfull received, then * communication enters SDO block upload end phase. */ -CO_SDO_ST_UPLOAD_BLK_SUBBLOCK_CRSP = 0x65U, -/** + CO_SDO_ST_UPLOAD_BLK_SUBBLOCK_CRSP = 0x65U, + /** * - SDO client waits for server request. * - SDO server sends SDO block upload end: * - byte 0: @b 110nnn01 binary: (nnn: number of data bytes, that do @b not * contain data) * - byte 1..2: 16 bit CRC for the data set, if enabled by client and server. * - byte 3..7: Reserved. */ -CO_SDO_ST_UPLOAD_BLK_END_SREQ = 0x66U, -/** + CO_SDO_ST_UPLOAD_BLK_END_SREQ = 0x66U, + /** * - SDO client responses: * - byte 0: @b 10100001 binary. * - byte 1..7: Reserved. @@ -317,10 +315,9 @@ CO_SDO_ST_UPLOAD_BLK_END_SREQ = 0x66U, * with client response. Client may then start next SDO communication * immediately. */ -CO_SDO_ST_UPLOAD_BLK_END_CRSP = 0x67U, + CO_SDO_ST_UPLOAD_BLK_END_CRSP = 0x67U, } CO_SDO_state_t; - /** * SDO abort codes. * @@ -330,78 +327,77 @@ CO_SDO_ST_UPLOAD_BLK_END_CRSP = 0x67U, */ typedef enum { /** 0x00000000, No abort */ - CO_SDO_AB_NONE = 0x00000000UL, + CO_SDO_AB_NONE = 0x00000000UL, /** 0x05030000, Toggle bit not altered */ - CO_SDO_AB_TOGGLE_BIT = 0x05030000UL, + CO_SDO_AB_TOGGLE_BIT = 0x05030000UL, /** 0x05040000, SDO protocol timed out */ - CO_SDO_AB_TIMEOUT = 0x05040000UL, + CO_SDO_AB_TIMEOUT = 0x05040000UL, /** 0x05040001, Command specifier not valid or unknown */ - CO_SDO_AB_CMD = 0x05040001UL, + CO_SDO_AB_CMD = 0x05040001UL, /** 0x05040002, Invalid block size in block mode */ - CO_SDO_AB_BLOCK_SIZE = 0x05040002UL, + CO_SDO_AB_BLOCK_SIZE = 0x05040002UL, /** 0x05040003, Invalid sequence number in block mode */ - CO_SDO_AB_SEQ_NUM = 0x05040003UL, + CO_SDO_AB_SEQ_NUM = 0x05040003UL, /** 0x05040004, CRC error (block mode only) */ - CO_SDO_AB_CRC = 0x05040004UL, + CO_SDO_AB_CRC = 0x05040004UL, /** 0x05040005, Out of memory */ - CO_SDO_AB_OUT_OF_MEM = 0x05040005UL, + CO_SDO_AB_OUT_OF_MEM = 0x05040005UL, /** 0x06010000, Unsupported access to an object */ - CO_SDO_AB_UNSUPPORTED_ACCESS = 0x06010000UL, + CO_SDO_AB_UNSUPPORTED_ACCESS = 0x06010000UL, /** 0x06010001, Attempt to read a write only object */ - CO_SDO_AB_WRITEONLY = 0x06010001UL, + CO_SDO_AB_WRITEONLY = 0x06010001UL, /** 0x06010002, Attempt to write a read only object */ - CO_SDO_AB_READONLY = 0x06010002UL, + CO_SDO_AB_READONLY = 0x06010002UL, /** 0x06020000, Object does not exist in the object dictionary */ - CO_SDO_AB_NOT_EXIST = 0x06020000UL, + CO_SDO_AB_NOT_EXIST = 0x06020000UL, /** 0x06040041, Object cannot be mapped to the PDO */ - CO_SDO_AB_NO_MAP = 0x06040041UL, + CO_SDO_AB_NO_MAP = 0x06040041UL, /** 0x06040042, Number and length of object to be mapped exceeds PDO * length */ - CO_SDO_AB_MAP_LEN = 0x06040042UL, + CO_SDO_AB_MAP_LEN = 0x06040042UL, /** 0x06040043, General parameter incompatibility reasons */ - CO_SDO_AB_PRAM_INCOMPAT = 0x06040043UL, + CO_SDO_AB_PRAM_INCOMPAT = 0x06040043UL, /** 0x06040047, General internal incompatibility in device */ - CO_SDO_AB_DEVICE_INCOMPAT = 0x06040047UL, + CO_SDO_AB_DEVICE_INCOMPAT = 0x06040047UL, /** 0x06060000, Access failed due to hardware error */ - CO_SDO_AB_HW = 0x06060000UL, + CO_SDO_AB_HW = 0x06060000UL, /** 0x06070010, Data type does not match, length of service parameter does * not match */ - CO_SDO_AB_TYPE_MISMATCH = 0x06070010UL, + CO_SDO_AB_TYPE_MISMATCH = 0x06070010UL, /** 0x06070012, Data type does not match, length of service parameter too * high */ - CO_SDO_AB_DATA_LONG = 0x06070012UL, + CO_SDO_AB_DATA_LONG = 0x06070012UL, /** 0x06070013, Data type does not match, length of service parameter too * short */ - CO_SDO_AB_DATA_SHORT = 0x06070013UL, + CO_SDO_AB_DATA_SHORT = 0x06070013UL, /** 0x06090011, Sub index does not exist */ - CO_SDO_AB_SUB_UNKNOWN = 0x06090011UL, + CO_SDO_AB_SUB_UNKNOWN = 0x06090011UL, /** 0x06090030, Invalid value for parameter (download only). */ - CO_SDO_AB_INVALID_VALUE = 0x06090030UL, + CO_SDO_AB_INVALID_VALUE = 0x06090030UL, /** 0x06090031, Value range of parameter written too high */ - CO_SDO_AB_VALUE_HIGH = 0x06090031UL, + CO_SDO_AB_VALUE_HIGH = 0x06090031UL, /** 0x06090032, Value range of parameter written too low */ - CO_SDO_AB_VALUE_LOW = 0x06090032UL, + CO_SDO_AB_VALUE_LOW = 0x06090032UL, /** 0x06090036, Maximum value is less than minimum value. */ - CO_SDO_AB_MAX_LESS_MIN = 0x06090036UL, + CO_SDO_AB_MAX_LESS_MIN = 0x06090036UL, /** 0x060A0023, Resource not available: SDO connection */ - CO_SDO_AB_NO_RESOURCE = 0x060A0023UL, + CO_SDO_AB_NO_RESOURCE = 0x060A0023UL, /** 0x08000000, General error */ - CO_SDO_AB_GENERAL = 0x08000000UL, + CO_SDO_AB_GENERAL = 0x08000000UL, /** 0x08000020, Data cannot be transferred or stored to application */ - CO_SDO_AB_DATA_TRANSF = 0x08000020UL, + CO_SDO_AB_DATA_TRANSF = 0x08000020UL, /** 0x08000021, Data cannot be transferred or stored to application because * of local control */ - CO_SDO_AB_DATA_LOC_CTRL = 0x08000021UL, + CO_SDO_AB_DATA_LOC_CTRL = 0x08000021UL, /** 0x08000022, Data cannot be transferred or stored to application because * of present device state */ - CO_SDO_AB_DATA_DEV_STATE = 0x08000022UL, + CO_SDO_AB_DATA_DEV_STATE = 0x08000022UL, /** 0x08000023, Object dictionary not present or dynamic generation fails */ - CO_SDO_AB_DATA_OD = 0x08000023UL, + CO_SDO_AB_DATA_OD = 0x08000023UL, /** 0x08000024, No data available */ - CO_SDO_AB_NO_DATA = 0x08000024UL + CO_SDO_AB_NO_DATA = 0x08000024UL } CO_SDO_abortCode_t; - /** * Return values from SDO server or client functions. */ @@ -430,17 +426,16 @@ typedef enum { CO_SDO_RT_endedWithServerAbort = -10, } CO_SDO_return_t; - /** * SDO server object. */ typedef struct { /** From CO_SDOserver_init() */ - CO_CANmodule_t *CANdevTx; + CO_CANmodule_t* CANdevTx; /** CAN transmit buffer inside CANdevTx for CAN tx message */ - CO_CANtx_t *CANtxBuff; + CO_CANtx_t* CANtxBuff; /** From CO_SDOserver_init() */ - OD_t *OD; + OD_t* OD; /** From CO_SDOserver_init() */ uint8_t nodeId; /* If true, SDO channel is valid */ @@ -455,12 +450,12 @@ typedef struct { uint8_t subIndex; /** Indicates, if new SDO message received from CAN bus. It is not cleared, * until received message is completely processed. */ - volatile void *CANrxNew; + volatile void* CANrxNew; /** 8 data bytes of the received message */ uint8_t CANrxData[8]; -#if (((CO_CONFIG_SDO_SRV) & CO_CONFIG_FLAG_OD_DYNAMIC) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_SDO_SRV)&CO_CONFIG_FLAG_OD_DYNAMIC) != 0) || defined CO_DOXYGEN /** From CO_SDOserver_init() */ - CO_CANmodule_t *CANdevRx; + CO_CANmodule_t* CANdevRx; /** From CO_SDOserver_init() */ uint16_t CANdevRxIdx; /** From CO_SDOserver_init() */ @@ -475,7 +470,7 @@ typedef struct { /** Extension for OD object */ OD_extension_t OD_1200_extension; #endif -#if (((CO_CONFIG_SDO_SRV) & CO_CONFIG_SDO_SRV_SEGMENTED) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_SDO_SRV)&CO_CONFIG_SDO_SRV_SEGMENTED) != 0) || defined CO_DOXYGEN /** Size of data, which will be transferred. It is optionally indicated by * client in case of download or by server in case of upload. */ OD_size_t sizeInd; @@ -497,7 +492,7 @@ typedef struct { /** Offset of first data available for read in the buffer */ OD_size_t bufOffsetRd; #endif -#if (((CO_CONFIG_SDO_SRV) & CO_CONFIG_SDO_SRV_BLOCK) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_SDO_SRV)&CO_CONFIG_SDO_SRV_BLOCK) != 0) || defined CO_DOXYGEN /** Timeout time for SDO sub-block download, half of #SDOtimeoutTime_us */ uint32_t block_SDOtimeoutTime_us; /** Timeout timer for SDO sub-block download */ @@ -513,15 +508,14 @@ typedef struct { /** Calculated CRC checksum */ uint16_t block_crc; #endif -#if (((CO_CONFIG_SDO_SRV) & CO_CONFIG_FLAG_CALLBACK_PRE) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_SDO_SRV)&CO_CONFIG_FLAG_CALLBACK_PRE) != 0) || defined CO_DOXYGEN /** From CO_SDOserver_initCallbackPre() or NULL */ - void (*pFunctSignalPre)(void *object); + void (*pFunctSignalPre)(void* object); /** From CO_SDOserver_initCallbackPre() or NULL */ - void *functSignalObjectPre; + void* functSignalObjectPre; #endif } CO_SDOserver_t; - /** * Initialize SDO object. * @@ -544,19 +538,11 @@ typedef struct { * * @return @ref CO_ReturnError_t CO_ERROR_NO in case of success. */ -CO_ReturnError_t CO_SDOserver_init(CO_SDOserver_t *SDO, - OD_t *OD, - OD_entry_t *OD_1200_SDOsrvPar, - uint8_t nodeId, - uint16_t SDOtimeoutTime_ms, - CO_CANmodule_t *CANdevRx, - uint16_t CANdevRxIdx, - CO_CANmodule_t *CANdevTx, - uint16_t CANdevTxIdx, - uint32_t *errInfo); +CO_ReturnError_t CO_SDOserver_init(CO_SDOserver_t* SDO, OD_t* OD, OD_entry_t* OD_1200_SDOsrvPar, uint8_t nodeId, + uint16_t SDOtimeoutTime_ms, CO_CANmodule_t* CANdevRx, uint16_t CANdevRxIdx, + CO_CANmodule_t* CANdevTx, uint16_t CANdevTxIdx, uint32_t* errInfo); - -#if (((CO_CONFIG_SDO_SRV) & CO_CONFIG_FLAG_CALLBACK_PRE) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_SDO_SRV)&CO_CONFIG_FLAG_CALLBACK_PRE) != 0) || defined CO_DOXYGEN /** * Initialize SDOrx callback function. * @@ -570,12 +556,9 @@ CO_ReturnError_t CO_SDOserver_init(CO_SDOserver_t *SDO, * Can be NULL * @param pFunctSignalPre Pointer to the callback function. Not called if NULL. */ -void CO_SDOserver_initCallbackPre(CO_SDOserver_t *SDO, - void *object, - void (*pFunctSignalPre)(void *object)); +void CO_SDOserver_initCallbackPre(CO_SDOserver_t* SDO, void* object, void (*pFunctSignalPre)(void* object)); #endif - /** * Process SDO communication. * @@ -590,10 +573,8 @@ void CO_SDOserver_initCallbackPre(CO_SDOserver_t *SDO, * * @return #CO_SDO_return_t */ -CO_SDO_return_t CO_SDOserver_process(CO_SDOserver_t *SDO, - bool_t NMTisPreOrOperational, - uint32_t timeDifference_us, - uint32_t *timerNext_us); +CO_SDO_return_t CO_SDOserver_process(CO_SDOserver_t* SDO, bool_t NMTisPreOrOperational, uint32_t timeDifference_us, + uint32_t* timerNext_us); /** @} */ /* CO_SDOserver */ diff --git a/301/CO_SYNC.h b/301/CO_SYNC.h index 8c2038a..080f0f8 100644 --- a/301/CO_SYNC.h +++ b/301/CO_SYNC.h @@ -25,17 +25,14 @@ #include "301/CO_ODinterface.h" #include "301/CO_Emergency.h" - /* default configuration, see CO_config.h */ #ifndef CO_CONFIG_SYNC -#define CO_CONFIG_SYNC (CO_CONFIG_SYNC_ENABLE | \ - CO_CONFIG_SYNC_PRODUCER | \ - CO_CONFIG_GLOBAL_RT_FLAG_CALLBACK_PRE | \ - CO_CONFIG_GLOBAL_FLAG_TIMERNEXT | \ - CO_CONFIG_GLOBAL_FLAG_OD_DYNAMIC) +#define CO_CONFIG_SYNC \ + (CO_CONFIG_SYNC_ENABLE | CO_CONFIG_SYNC_PRODUCER | CO_CONFIG_GLOBAL_RT_FLAG_CALLBACK_PRE \ + | CO_CONFIG_GLOBAL_FLAG_TIMERNEXT | CO_CONFIG_GLOBAL_FLAG_OD_DYNAMIC) #endif -#if (((CO_CONFIG_SYNC) & CO_CONFIG_SYNC_ENABLE) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_SYNC)&CO_CONFIG_SYNC_ENABLE) != 0) || defined CO_DOXYGEN #ifdef __cplusplus extern "C" { @@ -69,15 +66,14 @@ extern "C" { * RPDO reception and which for RPDO processing. */ - /** * SYNC producer and consumer object. */ typedef struct { /** From CO_SYNC_init() */ - CO_EM_t *em; + CO_EM_t* em; /** Indicates, if new SYNC message received from CAN bus */ - volatile void *CANrxNew; + volatile void* CANrxNew; /** Set to nonzero value, if SYNC with wrong data length is received */ uint8_t receiveError; /** Variable toggles, if new SYNC message received from CAN bus */ @@ -97,21 +93,21 @@ typedef struct { Set to zero after received or transmitted SYNC message */ uint32_t timer; /**Pointer to variable in OD, "Communication cycle period" in microseconds*/ - uint32_t *OD_1006_period; + uint32_t* OD_1006_period; /** Pointer to variable in OD, "Synchronous window length" in microseconds*/ - uint32_t *OD_1007_window; + uint32_t* OD_1007_window; -#if (((CO_CONFIG_SYNC) & CO_CONFIG_SYNC_PRODUCER) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_SYNC)&CO_CONFIG_SYNC_PRODUCER) != 0) || defined CO_DOXYGEN /** True, if device is SYNC producer. Calculated from _COB ID SYNC Message_ variable from Object dictionary (index 0x1005). */ bool_t isProducer; /** CAN transmit buffer inside CANdevTx */ - CO_CANtx_t *CANtxBuff; + CO_CANtx_t* CANtxBuff; #endif -#if ((CO_CONFIG_SYNC) & CO_CONFIG_FLAG_OD_DYNAMIC) || defined CO_DOXYGEN +#if ((CO_CONFIG_SYNC)&CO_CONFIG_FLAG_OD_DYNAMIC) || defined CO_DOXYGEN /** From CO_SYNC_init() */ - CO_CANmodule_t *CANdevRx; + CO_CANmodule_t* CANdevRx; /** From CO_SYNC_init() */ uint16_t CANdevRxIdx; /** Extension for OD object */ @@ -119,25 +115,24 @@ typedef struct { /** CAN ID of the SYNC message. Calculated from _COB ID SYNC Message_ variable from Object dictionary (index 0x1005). */ uint16_t CAN_ID; - #if (((CO_CONFIG_SYNC) & CO_CONFIG_SYNC_PRODUCER) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_SYNC)&CO_CONFIG_SYNC_PRODUCER) != 0) || defined CO_DOXYGEN /** From CO_SYNC_init() */ - CO_CANmodule_t *CANdevTx; + CO_CANmodule_t* CANdevTx; /** From CO_SYNC_init() */ uint16_t CANdevTxIdx; /** Extension for OD object */ OD_extension_t OD_1019_extension; - #endif +#endif #endif -#if (((CO_CONFIG_SYNC) & CO_CONFIG_FLAG_CALLBACK_PRE) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_SYNC)&CO_CONFIG_FLAG_CALLBACK_PRE) != 0) || defined CO_DOXYGEN /** From CO_SYNC_initCallbackPre() or NULL */ - void (*pFunctSignalPre)(void *object); + void (*pFunctSignalPre)(void* object); /** From CO_SYNC_initCallbackPre() or NULL */ - void *functSignalObjectPre; + void* functSignalObjectPre; #endif } CO_SYNC_t; - /** Return value for @ref CO_SYNC_process */ typedef enum { /** No SYNC event in last cycle */ @@ -148,7 +143,6 @@ typedef enum { CO_SYNC_PASSED_WINDOW = 2 } CO_SYNC_status_t; - /** * Initialize SYNC object. * @@ -172,22 +166,15 @@ typedef enum { * * @return #CO_ReturnError_t CO_ERROR_NO on success. */ -CO_ReturnError_t CO_SYNC_init(CO_SYNC_t *SYNC, - CO_EM_t *em, - OD_entry_t *OD_1005_cobIdSync, - OD_entry_t *OD_1006_commCyclePeriod, - OD_entry_t *OD_1007_syncWindowLen, - OD_entry_t *OD_1019_syncCounterOvf, - CO_CANmodule_t *CANdevRx, - uint16_t CANdevRxIdx, -#if (((CO_CONFIG_SYNC) & CO_CONFIG_SYNC_PRODUCER) != 0) || defined CO_DOXYGEN - CO_CANmodule_t *CANdevTx, - uint16_t CANdevTxIdx, +CO_ReturnError_t CO_SYNC_init(CO_SYNC_t* SYNC, CO_EM_t* em, OD_entry_t* OD_1005_cobIdSync, + OD_entry_t* OD_1006_commCyclePeriod, OD_entry_t* OD_1007_syncWindowLen, + OD_entry_t* OD_1019_syncCounterOvf, CO_CANmodule_t* CANdevRx, uint16_t CANdevRxIdx, +#if (((CO_CONFIG_SYNC)&CO_CONFIG_SYNC_PRODUCER) != 0) || defined CO_DOXYGEN + CO_CANmodule_t* CANdevTx, uint16_t CANdevTxIdx, #endif - uint32_t *errInfo); + uint32_t* errInfo); - -#if (((CO_CONFIG_SYNC) & CO_CONFIG_FLAG_CALLBACK_PRE) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_SYNC)&CO_CONFIG_FLAG_CALLBACK_PRE) != 0) || defined CO_DOXYGEN /** * Initialize SYNC callback function. * @@ -199,13 +186,10 @@ CO_ReturnError_t CO_SYNC_init(CO_SYNC_t *SYNC, * @param object Pointer to object, which will be passed to pFunctSignalPre(). * @param pFunctSignalPre Pointer to the callback function. Not called if NULL. */ -void CO_SYNC_initCallbackPre(CO_SYNC_t *SYNC, - void *object, - void (*pFunctSignalPre)(void *object)); +void CO_SYNC_initCallbackPre(CO_SYNC_t* SYNC, void* object, void (*pFunctSignalPre)(void* object)); #endif - -#if (((CO_CONFIG_SYNC) & CO_CONFIG_SYNC_PRODUCER) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_SYNC)&CO_CONFIG_SYNC_PRODUCER) != 0) || defined CO_DOXYGEN /** * Send SYNC message. * @@ -217,8 +201,11 @@ void CO_SYNC_initCallbackPre(CO_SYNC_t *SYNC, * * @return Same as CO_CANsend(). */ -static inline CO_ReturnError_t CO_SYNCsend(CO_SYNC_t *SYNC) { - if (++SYNC->counter > SYNC->counterOverflowValue) { SYNC->counter = 1; } +static inline CO_ReturnError_t +CO_SYNCsend(CO_SYNC_t* SYNC) { + if (++SYNC->counter > SYNC->counterOverflowValue) { + SYNC->counter = 1; + } SYNC->timer = 0; SYNC->CANrxToggle = SYNC->CANrxToggle ? false : true; SYNC->CANtxBuff->data[0] = SYNC->counter; @@ -226,7 +213,6 @@ static inline CO_ReturnError_t CO_SYNCsend(CO_SYNC_t *SYNC) { } #endif - /** * Process SYNC communication. * @@ -241,10 +227,8 @@ static inline CO_ReturnError_t CO_SYNCsend(CO_SYNC_t *SYNC) { * * @return @ref CO_SYNC_status_t */ -CO_SYNC_status_t CO_SYNC_process(CO_SYNC_t *SYNC, - bool_t NMTisPreOrOperational, - uint32_t timeDifference_us, - uint32_t *timerNext_us); +CO_SYNC_status_t CO_SYNC_process(CO_SYNC_t* SYNC, bool_t NMTisPreOrOperational, uint32_t timeDifference_us, + uint32_t* timerNext_us); /** @} */ /* CO_SYNC */ diff --git a/301/CO_TIME.h b/301/CO_TIME.h index b57bc55..cf7e352 100644 --- a/301/CO_TIME.h +++ b/301/CO_TIME.h @@ -25,15 +25,12 @@ #include "301/CO_ODinterface.h" #include "301/CO_NMT_Heartbeat.h" - /* default configuration, see CO_config.h */ #ifndef CO_CONFIG_TIME -#define CO_CONFIG_TIME (CO_CONFIG_TIME_ENABLE | \ - CO_CONFIG_GLOBAL_FLAG_CALLBACK_PRE | \ - CO_CONFIG_GLOBAL_FLAG_OD_DYNAMIC) +#define CO_CONFIG_TIME (CO_CONFIG_TIME_ENABLE | CO_CONFIG_GLOBAL_FLAG_CALLBACK_PRE | CO_CONFIG_GLOBAL_FLAG_OD_DYNAMIC) #endif -#if (((CO_CONFIG_TIME) & CO_CONFIG_TIME_ENABLE) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_TIME)&CO_CONFIG_TIME_ENABLE) != 0) || defined CO_DOXYGEN #ifdef __cplusplus extern "C" { @@ -65,11 +62,9 @@ extern "C" { * send from @ref CO_TIME_process() in intervals specified by @ref CO_TIME_set() */ - /** Length of the TIME message */ #define CO_TIME_MSG_LENGTH 6U - /** * TIME producer and consumer object. */ @@ -82,37 +77,36 @@ typedef struct { uint16_t days; /** Residual microseconds calculated inside CO_TIME_process() */ uint16_t residual_us; - /** True, if device is TIME consumer. Calculated from _COB ID TIME Message_ + /** True, if device is TIME consumer. Calculated from _COB ID TIME Message_ variable from Object dictionary (index 0x1012). */ bool_t isConsumer; /** True, if device is TIME producer. Calculated from _COB ID TIME Message_ variable from Object dictionary (index 0x1012). */ bool_t isProducer; /** Variable indicates, if new TIME message received from CAN bus */ - volatile void *CANrxNew; -#if (((CO_CONFIG_TIME) & CO_CONFIG_TIME_PRODUCER) != 0) || defined CO_DOXYGEN + volatile void* CANrxNew; +#if (((CO_CONFIG_TIME)&CO_CONFIG_TIME_PRODUCER) != 0) || defined CO_DOXYGEN /** Interval for time producer in milli seconds */ uint32_t producerInterval_ms; /** Sync producer timer */ uint32_t producerTimer_ms; /** From CO_TIME_init() */ - CO_CANmodule_t *CANdevTx; + CO_CANmodule_t* CANdevTx; /** CAN transmit buffer */ - CO_CANtx_t *CANtxBuff; + CO_CANtx_t* CANtxBuff; #endif -#if (((CO_CONFIG_TIME) & CO_CONFIG_FLAG_CALLBACK_PRE) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_TIME)&CO_CONFIG_FLAG_CALLBACK_PRE) != 0) || defined CO_DOXYGEN /** From CO_TIME_initCallbackPre() or NULL */ - void (*pFunctSignalPre)(void *object); + void (*pFunctSignalPre)(void* object); /** From CO_TIME_initCallbackPre() or NULL */ - void *functSignalObjectPre; + void* functSignalObjectPre; #endif -#if (((CO_CONFIG_TIME) & CO_CONFIG_FLAG_OD_DYNAMIC) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_TIME)&CO_CONFIG_FLAG_OD_DYNAMIC) != 0) || defined CO_DOXYGEN /** Extension for OD object */ OD_extension_t OD_1012_extension; #endif } CO_TIME_t; - /** * Initialize TIME object. * @@ -129,18 +123,14 @@ typedef struct { * * @return #CO_ReturnError_t CO_ERROR_NO on success. */ -CO_ReturnError_t CO_TIME_init(CO_TIME_t *TIME, - OD_entry_t *OD_1012_cobIdTimeStamp, - CO_CANmodule_t *CANdevRx, +CO_ReturnError_t CO_TIME_init(CO_TIME_t* TIME, OD_entry_t* OD_1012_cobIdTimeStamp, CO_CANmodule_t* CANdevRx, uint16_t CANdevRxIdx, -#if (((CO_CONFIG_TIME) & CO_CONFIG_TIME_PRODUCER) != 0) || defined CO_DOXYGEN - CO_CANmodule_t *CANdevTx, - uint16_t CANdevTxIdx, +#if (((CO_CONFIG_TIME)&CO_CONFIG_TIME_PRODUCER) != 0) || defined CO_DOXYGEN + CO_CANmodule_t* CANdevTx, uint16_t CANdevTxIdx, #endif - uint32_t *errInfo); + uint32_t* errInfo); - -#if (((CO_CONFIG_TIME) & CO_CONFIG_FLAG_CALLBACK_PRE) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_TIME)&CO_CONFIG_FLAG_CALLBACK_PRE) != 0) || defined CO_DOXYGEN /** * Initialize TIME callback function. * @@ -152,12 +142,9 @@ CO_ReturnError_t CO_TIME_init(CO_TIME_t *TIME, * @param object Pointer to object, which will be passed to pFunctSignalPre(). * @param pFunctSignalPre Pointer to the callback function. Not called if NULL. */ -void CO_TIME_initCallbackPre(CO_TIME_t *TIME, - void *object, - void (*pFunctSignalPre)(void *object)); +void CO_TIME_initCallbackPre(CO_TIME_t* TIME, void* object, void (*pFunctSignalPre)(void* object)); #endif - /** * Set current time * @@ -166,24 +153,20 @@ void CO_TIME_initCallbackPre(CO_TIME_t *TIME, * @param days Number of days since January 1, 1984 * @param producerInterval_ms Interval time for time producer in milliseconds */ -static inline void CO_TIME_set(CO_TIME_t *TIME, - uint32_t ms, - uint16_t days, - uint32_t producerInterval_ms) -{ +static inline void +CO_TIME_set(CO_TIME_t* TIME, uint32_t ms, uint16_t days, uint32_t producerInterval_ms) { (void)producerInterval_ms; /* may be unused */ if (TIME != NULL) { TIME->residual_us = 0; TIME->ms = ms; TIME->days = days; -#if ((CO_CONFIG_TIME) & CO_CONFIG_TIME_PRODUCER) != 0 - TIME->producerTimer_ms = TIME->producerInterval_ms =producerInterval_ms; +#if ((CO_CONFIG_TIME)&CO_CONFIG_TIME_PRODUCER) != 0 + TIME->producerTimer_ms = TIME->producerInterval_ms = producerInterval_ms; #endif } } - /** * Process TIME object. * @@ -199,10 +182,7 @@ static inline void CO_TIME_set(CO_TIME_t *TIME, * * @return True if new TIME stamp message recently received (consumer). */ -bool_t CO_TIME_process(CO_TIME_t *TIME, - bool_t NMTisPreOrOperational, - uint32_t timeDifference_us); - +bool_t CO_TIME_process(CO_TIME_t* TIME, bool_t NMTisPreOrOperational, uint32_t timeDifference_us); /** @} */ /* CO_TIME */ diff --git a/301/CO_config.h b/301/CO_config.h index 89e7730..5a07ae6 100644 --- a/301/CO_config.h +++ b/301/CO_config.h @@ -18,7 +18,6 @@ * See the License for the specific language governing permissions and limitations under the License. */ - #ifndef CO_CONFIG_FLAGS_H #define CO_CONFIG_FLAGS_H @@ -49,7 +48,6 @@ extern "C" { * @{ */ - /** * @defgroup CO_STACK_CONFIG_COMMON Common definitions * Constants for common definitions. @@ -81,7 +79,7 @@ extern "C" { * * This flag is common to multiple configuration macros. */ -#define CO_CONFIG_FLAG_TIMERNEXT 0x2000 +#define CO_CONFIG_FLAG_TIMERNEXT 0x2000 /** * Enable dynamic behaviour of Object Dictionary variables @@ -93,7 +91,7 @@ extern "C" { * * This flag is common to multiple configuration macros. */ -#define CO_CONFIG_FLAG_OD_DYNAMIC 0x4000 +#define CO_CONFIG_FLAG_OD_DYNAMIC 0x4000 /** This flag may be set globally for mainline objects to * @ref CO_CONFIG_FLAG_CALLBACK_PRE */ @@ -118,7 +116,6 @@ extern "C" { #endif /** @} */ /* CO_STACK_CONFIG_COMMON */ - /** * @defgroup CO_STACK_CONFIG_NMT_HB NMT master/slave and HB producer/consumer * Specified in standard CiA 301 @@ -142,7 +139,7 @@ extern "C" { #define CO_CONFIG_NMT (CO_CONFIG_GLOBAL_FLAG_CALLBACK_PRE | CO_CONFIG_GLOBAL_FLAG_TIMERNEXT) #endif #define CO_CONFIG_NMT_CALLBACK_CHANGE 0x01 -#define CO_CONFIG_NMT_MASTER 0x02 +#define CO_CONFIG_NMT_MASTER 0x02 /** * Configuration of @ref CO_HBconsumer @@ -172,15 +169,16 @@ extern "C" { * CO_CONFIG_HB_CONS_CALLBACK_MULTI cannot be set simultaneously. */ #ifdef CO_DOXYGEN -#define CO_CONFIG_HB_CONS (CO_CONFIG_HB_CONS_ENABLE | CO_CONFIG_GLOBAL_FLAG_CALLBACK_PRE | CO_CONFIG_GLOBAL_FLAG_TIMERNEXT | CO_CONFIG_GLOBAL_FLAG_OD_DYNAMIC) +#define CO_CONFIG_HB_CONS \ + (CO_CONFIG_HB_CONS_ENABLE | CO_CONFIG_GLOBAL_FLAG_CALLBACK_PRE | CO_CONFIG_GLOBAL_FLAG_TIMERNEXT \ + | CO_CONFIG_GLOBAL_FLAG_OD_DYNAMIC) #endif -#define CO_CONFIG_HB_CONS_ENABLE 0x01 +#define CO_CONFIG_HB_CONS_ENABLE 0x01 #define CO_CONFIG_HB_CONS_CALLBACK_CHANGE 0x02 -#define CO_CONFIG_HB_CONS_CALLBACK_MULTI 0x04 -#define CO_CONFIG_HB_CONS_QUERY_FUNCT 0x08 +#define CO_CONFIG_HB_CONS_CALLBACK_MULTI 0x04 +#define CO_CONFIG_HB_CONS_QUERY_FUNCT 0x08 /** @} */ /* CO_STACK_CONFIG_NMT_HB */ - /** * @defgroup CO_STACK_CONFIG_NODE_GUARDING CANopen Node Guarding slave and master objects. * Specified in standard CiA 301 @@ -198,7 +196,7 @@ extern "C" { #ifdef CO_DOXYGEN #define CO_CONFIG_NODE_GUARDING (0) #endif -#define CO_CONFIG_NODE_GUARDING_SLAVE_ENABLE 0x01 +#define CO_CONFIG_NODE_GUARDING_SLAVE_ENABLE 0x01 #define CO_CONFIG_NODE_GUARDING_MASTER_ENABLE 0x02 /** @@ -209,7 +207,6 @@ extern "C" { #endif /** @} */ /* CO_STACK_CONFIG_NODE_GUARDING */ - /** * @defgroup CO_STACK_CONFIG_EMERGENCY Emergency producer/consumer * Specified in standard CiA 301 @@ -236,14 +233,16 @@ extern "C" { * inside CO_EM_process(). */ #ifdef CO_DOXYGEN -#define CO_CONFIG_EM (CO_CONFIG_EM_PRODUCER | CO_CONFIG_EM_HISTORY | CO_CONFIG_GLOBAL_FLAG_CALLBACK_PRE | CO_CONFIG_GLOBAL_FLAG_TIMERNEXT) +#define CO_CONFIG_EM \ + (CO_CONFIG_EM_PRODUCER | CO_CONFIG_EM_HISTORY | CO_CONFIG_GLOBAL_FLAG_CALLBACK_PRE \ + | CO_CONFIG_GLOBAL_FLAG_TIMERNEXT) #endif -#define CO_CONFIG_EM_PRODUCER 0x01 +#define CO_CONFIG_EM_PRODUCER 0x01 #define CO_CONFIG_EM_PROD_CONFIGURABLE 0x02 -#define CO_CONFIG_EM_PROD_INHIBIT 0x04 -#define CO_CONFIG_EM_HISTORY 0x08 -#define CO_CONFIG_EM_STATUS_BITS 0x10 -#define CO_CONFIG_EM_CONSUMER 0x20 +#define CO_CONFIG_EM_PROD_INHIBIT 0x04 +#define CO_CONFIG_EM_HISTORY 0x08 +#define CO_CONFIG_EM_STATUS_BITS 0x10 +#define CO_CONFIG_EM_CONSUMER 0x20 /** * Maximum number of @ref CO_EM_errorStatusBits_t @@ -253,7 +252,7 @@ extern "C" { * Default is 80. */ #ifdef CO_DOXYGEN -#define CO_CONFIG_EM_ERR_STATUS_BITS_COUNT (10*8) +#define CO_CONFIG_EM_ERR_STATUS_BITS_COUNT (10 * 8) #endif /** @@ -333,7 +332,6 @@ extern "C" { #endif /** @} */ /* CO_STACK_CONFIG_EMERGENCY */ - /** * @defgroup CO_STACK_CONFIG_SDO SDO server/client * Specified in standard CiA 301 @@ -355,10 +353,12 @@ extern "C" { * servers (Writing to object 0x1201+ re-configures the additional server). */ #ifdef CO_DOXYGEN -#define CO_CONFIG_SDO_SRV (CO_CONFIG_SDO_SRV_SEGMENTED | CO_CONFIG_GLOBAL_FLAG_CALLBACK_PRE | CO_CONFIG_GLOBAL_FLAG_TIMERNEXT | CO_CONFIG_GLOBAL_FLAG_OD_DYNAMIC) +#define CO_CONFIG_SDO_SRV \ + (CO_CONFIG_SDO_SRV_SEGMENTED | CO_CONFIG_GLOBAL_FLAG_CALLBACK_PRE | CO_CONFIG_GLOBAL_FLAG_TIMERNEXT \ + | CO_CONFIG_GLOBAL_FLAG_OD_DYNAMIC) #endif #define CO_CONFIG_SDO_SRV_SEGMENTED 0x02 -#define CO_CONFIG_SDO_SRV_BLOCK 0x04 +#define CO_CONFIG_SDO_SRV_BLOCK 0x04 /** * Size of the internal data buffer for the SDO server. @@ -395,10 +395,10 @@ extern "C" { #ifdef CO_DOXYGEN #define CO_CONFIG_SDO_CLI (0) #endif -#define CO_CONFIG_SDO_CLI_ENABLE 0x01 +#define CO_CONFIG_SDO_CLI_ENABLE 0x01 #define CO_CONFIG_SDO_CLI_SEGMENTED 0x02 -#define CO_CONFIG_SDO_CLI_BLOCK 0x04 -#define CO_CONFIG_SDO_CLI_LOCAL 0x08 +#define CO_CONFIG_SDO_CLI_BLOCK 0x04 +#define CO_CONFIG_SDO_CLI_LOCAL 0x08 /** * Size of the internal data buffer for the SDO client. @@ -416,7 +416,6 @@ extern "C" { #endif /** @} */ /* CO_STACK_CONFIG_SDO */ - /** * @defgroup CO_STACK_CONFIG_TIME Time producer/consumer * Specified in standard CiA 301 @@ -437,11 +436,10 @@ extern "C" { #ifdef CO_DOXYGEN #define CO_CONFIG_TIME (CO_CONFIG_TIME_ENABLE | CO_CONFIG_GLOBAL_FLAG_CALLBACK_PRE | CO_CONFIG_GLOBAL_FLAG_OD_DYNAMIC) #endif -#define CO_CONFIG_TIME_ENABLE 0x01 +#define CO_CONFIG_TIME_ENABLE 0x01 #define CO_CONFIG_TIME_PRODUCER 0x02 /** @} */ /* CO_STACK_CONFIG_TIME */ - /** * @defgroup CO_STACK_CONFIG_SYNC_PDO SYNC and PDO producer/consumer * Specified in standard CiA 301 @@ -461,9 +459,11 @@ extern "C" { * - #CO_CONFIG_FLAG_OD_DYNAMIC - Enable dynamic configuration of SYNC. */ #ifdef CO_DOXYGEN -#define CO_CONFIG_SYNC (CO_CONFIG_SYNC_ENABLE | CO_CONFIG_SYNC_PRODUCER | CO_CONFIG_GLOBAL_RT_FLAG_CALLBACK_PRE | CO_CONFIG_GLOBAL_FLAG_TIMERNEXT | CO_CONFIG_GLOBAL_FLAG_OD_DYNAMIC) +#define CO_CONFIG_SYNC \ + (CO_CONFIG_SYNC_ENABLE | CO_CONFIG_SYNC_PRODUCER | CO_CONFIG_GLOBAL_RT_FLAG_CALLBACK_PRE \ + | CO_CONFIG_GLOBAL_FLAG_TIMERNEXT | CO_CONFIG_GLOBAL_FLAG_OD_DYNAMIC) #endif -#define CO_CONFIG_SYNC_ENABLE 0x01 +#define CO_CONFIG_SYNC_ENABLE 0x01 #define CO_CONFIG_SYNC_PRODUCER 0x02 /** @@ -490,17 +490,19 @@ extern "C" { * - #CO_CONFIG_FLAG_OD_DYNAMIC - Enable dynamic configuration of PDO. */ #ifdef CO_DOXYGEN -#define CO_CONFIG_PDO (CO_CONFIG_RPDO_ENABLE | CO_CONFIG_TPDO_ENABLE | CO_CONFIG_RPDO_TIMERS_ENABLE | CO_CONFIG_TPDO_TIMERS_ENABLE | CO_CONFIG_PDO_SYNC_ENABLE | CO_CONFIG_PDO_OD_IO_ACCESS | CO_CONFIG_GLOBAL_RT_FLAG_CALLBACK_PRE | CO_CONFIG_GLOBAL_FLAG_TIMERNEXT | CO_CONFIG_GLOBAL_FLAG_OD_DYNAMIC) +#define CO_CONFIG_PDO \ + (CO_CONFIG_RPDO_ENABLE | CO_CONFIG_TPDO_ENABLE | CO_CONFIG_RPDO_TIMERS_ENABLE | CO_CONFIG_TPDO_TIMERS_ENABLE \ + | CO_CONFIG_PDO_SYNC_ENABLE | CO_CONFIG_PDO_OD_IO_ACCESS | CO_CONFIG_GLOBAL_RT_FLAG_CALLBACK_PRE \ + | CO_CONFIG_GLOBAL_FLAG_TIMERNEXT | CO_CONFIG_GLOBAL_FLAG_OD_DYNAMIC) #endif -#define CO_CONFIG_RPDO_ENABLE 0x01 -#define CO_CONFIG_TPDO_ENABLE 0x02 +#define CO_CONFIG_RPDO_ENABLE 0x01 +#define CO_CONFIG_TPDO_ENABLE 0x02 #define CO_CONFIG_RPDO_TIMERS_ENABLE 0x04 #define CO_CONFIG_TPDO_TIMERS_ENABLE 0x08 -#define CO_CONFIG_PDO_SYNC_ENABLE 0x10 -#define CO_CONFIG_PDO_OD_IO_ACCESS 0x20 +#define CO_CONFIG_PDO_SYNC_ENABLE 0x10 +#define CO_CONFIG_PDO_OD_IO_ACCESS 0x20 /** @} */ /* CO_STACK_CONFIG_SYNC_PDO */ - /** * @defgroup CO_STACK_CONFIG_STORAGE Data storage * Data storage with CANopen OD objects 1010 and 1011, CiA 301 @@ -518,7 +520,6 @@ extern "C" { #define CO_CONFIG_STORAGE_ENABLE 0x01 /** @} */ /* CO_STACK_CONFIG_STORAGE */ - /** * @defgroup CO_STACK_CONFIG_LEDS CANopen LED diodes * Specified in standard CiA 303-3 @@ -538,7 +539,6 @@ extern "C" { #define CO_CONFIG_LEDS_ENABLE 0x01 /** @} */ /* CO_STACK_CONFIG_LEDS */ - /** * @defgroup CO_STACK_CONFIG_SRDO Safety Related Data Objects (SRDO) * Specified in standard EN 50325-5 (CiA 304) @@ -555,7 +555,7 @@ extern "C" { #ifdef CO_DOXYGEN #define CO_CONFIG_GFC (0) #endif -#define CO_CONFIG_GFC_ENABLE 0x01 +#define CO_CONFIG_GFC_ENABLE 0x01 #define CO_CONFIG_GFC_CONSUMER 0x02 #define CO_CONFIG_GFC_PRODUCER 0x04 @@ -574,7 +574,7 @@ extern "C" { #ifdef CO_DOXYGEN #define CO_CONFIG_SRDO (0) #endif -#define CO_CONFIG_SRDO_ENABLE 0x01 +#define CO_CONFIG_SRDO_ENABLE 0x01 #define CO_CONFIG_SRDO_CHECK_TX 0x02 /** @@ -588,7 +588,6 @@ extern "C" { #endif /** @} */ /* CO_STACK_CONFIG_SRDO */ - /** * @defgroup CO_STACK_CONFIG_LSS LSS master/slave * Specified in standard CiA 305 @@ -609,12 +608,11 @@ extern "C" { #ifdef CO_DOXYGEN #define CO_CONFIG_LSS (CO_CONFIG_LSS_SLAVE | CO_CONFIG_GLOBAL_FLAG_CALLBACK_PRE) #endif -#define CO_CONFIG_LSS_SLAVE 0x01 +#define CO_CONFIG_LSS_SLAVE 0x01 #define CO_CONFIG_LSS_SLAVE_FASTSCAN_DIRECT_RESPOND 0x02 -#define CO_CONFIG_LSS_MASTER 0x10 +#define CO_CONFIG_LSS_MASTER 0x10 /** @} */ /* CO_STACK_CONFIG_LSS */ - /** * @defgroup CO_STACK_CONFIG_GATEWAY CANopen gateway * Specified in standard CiA 309 @@ -647,12 +645,12 @@ extern "C" { #ifdef CO_DOXYGEN #define CO_CONFIG_GTW (0) #endif -#define CO_CONFIG_GTW_MULTI_NET 0x01 -#define CO_CONFIG_GTW_ASCII 0x02 -#define CO_CONFIG_GTW_ASCII_SDO 0x04 -#define CO_CONFIG_GTW_ASCII_NMT 0x08 -#define CO_CONFIG_GTW_ASCII_LSS 0x10 -#define CO_CONFIG_GTW_ASCII_LOG 0x20 +#define CO_CONFIG_GTW_MULTI_NET 0x01 +#define CO_CONFIG_GTW_ASCII 0x02 +#define CO_CONFIG_GTW_ASCII_SDO 0x04 +#define CO_CONFIG_GTW_ASCII_NMT 0x08 +#define CO_CONFIG_GTW_ASCII_LSS 0x10 +#define CO_CONFIG_GTW_ASCII_LOG 0x20 #define CO_CONFIG_GTW_ASCII_ERROR_DESC 0x40 #define CO_CONFIG_GTW_ASCII_PRINT_HELP 0x80 #define CO_CONFIG_GTW_ASCII_PRINT_LEDS 0x100 @@ -686,7 +684,6 @@ extern "C" { #endif /** @} */ /* CO_STACK_CONFIG_GATEWAY */ - /** * @defgroup CO_STACK_CONFIG_CRC16 CRC 16 calculation * Helper object for CRC-16 checksum @@ -702,11 +699,10 @@ extern "C" { #ifdef CO_DOXYGEN #define CO_CONFIG_CRC16 (0) #endif -#define CO_CONFIG_CRC16_ENABLE 0x01 +#define CO_CONFIG_CRC16_ENABLE 0x01 #define CO_CONFIG_CRC16_EXTERNAL 0x02 /** @} */ /* CO_STACK_CONFIG_CRC16 */ - /** * @defgroup CO_STACK_CONFIG_FIFO FIFO buffer * Helper object for FIFO buffer @@ -736,14 +732,13 @@ extern "C" { #ifdef CO_DOXYGEN #define CO_CONFIG_FIFO (0) #endif -#define CO_CONFIG_FIFO_ENABLE 0x01 -#define CO_CONFIG_FIFO_ALT_READ 0x02 -#define CO_CONFIG_FIFO_CRC16_CCITT 0x04 -#define CO_CONFIG_FIFO_ASCII_COMMANDS 0x08 +#define CO_CONFIG_FIFO_ENABLE 0x01 +#define CO_CONFIG_FIFO_ALT_READ 0x02 +#define CO_CONFIG_FIFO_CRC16_CCITT 0x04 +#define CO_CONFIG_FIFO_ASCII_COMMANDS 0x08 #define CO_CONFIG_FIFO_ASCII_DATATYPES 0x10 /** @} */ /* CO_STACK_CONFIG_FIFO */ - /** * @defgroup CO_STACK_CONFIG_TRACE Trace recorder * Non standard object @@ -760,11 +755,10 @@ extern "C" { #ifdef CO_DOXYGEN #define CO_CONFIG_TRACE (0) #endif -#define CO_CONFIG_TRACE_ENABLE 0x01 +#define CO_CONFIG_TRACE_ENABLE 0x01 #define CO_CONFIG_TRACE_OWN_INTTYPES 0x02 /** @} */ /* CO_STACK_CONFIG_TRACE */ - /** * @defgroup CO_STACK_CONFIG_DEBUG Debug messages * Messages from different parts of the stack. @@ -784,7 +778,7 @@ extern "C" { #ifdef CO_DOXYGEN #define CO_CONFIG_DEBUG (0) #endif -#define CO_CONFIG_DEBUG_COMMON 0x01 +#define CO_CONFIG_DEBUG_COMMON 0x01 #define CO_CONFIG_DEBUG_SDO_CLIENT 0x02 #define CO_CONFIG_DEBUG_SDO_SERVER 0x04 /** @} */ /* CO_STACK_CONFIG_DEBUG */ diff --git a/301/CO_driver.h b/301/CO_driver.h index d588505..834e369 100644 --- a/301/CO_driver.h +++ b/301/CO_driver.h @@ -33,24 +33,24 @@ extern "C" { /* Stack configuration default global values. * For more information see file CO_config.h. */ #ifndef CO_CONFIG_GLOBAL_FLAG_CALLBACK_PRE - #define CO_CONFIG_GLOBAL_FLAG_CALLBACK_PRE (0) +#define CO_CONFIG_GLOBAL_FLAG_CALLBACK_PRE (0) #endif #ifndef CO_CONFIG_GLOBAL_RT_FLAG_CALLBACK_PRE - #define CO_CONFIG_GLOBAL_RT_FLAG_CALLBACK_PRE (0) +#define CO_CONFIG_GLOBAL_RT_FLAG_CALLBACK_PRE (0) #endif #ifndef CO_CONFIG_GLOBAL_FLAG_TIMERNEXT - #define CO_CONFIG_GLOBAL_FLAG_TIMERNEXT (0) +#define CO_CONFIG_GLOBAL_FLAG_TIMERNEXT (0) #endif #ifndef CO_CONFIG_GLOBAL_FLAG_OD_DYNAMIC - #define CO_CONFIG_GLOBAL_FLAG_OD_DYNAMIC CO_CONFIG_FLAG_OD_DYNAMIC +#define CO_CONFIG_GLOBAL_FLAG_OD_DYNAMIC CO_CONFIG_FLAG_OD_DYNAMIC #endif #ifdef CO_DEBUG_COMMON - #if (CO_CONFIG_DEBUG) & CO_CONFIG_DEBUG_SDO_CLIENT - #define CO_DEBUG_SDO_CLIENT(msg) CO_DEBUG_COMMON(msg) - #endif - #if (CO_CONFIG_DEBUG) & CO_CONFIG_DEBUG_SDO_SERVER - #define CO_DEBUG_SDO_SERVER(msg) CO_DEBUG_COMMON(msg) - #endif +#if (CO_CONFIG_DEBUG) & CO_CONFIG_DEBUG_SDO_CLIENT +#define CO_DEBUG_SDO_CLIENT(msg) CO_DEBUG_COMMON(msg) +#endif +#if (CO_CONFIG_DEBUG) & CO_CONFIG_DEBUG_SDO_SERVER +#define CO_DEBUG_SDO_SERVER(msg) CO_DEBUG_COMMON(msg) +#endif #endif /** @@ -111,7 +111,6 @@ extern "C" { /** Minor version number of CANopenNode */ #define CO_VERSION_MINOR 0 - /* Macros and declarations in following part are only used for documentation. */ #ifdef CO_DOXYGEN /** @@ -139,11 +138,11 @@ extern "C" { /** Macro must swap bytes, if CO_BIG_ENDIAN is defined */ #define CO_SWAP_64(x) x /** NULL, for general usage */ -#define NULL (0) +#define NULL (0) /** Logical true, for general use */ -#define true 1 +#define true 1 /** Logical false, for general use */ -#define false 0 +#define false 0 /** Boolean data type for general use */ typedef uint_fast8_t bool_t; /** INTEGER8 in CANopen (0002h), 8-bit signed integer */ @@ -168,7 +167,6 @@ typedef float float32_t; typedef double float64_t; /** @} */ - /** * @defgroup CO_CAN_Message_reception Reception of CAN messages * @{ @@ -200,7 +198,7 @@ typedef double float64_t; * registered with CO_CANrxBufferInit() * @param rxMsg pointer to received CAN message */ -void CANrx_callback(void *object, void *rxMsg); +void CANrx_callback(void* object, void* rxMsg); /** * CANrx_callback() can read CAN identifier from received CAN message @@ -216,7 +214,8 @@ void CANrx_callback(void *object, void *rxMsg); * @param rxMsg Pointer to received message * @return 11-bit CAN standard identifier. */ -static inline uint16_t CO_CANrxMsg_readIdent(void *rxMsg) { +static inline uint16_t +CO_CANrxMsg_readIdent(void* rxMsg) { return 0; } @@ -228,7 +227,8 @@ static inline uint16_t CO_CANrxMsg_readIdent(void *rxMsg) { * @param rxMsg Pointer to received message * @return data length in bytes (0 to 8) */ -static inline uint8_t CO_CANrxMsg_readDLC(void *rxMsg) { +static inline uint8_t +CO_CANrxMsg_readDLC(void* rxMsg) { return 0; } @@ -240,7 +240,8 @@ static inline uint8_t CO_CANrxMsg_readDLC(void *rxMsg) { * @param rxMsg Pointer to received message * @return pointer to data buffer */ -static inline const uint8_t *CO_CANrxMsg_readData(void *rxMsg) { +static inline const uint8_t* +CO_CANrxMsg_readData(void* rxMsg) { return NULL; } @@ -256,17 +257,16 @@ static inline const uint8_t *CO_CANrxMsg_readData(void *rxMsg) { * CO_CANmodule_t. */ typedef struct { - uint16_t ident; /**< Standard CAN Identifier (bits 0..10) + RTR (bit 11) */ - uint16_t mask; /**< Standard CAN Identifier mask with the same alignment as + uint16_t ident; /**< Standard CAN Identifier (bits 0..10) + RTR (bit 11) */ + uint16_t mask; /**< Standard CAN Identifier mask with the same alignment as ident */ - void *object; /**< \ref CO_obj "CANopenNode Object" initialized in from + void* object; /**< \ref CO_obj "CANopenNode Object" initialized in from CO_CANrxBufferInit() */ - void (*pCANrx_callback)( - void *object, void *message); /**< Pointer to CANrx_callback() + void (*pCANrx_callback)(void* object, void* message); /**< Pointer to CANrx_callback() initialized in CO_CANrxBufferInit() */ } CO_CANrx_t; -/** @} */ +/** @} */ /** * @defgroup CO_CAN_Message_transmission Transmission of CAN messages @@ -306,8 +306,8 @@ typedef struct { volatile bool_t syncFlag; /**< Synchronous PDO messages has this flag set. It prevents them to be sent outside the synchronous window */ } CO_CANtx_t; -/** @} */ +/** @} */ /** * Complete CAN module object. @@ -318,10 +318,10 @@ typedef struct { * microcontrollers. */ typedef struct { - void *CANptr; /**< From CO_CANmodule_init() */ - CO_CANrx_t *rxArray; /**< From CO_CANmodule_init() */ + void* CANptr; /**< From CO_CANmodule_init() */ + CO_CANrx_t* rxArray; /**< From CO_CANmodule_init() */ uint16_t rxSize; /**< From CO_CANmodule_init() */ - CO_CANtx_t *txArray; /**< From CO_CANmodule_init() */ + CO_CANtx_t* txArray; /**< From CO_CANmodule_init() */ uint16_t txSize; /**< From CO_CANmodule_init() */ uint16_t CANerrorStatus; /**< CAN error status bitfield, see @ref CO_CAN_ERR_status_t */ @@ -341,7 +341,6 @@ typedef struct { uint32_t errOld; /**< Previous state of CAN errors */ } CO_CANmodule_t; - /** * Data storage object for one entry. * @@ -354,7 +353,7 @@ typedef struct { */ typedef struct { /** Address of data to store, always required. */ - void *addr; + void* addr; /** Length of data to store, always required. */ size_t len; /** Sub index in OD objects 1010 and 1011, from 2 to 127. Writing @@ -366,7 +365,7 @@ typedef struct { uint8_t attr; /** Pointer to storage module, target system specific usage, required with * @ref CO_storage_eeprom. */ - void *storageModule; + void* storageModule; /** CRC checksum of the data stored in eeprom, set on store, required with * @ref CO_storage_eeprom. */ uint16_t crc; @@ -380,10 +379,9 @@ typedef struct { * @ref CO_storage_eeprom. */ size_t offset; /** Additional target specific parameters, optional. */ - void *additionalParameters; + void* additionalParameters; } CO_storage_entry_t; - /** * @defgroup CO_critical_sections Critical sections * @{ @@ -455,14 +453,21 @@ typedef struct { /** Check if new message has arrived */ #define CO_FLAG_READ(rxNew) ((rxNew) != NULL) /** Set new message flag */ -#define CO_FLAG_SET(rxNew) { __sync_synchronize(); rxNew = (void *)1L; } +#define CO_FLAG_SET(rxNew) \ + { \ + __sync_synchronize(); \ + rxNew = (void*)1L; \ + } /** Clear new message flag */ -#define CO_FLAG_CLEAR(rxNew) { __sync_synchronize(); rxNew = NULL; } +#define CO_FLAG_CLEAR(rxNew) \ + { \ + __sync_synchronize(); \ + rxNew = NULL; \ + } /** @} */ #endif /* CO_DOXYGEN */ - /** * @defgroup CO_Default_CAN_ID_t Default CANopen identifiers * @{ @@ -472,29 +477,28 @@ typedef struct { * can be changed in CANopen. Especially PDO identifiers are configured * in PDO linking phase of the CANopen network configuration. */ -#define CO_CAN_ID_NMT_SERVICE 0x000U /**< 0x000 Network management */ -#define CO_CAN_ID_GFC 0x001U /**< 0x001 Global fail-safe command */ -#define CO_CAN_ID_SYNC 0x080U /**< 0x080 Synchronous message */ -#define CO_CAN_ID_EMERGENCY 0x080U /**< 0x080 Emergency messages (+nodeID) */ -#define CO_CAN_ID_TIME 0x100U /**< 0x100 Time message */ -#define CO_CAN_ID_SRDO_1 0x0FFU /**< 0x0FF Default SRDO1 (+2*nodeID) */ -#define CO_CAN_ID_TPDO_1 0x180U /**< 0x180 Default TPDO1 (+nodeID) */ -#define CO_CAN_ID_RPDO_1 0x200U /**< 0x200 Default RPDO1 (+nodeID) */ -#define CO_CAN_ID_TPDO_2 0x280U /**< 0x280 Default TPDO2 (+nodeID) */ -#define CO_CAN_ID_RPDO_2 0x300U /**< 0x300 Default RPDO2 (+nodeID) */ -#define CO_CAN_ID_TPDO_3 0x380U /**< 0x380 Default TPDO3 (+nodeID) */ -#define CO_CAN_ID_RPDO_3 0x400U /**< 0x400 Default RPDO3 (+nodeID) */ -#define CO_CAN_ID_TPDO_4 0x480U /**< 0x480 Default TPDO4 (+nodeID) */ -#define CO_CAN_ID_RPDO_4 0x500U /**< 0x500 Default RPDO5 (+nodeID) */ -#define CO_CAN_ID_SDO_SRV 0x580U /**< 0x580 SDO response from server (+nodeID) */ -#define CO_CAN_ID_SDO_CLI 0x600U /**< 0x600 SDO request from client (+nodeID) */ -#define CO_CAN_ID_HEARTBEAT 0x700U /**< 0x700 Heartbeat message */ -#define CO_CAN_ID_LSS_SLV 0x7E4U /**< 0x7E4 LSS response from slave */ -#define CO_CAN_ID_LSS_MST 0x7E5U /**< 0x7E5 LSS request from master */ +#define CO_CAN_ID_NMT_SERVICE 0x000U /**< 0x000 Network management */ +#define CO_CAN_ID_GFC 0x001U /**< 0x001 Global fail-safe command */ +#define CO_CAN_ID_SYNC 0x080U /**< 0x080 Synchronous message */ +#define CO_CAN_ID_EMERGENCY 0x080U /**< 0x080 Emergency messages (+nodeID) */ +#define CO_CAN_ID_TIME 0x100U /**< 0x100 Time message */ +#define CO_CAN_ID_SRDO_1 0x0FFU /**< 0x0FF Default SRDO1 (+2*nodeID) */ +#define CO_CAN_ID_TPDO_1 0x180U /**< 0x180 Default TPDO1 (+nodeID) */ +#define CO_CAN_ID_RPDO_1 0x200U /**< 0x200 Default RPDO1 (+nodeID) */ +#define CO_CAN_ID_TPDO_2 0x280U /**< 0x280 Default TPDO2 (+nodeID) */ +#define CO_CAN_ID_RPDO_2 0x300U /**< 0x300 Default RPDO2 (+nodeID) */ +#define CO_CAN_ID_TPDO_3 0x380U /**< 0x380 Default TPDO3 (+nodeID) */ +#define CO_CAN_ID_RPDO_3 0x400U /**< 0x400 Default RPDO3 (+nodeID) */ +#define CO_CAN_ID_TPDO_4 0x480U /**< 0x480 Default TPDO4 (+nodeID) */ +#define CO_CAN_ID_RPDO_4 0x500U /**< 0x500 Default RPDO5 (+nodeID) */ +#define CO_CAN_ID_SDO_SRV 0x580U /**< 0x580 SDO response from server (+nodeID) */ +#define CO_CAN_ID_SDO_CLI 0x600U /**< 0x600 SDO request from client (+nodeID) */ +#define CO_CAN_ID_HEARTBEAT 0x700U /**< 0x700 Heartbeat message */ +#define CO_CAN_ID_LSS_SLV 0x7E4U /**< 0x7E4 LSS response from slave */ +#define CO_CAN_ID_LSS_MST 0x7E5U /**< 0x7E5 LSS request from master */ /** @} */ /* CO_Default_CAN_ID_t */ - /** * Restricted CAN-IDs * @@ -502,15 +506,12 @@ typedef struct { * They shall not be used for SYNC, TIME, EMCY, PDO and SDO. */ #ifndef CO_IS_RESTRICTED_CAN_ID -#define CO_IS_RESTRICTED_CAN_ID(CAN_ID) (((CAN_ID) <= 0x7FU) \ - || (((CAN_ID) >= 0x101U) && ((CAN_ID) <= 0x180U)) \ - || (((CAN_ID) >= 0x581U) && ((CAN_ID) <= 0x5FFU)) \ - || (((CAN_ID) >= 0x601U) && ((CAN_ID) <= 0x67FU)) \ - || (((CAN_ID) >= 0x6E0U) && ((CAN_ID) <= 0x6FFU)) \ - || ((CAN_ID) >= 0x701U)) +#define CO_IS_RESTRICTED_CAN_ID(CAN_ID) \ + (((CAN_ID) <= 0x7FU) || (((CAN_ID) >= 0x101U) && ((CAN_ID) <= 0x180U)) \ + || (((CAN_ID) >= 0x581U) && ((CAN_ID) <= 0x5FFU)) || (((CAN_ID) >= 0x601U) && ((CAN_ID) <= 0x67FU)) \ + || (((CAN_ID) >= 0x6E0U) && ((CAN_ID) <= 0x6FFU)) || ((CAN_ID) >= 0x701U)) #endif - /** * @defgroup CO_CAN_ERR_status_t CAN error status bitmasks * @{ @@ -520,15 +521,15 @@ typedef struct { * equal to 128. Transmitter goes in error state 'bus off' if transmit error * counter is more or equal to 256. */ -#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 */ +#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 */ @@ -537,52 +538,49 @@ typedef struct { * successfully it returns 0 otherwise it returns <0. */ typedef enum { - CO_ERROR_NO = 0, /**< Operation completed successfully */ - CO_ERROR_ILLEGAL_ARGUMENT = -1, /**< Error in function arguments */ - CO_ERROR_OUT_OF_MEMORY = -2, /**< Memory allocation failed */ - CO_ERROR_TIMEOUT = -3, /**< Function timeout */ - CO_ERROR_ILLEGAL_BAUDRATE = -4, /**< Illegal baudrate passed to function + CO_ERROR_NO = 0, /**< Operation completed successfully */ + CO_ERROR_ILLEGAL_ARGUMENT = -1, /**< Error in function arguments */ + CO_ERROR_OUT_OF_MEMORY = -2, /**< Memory allocation failed */ + CO_ERROR_TIMEOUT = -3, /**< Function timeout */ + CO_ERROR_ILLEGAL_BAUDRATE = -4, /**< Illegal baudrate passed to function CO_CANmodule_init() */ - CO_ERROR_RX_OVERFLOW = -5, /**< Previous message was not processed + CO_ERROR_RX_OVERFLOW = -5, /**< Previous message was not processed yet */ - CO_ERROR_RX_PDO_OVERFLOW = -6, /**< previous PDO was not processed yet */ - CO_ERROR_RX_MSG_LENGTH = -7, /**< Wrong receive message length */ - CO_ERROR_RX_PDO_LENGTH = -8, /**< Wrong receive PDO length */ - CO_ERROR_TX_OVERFLOW = -9, /**< Previous message is still waiting, + CO_ERROR_RX_PDO_OVERFLOW = -6, /**< previous PDO was not processed yet */ + CO_ERROR_RX_MSG_LENGTH = -7, /**< Wrong receive message length */ + CO_ERROR_RX_PDO_LENGTH = -8, /**< Wrong receive PDO length */ + CO_ERROR_TX_OVERFLOW = -9, /**< Previous message is still waiting, buffer full */ - CO_ERROR_TX_PDO_WINDOW = -10, /**< Synchronous TPDO is outside window */ - CO_ERROR_TX_UNCONFIGURED = -11, /**< Transmit buffer was not configured + CO_ERROR_TX_PDO_WINDOW = -10, /**< Synchronous TPDO is outside window */ + CO_ERROR_TX_UNCONFIGURED = -11, /**< Transmit buffer was not configured properly */ - CO_ERROR_OD_PARAMETERS = -12, /**< Error in Object Dictionary parameters*/ - CO_ERROR_DATA_CORRUPT = -13, /**< Stored data are corrupt */ - CO_ERROR_CRC = -14, /**< CRC does not match */ - CO_ERROR_TX_BUSY = -15, /**< Sending rejected because driver is + CO_ERROR_OD_PARAMETERS = -12, /**< Error in Object Dictionary parameters*/ + CO_ERROR_DATA_CORRUPT = -13, /**< Stored data are corrupt */ + CO_ERROR_CRC = -14, /**< CRC does not match */ + CO_ERROR_TX_BUSY = -15, /**< Sending rejected because driver is busy. Try again */ - CO_ERROR_WRONG_NMT_STATE = -16, /**< Command can't be processed in current + CO_ERROR_WRONG_NMT_STATE = -16, /**< Command can't be processed in current state */ - CO_ERROR_SYSCALL = -17, /**< Syscall failed */ - CO_ERROR_INVALID_STATE = -18, /**< Driver not ready */ + CO_ERROR_SYSCALL = -17, /**< Syscall failed */ + CO_ERROR_INVALID_STATE = -18, /**< Driver not ready */ CO_ERROR_NODE_ID_UNCONFIGURED_LSS = -19 /**< Node-id is in LSS unconfigured state. If objects are handled properly, this may not be an error. */ } CO_ReturnError_t; - /** * Request CAN configuration (stopped) mode and *wait* until it is set. * * @param CANptr Pointer to CAN device */ -void CO_CANsetConfigurationMode(void *CANptr); - +void CO_CANsetConfigurationMode(void* CANptr); /** * Request CAN normal (operational) mode and *wait* until it is set. * * @param CANmodule CO_CANmodule_t object. */ -void CO_CANsetNormalMode(CO_CANmodule_t *CANmodule); - +void CO_CANsetNormalMode(CO_CANmodule_t* CANmodule); /** * Initialize CAN module object. @@ -603,22 +601,15 @@ void CO_CANsetNormalMode(CO_CANmodule_t *CANmodule); * * Return #CO_ReturnError_t: CO_ERROR_NO or CO_ERROR_ILLEGAL_ARGUMENT. */ -CO_ReturnError_t CO_CANmodule_init(CO_CANmodule_t *CANmodule, - void *CANptr, - CO_CANrx_t rxArray[], - uint16_t rxSize, - CO_CANtx_t txArray[], - uint16_t txSize, - uint16_t CANbitRate); - +CO_ReturnError_t CO_CANmodule_init(CO_CANmodule_t* CANmodule, void* CANptr, CO_CANrx_t rxArray[], uint16_t rxSize, + CO_CANtx_t txArray[], uint16_t txSize, uint16_t CANbitRate); /** * Switch off CANmodule. Call at program exit. * * @param CANmodule CAN module object. */ -void CO_CANmodule_disable(CO_CANmodule_t *CANmodule); - +void CO_CANmodule_disable(CO_CANmodule_t* CANmodule); /** * Configure CAN message receive buffer. @@ -645,15 +636,8 @@ void CO_CANmodule_disable(CO_CANmodule_t *CANmodule); * Return #CO_ReturnError_t: CO_ERROR_NO CO_ERROR_ILLEGAL_ARGUMENT or * CO_ERROR_OUT_OF_MEMORY (not enough masks for configuration). */ -CO_ReturnError_t CO_CANrxBufferInit(CO_CANmodule_t *CANmodule, - uint16_t index, - uint16_t ident, - uint16_t mask, - bool_t rtr, - void *object, - void (*CANrx_callback)(void *object, - void *message)); - +CO_ReturnError_t CO_CANrxBufferInit(CO_CANmodule_t* CANmodule, uint16_t index, uint16_t ident, uint16_t mask, + bool_t rtr, void* object, void (*CANrx_callback)(void* object, void* message)); /** * Configure CAN message transmit buffer. @@ -673,14 +657,9 @@ CO_ReturnError_t CO_CANrxBufferInit(CO_CANmodule_t *CANmodule, * buffer should be written, before CO_CANsend() function is called. * Zero is returned in case of wrong arguments. */ -CO_CANtx_t *CO_CANtxBufferInit(CO_CANmodule_t *CANmodule, - uint16_t index, - uint16_t ident, - bool_t rtr, - uint8_t noOfBytes, +CO_CANtx_t* CO_CANtxBufferInit(CO_CANmodule_t* CANmodule, uint16_t index, uint16_t ident, bool_t rtr, uint8_t noOfBytes, bool_t syncFlag); - /** * Send CAN message. * @@ -691,8 +670,7 @@ CO_CANtx_t *CO_CANtxBufferInit(CO_CANmodule_t *CANmodule, * @return #CO_ReturnError_t: CO_ERROR_NO, CO_ERROR_TX_OVERFLOW or * CO_ERROR_TX_PDO_WINDOW (Synchronous TPDO is outside window). */ -CO_ReturnError_t CO_CANsend(CO_CANmodule_t *CANmodule, CO_CANtx_t *buffer); - +CO_ReturnError_t CO_CANsend(CO_CANmodule_t* CANmodule, CO_CANtx_t* buffer); /** * Clear all synchronous TPDOs from CAN module transmit buffers. @@ -708,8 +686,7 @@ CO_ReturnError_t CO_CANsend(CO_CANmodule_t *CANmodule, CO_CANtx_t *buffer); * * @param CANmodule This object. */ -void CO_CANclearPendingSyncPDOs(CO_CANmodule_t *CANmodule); - +void CO_CANclearPendingSyncPDOs(CO_CANmodule_t* CANmodule); /** * Process can module - verify CAN errors @@ -719,8 +696,7 @@ void CO_CANclearPendingSyncPDOs(CO_CANmodule_t *CANmodule); * * @param CANmodule This object. */ -void CO_CANmodule_process(CO_CANmodule_t *CANmodule); - +void CO_CANmodule_process(CO_CANmodule_t* CANmodule); /** * Get uint8_t value from memory buffer @@ -729,16 +705,27 @@ void CO_CANmodule_process(CO_CANmodule_t *CANmodule); * * @return Value */ -static inline uint8_t CO_getUint8(const void *buf) { - uint8_t value; (void)memmove((void *)&value, buf, sizeof(value)); return value; +static inline uint8_t +CO_getUint8(const void* buf) { + uint8_t value; + (void)memmove((void*)&value, buf, sizeof(value)); + return value; } + /** Get uint16_t value from memory buffer, see @ref CO_getUint8 */ -static inline uint16_t CO_getUint16(const void *buf) { - uint16_t value; (void)memmove((void *)&value, buf, sizeof(value)); return value; +static inline uint16_t +CO_getUint16(const void* buf) { + uint16_t value; + (void)memmove((void*)&value, buf, sizeof(value)); + return value; } + /** Get uint32_t value from memory buffer, see @ref CO_getUint8 */ -static inline uint32_t CO_getUint32(const void *buf) { - uint32_t value; (void)memmove((void *)&value, buf, sizeof(value)); return value; +static inline uint32_t +CO_getUint32(const void* buf) { + uint32_t value; + (void)memmove((void*)&value, buf, sizeof(value)); + return value; } /** @@ -749,16 +736,24 @@ static inline uint32_t CO_getUint32(const void *buf) { * * @return number of bytes written. */ -static inline uint8_t CO_setUint8(void *buf, uint8_t value) { - (void)memmove(buf, (const void *)&value, sizeof(value)); return (uint8_t)(sizeof(value)); +static inline uint8_t +CO_setUint8(void* buf, uint8_t value) { + (void)memmove(buf, (const void*)&value, sizeof(value)); + return (uint8_t)(sizeof(value)); } + /** Write uint16_t value into memory buffer, see @ref CO_setUint8 */ -static inline uint8_t CO_setUint16(void *buf, uint16_t value) { - (void)memmove(buf, (const void *)&value, sizeof(value)); return (uint8_t)(sizeof(value)); +static inline uint8_t +CO_setUint16(void* buf, uint16_t value) { + (void)memmove(buf, (const void*)&value, sizeof(value)); + return (uint8_t)(sizeof(value)); } + /** Write uint32_t value into memory buffer, see @ref CO_setUint8 */ -static inline uint8_t CO_setUint32(void *buf, uint32_t value) { - (void)memmove(buf, (const void *)&value, sizeof(value)); return (uint8_t)(sizeof(value)); +static inline uint8_t +CO_setUint32(void* buf, uint32_t value) { + (void)memmove(buf, (const void*)&value, sizeof(value)); + return (uint8_t)(sizeof(value)); } /** @} */ /* CO_driver */ diff --git a/301/CO_fifo.h b/301/CO_fifo.h index 671699b..8c1a9ca 100644 --- a/301/CO_fifo.h +++ b/301/CO_fifo.h @@ -28,7 +28,7 @@ #define CO_CONFIG_FIFO (0) #endif -#if (((CO_CONFIG_FIFO) & CO_CONFIG_FIFO_ENABLE) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_FIFO)&CO_CONFIG_FIFO_ENABLE) != 0) || defined CO_DOXYGEN #ifdef __cplusplus extern "C" { @@ -56,18 +56,18 @@ extern "C" { */ typedef struct { /** Buffer of size bufSize. Initialized by CO_fifo_init() */ - uint8_t *buf; + uint8_t* buf; /** Initialized by CO_fifo_init() */ size_t bufSize; /** Location in the buffer, which will be next written. */ size_t writePtr; /** Location in the buffer, which will be next read. */ size_t readPtr; -#if (((CO_CONFIG_FIFO) & CO_CONFIG_FIFO_ALT_READ) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_FIFO)&CO_CONFIG_FIFO_ALT_READ) != 0) || defined CO_DOXYGEN /** Location in the buffer, which will be next read. */ size_t altReadPtr; #endif -#if (((CO_CONFIG_FIFO) & CO_CONFIG_FIFO_ASCII_DATATYPES) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_FIFO)&CO_CONFIG_FIFO_ASCII_DATATYPES) != 0) || defined CO_DOXYGEN /** helper variable, set to false in CO_fifo_reset(), used in some * functions. */ bool_t started; @@ -76,8 +76,6 @@ typedef struct { #endif } CO_fifo_t; - - /** * Initialize fifo object * @@ -86,19 +84,19 @@ typedef struct { * @param bufSize Size of the above buffer. Usable size of the buffer will be * one byte less than bufSize, it is used for operation of the circular buffer. */ -void CO_fifo_init(CO_fifo_t *fifo, uint8_t *buf, size_t bufSize); - +void CO_fifo_init(CO_fifo_t* fifo, uint8_t* buf, size_t bufSize); /** * Reset fifo object, make it empty * * @param fifo This object */ -static inline void CO_fifo_reset(CO_fifo_t *fifo) { +static inline void +CO_fifo_reset(CO_fifo_t* fifo) { if (fifo != NULL) { fifo->readPtr = 0; fifo->writePtr = 0; -#if ((CO_CONFIG_FIFO) & CO_CONFIG_FIFO_ASCII_DATATYPES) != 0 +#if ((CO_CONFIG_FIFO)&CO_CONFIG_FIFO_ASCII_DATATYPES) != 0 fifo->started = false; #endif } @@ -106,7 +104,6 @@ static inline void CO_fifo_reset(CO_fifo_t *fifo) { return; } - /** * Purge all data in fifo object, keep other properties * @@ -114,7 +111,8 @@ static inline void CO_fifo_reset(CO_fifo_t *fifo) { * * @return true, if data were purged or false, if fifo were already empty */ -static inline bool_t CO_fifo_purge(CO_fifo_t *fifo) { +static inline bool_t +CO_fifo_purge(CO_fifo_t* fifo) { if (fifo != NULL && fifo->readPtr != fifo->writePtr) { fifo->readPtr = 0; fifo->writePtr = 0; @@ -124,7 +122,6 @@ static inline bool_t CO_fifo_purge(CO_fifo_t *fifo) { return false; } - /** * Get free buffer space in CO_fifo_t object * @@ -132,16 +129,16 @@ static inline bool_t CO_fifo_purge(CO_fifo_t *fifo) { * * @return number of available bytes */ -static inline size_t CO_fifo_getSpace(CO_fifo_t *fifo) { +static inline size_t +CO_fifo_getSpace(CO_fifo_t* fifo) { int sizeLeft = (int)fifo->readPtr - (int)fifo->writePtr - 1; if (sizeLeft < 0) { sizeLeft += (int)fifo->bufSize; } - return (size_t) sizeLeft; + return (size_t)sizeLeft; } - /** * Get size of data inside CO_fifo_t buffer object * @@ -149,16 +146,16 @@ static inline size_t CO_fifo_getSpace(CO_fifo_t *fifo) { * * @return number of occupied bytes */ -static inline size_t CO_fifo_getOccupied(CO_fifo_t *fifo) { +static inline size_t +CO_fifo_getOccupied(CO_fifo_t* fifo) { int sizeOccupied = (int)fifo->writePtr - (int)fifo->readPtr; if (sizeOccupied < 0) { sizeOccupied += (int)fifo->bufSize; } - return (size_t) sizeOccupied; + return (size_t)sizeOccupied; } - /** * Put one character into CO_fifo_t buffer object * @@ -167,12 +164,11 @@ static inline size_t CO_fifo_getOccupied(CO_fifo_t *fifo) { * * @return true, if write was successful (enough space in fifo buffer) */ -static inline bool_t CO_fifo_putc(CO_fifo_t *fifo, const uint8_t c) { +static inline bool_t +CO_fifo_putc(CO_fifo_t* fifo, const uint8_t c) { if (fifo != NULL && fifo->buf != NULL) { size_t writePtrNext = fifo->writePtr + 1; - if (writePtrNext != fifo->readPtr && - !(writePtrNext == fifo->bufSize && fifo->readPtr == 0)) - { + if (writePtrNext != fifo->readPtr && !(writePtrNext == fifo->bufSize && fifo->readPtr == 0)) { fifo->buf[fifo->writePtr] = c; fifo->writePtr = (writePtrNext == fifo->bufSize) ? 0 : writePtrNext; return true; @@ -181,7 +177,6 @@ static inline bool_t CO_fifo_putc(CO_fifo_t *fifo, const uint8_t c) { return false; } - /** * Put one character into CO_fifo_t buffer object * @@ -190,18 +185,22 @@ static inline bool_t CO_fifo_putc(CO_fifo_t *fifo, const uint8_t c) { * @param fifo This object * @param c Character to put */ -static inline void CO_fifo_putc_ov(CO_fifo_t *fifo, const uint8_t c) { +static inline void +CO_fifo_putc_ov(CO_fifo_t* fifo, const uint8_t c) { if (fifo != NULL && fifo->buf != NULL) { fifo->buf[fifo->writePtr] = c; - if (++fifo->writePtr == fifo->bufSize) fifo->writePtr = 0; + if (++fifo->writePtr == fifo->bufSize) { + fifo->writePtr = 0; + } if (fifo->readPtr == fifo->writePtr) { - if (++fifo->readPtr == fifo->bufSize) fifo->readPtr = 0; + if (++fifo->readPtr == fifo->bufSize) { + fifo->readPtr = 0; + } } } } - /** * Get one character from CO_fifo_t buffer object * @@ -210,7 +209,8 @@ static inline void CO_fifo_putc_ov(CO_fifo_t *fifo, const uint8_t c) { * * @return true, if read was successful (non-empty fifo buffer) */ -static inline bool_t CO_fifo_getc(CO_fifo_t *fifo, uint8_t *buf) { +static inline bool_t +CO_fifo_getc(CO_fifo_t* fifo, uint8_t* buf) { if (fifo != NULL && buf != NULL && fifo->readPtr != fifo->writePtr) { *buf = fifo->buf[fifo->readPtr]; if (++fifo->readPtr == fifo->bufSize) { @@ -221,7 +221,6 @@ static inline bool_t CO_fifo_getc(CO_fifo_t *fifo, uint8_t *buf) { return false; } - /** * Write data into CO_fifo_t object. * @@ -237,11 +236,7 @@ static inline bool_t CO_fifo_getc(CO_fifo_t *fifo, uint8_t *buf) { * * @return number of bytes actually written. */ -size_t CO_fifo_write(CO_fifo_t *fifo, - const uint8_t *buf, - size_t count, - uint16_t *crc); - +size_t CO_fifo_write(CO_fifo_t* fifo, const uint8_t* buf, size_t count, uint16_t* crc); /** * Read data from CO_fifo_t object. @@ -259,10 +254,9 @@ size_t CO_fifo_write(CO_fifo_t *fifo, * * @return number of bytes actually read. */ -size_t CO_fifo_read(CO_fifo_t *fifo, uint8_t *buf, size_t count, bool_t *eof); +size_t CO_fifo_read(CO_fifo_t* fifo, uint8_t* buf, size_t count, bool_t* eof); - -#if (((CO_CONFIG_FIFO) & CO_CONFIG_FIFO_ALT_READ) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_FIFO)&CO_CONFIG_FIFO_ALT_READ) != 0) || defined CO_DOXYGEN /** * Initializes alternate read with #CO_fifo_altRead * @@ -271,8 +265,7 @@ size_t CO_fifo_read(CO_fifo_t *fifo, uint8_t *buf, size_t count, bool_t *eof); * * @return same as offset or lower, if there is not enough data. */ -size_t CO_fifo_altBegin(CO_fifo_t *fifo, size_t offset); - +size_t CO_fifo_altBegin(CO_fifo_t* fifo, size_t offset); /** * Ends alternate read with #CO_fifo_altRead and calculate crc checksum @@ -281,8 +274,7 @@ size_t CO_fifo_altBegin(CO_fifo_t *fifo, size_t offset); * @param [in,out] crc Externally defined variable for CRC checksum, ignored if * NULL */ -void CO_fifo_altFinish(CO_fifo_t *fifo, uint16_t *crc); - +void CO_fifo_altFinish(CO_fifo_t* fifo, uint16_t* crc); /** * Get alternate size of remaining data, see #CO_fifo_altRead @@ -291,16 +283,16 @@ void CO_fifo_altFinish(CO_fifo_t *fifo, uint16_t *crc); * * @return number of occupied bytes. */ -static inline size_t CO_fifo_altGetOccupied(CO_fifo_t *fifo) { +static inline size_t +CO_fifo_altGetOccupied(CO_fifo_t* fifo) { int sizeOccupied = (int)fifo->writePtr - (int)fifo->altReadPtr; if (sizeOccupied < 0) { sizeOccupied += (int)fifo->bufSize; } - return (size_t) sizeOccupied; + return (size_t)sizeOccupied; } - /** * Alternate read data from CO_fifo_t object. * @@ -317,11 +309,10 @@ static inline size_t CO_fifo_altGetOccupied(CO_fifo_t *fifo) { * * @return number of bytes actually read. */ -size_t CO_fifo_altRead(CO_fifo_t *fifo, uint8_t *buf, size_t count); +size_t CO_fifo_altRead(CO_fifo_t* fifo, uint8_t* buf, size_t count); #endif /* #if (CO_CONFIG_FIFO) & CO_CONFIG_FIFO_ALT_READ */ - -#if (((CO_CONFIG_FIFO) & CO_CONFIG_FIFO_ASCII_COMMANDS) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_FIFO)&CO_CONFIG_FIFO_ASCII_COMMANDS) != 0) || defined CO_DOXYGEN /** * Search command inside FIFO * @@ -346,8 +337,7 @@ size_t CO_fifo_altRead(CO_fifo_t *fifo, uint8_t *buf, size_t count); * * @return true if command with delimiter found or buffer full. */ -bool_t CO_fifo_CommSearch(CO_fifo_t *fifo, bool_t clear); - +bool_t CO_fifo_CommSearch(CO_fifo_t* fifo, bool_t clear); /** * Trim spaces inside FIFO @@ -363,8 +353,7 @@ bool_t CO_fifo_CommSearch(CO_fifo_t *fifo, bool_t clear); * * @return true if command delimiter was found. */ -bool_t CO_fifo_trimSpaces(CO_fifo_t *fifo, bool_t *insideComment); - +bool_t CO_fifo_trimSpaces(CO_fifo_t* fifo, bool_t* insideComment); /** * Get token from FIFO buffer @@ -403,15 +392,10 @@ bool_t CO_fifo_trimSpaces(CO_fifo_t *fifo, bool_t *insideComment); * * @return Number of bytes read. */ -size_t CO_fifo_readToken(CO_fifo_t *fifo, - char *buf, - size_t count, - uint8_t *closed, - bool_t *err); +size_t CO_fifo_readToken(CO_fifo_t* fifo, char* buf, size_t count, uint8_t* closed, bool_t* err); #endif /* (CO_CONFIG_FIFO) & CO_CONFIG_FIFO_ASCII_COMMANDS */ - -#if (((CO_CONFIG_FIFO) & CO_CONFIG_FIFO_ASCII_DATATYPES) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_FIFO)&CO_CONFIG_FIFO_ASCII_DATATYPES) != 0) || defined CO_DOXYGEN /** * Read uint8_t variable from fifo and output as ascii string. * @@ -422,64 +406,63 @@ size_t CO_fifo_readToken(CO_fifo_t *fifo, * * @return Number of ascii bytes written into buf. */ -size_t CO_fifo_readU82a (CO_fifo_t *fifo, char *buf, size_t count, bool_t end); +size_t CO_fifo_readU82a(CO_fifo_t* fifo, char* buf, size_t count, bool_t end); /** Read uint16_t variable from fifo as ascii string, see CO_fifo_readU82a */ -size_t CO_fifo_readU162a(CO_fifo_t *fifo, char *buf, size_t count, bool_t end); +size_t CO_fifo_readU162a(CO_fifo_t* fifo, char* buf, size_t count, bool_t end); /** Read uint32_t variable from fifo as ascii string, see CO_fifo_readU82a */ -size_t CO_fifo_readU322a(CO_fifo_t *fifo, char *buf, size_t count, bool_t end); +size_t CO_fifo_readU322a(CO_fifo_t* fifo, char* buf, size_t count, bool_t end); /** Read uint64_t variable from fifo as ascii string, see CO_fifo_readU82a */ -size_t CO_fifo_readU642a(CO_fifo_t *fifo, char *buf, size_t count, bool_t end); +size_t CO_fifo_readU642a(CO_fifo_t* fifo, char* buf, size_t count, bool_t end); /** Read uint8_t variable from fifo as ascii string, see CO_fifo_readU82a */ -size_t CO_fifo_readX82a (CO_fifo_t *fifo, char *buf, size_t count, bool_t end); +size_t CO_fifo_readX82a(CO_fifo_t* fifo, char* buf, size_t count, bool_t end); /** Read uint16_t variable from fifo as ascii string, see CO_fifo_readU82a */ -size_t CO_fifo_readX162a(CO_fifo_t *fifo, char *buf, size_t count, bool_t end); +size_t CO_fifo_readX162a(CO_fifo_t* fifo, char* buf, size_t count, bool_t end); /** Read uint32_t variable from fifo as ascii string, see CO_fifo_readU82a */ -size_t CO_fifo_readX322a(CO_fifo_t *fifo, char *buf, size_t count, bool_t end); +size_t CO_fifo_readX322a(CO_fifo_t* fifo, char* buf, size_t count, bool_t end); /** Read uint64_t variable from fifo as ascii string, see CO_fifo_readU82a */ -size_t CO_fifo_readX642a(CO_fifo_t *fifo, char *buf, size_t count, bool_t end); +size_t CO_fifo_readX642a(CO_fifo_t* fifo, char* buf, size_t count, bool_t end); /** Read int8_t variable from fifo as ascii string, see CO_fifo_readU82a */ -size_t CO_fifo_readI82a (CO_fifo_t *fifo, char *buf, size_t count, bool_t end); +size_t CO_fifo_readI82a(CO_fifo_t* fifo, char* buf, size_t count, bool_t end); /** Read int16_t variable from fifo as ascii string, see CO_fifo_readU82a */ -size_t CO_fifo_readI162a(CO_fifo_t *fifo, char *buf, size_t count, bool_t end); +size_t CO_fifo_readI162a(CO_fifo_t* fifo, char* buf, size_t count, bool_t end); /** Read int32_t variable from fifo as ascii string, see CO_fifo_readU82a */ -size_t CO_fifo_readI322a(CO_fifo_t *fifo, char *buf, size_t count, bool_t end); +size_t CO_fifo_readI322a(CO_fifo_t* fifo, char* buf, size_t count, bool_t end); /** Read int64_t variable from fifo as ascii string, see CO_fifo_readU82a */ -size_t CO_fifo_readI642a(CO_fifo_t *fifo, char *buf, size_t count, bool_t end); +size_t CO_fifo_readI642a(CO_fifo_t* fifo, char* buf, size_t count, bool_t end); /** Read float32_t variable from fifo as ascii string, see CO_fifo_readU82a */ -size_t CO_fifo_readR322a(CO_fifo_t *fifo, char *buf, size_t count, bool_t end); +size_t CO_fifo_readR322a(CO_fifo_t* fifo, char* buf, size_t count, bool_t end); /** Read float64_t variable from fifo as ascii string, see CO_fifo_readU82a */ -size_t CO_fifo_readR642a(CO_fifo_t *fifo, char *buf, size_t count, bool_t end); +size_t CO_fifo_readR642a(CO_fifo_t* fifo, char* buf, size_t count, bool_t end); /** Read data from fifo and output as space separated two digit ascii string, * see also CO_fifo_readU82a */ -size_t CO_fifo_readHex2a(CO_fifo_t *fifo, char *buf, size_t count, bool_t end); +size_t CO_fifo_readHex2a(CO_fifo_t* fifo, char* buf, size_t count, bool_t end); /** Read data from fifo and output as visible string. A visible string is * enclosed with double quotes. If a double quote is used within the string, * the quotes are escaped by a second quotes, e.g. “Hello “”World””, CANopen * is great”. UTF-8 characters and also line breaks works with this function. * Function removes all NULL and CR characters from output string. * See also CO_fifo_readU82a */ -size_t CO_fifo_readVs2a(CO_fifo_t *fifo, char *buf, size_t count, bool_t end); +size_t CO_fifo_readVs2a(CO_fifo_t* fifo, char* buf, size_t count, bool_t end); /** Read data from fifo and output as mime-base64 encoded string. Encoding is as * specified in RFC 2045, without CR-LF, but one long string. See also * CO_fifo_readU82a */ -size_t CO_fifo_readB642a(CO_fifo_t *fifo, char *buf, size_t count, bool_t end); - +size_t CO_fifo_readB642a(CO_fifo_t* fifo, char* buf, size_t count, bool_t end); /** Bitfields for status argument from CO_fifo_cpyTok2U8 function and similar */ - /** * @defgroup uint8_t Bitfields for status argument from CO_fifo_cpyTok2U8 function and similar * @{ */ -#define CO_fifo_st_closed 0x01U /**< Bit is set, if command delimiter is reached in src */ -#define CO_fifo_st_partial 0x02U /**< Bit is set, if copy was partial and more data are available. If unset and no error, then all data was successfully copied. */ -#define CO_fifo_st_errTok 0x10U /**< Bit is set, if no valid token found */ -#define CO_fifo_st_errVal 0x20U /**< Bit is set, if value is not valid or out of limits */ -#define CO_fifo_st_errBuf 0x40U /**< Bit is set, if destination buffer is to small */ -#define CO_fifo_st_errInt 0x80U /**< Bit is set, if internal error */ -#define CO_fifo_st_errMask 0xF0U /**< Bitmask for error bits */ -/** @} */ /* uint8_t */ +#define CO_fifo_st_closed 0x01U /**< Bit is set, if command delimiter is reached in src */ +#define CO_fifo_st_partial \ + 0x02U /**< Bit is set, if copy was partial and more data are available. If unset and no error, then all data was successfully copied. */ +#define CO_fifo_st_errTok 0x10U /**< Bit is set, if no valid token found */ +#define CO_fifo_st_errVal 0x20U /**< Bit is set, if value is not valid or out of limits */ +#define CO_fifo_st_errBuf 0x40U /**< Bit is set, if destination buffer is to small */ +#define CO_fifo_st_errInt 0x80U /**< Bit is set, if internal error */ +#define CO_fifo_st_errMask 0xF0U /**< Bitmask for error bits */ +/** @} */ /* uint8_t */ /** * Read ascii string from src fifo and copy as uint8_t variable to dest fifo. @@ -490,37 +473,37 @@ size_t CO_fifo_readB642a(CO_fifo_t *fifo, char *buf, size_t count, bool_t end); * * @return Number of bytes written into dest. */ -size_t CO_fifo_cpyTok2U8 (CO_fifo_t *dest, CO_fifo_t *src, uint8_t *status); +size_t CO_fifo_cpyTok2U8(CO_fifo_t* dest, CO_fifo_t* src, uint8_t* status); /** Copy ascii string to uint16_t variable, see CO_fifo_cpyTok2U8 */ -size_t CO_fifo_cpyTok2U16(CO_fifo_t *dest, CO_fifo_t *src, uint8_t *status); +size_t CO_fifo_cpyTok2U16(CO_fifo_t* dest, CO_fifo_t* src, uint8_t* status); /** Copy ascii string to uint32_t variable, see CO_fifo_cpyTok2U8 */ -size_t CO_fifo_cpyTok2U32(CO_fifo_t *dest, CO_fifo_t *src, uint8_t *status); +size_t CO_fifo_cpyTok2U32(CO_fifo_t* dest, CO_fifo_t* src, uint8_t* status); /** Copy ascii string to uint64_t variable, see CO_fifo_cpyTok2U8 */ -size_t CO_fifo_cpyTok2U64(CO_fifo_t *dest, CO_fifo_t *src, uint8_t *status); +size_t CO_fifo_cpyTok2U64(CO_fifo_t* dest, CO_fifo_t* src, uint8_t* status); /** Copy ascii string to int8_t variable, see CO_fifo_cpyTok2U8 */ -size_t CO_fifo_cpyTok2I8 (CO_fifo_t *dest, CO_fifo_t *src, uint8_t *status); +size_t CO_fifo_cpyTok2I8(CO_fifo_t* dest, CO_fifo_t* src, uint8_t* status); /** Copy ascii string to int16_t variable, see CO_fifo_cpyTok2U8 */ -size_t CO_fifo_cpyTok2I16(CO_fifo_t *dest, CO_fifo_t *src, uint8_t *status); +size_t CO_fifo_cpyTok2I16(CO_fifo_t* dest, CO_fifo_t* src, uint8_t* status); /** Copy ascii string to int32_t variable, see CO_fifo_cpyTok2U8 */ -size_t CO_fifo_cpyTok2I32(CO_fifo_t *dest, CO_fifo_t *src, uint8_t *status); +size_t CO_fifo_cpyTok2I32(CO_fifo_t* dest, CO_fifo_t* src, uint8_t* status); /** Copy ascii string to int64_t variable, see CO_fifo_cpyTok2U8 */ -size_t CO_fifo_cpyTok2I64(CO_fifo_t *dest, CO_fifo_t *src, uint8_t *status); +size_t CO_fifo_cpyTok2I64(CO_fifo_t* dest, CO_fifo_t* src, uint8_t* status); /** Copy ascii string to float32_t variable, see CO_fifo_cpyTok2U8 */ -size_t CO_fifo_cpyTok2R32(CO_fifo_t *dest, CO_fifo_t *src, uint8_t *status); +size_t CO_fifo_cpyTok2R32(CO_fifo_t* dest, CO_fifo_t* src, uint8_t* status); /** Copy ascii string to float64_t variable, see CO_fifo_cpyTok2U8 */ -size_t CO_fifo_cpyTok2R64(CO_fifo_t *dest, CO_fifo_t *src, uint8_t *status); +size_t CO_fifo_cpyTok2R64(CO_fifo_t* dest, CO_fifo_t* src, uint8_t* status); /** Copy bytes written as two hex digits into to data. Bytes may be space * separated. See CO_fifo_cpyTok2U8 for parameters. */ -size_t CO_fifo_cpyTok2Hex(CO_fifo_t *dest, CO_fifo_t *src, uint8_t *status); +size_t CO_fifo_cpyTok2Hex(CO_fifo_t* dest, CO_fifo_t* src, uint8_t* status); /** Copy visible string to data. A visible string must be enclosed with double * quotes, if it contains space. If a double quote is used within the string, * the quotes are escaped by a second quotes. Input string can not contain * newline characters. See CO_fifo_cpyTok2U8 */ -size_t CO_fifo_cpyTok2Vs(CO_fifo_t *dest, CO_fifo_t *src, uint8_t *status); +size_t CO_fifo_cpyTok2Vs(CO_fifo_t* dest, CO_fifo_t* src, uint8_t* status); /** Read ascii mime-base64 encoded string from src fifo and copy as binary data * to dest fifo. Encoding is as specified in RFC 2045, without CR-LF, but one * long string in single line. See also CO_fifo_readU82a */ -size_t CO_fifo_cpyTok2B64(CO_fifo_t *dest, CO_fifo_t *src, uint8_t *status); +size_t CO_fifo_cpyTok2B64(CO_fifo_t* dest, CO_fifo_t* src, uint8_t* status); #endif /* (CO_CONFIG_FIFO) & CO_CONFIG_FIFO_ASCII_DATATYPES */ diff --git a/301/crc16-ccitt.h b/301/crc16-ccitt.h index 2256903..8643d6d 100644 --- a/301/crc16-ccitt.h +++ b/301/crc16-ccitt.h @@ -29,7 +29,7 @@ #define CO_CONFIG_CRC16 (0) #endif -#if (((CO_CONFIG_CRC16) & CO_CONFIG_CRC16_ENABLE) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_CRC16)&CO_CONFIG_CRC16_ENABLE) != 0) || defined CO_DOXYGEN #ifdef __cplusplus extern "C" { @@ -47,7 +47,6 @@ extern "C" { * `x^16 + x^12 + x^5 + 1` */ - /** * Update crc16_ccitt variable with one data byte * @@ -58,8 +57,7 @@ extern "C" { * start of new CRC calculation, variable must be initialized (zero for xmodem). * @param chr One byte of data */ -void crc16_ccitt_single(uint16_t *crc, const uint8_t chr); - +void crc16_ccitt_single(uint16_t* crc, const uint8_t chr); /** * Calculate CRC sum on block of data. @@ -71,10 +69,7 @@ void crc16_ccitt_single(uint16_t *crc, const uint8_t chr); * * @return Calculated CRC. */ -uint16_t crc16_ccitt(const uint8_t block[], - size_t blockLength, - uint16_t crc); - +uint16_t crc16_ccitt(const uint8_t block[], size_t blockLength, uint16_t crc); /** @} */ /* CO_crc16_ccitt */ diff --git a/303/CO_LEDs.h b/303/CO_LEDs.h index caa2fb2..7cb4d9a 100644 --- a/303/CO_LEDs.h +++ b/303/CO_LEDs.h @@ -26,11 +26,10 @@ /* default configuration, see CO_config.h */ #ifndef CO_CONFIG_LEDS -#define CO_CONFIG_LEDS (CO_CONFIG_LEDS_ENABLE | \ - CO_CONFIG_GLOBAL_FLAG_TIMERNEXT) +#define CO_CONFIG_LEDS (CO_CONFIG_LEDS_ENABLE | CO_CONFIG_GLOBAL_FLAG_TIMERNEXT) #endif -#if (((CO_CONFIG_LEDS) & CO_CONFIG_LEDS_ENABLE) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_LEDS)&CO_CONFIG_LEDS_ENABLE) != 0) || defined CO_DOXYGEN #ifdef __cplusplus extern "C" { @@ -73,37 +72,35 @@ extern "C" { * @{ * */ -#define CO_LED_flicker 0x01U /**< LED flickering 10Hz */ -#define CO_LED_blink 0x02U /**< LED blinking 2,5Hz */ -#define CO_LED_flash_1 0x04U /**< LED single flash */ -#define CO_LED_flash_2 0x08U /**< LED double flash */ -#define CO_LED_flash_3 0x10U /**< LED triple flash */ -#define CO_LED_flash_4 0x20U /**< LED quadruple flash */ -#define CO_LED_CANopen 0x80U /**< LED CANopen according to CiA 303-3 */ +#define CO_LED_flicker 0x01U /**< LED flickering 10Hz */ +#define CO_LED_blink 0x02U /**< LED blinking 2,5Hz */ +#define CO_LED_flash_1 0x04U /**< LED single flash */ +#define CO_LED_flash_2 0x08U /**< LED double flash */ +#define CO_LED_flash_3 0x10U /**< LED triple flash */ +#define CO_LED_flash_4 0x20U /**< LED quadruple flash */ +#define CO_LED_CANopen 0x80U /**< LED CANopen according to CiA 303-3 */ /** @} */ /* CO_LED_BITFIELD_t */ /** Get on/off state for green led for specified bitfield */ -#define CO_LED_RED(LEDs, BITFIELD) ((((LEDs)->LEDred & BITFIELD) != 0U) ? 1U : 0U) +#define CO_LED_RED(LEDs, BITFIELD) ((((LEDs)->LEDred & BITFIELD) != 0U) ? 1U : 0U) /** Get on/off state for green led for specified bitfield */ #define CO_LED_GREEN(LEDs, BITFIELD) ((((LEDs)->LEDgreen & BITFIELD) != 0U) ? 1U : 0U) - /** * LEDs object, initialized by CO_LEDs_init() */ -typedef struct{ - uint32_t LEDtmr50ms; /**< 50ms led timer */ - uint8_t LEDtmr200ms; /**< 200ms led timer */ - uint8_t LEDtmrflash_1; /**< single flash led timer */ - uint8_t LEDtmrflash_2; /**< double flash led timer */ - uint8_t LEDtmrflash_3; /**< triple flash led timer */ - uint8_t LEDtmrflash_4; /**< quadruple flash led timer */ - uint8_t LEDred; /**< red led #CO_LED_BITFIELD_t */ - uint8_t LEDgreen; /**< green led #CO_LED_BITFIELD_t */ +typedef struct { + uint32_t LEDtmr50ms; /**< 50ms led timer */ + uint8_t LEDtmr200ms; /**< 200ms led timer */ + uint8_t LEDtmrflash_1; /**< single flash led timer */ + uint8_t LEDtmrflash_2; /**< double flash led timer */ + uint8_t LEDtmrflash_3; /**< triple flash led timer */ + uint8_t LEDtmrflash_4; /**< quadruple flash led timer */ + uint8_t LEDred; /**< red led #CO_LED_BITFIELD_t */ + uint8_t LEDgreen; /**< green led #CO_LED_BITFIELD_t */ } CO_LEDs_t; - /** * Initialize LEDs object. * @@ -113,8 +110,7 @@ typedef struct{ * * @return #CO_ReturnError_t CO_ERROR_NO or CO_ERROR_ILLEGAL_ARGUMENT. */ -CO_ReturnError_t CO_LEDs_init(CO_LEDs_t *LEDs); - +CO_ReturnError_t CO_LEDs_init(CO_LEDs_t* LEDs); /** * Process indicator states @@ -135,18 +131,9 @@ CO_ReturnError_t CO_LEDs_init(CO_LEDs_t *LEDs); * @param firmwareDownload Firmware download is in progress indication. * @param [out] timerNext_us info to OS - see CO_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); +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); /** @} */ /* CO_LEDs */ diff --git a/304/CO_GFC.h b/304/CO_GFC.h index 121946d..5f7ebec 100644 --- a/304/CO_GFC.h +++ b/304/CO_GFC.h @@ -30,7 +30,7 @@ #define CO_CONFIG_GFC (0) #endif -#if (((CO_CONFIG_GFC) & CO_CONFIG_GFC_ENABLE) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_GFC)&CO_CONFIG_GFC_ENABLE) != 0) || defined CO_DOXYGEN #ifdef __cplusplus extern "C" { @@ -53,13 +53,13 @@ extern "C" { * GFC object. */ typedef struct { - bool_t valid; /**< From OD parameter 1300 */ + bool_t valid; /**< From OD parameter 1300 */ OD_extension_t OD_gfcParam_ext; /**< Extension for OD object */ -#if (((CO_CONFIG_GFC) & CO_CONFIG_GFC_PRODUCER) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_GFC)&CO_CONFIG_GFC_PRODUCER) != 0) || defined CO_DOXYGEN CO_CANmodule_t* CANdevTx; /**< From CO_GFC_init() */ CO_CANtx_t* CANtxBuff; /**< CAN transmit buffer inside CANdevTx */ #endif -#if (((CO_CONFIG_GFC) & CO_CONFIG_GFC_CONSUMER) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_GFC)&CO_CONFIG_GFC_CONSUMER) != 0) || defined CO_DOXYGEN /** From CO_GFC_initCallbackEnterSafeState() or NULL */ void (*pFunctSignalSafe)(void* object); /** From CO_GFC_initCallbackEnterSafeState() or NULL */ @@ -84,11 +84,11 @@ typedef struct { * * @return #CO_ReturnError_t: CO_ERROR_NO or CO_ERROR_ILLEGAL_ARGUMENT. */ -CO_ReturnError_t CO_GFC_init(CO_GFC_t* GFC, OD_entry_t* OD_1300_gfcParameter, - CO_CANmodule_t* GFC_CANdevRx, uint16_t GFC_rxIdx, uint16_t CANidRxGFC, - CO_CANmodule_t* GFC_CANdevTx, uint16_t GFC_txIdx, uint16_t CANidTxGFC); +CO_ReturnError_t CO_GFC_init(CO_GFC_t* GFC, OD_entry_t* OD_1300_gfcParameter, CO_CANmodule_t* GFC_CANdevRx, + uint16_t GFC_rxIdx, uint16_t CANidRxGFC, CO_CANmodule_t* GFC_CANdevTx, uint16_t GFC_txIdx, + uint16_t CANidTxGFC); -#if (((CO_CONFIG_GFC) & CO_CONFIG_GFC_CONSUMER) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_GFC)&CO_CONFIG_GFC_CONSUMER) != 0) || defined CO_DOXYGEN /** * Initialize GFC callback function. * @@ -103,7 +103,7 @@ CO_ReturnError_t CO_GFC_init(CO_GFC_t* GFC, OD_entry_t* OD_1300_gfcParameter, void CO_GFC_initCallbackEnterSafeState(CO_GFC_t* GFC, void* object, void (*pFunctSignalSafe)(void* object)); #endif -#if (((CO_CONFIG_GFC) & CO_CONFIG_GFC_PRODUCER) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_GFC)&CO_CONFIG_GFC_PRODUCER) != 0) || defined CO_DOXYGEN /** * Send GFC message. * diff --git a/304/CO_SRDO.h b/304/CO_SRDO.h index 9625e22..82de455 100644 --- a/304/CO_SRDO.h +++ b/304/CO_SRDO.h @@ -34,7 +34,7 @@ #define CO_CONFIG_SRDO_MINIMUM_DELAY 0U #endif -#if (((CO_CONFIG_SRDO) & CO_CONFIG_SRDO_ENABLE) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_SRDO)&CO_CONFIG_SRDO_ENABLE) != 0) || defined CO_DOXYGEN #ifdef __cplusplus extern "C" { @@ -92,19 +92,20 @@ typedef uint8_t CO_SRDO_size_t; * SRDO internal state */ typedef enum { - CO_SRDO_state_error_internal = -10, /**< internal software error */ + CO_SRDO_state_error_internal = -10, /**< internal software error */ CO_SRDO_state_error_configuration = -9, /**< error in parameters, emergency message was sent */ CO_SRDO_state_error_txNotInverted = -6, /**< Transmitting SRDO messages was not inverted */ - CO_SRDO_state_error_txFail = -5, /**< SRDO CAN message transmission failed */ + CO_SRDO_state_error_txFail = -5, /**< SRDO CAN message transmission failed */ CO_SRDO_state_error_rxTimeoutSRVT = -4, /**< SRDO message didn't receive inside SRVT time */ - CO_SRDO_state_error_rxTimeoutSCT = -3, /**< SRDO inverted message didn't receive inside SCT time */ + CO_SRDO_state_error_rxTimeoutSCT = -3, /**< SRDO inverted message didn't receive inside SCT time */ CO_SRDO_state_error_rxNotInverted = -2, /**< Received SRDO messages was not inverted */ - CO_SRDO_state_error_rxShort = -1, /**< Received SRDO message is too short */ - CO_SRDO_state_unknown = 0, /**< unknown state, set by @CO_SRDO_init */ - CO_SRDO_state_nmtNotOperational = 1, /**< Internal NMT operating state is not NMT operational */ - CO_SRDO_state_initializing = 2, /**< Just entered NMT operational state, SRDO message not yet received or transmitted */ + CO_SRDO_state_error_rxShort = -1, /**< Received SRDO message is too short */ + CO_SRDO_state_unknown = 0, /**< unknown state, set by @CO_SRDO_init */ + CO_SRDO_state_nmtNotOperational = 1, /**< Internal NMT operating state is not NMT operational */ + CO_SRDO_state_initializing = + 2, /**< Just entered NMT operational state, SRDO message not yet received or transmitted */ CO_SRDO_state_communicationEstablished = 3, /**< SRDO communication established, fully functional */ - CO_SRDO_state_deleted = 10 /**< informationDirection for this SRDO is set to 0 */ + CO_SRDO_state_deleted = 10 /**< informationDirection for this SRDO is set to 0 */ } CO_SRDO_state_t; /** @@ -124,10 +125,10 @@ typedef struct { /** Object for input / output on the OD variable 13FE:00. Configuration * of any of the the SRDO parameters will write 0 to that variable. */ OD_IO_t OD_IO_configurationValid; - + OD_entry_t* OD_13FE_entry; OD_entry_t* OD_13FF_entry; - + /** Extension for OD object */ OD_extension_t OD_13FE_extension; /** Extension for OD object */ @@ -138,15 +139,15 @@ typedef struct { * SRDO object. */ typedef struct { - CO_SRDOGuard_t* SRDOGuard; /**< From CO_SRDO_init() */ - OD_t *OD; /**< From CO_SRDO_init() */ - CO_EM_t* em; /**< From CO_SRDO_init() */ - uint16_t defaultCOB_ID; /**< From CO_SRDO_init() */ - uint8_t nodeId; /**< From CO_SRDO_init() */ - CO_CANmodule_t* CANdevTx[2]; /**< From CO_SRDO_init() */ - uint16_t CANdevTxIdx[2]; /**< From CO_SRDO_init() */ - CO_CANmodule_t* CANdevRx[2]; /**< From CO_SRDO_init() */ - uint16_t CANdevRxIdx[2]; /**< From CO_SRDO_init() */ + CO_SRDOGuard_t* SRDOGuard; /**< From CO_SRDO_init() */ + OD_t* OD; /**< From CO_SRDO_init() */ + CO_EM_t* em; /**< From CO_SRDO_init() */ + uint16_t defaultCOB_ID; /**< From CO_SRDO_init() */ + uint8_t nodeId; /**< From CO_SRDO_init() */ + CO_CANmodule_t* CANdevTx[2]; /**< From CO_SRDO_init() */ + uint16_t CANdevTxIdx[2]; /**< From CO_SRDO_init() */ + CO_CANmodule_t* CANdevRx[2]; /**< From CO_SRDO_init() */ + uint16_t CANdevRxIdx[2]; /**< From CO_SRDO_init() */ /** Internal state of this SRDO. */ CO_SRDO_state_t internalState; /** Copy of variable, internal usage. */ @@ -185,14 +186,14 @@ typedef struct { /** If true, next processed SRDO message is normal (not inverted) */ bool_t nextIsNormal; - OD_entry_t* OD_communicationParam_entry;/**< From CO_SRDO_init() */ - OD_entry_t* OD_mappingParam_entry;/**< From CO_SRDO_init() */ + OD_entry_t* OD_communicationParam_entry; /**< From CO_SRDO_init() */ + OD_entry_t* OD_mappingParam_entry; /**< From CO_SRDO_init() */ /** Extension for OD object */ OD_extension_t OD_communicationParam_ext; /** Extension for OD object */ OD_extension_t OD_mappingParam_extension; -#if (((CO_CONFIG_SRDO) & CO_CONFIG_FLAG_CALLBACK_PRE) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_SRDO)&CO_CONFIG_FLAG_CALLBACK_PRE) != 0) || defined CO_DOXYGEN /** From CO_SRDO_initCallbackPre() or NULL */ void (*pFunctSignalPre)(void* object); /** From CO_SRDO_initCallbackPre() or NULL */ @@ -215,8 +216,7 @@ typedef struct { * @return #CO_ReturnError_t: CO_ERROR_NO or CO_ERROR_ILLEGAL_ARGUMENT. */ CO_ReturnError_t CO_SRDOGuard_init(CO_SRDOGuard_t* SRDOGuard, OD_entry_t* OD_13FE_configurationValid, - OD_entry_t* OD_13FF_safetyConfigurationSignature, uint32_t* errInfo); - + OD_entry_t* OD_13FF_safetyConfigurationSignature, uint32_t* errInfo); /** * Initialize SRDO object. @@ -251,11 +251,12 @@ CO_ReturnError_t CO_SRDOGuard_init(CO_SRDOGuard_t* SRDOGuard, OD_entry_t* OD_13F CO_ReturnError_t CO_SRDO_init(CO_SRDO_t* SRDO, uint8_t SRDO_Index, CO_SRDOGuard_t* SRDOGuard, OD_t* OD, CO_EM_t* em, uint8_t nodeId, uint16_t defaultCOB_ID, OD_entry_t* OD_130x_SRDOCommPar, OD_entry_t* OD_138x_SRDOMapPar, CO_CANmodule_t* CANdevRxNormal, - CO_CANmodule_t* CANdevRxInverted, uint16_t CANdevRxIdxNormal, uint16_t CANdevRxIdxInverted, - CO_CANmodule_t* CANdevTxNormal, CO_CANmodule_t* CANdevTxInverted, - uint16_t CANdevTxIdxNormal, uint16_t CANdevTxIdxInverted, uint32_t* errInfo); + CO_CANmodule_t* CANdevRxInverted, uint16_t CANdevRxIdxNormal, + uint16_t CANdevRxIdxInverted, CO_CANmodule_t* CANdevTxNormal, + CO_CANmodule_t* CANdevTxInverted, uint16_t CANdevTxIdxNormal, + uint16_t CANdevTxIdxInverted, uint32_t* errInfo); -#if (((CO_CONFIG_SRDO) & CO_CONFIG_FLAG_CALLBACK_PRE) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_SRDO)&CO_CONFIG_FLAG_CALLBACK_PRE) != 0) || defined CO_DOXYGEN /** * Initialize SRDO callback function. * @@ -282,8 +283,7 @@ void CO_SRDO_initCallbackPre(CO_SRDO_t* SRDO, void* object, void (*pFunctSignalP */ CO_ReturnError_t CO_SRDO_requestSend(CO_SRDO_t* SRDO); - -CO_ReturnError_t CO_SRDO_config( CO_SRDO_t* SRDO, uint8_t SRDO_Index, CO_SRDOGuard_t* SRDOGuard, uint32_t* errInfo); +CO_ReturnError_t CO_SRDO_config(CO_SRDO_t* SRDO, uint8_t SRDO_Index, CO_SRDOGuard_t* SRDOGuard, uint32_t* errInfo); /** * Process transmitting/receiving individual SRDO message. @@ -295,7 +295,8 @@ CO_ReturnError_t CO_SRDO_config( CO_SRDO_t* SRDO, uint8_t SRDO_Index, CO_SRDOGua * * @return CO_SRDO_state_t internal state */ -CO_SRDO_state_t CO_SRDO_process(CO_SRDO_t* SRDO, uint32_t timeDifference_us, uint32_t* timerNext_us, bool_t NMTisOperational); +CO_SRDO_state_t CO_SRDO_process(CO_SRDO_t* SRDO, uint32_t timeDifference_us, uint32_t* timerNext_us, + bool_t NMTisOperational); /** @} */ /* CO_SRDO */ diff --git a/305/CO_LSS.h b/305/CO_LSS.h index 0273639..4f63052 100644 --- a/305/CO_LSS.h +++ b/305/CO_LSS.h @@ -26,8 +26,7 @@ /* default configuration, see CO_config.h */ #ifndef CO_CONFIG_LSS -#define CO_CONFIG_LSS (CO_CONFIG_LSS_SLAVE | \ - CO_CONFIG_GLOBAL_FLAG_CALLBACK_PRE) +#define CO_CONFIG_LSS (CO_CONFIG_LSS_SLAVE | CO_CONFIG_GLOBAL_FLAG_CALLBACK_PRE) #endif #if (((CO_CONFIG_LSS) & (CO_CONFIG_LSS_SLAVE | CO_CONFIG_LSS_MASTER)) != 0) || defined CO_DOXYGEN @@ -79,71 +78,72 @@ extern "C" { * * As identifying method only "LSS fastscan" is supported. */ -#define CO_LSS_SWITCH_STATE_GLOBAL 0x04U /**< Switch state global protocol */ -#define CO_LSS_SWITCH_STATE_SEL_VENDOR 0x40U /**< Switch state selective protocol - Vendor ID */ -#define CO_LSS_SWITCH_STATE_SEL_PRODUCT 0x41U /**< Switch state selective protocol - Product code */ -#define CO_LSS_SWITCH_STATE_SEL_REV 0x42U /**< Switch state selective protocol - Revision number */ -#define CO_LSS_SWITCH_STATE_SEL_SERIAL 0x43U /**< Switch state selective protocol - Serial number */ -#define CO_LSS_SWITCH_STATE_SEL 0x44U /**< Switch state selective protocol - Slave response */ -#define CO_LSS_CFG_NODE_ID 0x11U /**< Configure node ID protocol */ -#define CO_LSS_CFG_BIT_TIMING 0x13U /**< Configure bit timing parameter protocol */ -#define CO_LSS_CFG_ACTIVATE_BIT_TIMING 0x15U /**< Activate bit timing parameter protocol */ -#define CO_LSS_CFG_STORE 0x17U /**< Store configuration protocol */ -#define CO_LSS_IDENT_SLAVE 0x4FU /**< LSS Fastscan response */ -#define CO_LSS_IDENT_FASTSCAN 0x51U /**< LSS Fastscan protocol */ -#define CO_LSS_INQUIRE_VENDOR 0x5AU /**< Inquire identity vendor-ID protocol */ -#define CO_LSS_INQUIRE_PRODUCT 0x5BU /**< Inquire identity product-code protocol */ -#define CO_LSS_INQUIRE_REV 0x5CU /**< Inquire identity revision-number protocol */ -#define CO_LSS_INQUIRE_SERIAL 0x5DU /**< Inquire identity serial-number protocol */ -#define CO_LSS_INQUIRE_NODE_ID 0x5EU /**< Inquire node-ID protocol */ -/** @} */ /* CO_LSS_cs_t */ +#define CO_LSS_SWITCH_STATE_GLOBAL 0x04U /**< Switch state global protocol */ +#define CO_LSS_SWITCH_STATE_SEL_VENDOR 0x40U /**< Switch state selective protocol - Vendor ID */ +#define CO_LSS_SWITCH_STATE_SEL_PRODUCT 0x41U /**< Switch state selective protocol - Product code */ +#define CO_LSS_SWITCH_STATE_SEL_REV 0x42U /**< Switch state selective protocol - Revision number */ +#define CO_LSS_SWITCH_STATE_SEL_SERIAL 0x43U /**< Switch state selective protocol - Serial number */ +#define CO_LSS_SWITCH_STATE_SEL 0x44U /**< Switch state selective protocol - Slave response */ +#define CO_LSS_CFG_NODE_ID 0x11U /**< Configure node ID protocol */ +#define CO_LSS_CFG_BIT_TIMING 0x13U /**< Configure bit timing parameter protocol */ +#define CO_LSS_CFG_ACTIVATE_BIT_TIMING 0x15U /**< Activate bit timing parameter protocol */ +#define CO_LSS_CFG_STORE 0x17U /**< Store configuration protocol */ +#define CO_LSS_IDENT_SLAVE 0x4FU /**< LSS Fastscan response */ +#define CO_LSS_IDENT_FASTSCAN 0x51U /**< LSS Fastscan protocol */ +#define CO_LSS_INQUIRE_VENDOR 0x5AU /**< Inquire identity vendor-ID protocol */ +#define CO_LSS_INQUIRE_PRODUCT 0x5BU /**< Inquire identity product-code protocol */ +#define CO_LSS_INQUIRE_REV 0x5CU /**< Inquire identity revision-number protocol */ +#define CO_LSS_INQUIRE_SERIAL 0x5DU /**< Inquire identity serial-number protocol */ +#define CO_LSS_INQUIRE_NODE_ID 0x5EU /**< Inquire node-ID protocol */ +/** @} */ /* CO_LSS_cs_t */ /** * @defgroup CO_LSS_cfgNodeId_t Error codes for Configure node ID protocol * @{ */ -#define CO_LSS_CFG_NODE_ID_OK 0x00U /**< Protocol successfully completed */ -#define CO_LSS_CFG_NODE_ID_OUT_OF_RANGE 0x01U /**< NID out of range */ -#define CO_LSS_CFG_NODE_ID_MANUFACTURER 0xFFU /**< Manufacturer specific error. No further support */ -/** @} */ /* CO_LSS_cfgNodeId_t */ +#define CO_LSS_CFG_NODE_ID_OK 0x00U /**< Protocol successfully completed */ +#define CO_LSS_CFG_NODE_ID_OUT_OF_RANGE 0x01U /**< NID out of range */ +#define CO_LSS_CFG_NODE_ID_MANUFACTURER 0xFFU /**< Manufacturer specific error. No further support */ +/** @} */ /* CO_LSS_cfgNodeId_t */ /** * @defgroup CO_LSS_cfgBitTiming_t Error codes for Configure bit timing parameters protocol * @{ */ -#define CO_LSS_CFG_BIT_TIMING_OK 0x00U /**< Protocol successfully completed */ -#define CO_LSS_CFG_BIT_TIMING_OUT_OF_RANGE 0x01U /**< Bit timing / Bit rate not supported */ -#define CO_LSS_CFG_BIT_TIMING_MANUFACTURER 0xFFU /**< Manufacturer specific error. No further support */ -/** @} */ /* CO_LSS_cfgBitTiming_t */ +#define CO_LSS_CFG_BIT_TIMING_OK 0x00U /**< Protocol successfully completed */ +#define CO_LSS_CFG_BIT_TIMING_OUT_OF_RANGE 0x01U /**< Bit timing / Bit rate not supported */ +#define CO_LSS_CFG_BIT_TIMING_MANUFACTURER 0xFFU /**< Manufacturer specific error. No further support */ +/** @} */ /* CO_LSS_cfgBitTiming_t */ /** * @defgroup CO_LSS_cfgStore_t Error codes for Store configuration protocol * @{ */ -#define CO_LSS_CFG_STORE_OK 0x00U /**< Protocol successfully completed */ -#define CO_LSS_CFG_STORE_NOT_SUPPORTED 0x01U /**< Store configuration not supported */ -#define CO_LSS_CFG_STORE_FAILED 0x02U /**< Storage media access error */ -#define CO_LSS_CFG_STORE_MANUFACTURER 0xFFU /**< Manufacturer specific error. No further support */ -/** @} */ /* CO_LSS_cfgStore_t */ +#define CO_LSS_CFG_STORE_OK 0x00U /**< Protocol successfully completed */ +#define CO_LSS_CFG_STORE_NOT_SUPPORTED 0x01U /**< Store configuration not supported */ +#define CO_LSS_CFG_STORE_FAILED 0x02U /**< Storage media access error */ +#define CO_LSS_CFG_STORE_MANUFACTURER 0xFFU /**< Manufacturer specific error. No further support */ +/** @} */ /* CO_LSS_cfgStore_t */ /** * @defgroup CO_LSS_fastscan_bitcheck Fastscan BitCheck. BIT0 means all bits are checked for equality by slave * @{ */ -#define CO_LSS_FASTSCAN_BIT0 0x00U /**< Least significant bit of IDnumbners bit area to be checked */ - /* ... */ -#define CO_LSS_FASTSCAN_BIT31 0x1FU /**< dito */ -#define CO_LSS_FASTSCAN_CONFIRM 0x80U /**< All LSS slaves waiting for scan respond and previous scan is reset */ -/** @} */ /* CO_LSS_fastscan_bitcheck */ +#define CO_LSS_FASTSCAN_BIT0 0x00U /**< Least significant bit of IDnumbners bit area to be checked */ +/* ... */ +#define CO_LSS_FASTSCAN_BIT31 0x1FU /**< dito */ +#define CO_LSS_FASTSCAN_CONFIRM 0x80U /**< All LSS slaves waiting for scan respond and previous scan is reset */ +/** @} */ /* CO_LSS_fastscan_bitcheck */ /** * @defgroup CO_LSS_fastscan_lss_sub_next Fastscan LSSsub, LSSnext * @{ */ -#define CO_LSS_FASTSCAN_VENDOR_ID 0x00U /**< Vendor ID */ -#define CO_LSS_FASTSCAN_PRODUCT 0x01U /**< Product code */ -#define CO_LSS_FASTSCAN_REV 0x02U /**< Revision number */ -#define CO_LSS_FASTSCAN_SERIAL 0x03U /**< Serial number */ +#define CO_LSS_FASTSCAN_VENDOR_ID 0x00U /**< Vendor ID */ +#define CO_LSS_FASTSCAN_PRODUCT 0x01U /**< Product code */ +#define CO_LSS_FASTSCAN_REV 0x02U /**< Revision number */ +#define CO_LSS_FASTSCAN_SERIAL 0x03U /**< Serial number */ + /** @} */ /* CO_LSS_fastscan_lss_sub_next */ /** @@ -152,6 +152,7 @@ extern "C" { */ typedef union { uint32_t addr[4]; + struct { uint32_t vendorID; uint32_t productCode; @@ -170,42 +171,31 @@ typedef union { * - LSS configuration: In this state variables may be configured in the LSS slave. * - Final: Pseudo state, indicating the deactivation of the FSA. */ -#define CO_LSS_STATE_WAITING 0x00U /**< LSS FSA waiting for requests*/ -#define CO_LSS_STATE_CONFIGURATION 0x01U /**< LSS FSA waiting for configuration*/ -/** @} */ /* CO_LSS_state_t */ +#define CO_LSS_STATE_WAITING 0x00U /**< LSS FSA waiting for requests*/ +#define CO_LSS_STATE_CONFIGURATION 0x01U /**< LSS FSA waiting for configuration*/ +/** @} */ /* CO_LSS_state_t */ /** * @defgroup CO_LSS_bitTimingTable_t Definition of table_index for /CiA301/ bit timing table * @{ */ -#define CO_LSS_BIT_TIMING_1000 0U /**< 1000kbit/s */ -#define CO_LSS_BIT_TIMING_800 1U /**< 800kbit/s */ -#define CO_LSS_BIT_TIMING_500 2U /**< 500kbit/s */ -#define CO_LSS_BIT_TIMING_250 3U /**< 250kbit/s */ -#define CO_LSS_BIT_TIMING_125 4U /**< 125kbit/s */ - /* reserved 5U */ -#define CO_LSS_BIT_TIMING_50 6U /**< 50kbit/s */ -#define CO_LSS_BIT_TIMING_20 7U /**< 20kbit/s */ -#define CO_LSS_BIT_TIMING_10 8U /**< 10kbit/s */ -#define CO_LSS_BIT_TIMING_AUTO 9U /**< Automatic bit rate detection */ -/** @} */ /* CO_LSS_bitTimingTable_t */ +#define CO_LSS_BIT_TIMING_1000 0U /**< 1000kbit/s */ +#define CO_LSS_BIT_TIMING_800 1U /**< 800kbit/s */ +#define CO_LSS_BIT_TIMING_500 2U /**< 500kbit/s */ +#define CO_LSS_BIT_TIMING_250 3U /**< 250kbit/s */ +#define CO_LSS_BIT_TIMING_125 4U /**< 125kbit/s */ + /* reserved 5U */ +#define CO_LSS_BIT_TIMING_50 6U /**< 50kbit/s */ +#define CO_LSS_BIT_TIMING_20 7U /**< 20kbit/s */ +#define CO_LSS_BIT_TIMING_10 8U /**< 10kbit/s */ +#define CO_LSS_BIT_TIMING_AUTO 9U /**< Automatic bit rate detection */ +/** @} */ /* CO_LSS_bitTimingTable_t */ /** * Lookup table for conversion between bit timing table and numerical * bit rate */ -static const uint16_t CO_LSS_bitTimingTableLookup[] = { - 1000, - 800, - 500, - 250, - 125, - 0, - 50, - 20, - 10, - 0 -}; +static const uint16_t CO_LSS_bitTimingTableLookup[] = {1000, 800, 500, 250, 125, 0, 50, 20, 10, 0}; /** * Invalid node ID triggers node ID assignment @@ -220,11 +210,10 @@ static const uint16_t CO_LSS_bitTimingTableLookup[] = { /** * Macro to check if two LSS addresses are equal */ -#define CO_LSS_ADDRESS_EQUAL(/*CO_LSS_address_t*/ a1, /*CO_LSS_address_t*/ a2) \ - ((a1.identity.productCode == a2.identity.productCode) && \ - (a1.identity.revisionNumber == a2.identity.revisionNumber) && \ - (a1.identity.serialNumber == a2.identity.serialNumber) && \ - (a1.identity.vendorID == a2.identity.vendorID)) +#define CO_LSS_ADDRESS_EQUAL(/*CO_LSS_address_t*/ a1, /*CO_LSS_address_t*/ a2) \ + ((a1.identity.productCode == a2.identity.productCode) \ + && (a1.identity.revisionNumber == a2.identity.revisionNumber) \ + && (a1.identity.serialNumber == a2.identity.serialNumber) && (a1.identity.vendorID == a2.identity.vendorID)) /** @} */ /*@defgroup CO_LSS*/ diff --git a/305/CO_LSSmaster.h b/305/CO_LSSmaster.h index 437ea97..39c8479 100644 --- a/305/CO_LSSmaster.h +++ b/305/CO_LSSmaster.h @@ -24,7 +24,7 @@ #include "305/CO_LSS.h" -#if (((CO_CONFIG_LSS) & CO_CONFIG_LSS_MASTER) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_LSS)&CO_CONFIG_LSS_MASTER) != 0) || defined CO_DOXYGEN #ifdef __cplusplus extern "C" { @@ -82,44 +82,43 @@ extern "C" { * Return values of LSS master functions. */ typedef enum { - CO_LSSmaster_SCAN_FINISHED = 2, /**< Scanning finished successful */ - CO_LSSmaster_WAIT_SLAVE = 1, /**< No response arrived from slave yet */ - CO_LSSmaster_OK = 0, /**< Success, end of communication */ - CO_LSSmaster_TIMEOUT = -1, /**< No reply received */ - CO_LSSmaster_ILLEGAL_ARGUMENT = -2, /**< Invalid argument */ - CO_LSSmaster_INVALID_STATE = -3, /**< State machine not ready or already processing a request */ - CO_LSSmaster_SCAN_NOACK = -4, /**< No node found that matches scan request */ - CO_LSSmaster_SCAN_FAILED = -5, /**< An error occurred while scanning. Try again */ + CO_LSSmaster_SCAN_FINISHED = 2, /**< Scanning finished successful */ + CO_LSSmaster_WAIT_SLAVE = 1, /**< No response arrived from slave yet */ + CO_LSSmaster_OK = 0, /**< Success, end of communication */ + CO_LSSmaster_TIMEOUT = -1, /**< No reply received */ + CO_LSSmaster_ILLEGAL_ARGUMENT = -2, /**< Invalid argument */ + CO_LSSmaster_INVALID_STATE = -3, /**< State machine not ready or already processing a request */ + CO_LSSmaster_SCAN_NOACK = -4, /**< No node found that matches scan request */ + CO_LSSmaster_SCAN_FAILED = -5, /**< An error occurred while scanning. Try again */ CO_LSSmaster_OK_ILLEGAL_ARGUMENT = -101, /**< LSS success, node rejected argument because of non-supported value */ - CO_LSSmaster_OK_MANUFACTURER = -102, /**< LSS success, node rejected argument with manufacturer error code */ + CO_LSSmaster_OK_MANUFACTURER = -102, /**< LSS success, node rejected argument with manufacturer error code */ } CO_LSSmaster_return_t; - /** * LSS master object. */ -typedef struct{ - uint32_t timeout_us; /**< LSS response timeout in us */ +typedef struct { + uint32_t timeout_us; /**< LSS response timeout in us */ - uint8_t state; /**< Node is currently selected */ - uint8_t command; /**< Active command */ - uint32_t timeoutTimer; /**< Timeout timer for LSS communication */ + uint8_t state; /**< Node is currently selected */ + uint8_t command; /**< Active command */ + uint32_t timeoutTimer; /**< Timeout timer for LSS communication */ - uint8_t fsState; /**< Current state of fastscan master state machine */ - uint8_t fsLssSub; /**< Current state of node state machine */ - uint8_t fsBitChecked; /**< Current scan bit position */ - uint32_t fsIdNumber; /**< Current scan result */ + uint8_t fsState; /**< Current state of fastscan master state machine */ + uint8_t fsLssSub; /**< Current state of node state machine */ + uint8_t fsBitChecked; /**< Current scan bit position */ + uint32_t fsIdNumber; /**< Current scan result */ - volatile void *CANrxNew; /**< Indication if new LSS message is received from CAN bus. It needs to be cleared when received message is completely processed. */ - uint8_t CANrxData[8]; /**< 8 data bytes of the received message */ -#if (((CO_CONFIG_LSS) & CO_CONFIG_FLAG_CALLBACK_PRE) != 0) || defined CO_DOXYGEN - void (*pFunctSignal)(void *object); /**< From CO_LSSmaster_initCallbackPre() or NULL */ - void *functSignalObject;/**< Pointer to object */ + volatile void* + CANrxNew; /**< Indication if new LSS message is received from CAN bus. It needs to be cleared when received message is completely processed. */ + uint8_t CANrxData[8]; /**< 8 data bytes of the received message */ +#if (((CO_CONFIG_LSS)&CO_CONFIG_FLAG_CALLBACK_PRE) != 0) || defined CO_DOXYGEN + void (*pFunctSignal)(void* object); /**< From CO_LSSmaster_initCallbackPre() or NULL */ + void* functSignalObject; /**< Pointer to object */ #endif - CO_CANmodule_t *CANdevTx; /**< From CO_LSSmaster_init() */ - CO_CANtx_t *TXbuff; /**< CAN transmit buffer */ -}CO_LSSmaster_t; - + CO_CANmodule_t* CANdevTx; /**< From CO_LSSmaster_init() */ + CO_CANtx_t* TXbuff; /**< CAN transmit buffer */ +} CO_LSSmaster_t; /** * Default timeout for LSS slave in ms. This is the same as for SDO. For more @@ -129,7 +128,6 @@ typedef struct{ #define CO_LSSmaster_DEFAULT_TIMEOUT 1000U /* ms */ #endif - /** * Initialize LSS object. * @@ -146,15 +144,9 @@ typedef struct{ * @param CANidLssMaster COB ID for transmission. * @return #CO_ReturnError_t: CO_ERROR_NO or CO_ERROR_ILLEGAL_ARGUMENT. */ -CO_ReturnError_t CO_LSSmaster_init( - CO_LSSmaster_t *LSSmaster, - uint16_t timeout_ms, - CO_CANmodule_t *CANdevRx, - uint16_t CANdevRxIdx, - uint16_t CANidLssSlave, - CO_CANmodule_t *CANdevTx, - uint16_t CANdevTxIdx, - uint16_t CANidLssMaster); +CO_ReturnError_t CO_LSSmaster_init(CO_LSSmaster_t* LSSmaster, uint16_t timeout_ms, CO_CANmodule_t* CANdevRx, + uint16_t CANdevRxIdx, uint16_t CANidLssSlave, CO_CANmodule_t* CANdevTx, + uint16_t CANdevTxIdx, uint16_t CANidLssMaster); /** * Change LSS master timeout @@ -175,12 +167,9 @@ CO_ReturnError_t CO_LSSmaster_init( * @param LSSmaster This object. * @param timeout_ms timeout value in ms */ -void CO_LSSmaster_changeTimeout( - CO_LSSmaster_t *LSSmaster, - uint16_t timeout_ms); +void CO_LSSmaster_changeTimeout(CO_LSSmaster_t* LSSmaster, uint16_t timeout_ms); - -#if (((CO_CONFIG_LSS) & CO_CONFIG_FLAG_CALLBACK_PRE) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_LSS)&CO_CONFIG_FLAG_CALLBACK_PRE) != 0) || defined CO_DOXYGEN /** * Initialize LSSmasterRx callback function. * @@ -193,13 +182,9 @@ void CO_LSSmaster_changeTimeout( * @param object Pointer to object, which will be passed to pFunctSignal(). Can be NULL * @param pFunctSignal Pointer to the callback function. Not called if NULL. */ -void CO_LSSmaster_initCallbackPre( - CO_LSSmaster_t *LSSmaster, - void *object, - void (*pFunctSignal)(void *object)); +void CO_LSSmaster_initCallbackPre(CO_LSSmaster_t* LSSmaster, void* object, void (*pFunctSignal)(void* object)); #endif - /** * Request LSS switch state select * @@ -217,11 +202,8 @@ void CO_LSSmaster_initCallbackPre( * @return #CO_LSSmaster_ILLEGAL_ARGUMENT, #CO_LSSmaster_INVALID_STATE, * #CO_LSSmaster_WAIT_SLAVE, #CO_LSSmaster_OK, #CO_LSSmaster_TIMEOUT */ -CO_LSSmaster_return_t CO_LSSmaster_swStateSelect( - CO_LSSmaster_t *LSSmaster, - uint32_t timeDifference_us, - CO_LSS_address_t *lssAddress); - +CO_LSSmaster_return_t CO_LSSmaster_swStateSelect(CO_LSSmaster_t* LSSmaster, uint32_t timeDifference_us, + CO_LSS_address_t* lssAddress); /** * Request LSS switch state deselect @@ -235,9 +217,7 @@ CO_LSSmaster_return_t CO_LSSmaster_swStateSelect( * @return #CO_LSSmaster_ILLEGAL_ARGUMENT, #CO_LSSmaster_INVALID_STATE, * #CO_LSSmaster_OK */ -CO_LSSmaster_return_t CO_LSSmaster_swStateDeselect( - CO_LSSmaster_t *LSSmaster); - +CO_LSSmaster_return_t CO_LSSmaster_swStateDeselect(CO_LSSmaster_t* LSSmaster); /** * Request LSS configure Bit Timing @@ -257,11 +237,8 @@ CO_LSSmaster_return_t CO_LSSmaster_swStateDeselect( * #CO_LSSmaster_WAIT_SLAVE, #CO_LSSmaster_OK, #CO_LSSmaster_TIMEOUT, * #CO_LSSmaster_OK_MANUFACTURER, #CO_LSSmaster_OK_ILLEGAL_ARGUMENT */ -CO_LSSmaster_return_t CO_LSSmaster_configureBitTiming( - CO_LSSmaster_t *LSSmaster, - uint32_t timeDifference_us, - uint16_t bit); - +CO_LSSmaster_return_t CO_LSSmaster_configureBitTiming(CO_LSSmaster_t* LSSmaster, uint32_t timeDifference_us, + uint16_t bit); /** * Request LSS configure node ID @@ -282,11 +259,8 @@ CO_LSSmaster_return_t CO_LSSmaster_configureBitTiming( * #CO_LSSmaster_WAIT_SLAVE, #CO_LSSmaster_OK, #CO_LSSmaster_TIMEOUT, * #CO_LSSmaster_OK_MANUFACTURER, #CO_LSSmaster_OK_ILLEGAL_ARGUMENT */ -CO_LSSmaster_return_t CO_LSSmaster_configureNodeId( - CO_LSSmaster_t *LSSmaster, - uint32_t timeDifference_us, - uint8_t nodeId); - +CO_LSSmaster_return_t CO_LSSmaster_configureNodeId(CO_LSSmaster_t* LSSmaster, uint32_t timeDifference_us, + uint8_t nodeId); /** * Request LSS store configuration @@ -306,10 +280,7 @@ CO_LSSmaster_return_t CO_LSSmaster_configureNodeId( * #CO_LSSmaster_WAIT_SLAVE, #CO_LSSmaster_OK, #CO_LSSmaster_TIMEOUT, * #CO_LSSmaster_OK_MANUFACTURER, #CO_LSSmaster_OK_ILLEGAL_ARGUMENT */ -CO_LSSmaster_return_t CO_LSSmaster_configureStore( - CO_LSSmaster_t *LSSmaster, - uint32_t timeDifference_us); - +CO_LSSmaster_return_t CO_LSSmaster_configureStore(CO_LSSmaster_t* LSSmaster, uint32_t timeDifference_us); /** * Request LSS activate bit timing @@ -330,10 +301,7 @@ CO_LSSmaster_return_t CO_LSSmaster_configureStore( * @return #CO_LSSmaster_ILLEGAL_ARGUMENT, #CO_LSSmaster_INVALID_STATE, * #CO_LSSmaster_OK */ -CO_LSSmaster_return_t CO_LSSmaster_ActivateBit( - CO_LSSmaster_t *LSSmaster, - uint16_t switchDelay_ms); - +CO_LSSmaster_return_t CO_LSSmaster_ActivateBit(CO_LSSmaster_t* LSSmaster, uint16_t switchDelay_ms); /** * Request LSS inquire LSS address @@ -353,11 +321,8 @@ CO_LSSmaster_return_t CO_LSSmaster_ActivateBit( * @return #CO_LSSmaster_ILLEGAL_ARGUMENT, #CO_LSSmaster_INVALID_STATE, * #CO_LSSmaster_WAIT_SLAVE, #CO_LSSmaster_OK, #CO_LSSmaster_TIMEOUT */ -CO_LSSmaster_return_t CO_LSSmaster_InquireLssAddress( - CO_LSSmaster_t *LSSmaster, - uint32_t timeDifference_us, - CO_LSS_address_t *lssAddress); - +CO_LSSmaster_return_t CO_LSSmaster_InquireLssAddress(CO_LSSmaster_t* LSSmaster, uint32_t timeDifference_us, + CO_LSS_address_t* lssAddress); /** * Request LSS inquire node ID or part of LSS address @@ -378,29 +343,25 @@ CO_LSSmaster_return_t CO_LSSmaster_InquireLssAddress( * @return #CO_LSSmaster_ILLEGAL_ARGUMENT, #CO_LSSmaster_INVALID_STATE, * #CO_LSSmaster_WAIT_SLAVE, #CO_LSSmaster_OK, #CO_LSSmaster_TIMEOUT */ -CO_LSSmaster_return_t CO_LSSmaster_Inquire( - CO_LSSmaster_t *LSSmaster, - uint32_t timeDifference_us, - uint8_t lssInquireCs, - uint32_t *value); - +CO_LSSmaster_return_t CO_LSSmaster_Inquire(CO_LSSmaster_t* LSSmaster, uint32_t timeDifference_us, uint8_t lssInquireCs, + uint32_t* value); /** * Scan type for #CO_LSSmaster_fastscan_t scan */ typedef enum { - CO_LSSmaster_FS_SCAN = 0, /**< Do full 32 bit scan */ - CO_LSSmaster_FS_SKIP = 1, /**< Skip this value */ - CO_LSSmaster_FS_MATCH = 2, /**< Full 32 bit value is given as argument, just verify */ + CO_LSSmaster_FS_SCAN = 0, /**< Do full 32 bit scan */ + CO_LSSmaster_FS_SKIP = 1, /**< Skip this value */ + CO_LSSmaster_FS_MATCH = 2, /**< Full 32 bit value is given as argument, just verify */ } CO_LSSmaster_scantype_t; /** * Parameters for LSS fastscan #CO_LSSmaster_IdentifyFastscan */ -typedef struct{ - CO_LSSmaster_scantype_t scan[4]; /**< Scan type for each part of the LSS address */ - CO_LSS_address_t match; /**< Value to match in case of #CO_LSSmaster_FS_MATCH */ - CO_LSS_address_t found; /**< Scan result */ +typedef struct { + CO_LSSmaster_scantype_t scan[4]; /**< Scan type for each part of the LSS address */ + CO_LSS_address_t match; /**< Value to match in case of #CO_LSSmaster_FS_MATCH */ + CO_LSS_address_t found; /**< Scan result */ } CO_LSSmaster_fastscan_t; /** @@ -457,10 +418,8 @@ fastscan.scan[CO_LSS_FASTSCAN_SERIAL] = CO_LSSmaster_FS_SCAN; * #CO_LSSmaster_WAIT_SLAVE, #CO_LSSmaster_SCAN_FINISHED, #CO_LSSmaster_SCAN_NOACK, * #CO_LSSmaster_SCAN_FAILED */ -CO_LSSmaster_return_t CO_LSSmaster_IdentifyFastscan( - CO_LSSmaster_t *LSSmaster, - uint32_t timeDifference_us, - CO_LSSmaster_fastscan_t *fastscan); +CO_LSSmaster_return_t CO_LSSmaster_IdentifyFastscan(CO_LSSmaster_t* LSSmaster, uint32_t timeDifference_us, + CO_LSSmaster_fastscan_t* fastscan); /** @} */ /*@defgroup CO_LSSmaster*/ diff --git a/305/CO_LSSslave.h b/305/CO_LSSslave.h index e56ba44..26afea4 100644 --- a/305/CO_LSSslave.h +++ b/305/CO_LSSslave.h @@ -25,7 +25,7 @@ #include "305/CO_LSS.h" -#if (((CO_CONFIG_LSS) & CO_CONFIG_LSS_SLAVE) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_LSS)&CO_CONFIG_LSS_SLAVE) != 0) || defined CO_DOXYGEN #ifdef __cplusplus extern "C" { @@ -81,36 +81,40 @@ extern "C" { /** * LSS slave object. */ -typedef struct{ - CO_LSS_address_t lssAddress; /**< From #CO_LSSslave_init */ - uint8_t lssState; /**< #CO_LSS_state_t */ - CO_LSS_address_t lssSelect; /**< Received LSS Address by select */ +typedef struct { + CO_LSS_address_t lssAddress; /**< From #CO_LSSslave_init */ + uint8_t lssState; /**< #CO_LSS_state_t */ + CO_LSS_address_t lssSelect; /**< Received LSS Address by select */ - CO_LSS_address_t lssFastscan; /**< Received LSS Address by fastscan */ - uint8_t fastscanPos; /**< Current state of fastscan */ + CO_LSS_address_t lssFastscan; /**< Received LSS Address by fastscan */ + uint8_t fastscanPos; /**< Current state of fastscan */ - uint16_t *pendingBitRate; /**< Bit rate value that is temporarily configured */ - uint8_t *pendingNodeID; /**< Node ID that is temporarily configured */ - uint8_t activeNodeID; /**< Node ID used at the CAN interface */ + uint16_t* pendingBitRate; /**< Bit rate value that is temporarily configured */ + uint8_t* pendingNodeID; /**< Node ID that is temporarily configured */ + uint8_t activeNodeID; /**< Node ID used at the CAN interface */ - volatile void *sendResponse; /**< Variable indicates, if LSS response has to be sent by mainline processing function */ - uint8_t service; /**< Service, which will have to be processed by mainline processing function */ - uint8_t CANdata[8]; /**< Received CAN data, which will be processed by mainline processing function */ + volatile void* + sendResponse; /**< Variable indicates, if LSS response has to be sent by mainline processing function */ + uint8_t service; /**< Service, which will have to be processed by mainline processing function */ + uint8_t CANdata[8]; /**< Received CAN data, which will be processed by mainline processing function */ -#if (((CO_CONFIG_LSS) & CO_CONFIG_FLAG_CALLBACK_PRE) != 0) || defined CO_DOXYGEN - void (*pFunctSignalPre)(void *object); /**< From CO_LSSslave_initCallbackPre() or NULL */ - void *functSignalObjectPre;/**< Pointer to object */ +#if (((CO_CONFIG_LSS)&CO_CONFIG_FLAG_CALLBACK_PRE) != 0) || defined CO_DOXYGEN + void (*pFunctSignalPre)(void* object); /**< From CO_LSSslave_initCallbackPre() or NULL */ + void* functSignalObjectPre; /**< Pointer to object */ #endif - bool_t (*pFunctLSScheckBitRate)(void *object, uint16_t bitRate); /**< From CO_LSSslave_initCkBitRateCall() or NULL */ - void *functLSScheckBitRateObject; /** Pointer to object */ - void (*pFunctLSSactivateBitRate)(void *object, uint16_t delay); /**< From CO_LSSslave_initActBitRateCall() or NULL. Delay is in ms */ - void *functLSSactivateBitRateObject; /** Pointer to object */ - bool_t (*pFunctLSScfgStore)(void *object, uint8_t id, uint16_t bitRate); /**< From CO_LSSslave_initCfgStoreCall() or NULL */ - void *functLSScfgStoreObject; /** Pointer to object */ + bool_t (*pFunctLSScheckBitRate)(void* object, + uint16_t bitRate); /**< From CO_LSSslave_initCkBitRateCall() or NULL */ + void* functLSScheckBitRateObject; /** Pointer to object */ + void (*pFunctLSSactivateBitRate)( + void* object, uint16_t delay); /**< From CO_LSSslave_initActBitRateCall() or NULL. Delay is in ms */ + void* functLSSactivateBitRateObject; /** Pointer to object */ + bool_t (*pFunctLSScfgStore)(void* object, uint8_t id, + uint16_t bitRate); /**< From CO_LSSslave_initCfgStoreCall() or NULL */ + void* functLSScfgStoreObject; /** Pointer to object */ - CO_CANmodule_t *CANdevTx; /**< From #CO_LSSslave_init() */ - CO_CANtx_t *TXbuff; /**< CAN transmit buffer */ -}CO_LSSslave_t; + CO_CANmodule_t* CANdevTx; /**< From #CO_LSSslave_init() */ + CO_CANtx_t* TXbuff; /**< CAN transmit buffer */ +} CO_LSSslave_t; /** * Initialize LSS object. @@ -151,17 +155,10 @@ typedef struct{ * @param CANidLssSlave COB ID for transmission. * @return #CO_ReturnError_t: CO_ERROR_NO or CO_ERROR_ILLEGAL_ARGUMENT. */ -CO_ReturnError_t CO_LSSslave_init( - CO_LSSslave_t *LSSslave, - CO_LSS_address_t *lssAddress, - uint16_t *pendingBitRate, - uint8_t *pendingNodeID, - CO_CANmodule_t *CANdevRx, - uint16_t CANdevRxIdx, - uint16_t CANidLssMaster, - CO_CANmodule_t *CANdevTx, - uint16_t CANdevTxIdx, - uint16_t CANidLssSlave); +CO_ReturnError_t CO_LSSslave_init(CO_LSSslave_t* LSSslave, CO_LSS_address_t* lssAddress, uint16_t* pendingBitRate, + uint8_t* pendingNodeID, CO_CANmodule_t* CANdevRx, uint16_t CANdevRxIdx, + uint16_t CANidLssMaster, CO_CANmodule_t* CANdevTx, uint16_t CANdevTxIdx, + uint16_t CANidLssSlave); /** * Process LSS communication @@ -176,7 +173,7 @@ CO_ReturnError_t CO_LSSslave_init( * @param LSSslave This object. * @return True, if #CO_NMT_RESET_COMMUNICATION is requested */ -bool_t CO_LSSslave_process(CO_LSSslave_t *LSSslave); +bool_t CO_LSSslave_process(CO_LSSslave_t* LSSslave); /** * Get current LSS state @@ -184,12 +181,12 @@ bool_t CO_LSSslave_process(CO_LSSslave_t *LSSslave); * @param LSSslave This object. * @return #CO_LSS_state_t */ -static inline uint8_t CO_LSSslave_getState(CO_LSSslave_t *LSSslave) { +static inline uint8_t +CO_LSSslave_getState(CO_LSSslave_t* LSSslave) { return (LSSslave == NULL) ? CO_LSS_STATE_WAITING : LSSslave->lssState; } - -#if (((CO_CONFIG_LSS) & CO_CONFIG_FLAG_CALLBACK_PRE) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_LSS)&CO_CONFIG_FLAG_CALLBACK_PRE) != 0) || defined CO_DOXYGEN /** * Initialize LSSslaveRx callback function. * @@ -202,13 +199,9 @@ static inline uint8_t CO_LSSslave_getState(CO_LSSslave_t *LSSslave) { * @param object Pointer to object, which will be passed to pFunctSignal(). Can be NULL * @param pFunctSignalPre Pointer to the callback function. Not called if NULL. */ -void CO_LSSslave_initCallbackPre( - CO_LSSslave_t *LSSslave, - void *object, - void (*pFunctSignalPre)(void *object)); +void CO_LSSslave_initCallbackPre(CO_LSSslave_t* LSSslave, void* object, void (*pFunctSignalPre)(void* object)); #endif - /** * Initialize verify bit rate callback * @@ -222,10 +215,8 @@ void CO_LSSslave_initCallbackPre( * @param object Pointer to object, which will be passed to pFunctLSScheckBitRate(). Can be NULL * @param pFunctLSScheckBitRate Pointer to the callback function. Not called if NULL. */ -void CO_LSSslave_initCkBitRateCall( - CO_LSSslave_t *LSSslave, - void *object, - bool_t (*pFunctLSScheckBitRate)(void *object, uint16_t bitRate)); +void CO_LSSslave_initCkBitRateCall(CO_LSSslave_t* LSSslave, void* object, + bool_t (*pFunctLSScheckBitRate)(void* object, uint16_t bitRate)); /** * Initialize activate bit rate callback @@ -241,10 +232,8 @@ void CO_LSSslave_initCkBitRateCall( * @param object Pointer to object, which will be passed to pFunctLSSactivateBitRate(). Can be NULL * @param pFunctLSSactivateBitRate Pointer to the callback function. Not called if NULL. */ -void CO_LSSslave_initActBitRateCall( - CO_LSSslave_t *LSSslave, - void *object, - void (*pFunctLSSactivateBitRate)(void *object, uint16_t delay)); +void CO_LSSslave_initActBitRateCall(CO_LSSslave_t* LSSslave, void* object, + void (*pFunctLSSactivateBitRate)(void* object, uint16_t delay)); /** * Store configuration callback @@ -260,10 +249,8 @@ void CO_LSSslave_initActBitRateCall( * @param object Pointer to object, which will be passed to pFunctLSScfgStore(). Can be NULL * @param pFunctLSScfgStore Pointer to the callback function. Not called if NULL. */ -void CO_LSSslave_initCfgStoreCall( - CO_LSSslave_t *LSSslave, - void *object, - bool_t (*pFunctLSScfgStore)(void *object, uint8_t id, uint16_t bitRate)); +void CO_LSSslave_initCfgStoreCall(CO_LSSslave_t* LSSslave, void* object, + bool_t (*pFunctLSScfgStore)(void* object, uint8_t id, uint16_t bitRate)); /** @} */ /*@defgroup CO_LSSslave*/ diff --git a/309/CO_gateway_ascii.h b/309/CO_gateway_ascii.h index 6e26260..0aaa459 100644 --- a/309/CO_gateway_ascii.h +++ b/309/CO_gateway_ascii.h @@ -34,7 +34,7 @@ #define CO_CONFIG_GTW (0) #endif -#if (((CO_CONFIG_GTW) & CO_CONFIG_GTW_ASCII) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_GTW)&CO_CONFIG_GTW_ASCII) != 0) || defined CO_DOXYGEN #ifdef __cplusplus extern "C" { @@ -140,84 +140,80 @@ lss_allnodes [ [ \\ * @} */ - /** Size of response string buffer. This is intermediate buffer. If there is * larger amount of data to transfer, then multiple transfers will occur. */ #ifndef CO_GTWA_RESP_BUF_SIZE #define CO_GTWA_RESP_BUF_SIZE 200U #endif - /** Timeout time in microseconds for some internal states. */ #ifndef CO_GTWA_STATE_TIMEOUT_TIME_US #define CO_GTWA_STATE_TIMEOUT_TIME_US 1200000U #endif - /** * Response error codes as specified by CiA 309-3. Values less or equal to 0 * are used for control for some functions and are not part of the standard. */ typedef enum { /** 0 - No error or idle */ - CO_GTWA_respErrorNone = 0, + CO_GTWA_respErrorNone = 0, /** 100 - Request not supported */ - CO_GTWA_respErrorReqNotSupported = 100, + CO_GTWA_respErrorReqNotSupported = 100, /** 101 - Syntax error */ - CO_GTWA_respErrorSyntax = 101, + CO_GTWA_respErrorSyntax = 101, /** 102 - Request not processed due to internal state */ - CO_GTWA_respErrorInternalState = 102, + CO_GTWA_respErrorInternalState = 102, /** 103 - Time-out (where applicable) */ - CO_GTWA_respErrorTimeOut = 103, + CO_GTWA_respErrorTimeOut = 103, /** 104 - No default net set */ - CO_GTWA_respErrorNoDefaultNetSet = 104, + CO_GTWA_respErrorNoDefaultNetSet = 104, /** 105 - No default node set */ - CO_GTWA_respErrorNoDefaultNodeSet = 105, + CO_GTWA_respErrorNoDefaultNodeSet = 105, /** 106 - Unsupported net */ - CO_GTWA_respErrorUnsupportedNet = 106, + CO_GTWA_respErrorUnsupportedNet = 106, /** 107 - Unsupported node */ - CO_GTWA_respErrorUnsupportedNode = 107, + CO_GTWA_respErrorUnsupportedNode = 107, /** 200 - Lost guarding message */ - CO_GTWA_respErrorLostGuardingMessage = 200, + CO_GTWA_respErrorLostGuardingMessage = 200, /** 201 - Lost connection */ - CO_GTWA_respErrorLostConnection = 201, + CO_GTWA_respErrorLostConnection = 201, /** 202 - Heartbeat started */ - CO_GTWA_respErrorHeartbeatStarted = 202, + CO_GTWA_respErrorHeartbeatStarted = 202, /** 203 - Heartbeat lost */ - CO_GTWA_respErrorHeartbeatLost = 203, + CO_GTWA_respErrorHeartbeatLost = 203, /** 204 - Wrong NMT state */ - CO_GTWA_respErrorWrongNMTstate = 204, + CO_GTWA_respErrorWrongNMTstate = 204, /** 205 - Boot-up */ - CO_GTWA_respErrorBootUp = 205, + CO_GTWA_respErrorBootUp = 205, /** 300 - Error passive */ - CO_GTWA_respErrorErrorPassive = 300, + CO_GTWA_respErrorErrorPassive = 300, /** 301 - Bus off */ - CO_GTWA_respErrorBusOff = 301, + CO_GTWA_respErrorBusOff = 301, /** 303 - CAN buffer overflow */ - CO_GTWA_respErrorCANbufferOverflow = 303, + CO_GTWA_respErrorCANbufferOverflow = 303, /** 304 - CAN init */ - CO_GTWA_respErrorCANinit = 304, + CO_GTWA_respErrorCANinit = 304, /** 305 - CAN active (at init or start-up) */ - CO_GTWA_respErrorCANactive = 305, + CO_GTWA_respErrorCANactive = 305, /** 400 - PDO already used */ - CO_GTWA_respErrorPDOalreadyUsed = 400, + CO_GTWA_respErrorPDOalreadyUsed = 400, /** 401 - PDO length exceeded */ - CO_GTWA_respErrorPDOlengthExceeded = 401, + CO_GTWA_respErrorPDOlengthExceeded = 401, /** 501 - LSS implementation- / manufacturer-specific error */ - CO_GTWA_respErrorLSSmanufacturer = 501, + CO_GTWA_respErrorLSSmanufacturer = 501, /** 502 - LSS node-ID not supported */ - CO_GTWA_respErrorLSSnodeIdNotSupported = 502, + CO_GTWA_respErrorLSSnodeIdNotSupported = 502, /** 503 - LSS bit-rate not supported */ - CO_GTWA_respErrorLSSbitRateNotSupported = 503, + CO_GTWA_respErrorLSSbitRateNotSupported = 503, /** 504 - LSS parameter storing failed */ - CO_GTWA_respErrorLSSparameterStoringFailed = 504, + CO_GTWA_respErrorLSSparameterStoringFailed = 504, /** 505 - LSS command failed because of media error */ - CO_GTWA_respErrorLSSmediaError = 505, + CO_GTWA_respErrorLSSmediaError = 505, /** 600 - Running out of memory */ - CO_GTWA_respErrorRunningOutOfMemory = 600 + CO_GTWA_respErrorRunningOutOfMemory = 600 } CO_GTWA_respErrorCode_t; - /** * Internal states of the Gateway-ascii state machine. */ @@ -257,8 +253,7 @@ typedef enum { CO_GTWA_ST_LED = 0x82U } CO_GTWA_state_t; - -#if (((CO_CONFIG_GTW) & CO_CONFIG_GTW_ASCII_SDO) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_GTW)&CO_CONFIG_GTW_ASCII_SDO) != 0) || defined CO_DOXYGEN /* * CANopen Gateway-ascii data types structure */ @@ -271,21 +266,15 @@ typedef struct { * writes them as corresponding ascii string. It is a pointer to * #CO_fifo_readU82a function or similar and is used with SDO upload. For * description of parameters see #CO_fifo_readU82a */ - size_t (*dataTypePrint)(CO_fifo_t *fifo, - char *buf, - size_t count, - bool_t end); + size_t (*dataTypePrint)(CO_fifo_t* fifo, char* buf, size_t count, bool_t end); /** Function, which reads ascii-data of specific data type from fifo buffer * and copies them to another fifo buffer as binary data. It is a pointer to * #CO_fifo_cpyTok2U8 function or similar and is used with SDO download. For * description of parameters see #CO_fifo_cpyTok2U8 */ - size_t (*dataTypeScan)(CO_fifo_t *dest, - CO_fifo_t *src, - uint8_t *status); + size_t (*dataTypeScan)(CO_fifo_t* dest, CO_fifo_t* src, uint8_t* status); } CO_GTWA_dataType_t; #endif /* (CO_CONFIG_GTW) & CO_CONFIG_GTW_ASCII_SDO */ - /** * CANopen Gateway-ascii object */ @@ -300,13 +289,10 @@ typedef struct { * * @return Count of bytes actually transferred. */ - size_t (*readCallback)(void *object, - const char *buf, - size_t count, - uint8_t *connectionOK); + size_t (*readCallback)(void* object, const char* buf, size_t count, uint8_t* connectionOK); /** Pointer to object, which will be used inside readCallback, from * CO_GTWA_init() */ - void *readCallbackObject; + void* readCallbackObject; /** Sequence number of the command */ uint32_t sequence; /** Default CANopen Net number is undefined (-1) at startup */ @@ -338,9 +324,9 @@ typedef struct { CO_GTWA_state_t state; /** Timeout timer for the current state */ uint32_t stateTimeoutTmr; -#if (((CO_CONFIG_GTW) & CO_CONFIG_GTW_ASCII_SDO) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_GTW)&CO_CONFIG_GTW_ASCII_SDO) != 0) || defined CO_DOXYGEN /** SDO client object from CO_GTWA_init() */ - CO_SDOclient_t *SDO_C; + CO_SDOclient_t* SDO_C; /** Timeout time for SDO transfer in milliseconds, if no response */ uint16_t SDOtimeoutTime; /** SDO block transfer enabled? */ @@ -350,15 +336,15 @@ typedef struct { * SDO buffer contains only part of data and more data will follow. */ bool_t SDOdataCopyStatus; /** Data type of variable in current SDO communication */ - const CO_GTWA_dataType_t *SDOdataType; + const CO_GTWA_dataType_t* SDOdataType; #endif -#if (((CO_CONFIG_GTW) & CO_CONFIG_GTW_ASCII_NMT) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_GTW)&CO_CONFIG_GTW_ASCII_NMT) != 0) || defined CO_DOXYGEN /** NMT object from CO_GTWA_init() */ - CO_NMT_t *NMT; + CO_NMT_t* NMT; #endif -#if (((CO_CONFIG_GTW) & CO_CONFIG_GTW_ASCII_LSS) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_GTW)&CO_CONFIG_GTW_ASCII_LSS) != 0) || defined CO_DOXYGEN /** LSSmaster object from CO_GTWA_init() */ - CO_LSSmaster_t *LSSmaster; + CO_LSSmaster_t* LSSmaster; /** 128 bit number, uniquely identifying each node */ CO_LSS_address_t lssAddress; /** LSS Node-ID parameter */ @@ -378,25 +364,24 @@ typedef struct { /** LSS allnodes timeout parameter */ uint16_t lssTimeout_ms; #endif -#if (((CO_CONFIG_GTW) & CO_CONFIG_GTW_ASCII_LOG) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_GTW)&CO_CONFIG_GTW_ASCII_LOG) != 0) || defined CO_DOXYGEN /** Message log buffer of usable size @ref CO_CONFIG_GTWA_LOG_BUF_SIZE */ uint8_t logBuf[CO_CONFIG_GTWA_LOG_BUF_SIZE + 1]; /** CO_fifo_t object for message log (not pointer) */ CO_fifo_t logFifo; #endif -#if (((CO_CONFIG_GTW) & CO_CONFIG_GTW_ASCII_PRINT_HELP) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_GTW)&CO_CONFIG_GTW_ASCII_PRINT_HELP) != 0) || defined CO_DOXYGEN /** Offset, when printing help text */ - const char *helpString; + const char* helpString; size_t helpStringOffset; #endif -#if (((CO_CONFIG_GTW) & CO_CONFIG_GTW_ASCII_PRINT_LEDS) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_GTW)&CO_CONFIG_GTW_ASCII_PRINT_LEDS) != 0) || defined CO_DOXYGEN /** CO_LEDs_t object for CANopen status LEDs imitation from CO_GTWA_init()*/ - CO_LEDs_t *LEDs; + CO_LEDs_t* LEDs; uint8_t ledStringPreviousIndex; #endif } CO_GTWA_t; - /** * Initialize Gateway-ascii object * @@ -412,23 +397,20 @@ typedef struct { * @return #CO_ReturnError_t: CO_ERROR_NO or CO_ERROR_ILLEGAL_ARGUMENT */ CO_ReturnError_t CO_GTWA_init(CO_GTWA_t* gtwa, -#if (((CO_CONFIG_GTW) & CO_CONFIG_GTW_ASCII_SDO) != 0) || defined CO_DOXYGEN - CO_SDOclient_t* SDO_C, - uint16_t SDOclientTimeoutTime_ms, - bool_t SDOclientBlockTransfer, +#if (((CO_CONFIG_GTW)&CO_CONFIG_GTW_ASCII_SDO) != 0) || defined CO_DOXYGEN + CO_SDOclient_t* SDO_C, uint16_t SDOclientTimeoutTime_ms, bool_t SDOclientBlockTransfer, #endif -#if (((CO_CONFIG_GTW) & CO_CONFIG_GTW_ASCII_NMT) != 0) || defined CO_DOXYGEN - CO_NMT_t *NMT, +#if (((CO_CONFIG_GTW)&CO_CONFIG_GTW_ASCII_NMT) != 0) || defined CO_DOXYGEN + CO_NMT_t* NMT, #endif -#if (((CO_CONFIG_GTW) & CO_CONFIG_GTW_ASCII_LSS) != 0) || defined CO_DOXYGEN - CO_LSSmaster_t *LSSmaster, +#if (((CO_CONFIG_GTW)&CO_CONFIG_GTW_ASCII_LSS) != 0) || defined CO_DOXYGEN + CO_LSSmaster_t* LSSmaster, #endif -#if (((CO_CONFIG_GTW) & CO_CONFIG_GTW_ASCII_PRINT_LEDS) != 0) || defined CO_DOXYGEN - CO_LEDs_t *LEDs, +#if (((CO_CONFIG_GTW)&CO_CONFIG_GTW_ASCII_PRINT_LEDS) != 0) || defined CO_DOXYGEN + CO_LEDs_t* LEDs, #endif uint8_t dummy); - /** * Initialize read callback in Gateway-ascii object * @@ -444,12 +426,8 @@ CO_ReturnError_t CO_GTWA_init(CO_GTWA_t* gtwa, * readCallback */ void CO_GTWA_initRead(CO_GTWA_t* gtwa, - size_t (*readCallback)(void *object, - const char *buf, - size_t count, - uint8_t *connectionOK), - void *readCallbackObject); - + size_t (*readCallback)(void* object, const char* buf, size_t count, uint8_t* connectionOK), + void* readCallbackObject); /** * Get free write buffer space @@ -458,11 +436,11 @@ void CO_GTWA_initRead(CO_GTWA_t* gtwa, * * @return number of available bytes */ -static inline size_t CO_GTWA_write_getSpace(CO_GTWA_t* gtwa) { +static inline size_t +CO_GTWA_write_getSpace(CO_GTWA_t* gtwa) { return CO_fifo_getSpace(>wa->commFifo); } - /** * Write command into CO_GTWA_t object. * @@ -478,15 +456,12 @@ static inline size_t CO_GTWA_write_getSpace(CO_GTWA_t* gtwa) { * * @return number of bytes actually written. */ -static inline size_t CO_GTWA_write(CO_GTWA_t* gtwa, - const char *buf, - size_t count) -{ - return CO_fifo_write(>wa->commFifo, (const uint8_t *)buf, count, NULL); +static inline size_t +CO_GTWA_write(CO_GTWA_t* gtwa, const char* buf, size_t count) { + return CO_fifo_write(>wa->commFifo, (const uint8_t*)buf, count, NULL); } - -#if (((CO_CONFIG_GTW) & CO_CONFIG_GTW_ASCII_LOG) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_GTW)&CO_CONFIG_GTW_ASCII_LOG) != 0) || defined CO_DOXYGEN /** * Print message log string into fifo buffer * @@ -499,10 +474,9 @@ static inline size_t CO_GTWA_write(CO_GTWA_t* gtwa, * @param gtwa This object * @param message Null terminated string */ -void CO_GTWA_log_print(CO_GTWA_t* gtwa, const char *message); +void CO_GTWA_log_print(CO_GTWA_t* gtwa, const char* message); #endif /* (CO_CONFIG_GTW) & CO_CONFIG_GTW_ASCII_LOG */ - /** * Process Gateway-ascii object * @@ -518,10 +492,7 @@ void CO_GTWA_log_print(CO_GTWA_t* gtwa, const char *message); * * @return CO_ReturnError_t: CO_ERROR_NO on success or CO_ERROR_ILLEGAL_ARGUMENT */ -void CO_GTWA_process(CO_GTWA_t *gtwa, - bool_t enable, - uint32_t timeDifference_us, - uint32_t *timerNext_us); +void CO_GTWA_process(CO_GTWA_t* gtwa, bool_t enable, uint32_t timeDifference_us, uint32_t* timerNext_us); /** @} */ /* CO_CANopen_309_3 */ @@ -529,6 +500,6 @@ void CO_GTWA_process(CO_GTWA_t *gtwa, } #endif /*__cplusplus*/ -#endif /* (CO_CONFIG_GTW) & CO_CONFIG_GTW_ASCII */ +#endif /* (CO_CONFIG_GTW) & CO_CONFIG_GTW_ASCII */ #endif /* CO_GATEWAY_ASCII_H */ diff --git a/CANopen.h b/CANopen.h index ecbbd43..c4fa202 100644 --- a/CANopen.h +++ b/CANopen.h @@ -19,7 +19,6 @@ * See the License for the specific language governing permissions and limitations under the License. */ - #ifndef CANopen_H #define CANopen_H @@ -42,7 +41,6 @@ #include "309/CO_gateway_ascii.h" #include "extra/CO_trace.h" - #ifdef __cplusplus extern "C" { #endif @@ -182,7 +180,6 @@ extern "C" { #define CO_USE_GLOBALS #endif - #if defined CO_MULTIPLE_OD || defined CO_DOXYGEN /** * CANopen configuration, used with @ref CO_new() @@ -196,68 +193,68 @@ typedef struct { * @ref CO_CONFIG_NMT. Start indexes inside CANrx and CANtx are always 0. * There must be one NMT object in the device. */ uint8_t CNT_NMT; - OD_entry_t *ENTRY_H1017; /**< OD entry for @ref CO_NMT_init() */ + OD_entry_t* ENTRY_H1017; /**< OD entry for @ref CO_NMT_init() */ /** Number of Heartbeat consumer objects, 0 or 1 */ uint8_t CNT_HB_CONS; /** Number of internal consumers (CANrx), used inside Heartbeat consumer * object, 1 to 127. */ uint8_t CNT_ARR_1016; - OD_entry_t *ENTRY_H1016; /**< OD entry for @ref CO_HBconsumer_init()*/ + OD_entry_t* ENTRY_H1016; /**< OD entry for @ref CO_HBconsumer_init()*/ /** OD entry for @ref CO_nodeGuardingSlave_init() */ - OD_entry_t *ENTRY_H100C; + OD_entry_t* ENTRY_H100C; /** OD entry for @ref CO_nodeGuardingSlave_init() */ - OD_entry_t *ENTRY_H100D; + OD_entry_t* ENTRY_H100D; /** Number of Emergency objects, 0 or 1: optional producer (CANtx) + * optional consumer (CANrx), configurable by @ref CO_CONFIG_EM. * There must be one Emergency object in the device. */ uint8_t CNT_EM; - const OD_entry_t *ENTRY_H1001; /**< OD entry for @ref CO_EM_init() */ - OD_entry_t *ENTRY_H1014; /**< OD entry for @ref CO_EM_init() */ - OD_entry_t *ENTRY_H1015; /**< OD entry for @ref CO_EM_init() */ + const OD_entry_t* ENTRY_H1001; /**< OD entry for @ref CO_EM_init() */ + OD_entry_t* ENTRY_H1014; /**< OD entry for @ref CO_EM_init() */ + OD_entry_t* ENTRY_H1015; /**< OD entry for @ref CO_EM_init() */ /** Size of the fifo buffer, which is used for intermediate storage of * emergency messages. Fifo is used by emergency producer and by error * history (OD object 0x1003). Size is usually equal to size of array in * OD object 0x1003. If later is not used, CNT_ARR_1003 must also be set to * value greater than 0, or emergency producer will not work. */ uint8_t CNT_ARR_1003; - OD_entry_t *ENTRY_H1003; /**< OD entry for @ref CO_EM_init() */ + OD_entry_t* ENTRY_H1003; /**< OD entry for @ref CO_EM_init() */ /** Number of SDO server objects, from 0 to 128 (CANrx + CANtx). There must * be at least one SDO server object in the device. */ uint8_t CNT_SDO_SRV; - OD_entry_t *ENTRY_H1200; /**< OD entry for @ref CO_SDOserver_init()*/ + OD_entry_t* ENTRY_H1200; /**< OD entry for @ref CO_SDOserver_init()*/ /** Number of SDO client objects, from 0 to 128 (CANrx + CANtx). */ uint8_t CNT_SDO_CLI; - OD_entry_t *ENTRY_H1280; /**< OD entry for @ref CO_SDOclient_init()*/ + OD_entry_t* ENTRY_H1280; /**< OD entry for @ref CO_SDOclient_init()*/ /** Number of TIME objects, 0 or 1: consumer (CANrx) + optional producer * (CANtx), configurable by @ref CO_CONFIG_TIME. */ uint8_t CNT_TIME; - OD_entry_t *ENTRY_H1012; /**< OD entry for @ref CO_TIME_init() */ + OD_entry_t* ENTRY_H1012; /**< OD entry for @ref CO_TIME_init() */ /** Number of SYNC objects, 0 or 1: consumer (CANrx) + optional producer * (CANtx), configurable by @ref CO_CONFIG_SYNC. */ uint8_t CNT_SYNC; - OD_entry_t *ENTRY_H1005; /**< OD entry for @ref CO_SYNC_init() */ - OD_entry_t *ENTRY_H1006; /**< OD entry for @ref CO_SYNC_init() */ - OD_entry_t *ENTRY_H1007; /**< OD entry for @ref CO_SYNC_init() */ - OD_entry_t *ENTRY_H1019; /**< OD entry for @ref CO_SYNC_init() */ + OD_entry_t* ENTRY_H1005; /**< OD entry for @ref CO_SYNC_init() */ + OD_entry_t* ENTRY_H1006; /**< OD entry for @ref CO_SYNC_init() */ + OD_entry_t* ENTRY_H1007; /**< OD entry for @ref CO_SYNC_init() */ + OD_entry_t* ENTRY_H1019; /**< OD entry for @ref CO_SYNC_init() */ /** Number of RPDO objects, from 0 to 512 consumers (CANrx) */ uint16_t CNT_RPDO; - OD_entry_t *ENTRY_H1400; /**< OD entry for @ref CO_RPDO_init() */ - OD_entry_t *ENTRY_H1600; /**< OD entry for @ref CO_RPDO_init() */ + OD_entry_t* ENTRY_H1400; /**< OD entry for @ref CO_RPDO_init() */ + OD_entry_t* ENTRY_H1600; /**< OD entry for @ref CO_RPDO_init() */ /** Number of TPDO objects, from 0 to 512 producers (CANtx) */ uint16_t CNT_TPDO; - OD_entry_t *ENTRY_H1800; /**< OD entry for @ref CO_TPDO_init() */ - OD_entry_t *ENTRY_H1A00; /**< OD entry for @ref CO_TPDO_init() */ + OD_entry_t* ENTRY_H1800; /**< OD entry for @ref CO_TPDO_init() */ + OD_entry_t* ENTRY_H1A00; /**< OD entry for @ref CO_TPDO_init() */ /** Number of LEDs objects, 0 or 1. */ uint8_t CNT_LEDS; /** Number of GFC objects, 0 or 1 (CANrx + CANtx). */ uint8_t CNT_GFC; - OD_entry_t *ENTRY_H1300; /**< OD entry for @ref CO_GFC_init() */ + OD_entry_t* ENTRY_H1300; /**< OD entry for @ref CO_GFC_init() */ /** Number of SRDO objects, from 0 to 64 (2*CANrx + 2*CANtx). */ uint8_t CNT_SRDO; - OD_entry_t *ENTRY_H1301; /**< OD entry for @ref CO_SRDO_init() */ - OD_entry_t *ENTRY_H1381; /**< OD entry for @ref CO_SRDO_init() */ - OD_entry_t *ENTRY_H13FE; /**< OD entry for @ref CO_SRDO_init() */ - OD_entry_t *ENTRY_H13FF; /**< OD entry for @ref CO_SRDO_init() */ + OD_entry_t* ENTRY_H1301; /**< OD entry for @ref CO_SRDO_init() */ + OD_entry_t* ENTRY_H1381; /**< OD entry for @ref CO_SRDO_init() */ + OD_entry_t* ENTRY_H13FE; /**< OD entry for @ref CO_SRDO_init() */ + OD_entry_t* ENTRY_H13FF; /**< OD entry for @ref CO_SRDO_init() */ /** Number of LSSslave objects, 0 or 1 (CANrx + CANtx). */ uint8_t CNT_LSS_SLV; /** Number of LSSmaster objects, 0 or 1 (CANrx + CANtx). */ @@ -271,162 +268,159 @@ typedef struct { typedef void CO_config_t; #endif /* CO_MULTIPLE_OD */ - /** * CANopen object - collection of all CANopenNode objects */ typedef struct { bool_t nodeIdUnconfigured; /**< True in un-configured LSS slave */ - #if defined CO_MULTIPLE_OD || defined CO_DOXYGEN - CO_config_t *config; /**< Remember the configuration parameters */ - #endif +#if defined CO_MULTIPLE_OD || defined CO_DOXYGEN + CO_config_t* config; /**< Remember the configuration parameters */ +#endif /** One CAN module object, initialised by @ref CO_CANmodule_init() */ - CO_CANmodule_t *CANmodule; - CO_CANrx_t *CANrx; /**< CAN receive message objects */ - CO_CANtx_t *CANtx; /**< CAN transmit message objects */ - #if defined CO_MULTIPLE_OD || defined CO_DOXYGEN + CO_CANmodule_t* CANmodule; + CO_CANrx_t* CANrx; /**< CAN receive message objects */ + CO_CANtx_t* CANtx; /**< CAN transmit message objects */ +#if defined CO_MULTIPLE_OD || defined CO_DOXYGEN uint16_t CNT_ALL_RX_MSGS; /**< Number of all CAN receive message objects. */ uint16_t CNT_ALL_TX_MSGS; /**< Number of all CAN transmit message objects.*/ - #endif +#endif /** NMT and heartbeat object, initialised by @ref CO_NMT_init() */ - CO_NMT_t *NMT; - #if defined CO_MULTIPLE_OD || defined CO_DOXYGEN + CO_NMT_t* NMT; +#if defined CO_MULTIPLE_OD || defined CO_DOXYGEN uint16_t RX_IDX_NMT_SLV; /**< Start index in CANrx. */ uint16_t TX_IDX_NMT_MST; /**< Start index in CANtx. */ uint16_t TX_IDX_HB_PROD; /**< Start index in CANtx. */ - #endif -#if (((CO_CONFIG_HB_CONS) & CO_CONFIG_HB_CONS_ENABLE) != 0) || defined CO_DOXYGEN - /** Heartbeat consumer object, initialised by @ref CO_HBconsumer_init() */ - CO_HBconsumer_t *HBcons; - /** Object for monitored nodes, initialised by @ref CO_HBconsumer_init() */ - CO_HBconsNode_t *HBconsMonitoredNodes; - #if defined CO_MULTIPLE_OD || defined CO_DOXYGEN - uint16_t RX_IDX_HB_CONS; /**< Start index in CANrx. */ - #endif #endif -#if (((CO_CONFIG_NODE_GUARDING) & CO_CONFIG_NODE_GUARDING_SLAVE_ENABLE) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_HB_CONS)&CO_CONFIG_HB_CONS_ENABLE) != 0) || defined CO_DOXYGEN + /** Heartbeat consumer object, initialised by @ref CO_HBconsumer_init() */ + CO_HBconsumer_t* HBcons; + /** Object for monitored nodes, initialised by @ref CO_HBconsumer_init() */ + CO_HBconsNode_t* HBconsMonitoredNodes; +#if defined CO_MULTIPLE_OD || defined CO_DOXYGEN + uint16_t RX_IDX_HB_CONS; /**< Start index in CANrx. */ +#endif +#endif +#if (((CO_CONFIG_NODE_GUARDING)&CO_CONFIG_NODE_GUARDING_SLAVE_ENABLE) != 0) || defined CO_DOXYGEN /** Node guarding slave object, initialised by @ref CO_nodeGuardingSlave_init() */ - CO_nodeGuardingSlave_t *NGslave; - #if defined CO_MULTIPLE_OD || defined CO_DOXYGEN + CO_nodeGuardingSlave_t* NGslave; +#if defined CO_MULTIPLE_OD || defined CO_DOXYGEN uint16_t RX_IDX_NG_SLV; /**< Start index in CANrx. */ uint16_t TX_IDX_NG_SLV; /**< Start index in CANtx. */ - #endif #endif -#if (((CO_CONFIG_NODE_GUARDING) & CO_CONFIG_NODE_GUARDING_MASTER_ENABLE) != 0) || defined CO_DOXYGEN +#endif +#if (((CO_CONFIG_NODE_GUARDING)&CO_CONFIG_NODE_GUARDING_MASTER_ENABLE) != 0) || defined CO_DOXYGEN /** Node guarding master object, initialised by @ref CO_nodeGuardingMaster_init() */ - CO_nodeGuardingMaster_t *NGmaster; - #if defined CO_MULTIPLE_OD || defined CO_DOXYGEN + CO_nodeGuardingMaster_t* NGmaster; +#if defined CO_MULTIPLE_OD || defined CO_DOXYGEN uint16_t RX_IDX_NG_MST; /**< Start index in CANrx. */ uint16_t TX_IDX_NG_MST; /**< Start index in CANtx. */ - #endif +#endif #endif /** Emergency object, initialised by @ref CO_EM_init() */ - CO_EM_t *em; - #if defined CO_MULTIPLE_OD || defined CO_DOXYGEN + CO_EM_t* em; +#if defined CO_MULTIPLE_OD || defined CO_DOXYGEN uint16_t RX_IDX_EM_CONS; /**< Start index in CANrx. */ uint16_t TX_IDX_EM_PROD; /**< Start index in CANtx. */ - #endif -#if (((CO_CONFIG_EM) & (CO_CONFIG_EM_PRODUCER | CO_CONFIG_EM_HISTORY)) != 0) \ - || defined CO_DOXYGEN +#endif +#if (((CO_CONFIG_EM) & (CO_CONFIG_EM_PRODUCER | CO_CONFIG_EM_HISTORY)) != 0) || defined CO_DOXYGEN /** FIFO for emergency object, initialised by @ref CO_EM_init() */ - CO_EM_fifo_t *em_fifo; + CO_EM_fifo_t* em_fifo; #endif /** SDO server objects, initialised by @ref CO_SDOserver_init() */ - CO_SDOserver_t *SDOserver; - #if defined CO_MULTIPLE_OD || defined CO_DOXYGEN + CO_SDOserver_t* SDOserver; +#if defined CO_MULTIPLE_OD || defined CO_DOXYGEN uint16_t RX_IDX_SDO_SRV; /**< Start index in CANrx. */ uint16_t TX_IDX_SDO_SRV; /**< Start index in CANtx. */ - #endif -#if (((CO_CONFIG_SDO_CLI) & CO_CONFIG_SDO_CLI_ENABLE) != 0) || defined CO_DOXYGEN +#endif +#if (((CO_CONFIG_SDO_CLI)&CO_CONFIG_SDO_CLI_ENABLE) != 0) || defined CO_DOXYGEN /** SDO client objects, initialised by @ref CO_SDOclient_init() */ - CO_SDOclient_t *SDOclient; - #if defined CO_MULTIPLE_OD || defined CO_DOXYGEN + CO_SDOclient_t* SDOclient; +#if defined CO_MULTIPLE_OD || defined CO_DOXYGEN uint16_t RX_IDX_SDO_CLI; /**< Start index in CANrx. */ uint16_t TX_IDX_SDO_CLI; /**< Start index in CANtx. */ - #endif #endif -#if (((CO_CONFIG_TIME) & CO_CONFIG_TIME_ENABLE) != 0) || defined CO_DOXYGEN +#endif +#if (((CO_CONFIG_TIME)&CO_CONFIG_TIME_ENABLE) != 0) || defined CO_DOXYGEN /** TIME object, initialised by @ref CO_TIME_init() */ - CO_TIME_t *TIME; - #if defined CO_MULTIPLE_OD || defined CO_DOXYGEN + CO_TIME_t* TIME; +#if defined CO_MULTIPLE_OD || defined CO_DOXYGEN uint16_t RX_IDX_TIME; /**< Start index in CANrx. */ uint16_t TX_IDX_TIME; /**< Start index in CANtx. */ - #endif #endif -#if (((CO_CONFIG_SYNC) & CO_CONFIG_SYNC_ENABLE) != 0) || defined CO_DOXYGEN +#endif +#if (((CO_CONFIG_SYNC)&CO_CONFIG_SYNC_ENABLE) != 0) || defined CO_DOXYGEN /** SYNC object, initialised by @ref CO_SYNC_init() */ - CO_SYNC_t *SYNC; - #if defined CO_MULTIPLE_OD || defined CO_DOXYGEN + CO_SYNC_t* SYNC; +#if defined CO_MULTIPLE_OD || defined CO_DOXYGEN uint16_t RX_IDX_SYNC; /**< Start index in CANrx. */ uint16_t TX_IDX_SYNC; /**< Start index in CANtx. */ - #endif #endif -#if (((CO_CONFIG_PDO) & CO_CONFIG_RPDO_ENABLE) != 0) || defined CO_DOXYGEN +#endif +#if (((CO_CONFIG_PDO)&CO_CONFIG_RPDO_ENABLE) != 0) || defined CO_DOXYGEN /** RPDO objects, initialised by @ref CO_RPDO_init() */ - CO_RPDO_t *RPDO; - #if defined CO_MULTIPLE_OD || defined CO_DOXYGEN + CO_RPDO_t* RPDO; +#if defined CO_MULTIPLE_OD || defined CO_DOXYGEN uint16_t RX_IDX_RPDO; /**< Start index in CANrx. */ - #endif #endif -#if (((CO_CONFIG_PDO) & CO_CONFIG_TPDO_ENABLE) != 0) || defined CO_DOXYGEN +#endif +#if (((CO_CONFIG_PDO)&CO_CONFIG_TPDO_ENABLE) != 0) || defined CO_DOXYGEN /** TPDO objects, initialised by @ref CO_TPDO_init() */ - CO_TPDO_t *TPDO; - #if defined CO_MULTIPLE_OD || defined CO_DOXYGEN + CO_TPDO_t* TPDO; +#if defined CO_MULTIPLE_OD || defined CO_DOXYGEN uint16_t TX_IDX_TPDO; /**< Start index in CANtx. */ - #endif #endif -#if (((CO_CONFIG_LEDS) & CO_CONFIG_LEDS_ENABLE) != 0) || defined CO_DOXYGEN +#endif +#if (((CO_CONFIG_LEDS)&CO_CONFIG_LEDS_ENABLE) != 0) || defined CO_DOXYGEN /** LEDs object, initialised by @ref CO_LEDs_init() */ - CO_LEDs_t *LEDs; + CO_LEDs_t* LEDs; #endif -#if (((CO_CONFIG_GFC) & CO_CONFIG_GFC_ENABLE) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_GFC)&CO_CONFIG_GFC_ENABLE) != 0) || defined CO_DOXYGEN /** GFC object, initialised by @ref CO_GFC_init() */ - CO_GFC_t *GFC; - #if defined CO_MULTIPLE_OD || defined CO_DOXYGEN + CO_GFC_t* GFC; +#if defined CO_MULTIPLE_OD || defined CO_DOXYGEN uint16_t RX_IDX_GFC; /**< Start index in CANrx. */ uint16_t TX_IDX_GFC; /**< Start index in CANtx. */ - #endif #endif -#if (((CO_CONFIG_SRDO) & CO_CONFIG_SRDO_ENABLE) != 0) || defined CO_DOXYGEN +#endif +#if (((CO_CONFIG_SRDO)&CO_CONFIG_SRDO_ENABLE) != 0) || defined CO_DOXYGEN /** SRDO guard object, initialised by @ref CO_SRDO_init_start(), single * SRDOGuard object is included inside all SRDO objects */ - CO_SRDOGuard_t *SRDOGuard; + CO_SRDOGuard_t* SRDOGuard; /** SRDO objects, initialised by @ref CO_SRDO_init() */ - CO_SRDO_t *SRDO; - #if defined CO_MULTIPLE_OD || defined CO_DOXYGEN + CO_SRDO_t* SRDO; +#if defined CO_MULTIPLE_OD || defined CO_DOXYGEN uint16_t RX_IDX_SRDO; /**< Start index in CANrx. */ uint16_t TX_IDX_SRDO; /**< Start index in CANtx. */ - #endif #endif -#if (((CO_CONFIG_LSS) & CO_CONFIG_LSS_SLAVE) != 0) || defined CO_DOXYGEN +#endif +#if (((CO_CONFIG_LSS)&CO_CONFIG_LSS_SLAVE) != 0) || defined CO_DOXYGEN /** LSS slave object, initialised by @ref CO_LSSslave_init(). */ - CO_LSSslave_t *LSSslave; - #if defined CO_MULTIPLE_OD || defined CO_DOXYGEN + CO_LSSslave_t* LSSslave; +#if defined CO_MULTIPLE_OD || defined CO_DOXYGEN uint16_t RX_IDX_LSS_SLV; /**< Start index in CANrx. */ uint16_t TX_IDX_LSS_SLV; /**< Start index in CANtx. */ - #endif #endif -#if (((CO_CONFIG_LSS) & CO_CONFIG_LSS_MASTER) != 0) || defined CO_DOXYGEN +#endif +#if (((CO_CONFIG_LSS)&CO_CONFIG_LSS_MASTER) != 0) || defined CO_DOXYGEN /** LSS master object, initialised by @ref CO_LSSmaster_init(). */ - CO_LSSmaster_t *LSSmaster; - #if defined CO_MULTIPLE_OD || defined CO_DOXYGEN + CO_LSSmaster_t* LSSmaster; +#if defined CO_MULTIPLE_OD || defined CO_DOXYGEN uint16_t RX_IDX_LSS_MST; /**< Start index in CANrx. */ uint16_t TX_IDX_LSS_MST; /**< Start index in CANtx. */ - #endif #endif -#if (((CO_CONFIG_GTW) & CO_CONFIG_GTW_ASCII) != 0) || defined CO_DOXYGEN +#endif +#if (((CO_CONFIG_GTW)&CO_CONFIG_GTW_ASCII) != 0) || defined CO_DOXYGEN /** Gateway-ascii object, initialised by @ref CO_GTWA_init(). */ - CO_GTWA_t *gtwa; - #if defined CO_MULTIPLE_OD || defined CO_DOXYGEN - #endif + CO_GTWA_t* gtwa; +#if defined CO_MULTIPLE_OD || defined CO_DOXYGEN #endif -#if ((CO_CONFIG_TRACE) & CO_CONFIG_TRACE_ENABLE) || defined CO_DOXYGEN +#endif +#if ((CO_CONFIG_TRACE)&CO_CONFIG_TRACE_ENABLE) || defined CO_DOXYGEN /** Trace object, initialised by @ref CO_trace_init(). */ - CO_trace_t *trace; + CO_trace_t* trace; #endif } CO_t; - /** * Create new CANopen object * @@ -446,16 +440,14 @@ typedef struct { * * @return Successfully allocated and configured CO_t object or NULL. */ -CO_t *CO_new(CO_config_t *config, uint32_t *heapMemoryUsed); - +CO_t* CO_new(CO_config_t* config, uint32_t* heapMemoryUsed); /** * Delete CANopen object and free memory. Must be called at program exit. * * @param co CANopen object. */ -void CO_delete(CO_t *co); - +void CO_delete(CO_t* co); /** * Test if LSS slave is enabled @@ -464,8 +456,7 @@ void CO_delete(CO_t *co); * * @return True if enabled */ -bool_t CO_isLSSslaveEnabled(CO_t *co); - +bool_t CO_isLSSslaveEnabled(CO_t* co); /** * Initialize CAN driver @@ -478,10 +469,9 @@ bool_t CO_isLSSslaveEnabled(CO_t *co); * @param bitRate CAN bit rate. * @return CO_ERROR_NO in case of success. */ -CO_ReturnError_t CO_CANinit(CO_t *co, void *CANptr, uint16_t bitRate); +CO_ReturnError_t CO_CANinit(CO_t* co, void* CANptr, uint16_t bitRate); - -#if (((CO_CONFIG_LSS) & CO_CONFIG_LSS_SLAVE) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_LSS)&CO_CONFIG_LSS_SLAVE) != 0) || defined CO_DOXYGEN /** * Initialize CANopen LSS slave * @@ -496,13 +486,9 @@ CO_ReturnError_t CO_CANinit(CO_t *co, void *CANptr, uint16_t bitRate); * * @return CO_ERROR_NO in case of success. */ -CO_ReturnError_t CO_LSSinit(CO_t *co, - CO_LSS_address_t *lssAddress, - uint8_t *pendingNodeID, - uint16_t *pendingBitRate); +CO_ReturnError_t CO_LSSinit(CO_t* co, CO_LSS_address_t* lssAddress, uint8_t* pendingNodeID, uint16_t* pendingBitRate); #endif - /** * Initialize CANopenNode except PDO objects. * @@ -534,19 +520,10 @@ CO_ReturnError_t CO_LSSinit(CO_t *co, * * @return CO_ERROR_NO in case of success. */ -CO_ReturnError_t CO_CANopenInit(CO_t *co, - CO_NMT_t *NMT, - CO_EM_t *em, - OD_t *od, - OD_entry_t *OD_statusBits, - uint16_t NMTcontrol, - uint16_t firstHBTime_ms, - uint16_t SDOserverTimeoutTime_ms, - uint16_t SDOclientTimeoutTime_ms, - bool_t SDOclientBlockTransfer, - uint8_t nodeId, - uint32_t *errInfo); - +CO_ReturnError_t CO_CANopenInit(CO_t* co, CO_NMT_t* NMT, CO_EM_t* em, OD_t* od, OD_entry_t* OD_statusBits, + uint16_t NMTcontrol, uint16_t firstHBTime_ms, uint16_t SDOserverTimeoutTime_ms, + uint16_t SDOclientTimeoutTime_ms, bool_t SDOclientBlockTransfer, uint8_t nodeId, + uint32_t* errInfo); /** * Initialize CANopenNode PDO objects. @@ -565,14 +542,7 @@ CO_ReturnError_t CO_CANopenInit(CO_t *co, * * @return CO_ERROR_NO in case of success. */ -CO_ReturnError_t CO_CANopenInitPDO(CO_t *co, - CO_EM_t *em, - OD_t *od, - uint8_t nodeId, - uint32_t *errInfo); - - - +CO_ReturnError_t CO_CANopenInitPDO(CO_t* co, CO_EM_t* em, OD_t* od, uint8_t nodeId, uint32_t* errInfo); /** * Initialize Safety related Data Objects. @@ -591,15 +561,10 @@ CO_ReturnError_t CO_CANopenInitPDO(CO_t *co, * * @return CO_ERROR_NO in case of success. */ -#if (((CO_CONFIG_GFC) & CO_CONFIG_GFC_ENABLE) != 0) || (((CO_CONFIG_SRDO) & CO_CONFIG_SRDO_ENABLE) != 0) -CO_ReturnError_t CO_CANopenInitSRDO(CO_t *co, - CO_EM_t *em, - OD_t *od, - uint8_t nodeId, - uint32_t *errInfo); +#if (((CO_CONFIG_GFC)&CO_CONFIG_GFC_ENABLE) != 0) || (((CO_CONFIG_SRDO)&CO_CONFIG_SRDO_ENABLE) != 0) +CO_ReturnError_t CO_CANopenInitSRDO(CO_t* co, CO_EM_t* em, OD_t* od, uint8_t nodeId, uint32_t* errInfo); #endif - /** * Process CANopen objects. * @@ -622,13 +587,9 @@ CO_ReturnError_t CO_CANopenInitSRDO(CO_t *co, * * @return Node or communication reset request, from @ref CO_NMT_process(). */ -CO_NMT_reset_cmd_t CO_process(CO_t *co, - bool_t enableGateway, - uint32_t timeDifference_us, - uint32_t *timerNext_us); +CO_NMT_reset_cmd_t CO_process(CO_t* co, bool_t enableGateway, uint32_t timeDifference_us, uint32_t* timerNext_us); - -#if (((CO_CONFIG_SYNC) & CO_CONFIG_SYNC_ENABLE) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_SYNC)&CO_CONFIG_SYNC_ENABLE) != 0) || defined CO_DOXYGEN /** * Process CANopen SYNC objects. * @@ -643,13 +604,10 @@ CO_NMT_reset_cmd_t CO_process(CO_t *co, * * @return True, if CANopen SYNC message was just received or transmitted. */ -bool_t CO_process_SYNC(CO_t *co, - uint32_t timeDifference_us, - uint32_t *timerNext_us); +bool_t CO_process_SYNC(CO_t* co, uint32_t timeDifference_us, uint32_t* timerNext_us); #endif - -#if (((CO_CONFIG_PDO) & CO_CONFIG_RPDO_ENABLE) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_PDO)&CO_CONFIG_RPDO_ENABLE) != 0) || defined CO_DOXYGEN /** * Process CANopen RPDO objects. * @@ -664,14 +622,10 @@ bool_t CO_process_SYNC(CO_t *co, * microseconds. * @param [out] timerNext_us info to OS - see CO_process(). */ -void CO_process_RPDO(CO_t *co, - bool_t syncWas, - uint32_t timeDifference_us, - uint32_t *timerNext_us); +void CO_process_RPDO(CO_t* co, bool_t syncWas, uint32_t timeDifference_us, uint32_t* timerNext_us); #endif - -#if (((CO_CONFIG_PDO) & CO_CONFIG_TPDO_ENABLE) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_PDO)&CO_CONFIG_TPDO_ENABLE) != 0) || defined CO_DOXYGEN /** * Process CANopen TPDO objects. * @@ -686,14 +640,10 @@ void CO_process_RPDO(CO_t *co, * microseconds. * @param [out] timerNext_us info to OS - see CO_process(). */ -void CO_process_TPDO(CO_t *co, - bool_t syncWas, - uint32_t timeDifference_us, - uint32_t *timerNext_us); +void CO_process_TPDO(CO_t* co, bool_t syncWas, uint32_t timeDifference_us, uint32_t* timerNext_us); #endif - -#if (((CO_CONFIG_SRDO) & CO_CONFIG_SRDO_ENABLE) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_SRDO)&CO_CONFIG_SRDO_ENABLE) != 0) || defined CO_DOXYGEN /** * Process CANopen SRDO objects. * @@ -708,9 +658,7 @@ void CO_process_TPDO(CO_t *co, * * @return @CO_SRDO_state_t lowest state of the SRDO objects. */ -CO_SRDO_state_t CO_process_SRDO(CO_t *co, - uint32_t timeDifference_us, - uint32_t *timerNext_us); +CO_SRDO_state_t CO_process_SRDO(CO_t* co, uint32_t timeDifference_us, uint32_t* timerNext_us); #endif /** @} */ /* CO_CANopen */ diff --git a/example/CO_driver_target.h b/example/CO_driver_target.h index d560f72..690f18c 100644 --- a/example/CO_driver_target.h +++ b/example/CO_driver_target.h @@ -17,7 +17,6 @@ * See the License for the specific language governing permissions and limitations under the License. */ - #ifndef CO_DRIVER_TARGET_H #define CO_DRIVER_TARGET_H @@ -40,7 +39,6 @@ extern "C" { /* Stack configuration override default values. * For more information see file CO_config.h. */ - /* Basic definitions. If big endian, CO_SWAP_xx macros must swap bytes. */ #define CO_LITTLE_ENDIAN #define CO_SWAP_16(x) x @@ -49,22 +47,21 @@ extern "C" { /* NULL is defined in stddef.h */ /* true and false are defined in stdbool.h */ /* int8_t to uint64_t are defined in stdint.h */ -typedef uint_fast8_t bool_t; -typedef float float32_t; -typedef double float64_t; - +typedef uint_fast8_t bool_t; +typedef float float32_t; +typedef double float64_t; /* Access to received CAN message */ #define CO_CANrxMsg_readIdent(msg) ((uint16_t)0) #define CO_CANrxMsg_readDLC(msg) ((uint8_t)0) -#define CO_CANrxMsg_readData(msg) ((const uint8_t *)NULL) +#define CO_CANrxMsg_readData(msg) ((const uint8_t*)NULL) /* Received message object */ typedef struct { uint16_t ident; uint16_t mask; - void *object; - void (*CANrx_callback)(void *object, void *message); + void* object; + void (*CANrx_callback)(void* object, void* message); } CO_CANrx_t; /* Transmit message object */ @@ -78,10 +75,10 @@ typedef struct { /* CAN module object */ typedef struct { - void *CANptr; - CO_CANrx_t *rxArray; + void* CANptr; + CO_CANrx_t* rxArray; uint16_t rxSize; - CO_CANtx_t *txArray; + CO_CANtx_t* txArray; uint16_t txSize; uint16_t CANerrorStatus; volatile bool_t CANnormal; @@ -92,18 +89,16 @@ typedef struct { uint32_t errOld; } CO_CANmodule_t; - /* Data storage object for one entry */ typedef struct { - void *addr; + void* addr; size_t len; uint8_t subIndexOD; uint8_t attr; /* Additional variables (target specific) */ - void *addrNV; + void* addrNV; } CO_storage_entry_t; - /* (un)lock critical section in CO_CANsend() */ #define CO_LOCK_CAN_SEND(CAN_MODULE) #define CO_UNLOCK_CAN_SEND(CAN_MODULE) @@ -119,9 +114,16 @@ typedef struct { /* Synchronization between CAN receive and message processing threads. */ #define CO_MemoryBarrier() #define CO_FLAG_READ(rxNew) ((rxNew) != NULL) -#define CO_FLAG_SET(rxNew) {CO_MemoryBarrier(); rxNew = (void*)1L;} -#define CO_FLAG_CLEAR(rxNew) {CO_MemoryBarrier(); rxNew = NULL;} - +#define CO_FLAG_SET(rxNew) \ + { \ + CO_MemoryBarrier(); \ + rxNew = (void*)1L; \ + } +#define CO_FLAG_CLEAR(rxNew) \ + { \ + CO_MemoryBarrier(); \ + rxNew = NULL; \ + } #ifdef __cplusplus } diff --git a/example/CO_storageBlank.h b/example/CO_storageBlank.h index 2e1525d..811a4cc 100644 --- a/example/CO_storageBlank.h +++ b/example/CO_storageBlank.h @@ -22,7 +22,7 @@ #include "storage/CO_storage.h" -#if ((CO_CONFIG_STORAGE) & CO_CONFIG_STORAGE_ENABLE) || defined CO_DOXYGEN +#if ((CO_CONFIG_STORAGE)&CO_CONFIG_STORAGE_ENABLE) || defined CO_DOXYGEN #ifdef __cplusplus extern "C" { @@ -38,16 +38,11 @@ extern "C" { * CANopenLinux/CO_storageLinux.h files. */ -CO_ReturnError_t CO_storageBlank_init(CO_storage_t *storage, - CO_CANmodule_t *CANmodule, - OD_entry_t *OD_1010_StoreParameters, - OD_entry_t *OD_1011_RestoreDefaultParam, - CO_storage_entry_t *entries, - uint8_t entriesCount, - uint32_t *storageInitError); +CO_ReturnError_t CO_storageBlank_init(CO_storage_t* storage, CO_CANmodule_t* CANmodule, + OD_entry_t* OD_1010_StoreParameters, OD_entry_t* OD_1011_RestoreDefaultParam, + CO_storage_entry_t* entries, uint8_t entriesCount, uint32_t* storageInitError); -uint32_t CO_storageBlank_auto_process(CO_storage_t *storage, - bool_t closeFiles); +uint32_t CO_storageBlank_auto_process(CO_storage_t* storage, bool_t closeFiles); #ifdef __cplusplus } diff --git a/storage/CO_eeprom.h b/storage/CO_eeprom.h index c37c9a5..ce05df2 100644 --- a/storage/CO_eeprom.h +++ b/storage/CO_eeprom.h @@ -39,8 +39,7 @@ extern "C" { * * @return True on success */ -bool_t CO_eeprom_init(void *storageModule); - +bool_t CO_eeprom_init(void* storageModule); /** * Get free address inside eeprom, target system specific function. @@ -55,9 +54,7 @@ bool_t CO_eeprom_init(void *storageModule); * * @return Asigned eeprom address */ -size_t CO_eeprom_getAddr(void *storageModule, bool_t isAuto, - size_t len, bool_t *overflow); - +size_t CO_eeprom_getAddr(void* storageModule, bool_t isAuto, size_t len, bool_t* overflow); /** * Read block of data from the eeprom, target system specific function. @@ -67,9 +64,7 @@ size_t CO_eeprom_getAddr(void *storageModule, bool_t isAuto, * @param eepromAddr Address in eeprom, from where data will be read. * @param len Length of the data block to be read. */ -void CO_eeprom_readBlock(void *storageModule, uint8_t *data, - size_t eepromAddr, size_t len); - +void CO_eeprom_readBlock(void* storageModule, uint8_t* data, size_t eepromAddr, size_t len); /** * Write block of data to the eeprom, target system specific function. @@ -84,9 +79,7 @@ void CO_eeprom_readBlock(void *storageModule, uint8_t *data, * * @return true on success */ -bool_t CO_eeprom_writeBlock(void *storageModule, uint8_t *data, - size_t eepromAddr, size_t len); - +bool_t CO_eeprom_writeBlock(void* storageModule, uint8_t* data, size_t eepromAddr, size_t len); /** * Get CRC checksum of the block of data stored in the eeprom, target system @@ -98,9 +91,7 @@ bool_t CO_eeprom_writeBlock(void *storageModule, uint8_t *data, * * @return CRC checksum */ -uint16_t CO_eeprom_getCrcBlock(void *storageModule, - size_t eepromAddr, size_t len); - +uint16_t CO_eeprom_getCrcBlock(void* storageModule, size_t eepromAddr, size_t len); /** * Update one byte of data in the eeprom, target system specific function. @@ -115,9 +106,7 @@ uint16_t CO_eeprom_getCrcBlock(void *storageModule, * @return true if write was successful or false, if still waiting previous * data to finish writing. */ -bool_t CO_eeprom_updateByte(void *storageModule, uint8_t data, - size_t eepromAddr); - +bool_t CO_eeprom_updateByte(void* storageModule, uint8_t data, size_t eepromAddr); /** @} */ /* CO_storage_eeprom */ diff --git a/storage/CO_storage.h b/storage/CO_storage.h index ddfdfd3..7329ebd 100644 --- a/storage/CO_storage.h +++ b/storage/CO_storage.h @@ -29,7 +29,7 @@ #define CO_CONFIG_STORAGE (CO_CONFIG_STORAGE_ENABLE) #endif -#if (((CO_CONFIG_STORAGE) & CO_CONFIG_STORAGE_ENABLE) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_STORAGE)&CO_CONFIG_STORAGE_ENABLE) != 0) || defined CO_DOXYGEN #ifdef __cplusplus extern "C" { @@ -79,7 +79,6 @@ extern "C" { * corresponding data. */ - /** * Attributes (bit masks) for Data storage object. */ @@ -92,27 +91,23 @@ typedef enum { CO_storage_restore = 0x04 } CO_storage_attributes_t; - /** * Data storage object. * * Object is used with CANopen OD objects at index 1010 and 1011. */ typedef struct { - OD_extension_t OD_1010_extension; /**< Extension for OD object */ - OD_extension_t OD_1011_extension; /**< Extension for OD object */ - CO_CANmodule_t *CANmodule; /**< From CO_storage_init() */ - ODR_t (*store)(CO_storage_entry_t *entry, - CO_CANmodule_t *CANmodule); /**< From CO_storage_init() */ - ODR_t (*restore)(CO_storage_entry_t *entry, - CO_CANmodule_t *CANmodule); /**< From CO_storage_init() */ - CO_storage_entry_t *entries; /**< From CO_storage_init() */ - uint8_t entriesCount; /**< From CO_storage_init() */ + OD_extension_t OD_1010_extension; /**< Extension for OD object */ + OD_extension_t OD_1011_extension; /**< Extension for OD object */ + CO_CANmodule_t* CANmodule; /**< From CO_storage_init() */ + ODR_t (*store)(CO_storage_entry_t* entry, CO_CANmodule_t* CANmodule); /**< From CO_storage_init() */ + ODR_t (*restore)(CO_storage_entry_t* entry, CO_CANmodule_t* CANmodule); /**< From CO_storage_init() */ + CO_storage_entry_t* entries; /**< From CO_storage_init() */ + uint8_t entriesCount; /**< From CO_storage_init() */ bool_t enabled; /**< true, if storage is enabled. Setting of this variable is implementation specific. */ } CO_storage_t; - /** * Initialize data storage object * @@ -142,16 +137,11 @@ typedef struct { * * @return CO_ERROR_NO or CO_ERROR_ILLEGAL_ARGUMENT. */ -CO_ReturnError_t CO_storage_init(CO_storage_t *storage, - CO_CANmodule_t *CANmodule, - OD_entry_t *OD_1010_StoreParameters, - OD_entry_t *OD_1011_RestoreDefaultParameters, - ODR_t (*store)(CO_storage_entry_t *entry, - CO_CANmodule_t *CANmodule), - ODR_t (*restore)(CO_storage_entry_t *entry, - CO_CANmodule_t *CANmodule), - CO_storage_entry_t *entries, - uint8_t entriesCount); +CO_ReturnError_t CO_storage_init(CO_storage_t* storage, CO_CANmodule_t* CANmodule, OD_entry_t* OD_1010_StoreParameters, + OD_entry_t* OD_1011_RestoreDefaultParameters, + ODR_t (*store)(CO_storage_entry_t* entry, CO_CANmodule_t* CANmodule), + ODR_t (*restore)(CO_storage_entry_t* entry, CO_CANmodule_t* CANmodule), + CO_storage_entry_t* entries, uint8_t entriesCount); /** @} */ /* CO_storage */ diff --git a/storage/CO_storageEeprom.h b/storage/CO_storageEeprom.h index 44cda6e..52ec477 100644 --- a/storage/CO_storageEeprom.h +++ b/storage/CO_storageEeprom.h @@ -27,7 +27,7 @@ #define CO_CONFIG_STORAGE_MAX_ENTRIES_COUNT 5U #endif -#if (((CO_CONFIG_STORAGE) & CO_CONFIG_STORAGE_ENABLE) != 0) || defined CO_DOXYGEN +#if (((CO_CONFIG_STORAGE)&CO_CONFIG_STORAGE_ENABLE) != 0) || defined CO_DOXYGEN #ifdef __cplusplus extern "C" { @@ -71,7 +71,6 @@ extern "C" { * used. */ - /** * Initialize data storage object (block device (eeprom) specific) * @@ -102,15 +101,9 @@ extern "C" { * @return CO_ERROR_NO, CO_ERROR_DATA_CORRUPT if data can not be initialized, * CO_ERROR_ILLEGAL_ARGUMENT or CO_ERROR_OUT_OF_MEMORY. */ -CO_ReturnError_t CO_storageEeprom_init(CO_storage_t *storage, - CO_CANmodule_t *CANmodule, - void *storageModule, - OD_entry_t *OD_1010_StoreParameters, - OD_entry_t *OD_1011_RestoreDefaultParam, - CO_storage_entry_t *entries, - uint8_t entriesCount, - uint32_t *storageInitError); - +CO_ReturnError_t CO_storageEeprom_init(CO_storage_t* storage, CO_CANmodule_t* CANmodule, void* storageModule, + OD_entry_t* OD_1010_StoreParameters, OD_entry_t* OD_1011_RestoreDefaultParam, + CO_storage_entry_t* entries, uint8_t entriesCount, uint32_t* storageInitError); /** * Automatically update data if differs inside eeprom. @@ -120,7 +113,7 @@ CO_ReturnError_t CO_storageEeprom_init(CO_storage_t *storage, * @param storage This object * @param saveAll If true, all bytes are updated, useful on program end. */ -void CO_storageEeprom_auto_process(CO_storage_t *storage, bool_t saveAll); +void CO_storageEeprom_auto_process(CO_storage_t* storage, bool_t saveAll); /** @} */ /* CO_storage_eeprom */