CANopenNode
CANopen protocol stack
Loading...
Searching...
No Matches
CO_NMT_Heartbeat.h File Reference

CANopen Network management and Heartbeat producer protocol. More...

#include "301/CO_driver.h"
#include "301/CO_ODinterface.h"
#include "301/CO_Emergency.h"
+ Include dependency graph for CO_NMT_Heartbeat.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  CO_NMT_t
 NMT consumer and Heartbeat producer object. More...
 

Macros

#define CO_NMT_ERR_REG_MASK   0x00FFU
 First 8 bits can be used to specify bitmask for the CANopen Error register to get relevant bits for the calculation.
 
#define CO_NMT_STARTUP_TO_OPERATIONAL   0x0100U
 If bit is set then device enters NMT operational state after the initialization phase otherwise it enters NMT pre-operational state.
 
#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 CAN bus is off or heartbeat consumer timeout is detected.
 
#define CO_NMT_ERR_ON_ERR_REG   0x2000U
 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_TO_STOPPED   0x4000U
 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_FREE_TO_OPERATIONAL   0x8000U
 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.
 

Enumerations

enum  CO_NMT_internalState_t {
  CO_NMT_UNKNOWN = -1 , CO_NMT_INITIALIZING = 0 , CO_NMT_PRE_OPERATIONAL = 127 , CO_NMT_OPERATIONAL = 5 ,
  CO_NMT_STOPPED = 4
}
 Internal network state of the CANopen node. More...
 
enum  CO_NMT_command_t {
  CO_NMT_NO_COMMAND = 0 , CO_NMT_ENTER_OPERATIONAL = 1 , CO_NMT_ENTER_STOPPED = 2 , CO_NMT_ENTER_PRE_OPERATIONAL = 128 ,
  CO_NMT_RESET_NODE = 129 , CO_NMT_RESET_COMMUNICATION = 130
}
 Commands from NMT master. More...
 
enum  CO_NMT_reset_cmd_t { CO_RESET_NOT = 0 , CO_RESET_COMM = 1 , CO_RESET_APP = 2 , CO_RESET_QUIT = 3 }
 Return code from CO_NMT_process() that tells application code what to reset. More...
 

Functions

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.
 
void CO_NMT_initCallbackPre (CO_NMT_t *NMT, void *object, void(*pFunctSignal)(void *object))
 Initialize NMT callback function after message preprocessed.
 
void CO_NMT_initCallbackChanged (CO_NMT_t *NMT, void(*pFunctNMT)(CO_NMT_internalState_t state))
 Initialize NMT callback function.
 
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.
 
static CO_NMT_internalState_t CO_NMT_getInternalState (CO_NMT_t *NMT)
 Query current NMT state.
 
static void CO_NMT_sendInternalCommand (CO_NMT_t *NMT, CO_NMT_command_t command)
 Send NMT command to self, without sending NMT message.
 
CO_ReturnError_t CO_NMT_sendCommand (CO_NMT_t *NMT, CO_NMT_command_t command, uint8_t nodeID)
 Send NMT master command.
 

Detailed Description

CANopen Network management and Heartbeat producer protocol.

Author
Janez Paternoster

This file is part of https://github.com/CANopenNode/CANopenNode, a CANopen Stack.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.