CANopenNode
CO_HBconsumer.h
Go to the documentation of this file.
1 
26 #ifndef CO_HB_CONS_H
27 #define CO_HB_CONS_H
28 
29 #include "301/CO_driver.h"
30 
31 /* default configuration, see CO_config.h */
32 #ifndef CO_CONFIG_HB_CONS
33 #define CO_CONFIG_HB_CONS (CO_CONFIG_HB_CONS_ENABLE)
34 #endif
35 #ifndef CO_CONFIG_HB_CONS_SIZE
36 #define CO_CONFIG_HB_CONS_SIZE 8
37 #endif
38 
39 #if ((CO_CONFIG_HB_CONS) & CO_CONFIG_HB_CONS_ENABLE) || defined CO_DOXYGEN
40 
41 #include "301/CO_SDOserver.h"
42 
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46 
69 typedef enum {
75 
76 
80 typedef struct {
92  volatile void *CANrxNew;
93 #if ((CO_CONFIG_HB_CONS) & CO_CONFIG_FLAG_CALLBACK_PRE) || defined CO_DOXYGEN
94 
95  void (*pFunctSignalPre)(void *object);
98 #endif
99 #if ((CO_CONFIG_HB_CONS) & CO_CONFIG_HB_CONS_CALLBACK_CHANGE) \
100  || ((CO_CONFIG_HB_CONS) & CO_CONFIG_HB_CONS_CALLBACK_MULTI) \
101  || defined CO_DOXYGEN
102 
104 #endif
105 #if ((CO_CONFIG_HB_CONS) & CO_CONFIG_HB_CONS_CALLBACK_MULTI) || defined CO_DOXYGEN
106 
108  void (*pFunctSignalNmtChanged)(uint8_t nodeId, uint8_t idx,
110  void *object);
115  void (*pFunctSignalHbStarted)(uint8_t nodeId, uint8_t idx, void *object);
120  void (*pFunctSignalTimeout)(uint8_t nodeId, uint8_t idx, void *object);
125  void (*pFunctSignalRemoteReset)(uint8_t nodeId, uint8_t idx, void *object);
128 #endif
130 
131 
138 typedef struct{
152 #if ((CO_CONFIG_HB_CONS) & CO_CONFIG_HB_CONS_CALLBACK_CHANGE) || defined CO_DOXYGEN
153 
155  void (*pFunctSignalNmtChanged)(uint8_t nodeId, uint8_t idx,
157  void *object);
160 #endif
162 
163 
184  CO_HBconsumer_t *HBcons,
185  CO_EM_t *em,
186  CO_SDO_t *SDO,
187  const uint32_t HBconsTime[],
188  CO_HBconsNode_t monitoredNodes[],
189  uint8_t numberOfMonitoredNodes,
190  CO_CANmodule_t *CANdevRx,
191  uint16_t CANdevRxIdxStart);
192 
208  CO_HBconsumer_t *HBcons,
209  uint8_t idx,
210  uint8_t nodeId,
211  uint16_t consumerTime_ms);
212 
213 #if ((CO_CONFIG_HB_CONS) & CO_CONFIG_FLAG_CALLBACK_PRE) || defined CO_DOXYGEN
214 
226  CO_HBconsumer_t *HBcons,
227  void *object,
228  void (*pFunctSignal)(void *object));
229 #endif
230 
231 #if ((CO_CONFIG_HB_CONS) & CO_CONFIG_HB_CONS_CALLBACK_CHANGE) \
232  || ((CO_CONFIG_HB_CONS) & CO_CONFIG_HB_CONS_CALLBACK_MULTI) \
233  || defined CO_DOXYGEN
234 
248  CO_HBconsumer_t *HBcons,
249 #if ((CO_CONFIG_HB_CONS) & CO_CONFIG_HB_CONS_CALLBACK_MULTI) || defined CO_DOXYGEN
250  uint8_t idx,
251 #endif
252  void *object,
253  void (*pFunctSignal)(uint8_t nodeId, uint8_t idx,
255  void *object));
256 #endif
257 
258 #if ((CO_CONFIG_HB_CONS) & CO_CONFIG_HB_CONS_CALLBACK_MULTI) || defined CO_DOXYGEN
259 
272  CO_HBconsumer_t *HBcons,
273  uint8_t idx,
274  void *object,
275  void (*pFunctSignal)(uint8_t nodeId, uint8_t idx, void *object));
276 
290  CO_HBconsumer_t *HBcons,
291  uint8_t idx,
292  void *object,
293  void (*pFunctSignal)(uint8_t nodeId, uint8_t idx, void *object));
294 
308  CO_HBconsumer_t *HBcons,
309  uint8_t idx,
310  void *object,
311  void (*pFunctSignal)(uint8_t nodeId, uint8_t idx, void *object));
312 #endif /* (CO_CONFIG_HB_CONS) & CO_CONFIG_HB_CONS_CALLBACK_MULTI */
313 
325  CO_HBconsumer_t *HBcons,
326  bool_t NMTisPreOrOperational,
327  uint32_t timeDifference_us,
328  uint32_t *timerNext_us);
329 
330 
331 #if ((CO_CONFIG_HB_CONS) & CO_CONFIG_HB_CONS_QUERY_FUNCT) || defined CO_DOXYGEN
332 
340  CO_HBconsumer_t *HBcons,
341  uint8_t nodeId);
342 
351  CO_HBconsumer_t *HBcons,
352  uint8_t idx);
353 
366  CO_HBconsumer_t *HBcons,
367  uint8_t idx,
368  CO_NMT_internalState_t *nmtState);
369 
370 #endif /* (CO_CONFIG_HB_CONS) & CO_CONFIG_HB_CONS_QUERY_FUNCT */
371  /* CO_HBconsumer */
373 
374 #ifdef __cplusplus
375 }
376 #endif /*__cplusplus*/
377 
378 #endif /* (CO_CONFIG_HB_CONS) & CO_CONFIG_HB_CONS_ENABLE */
379 
380 #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