21#ifndef CO_NMT_HEARTBEAT_H
22#define CO_NMT_HEARTBEAT_H
30#define CO_CONFIG_NMT (CO_CONFIG_GLOBAL_FLAG_CALLBACK_PRE | CO_CONFIG_GLOBAL_FLAG_TIMERNEXT)
114#define CO_NMT_ERR_REG_MASK 0x00FFU
117#define CO_NMT_STARTUP_TO_OPERATIONAL 0x0100U
120#define CO_NMT_ERR_ON_BUSOFF_HB 0x1000U
123#define CO_NMT_ERR_ON_ERR_REG 0x2000U
126#define CO_NMT_ERR_TO_STOPPED 0x4000U
129#define CO_NMT_ERR_FREE_TO_OPERATIONAL 0x8000U
147#if (((CO_CONFIG_NMT)&CO_CONFIG_NMT_MASTER) != 0) || defined CO_DOXYGEN
153#if (((CO_CONFIG_NMT)&CO_CONFIG_FLAG_CALLBACK_PRE) != 0) || defined CO_DOXYGEN
154 void (*pFunctSignalPre)(
void* object);
157#if (((CO_CONFIG_NMT)&CO_CONFIG_NMT_CALLBACK_CHANGE) != 0) || defined CO_DOXYGEN
193#
if (((CO_CONFIG_NMT)&CO_CONFIG_NMT_MASTER) != 0) || defined CO_DOXYGEN
198#if (((CO_CONFIG_NMT)&CO_CONFIG_FLAG_CALLBACK_PRE) != 0) || defined CO_DOXYGEN
212#if (((CO_CONFIG_NMT)&CO_CONFIG_NMT_CALLBACK_CHANGE) != 0) || defined CO_DOXYGEN
268#if ((CO_CONFIG_NMT)&CO_CONFIG_NMT_MASTER) || defined CO_DOXYGEN
CANopen Emergency protocol.
CANopen Object Dictionary interface.
Interface between CAN hardware and CANopenNode.
static void CO_NMT_sendInternalCommand(CO_NMT_t *NMT, CO_NMT_command_t command)
Send NMT command to self, without sending NMT message.
Definition CO_NMT_Heartbeat.h:262
CO_NMT_internalState_t
Internal network state of the CANopen node.
Definition CO_NMT_Heartbeat.h:70
static CO_NMT_internalState_t CO_NMT_getInternalState(CO_NMT_t *NMT)
Query current NMT state.
Definition CO_NMT_Heartbeat.h:249
void CO_NMT_initCallbackPre(CO_NMT_t *NMT, void *object, void(*pFunctSignal)(void *object))
Initialize NMT callback function after message preprocessed.
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, CO_CANmodule_t *NMT_CANdevTx, uint16_t NMT_txIdx, uint16_t CANidTxNMT, CO_CANmodule_t *HB_CANdevTx, uint16_t HB_txIdx, uint16_t CANidTxHB, uint32_t *errInfo)
Initialize NMT and Heartbeat producer object.
Definition CO_NMT_Heartbeat.c:73
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)
Process received NMT and produce Heartbeat messages.
Definition CO_NMT_Heartbeat.c:176
void CO_NMT_initCallbackChanged(CO_NMT_t *NMT, void(*pFunctNMT)(CO_NMT_internalState_t state))
Initialize NMT callback function.
CO_ReturnError_t CO_NMT_sendCommand(CO_NMT_t *NMT, CO_NMT_command_t command, uint8_t nodeID)
Send NMT master command.
CO_NMT_command_t
Commands from NMT master.
Definition CO_NMT_Heartbeat.h:81
CO_NMT_reset_cmd_t
Return code from CO_NMT_process() that tells application code what to reset.
Definition CO_NMT_Heartbeat.h:93
@ CO_NMT_OPERATIONAL
5, Device is in operational state
Definition CO_NMT_Heartbeat.h:74
@ CO_NMT_UNKNOWN
-1, Device state is unknown (for heartbeat consumer)
Definition CO_NMT_Heartbeat.h:71
@ CO_NMT_INITIALIZING
0, Device is initializing
Definition CO_NMT_Heartbeat.h:72
@ CO_NMT_STOPPED
4, Device is stopped
Definition CO_NMT_Heartbeat.h:75
@ CO_NMT_PRE_OPERATIONAL
127, Device is in pre-operational state
Definition CO_NMT_Heartbeat.h:73
@ CO_NMT_ENTER_PRE_OPERATIONAL
128, Put device into pre-operational
Definition CO_NMT_Heartbeat.h:85
@ CO_NMT_ENTER_OPERATIONAL
1, Start device
Definition CO_NMT_Heartbeat.h:83
@ CO_NMT_ENTER_STOPPED
2, Stop device
Definition CO_NMT_Heartbeat.h:84
@ CO_NMT_RESET_NODE
129, Reset device
Definition CO_NMT_Heartbeat.h:86
@ CO_NMT_RESET_COMMUNICATION
130, Reset CANopen communication on device
Definition CO_NMT_Heartbeat.h:87
@ CO_NMT_NO_COMMAND
0, No command
Definition CO_NMT_Heartbeat.h:82
@ CO_RESET_NOT
0, Normal return, no action
Definition CO_NMT_Heartbeat.h:94
@ CO_RESET_COMM
1, Application must provide communication reset.
Definition CO_NMT_Heartbeat.h:95
@ CO_RESET_APP
2, Application must provide complete device reset
Definition CO_NMT_Heartbeat.h:96
@ CO_RESET_QUIT
3, Application must quit, no reset of microcontroller (command is not requested by the stack....
Definition CO_NMT_Heartbeat.h:97
#define NULL
NULL, for general usage.
Definition CO_driver.h:123
unsigned int uint16_t
UNSIGNED16 in CANopen (0006h), 16-bit unsigned integer.
Definition CO_driver.h:132
unsigned long int uint32_t
UNSIGNED32 in CANopen (0007h), 32-bit unsigned integer.
Definition CO_driver.h:133
unsigned char uint8_t
UNSIGNED8 in CANopen (0005h), 8-bit unsigned integer.
Definition CO_driver.h:131
CO_ReturnError_t
Return values of some CANopen functions.
Definition CO_driver.h:449
Complete CAN module object.
Definition CO_driver.h:268
Configuration object for CAN transmit message for specific CANopenNode Object.
Definition CO_driver.h:250
Emergency object.
Definition CO_Emergency.h:259
NMT consumer and Heartbeat producer object.
Definition CO_NMT_Heartbeat.h:136
uint16_t NMTcontrol
From CO_NMT_init()
Definition CO_NMT_Heartbeat.h:142
uint32_t HBproducerTimer
Internal timer for HB producer.
Definition CO_NMT_Heartbeat.h:144
CO_NMT_command_t internalCommand
NMT internal command from CO_NMT_receive() or CO_NMT_sendCommand(), processed in CO_NMT_process().
Definition CO_NMT_Heartbeat.h:139
CO_EM_t * em
From CO_NMT_init()
Definition CO_NMT_Heartbeat.h:146
CO_CANtx_t * NMT_TXbuff
CAN transmit buffer for NMT master message.
Definition CO_NMT_Heartbeat.h:149
uint8_t nodeId
From CO_NMT_init()
Definition CO_NMT_Heartbeat.h:141
uint32_t HBproducerTime_us
Producer heartbeat time, calculated from OD 0x1017.
Definition CO_NMT_Heartbeat.h:143
void * functSignalObjectPre
From CO_NMT_initCallbackPre() or NULL.
Definition CO_NMT_Heartbeat.h:155
CO_NMT_internalState_t operatingStatePrev
Previous NMT operating state.
Definition CO_NMT_Heartbeat.h:138
CO_CANtx_t * HB_TXbuff
CAN transmit buffer for heartbeat message.
Definition CO_NMT_Heartbeat.h:152
CO_CANmodule_t * NMT_CANdevTx
From CO_NMT_init()
Definition CO_NMT_Heartbeat.h:148
CO_NMT_internalState_t operatingState
Current NMT operating state.
Definition CO_NMT_Heartbeat.h:137
CO_CANmodule_t * HB_CANdevTx
From CO_NMT_init()
Definition CO_NMT_Heartbeat.h:151
OD_extension_t OD_1017_extension
Extension for OD object.
Definition CO_NMT_Heartbeat.h:145
Object Dictionary entry for one OD object.
Definition CO_ODinterface.h:272
Extension of OD object, which can optionally be specified by application in initialization phase with...
Definition CO_ODinterface.h:245