CO_HBconsumer.h
Go to the documentation of this file.
#ifndef CO_HB_CONS_H
#define CO_HB_CONS_H
#include "301/CO_driver.h"
/* default configuration, see CO_config.h */
#ifndef CO_CONFIG_HB_CONS
#define CO_CONFIG_HB_CONS (CO_CONFIG_HB_CONS_ENABLE)
#endif
#ifndef CO_CONFIG_HB_CONS_SIZE
#define CO_CONFIG_HB_CONS_SIZE 8
#endif
#if ((CO_CONFIG_HB_CONS) & CO_CONFIG_HB_CONS_ENABLE) || defined CO_DOXYGEN
#include "301/CO_SDOserver.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
CO_HBconsumer_UNCONFIGURED = 0x00U,
CO_HBconsumer_UNKNOWN = 0x01U,
CO_HBconsumer_ACTIVE = 0x02U,
CO_HBconsumer_TIMEOUT = 0x03U,
} CO_HBconsumer_state_t;
typedef struct {
uint8_t nodeId;
CO_NMT_internalState_t NMTstate;
CO_HBconsumer_state_t HBstate;
uint32_t timeoutTimer;
uint32_t time_us;
volatile void *CANrxNew;
#if ((CO_CONFIG_HB_CONS) & CO_CONFIG_FLAG_CALLBACK_PRE) || defined CO_DOXYGEN
void (*pFunctSignalPre)(void *object);
void *functSignalObjectPre;
#endif
#if ((CO_CONFIG_HB_CONS) & CO_CONFIG_HB_CONS_CALLBACK_CHANGE) \
|| ((CO_CONFIG_HB_CONS) & CO_CONFIG_HB_CONS_CALLBACK_MULTI) \
|| defined CO_DOXYGEN
CO_NMT_internalState_t NMTstatePrev;
#endif
#if ((CO_CONFIG_HB_CONS) & CO_CONFIG_HB_CONS_CALLBACK_MULTI) || defined CO_DOXYGEN
void (*pFunctSignalNmtChanged)(uint8_t nodeId, uint8_t idx,
CO_NMT_internalState_t state,
void *object);
void *pFunctSignalObjectNmtChanged;
void (*pFunctSignalHbStarted)(uint8_t nodeId, uint8_t idx, void *object);
void *functSignalObjectHbStarted;
void (*pFunctSignalTimeout)(uint8_t nodeId, uint8_t idx, void *object);
void *functSignalObjectTimeout;
void (*pFunctSignalRemoteReset)(uint8_t nodeId, uint8_t idx, void *object);
void *functSignalObjectRemoteReset;
#endif
} CO_HBconsNode_t;
typedef struct{
CO_EM_t *em;
const uint32_t *HBconsTime;
CO_HBconsNode_t *monitoredNodes;
uint8_t numberOfMonitoredNodes;
bool_t allMonitoredActive;
uint8_t allMonitoredOperational;
bool_t NMTisPreOrOperationalPrev;
CO_CANmodule_t *CANdevRx;
uint16_t CANdevRxIdxStart;
#if ((CO_CONFIG_HB_CONS) & CO_CONFIG_HB_CONS_CALLBACK_CHANGE) || defined CO_DOXYGEN
void (*pFunctSignalNmtChanged)(uint8_t nodeId, uint8_t idx,
CO_NMT_internalState_t state,
void *object);
void *pFunctSignalObjectNmtChanged;
#endif
}CO_HBconsumer_t;
CO_ReturnError_t CO_HBconsumer_init(
CO_HBconsumer_t *HBcons,
CO_EM_t *em,
CO_SDO_t *SDO,
const uint32_t HBconsTime[],
CO_HBconsNode_t monitoredNodes[],
uint8_t numberOfMonitoredNodes,
CO_CANmodule_t *CANdevRx,
uint16_t CANdevRxIdxStart);
CO_ReturnError_t CO_HBconsumer_initEntry(
CO_HBconsumer_t *HBcons,
uint8_t idx,
uint8_t nodeId,
uint16_t consumerTime_ms);
#if ((CO_CONFIG_HB_CONS) & CO_CONFIG_FLAG_CALLBACK_PRE) || defined CO_DOXYGEN
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) \
|| ((CO_CONFIG_HB_CONS) & CO_CONFIG_HB_CONS_CALLBACK_MULTI) \
|| defined CO_DOXYGEN
void CO_HBconsumer_initCallbackNmtChanged(
CO_HBconsumer_t *HBcons,
#if ((CO_CONFIG_HB_CONS) & CO_CONFIG_HB_CONS_CALLBACK_MULTI) || defined CO_DOXYGEN
uint8_t idx,
#endif
void *object,
void (*pFunctSignal)(uint8_t nodeId, uint8_t idx,
CO_NMT_internalState_t state,
void *object));
#endif
#if ((CO_CONFIG_HB_CONS) & CO_CONFIG_HB_CONS_CALLBACK_MULTI) || defined CO_DOXYGEN
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_initCallbackTimeout(
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 */
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) || defined CO_DOXYGEN
int8_t CO_HBconsumer_getIdxByNodeId(
CO_HBconsumer_t *HBcons,
uint8_t nodeId);
CO_HBconsumer_state_t CO_HBconsumer_getState(
CO_HBconsumer_t *HBcons,
uint8_t idx);
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 */
/* CO_HBconsumer */
#ifdef __cplusplus
}
#endif /*__cplusplus*/
#endif /* (CO_CONFIG_HB_CONS) & CO_CONFIG_HB_CONS_ENABLE */
#endif /* CO_HB_CONS_H */
CO_HBconsNode_t::functSignalObjectPre
void * functSignalObjectPre
From CO_HBconsumer_initCallbackPre() or NULL.
Definition: CO_HBconsumer.h:97
uint32_t
unsigned long int uint32_t
UNSIGNED32 in CANopen (0007h), 32-bit unsigned integer.
Definition: CO_driver.h:155
CO_driver.h
Interface between CAN hardware and CANopenNode.
CO_HBconsumer_initCallbackPre
void CO_HBconsumer_initCallbackPre(CO_HBconsumer_t *HBcons, void *object, void(*pFunctSignal)(void *object))
Initialize Heartbeat consumer callback function.
CO_HBconsumer_getNmtState
int8_t CO_HBconsumer_getNmtState(CO_HBconsumer_t *HBcons, uint8_t idx, CO_NMT_internalState_t *nmtState)
Get the current NMT state of a heartbeat producer by the index in OD 0x1016.
CO_HBconsumer_initEntry
CO_ReturnError_t CO_HBconsumer_initEntry(CO_HBconsumer_t *HBcons, uint8_t idx, uint8_t nodeId, uint16_t consumerTime_ms)
Initialize one Heartbeat consumer entry.
CO_HBconsumer_t::CANdevRxIdxStart
uint16_t CANdevRxIdxStart
From CO_HBconsumer_init()
Definition: CO_HBconsumer.h:151
uint16_t
unsigned int uint16_t
UNSIGNED16 in CANopen (0006h), 16-bit unsigned integer.
Definition: CO_driver.h:153
CO_HBconsumer_t::monitoredNodes
CO_HBconsNode_t * monitoredNodes
From CO_HBconsumer_init()
Definition: CO_HBconsumer.h:141
CO_ReturnError_t
CO_ReturnError_t
Return values of some CANopen functions.
Definition: CO_driver.h:488
bool_t
unsigned char bool_t
Boolean data type for general use.
Definition: CO_driver.h:141
CO_HBconsumer_UNKNOWN
@ CO_HBconsumer_UNKNOWN
Consumer enabled, but no heartbeat received yet.
Definition: CO_HBconsumer.h:71
CO_HBconsumer_initCallbackRemoteReset
void CO_HBconsumer_initCallbackRemoteReset(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.
CO_HBconsumer_state_t
CO_HBconsumer_state_t
Heartbeat state of a node.
Definition: CO_HBconsumer.h:69
CO_HBconsumer_TIMEOUT
@ CO_HBconsumer_TIMEOUT
No heatbeat received for set time.
Definition: CO_HBconsumer.h:73
CO_HBconsumer_initCallbackTimeout
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 timeout callback function.
int8_t
signed char int8_t
INTEGER8 in CANopen (0002h), 8-bit signed integer.
Definition: CO_driver.h:143
CO_HBconsumer_getIdxByNodeId
int8_t CO_HBconsumer_getIdxByNodeId(CO_HBconsumer_t *HBcons, uint8_t nodeId)
Get the heartbeat producer object index by node ID.
CO_SDOserver.h
CANopen Service Data Object - server protocol.
CO_HBconsumer_t::pFunctSignalObjectNmtChanged
void * pFunctSignalObjectNmtChanged
Pointer to object.
Definition: CO_HBconsumer.h:159
CO_HBconsNode_t::functSignalObjectRemoteReset
void * functSignalObjectRemoteReset
Pointer to object.
Definition: CO_HBconsumer.h:127
CO_HBconsumer_UNCONFIGURED
@ CO_HBconsumer_UNCONFIGURED
Consumer entry inactive.
Definition: CO_HBconsumer.h:70
CO_HBconsNode_t::time_us
uint32_t time_us
Consumer heartbeat time from OD.
Definition: CO_HBconsumer.h:90
CO_HBconsNode_t::functSignalObjectHbStarted
void * functSignalObjectHbStarted
Pointer to object.
Definition: CO_HBconsumer.h:117
CO_HBconsumer_t
Heartbeat consumer object.
Definition: CO_HBconsumer.h:138
CO_HBconsumer_t::em
CO_EM_t * em
From CO_HBconsumer_init()
Definition: CO_HBconsumer.h:139
CO_HBconsumer_t::allMonitoredActive
bool_t allMonitoredActive
True, if all monitored nodes are active or no node is monitored.
Definition: CO_HBconsumer.h:145
CO_HBconsNode_t::timeoutTimer
uint32_t timeoutTimer
Time since last heartbeat received.
Definition: CO_HBconsumer.h:88
CO_HBconsumer_init
CO_ReturnError_t CO_HBconsumer_init(CO_HBconsumer_t *HBcons, CO_EM_t *em, CO_SDO_t *SDO, const uint32_t HBconsTime[], CO_HBconsNode_t monitoredNodes[], uint8_t numberOfMonitoredNodes, CO_CANmodule_t *CANdevRx, uint16_t CANdevRxIdxStart)
Initialize Heartbeat consumer object.
CO_HBconsumer_process
void CO_HBconsumer_process(CO_HBconsumer_t *HBcons, bool_t NMTisPreOrOperational, uint32_t timeDifference_us, uint32_t *timerNext_us)
Process Heartbeat consumer object.
CO_HBconsumer_t::NMTisPreOrOperationalPrev
bool_t NMTisPreOrOperationalPrev
previous state of var
Definition: CO_HBconsumer.h:149
CO_CONFIG_HB_CONS
#define CO_CONFIG_HB_CONS
Configuration of Heartbeat consumer.
Definition: CO_config.h:153
CO_EM_t
Emergency object.
Definition: CO_Emergency.h:369
CO_HBconsNode_t::NMTstatePrev
CO_NMT_internalState_t NMTstatePrev
Previous value of the remote node (Heartbeat payload)
Definition: CO_HBconsumer.h:103
CO_NMT_internalState_t
CO_NMT_internalState_t
Internal network state of the CANopen node.
Definition: CO_NMT_Heartbeat.h:77
CO_HBconsumer_initCallbackHeartbeatStarted
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 started callback function.
CO_HBconsumer_t::CANdevRx
CO_CANmodule_t * CANdevRx
From CO_HBconsumer_init()
Definition: CO_HBconsumer.h:150
CO_HBconsumer_getState
CO_HBconsumer_state_t CO_HBconsumer_getState(CO_HBconsumer_t *HBcons, uint8_t idx)
Get the current state of a heartbeat producer by the index in OD 0x1016.
CO_HBconsumer_t::allMonitoredOperational
uint8_t allMonitoredOperational
True, if all monitored nodes are NMT operational or no node is monitored.
Definition: CO_HBconsumer.h:148
CO_HBconsNode_t::pFunctSignalObjectNmtChanged
void * pFunctSignalObjectNmtChanged
Pointer to object.
Definition: CO_HBconsumer.h:112
CO_HBconsNode_t::functSignalObjectTimeout
void * functSignalObjectTimeout
Pointer to object.
Definition: CO_HBconsumer.h:122
CO_HBconsNode_t::nodeId
uint8_t nodeId
Node Id of the monitored node.
Definition: CO_HBconsumer.h:82
CO_HBconsumer_t::numberOfMonitoredNodes
uint8_t numberOfMonitoredNodes
From CO_HBconsumer_init()
Definition: CO_HBconsumer.h:142
CO_CANmodule_t
Complete CAN module object.
Definition: CO_driver.h:319
CO_HBconsNode_t::NMTstate
CO_NMT_internalState_t NMTstate
Of the remote node (Heartbeat payload)
Definition: CO_HBconsumer.h:84
CO_HBconsumer_t::HBconsTime
const uint32_t * HBconsTime
From CO_HBconsumer_init()
Definition: CO_HBconsumer.h:140
CO_HBconsumer_initCallbackNmtChanged
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 state, void *object))
Initialize Heartbeat consumer NMT changed callback function.
CO_HBconsNode_t::CANrxNew
volatile void * CANrxNew
Indication if new Heartbeat message received from the CAN bus.
Definition: CO_HBconsumer.h:92
CO_HBconsNode_t
One monitored node inside CO_HBconsumer_t.
Definition: CO_HBconsumer.h:80
CO_HBconsNode_t::HBstate
CO_HBconsumer_state_t HBstate
Current heartbeat state.
Definition: CO_HBconsumer.h:86
CO_HBconsumer_ACTIVE
@ CO_HBconsumer_ACTIVE
Heartbeat received within set time.
Definition: CO_HBconsumer.h:72
uint8_t
unsigned char uint8_t
UNSIGNED8 in CANopen (0005h), 8-bit unsigned integer.
Definition: CO_driver.h:151