CO_SYNC.h
Go to the documentation of this file.
#ifndef CO_SYNC_H
#define CO_SYNC_H
#include "301/CO_driver.h"
/* default configuration, see CO_config.h */
#ifndef CO_CONFIG_SYNC
#define CO_CONFIG_SYNC (CO_CONFIG_SYNC_ENABLE | CO_CONFIG_SYNC_PRODUCER)
#endif
#if ((CO_CONFIG_SYNC) & CO_CONFIG_SYNC_ENABLE) || defined CO_DOXYGEN
#ifdef __cplusplus
extern "C" {
#endif
typedef struct{
CO_EM_t *em;
CO_NMT_internalState_t *operatingState;
bool_t isProducer;
uint16_t COB_ID;
uint32_t periodTime;
uint32_t periodTimeoutTime;
uint8_t counterOverflowValue;
bool_t curentSyncTimeIsInsideWindow;
volatile void *CANrxNew;
bool_t CANrxToggle;
uint8_t counter;
uint32_t timer;
uint16_t receiveError;
#if ((CO_CONFIG_SYNC) & CO_CONFIG_FLAG_CALLBACK_PRE) || defined CO_DOXYGEN
void (*pFunctSignalPre)(void *object);
void *functSignalObjectPre;
#endif
CO_CANmodule_t *CANdevRx;
uint16_t CANdevRxIdx;
CO_CANmodule_t *CANdevTx;
CO_CANtx_t *CANtxBuff;
uint16_t CANdevTxIdx;
}CO_SYNC_t;
typedef enum {
CO_SYNC_NONE = 0,
CO_SYNC_RECEIVED = 1,
CO_SYNC_OUTSIDE_WINDOW = 2
} CO_SYNC_status_t;
CO_ReturnError_t CO_SYNC_init(
CO_SYNC_t *SYNC,
CO_EM_t *em,
CO_SDO_t *SDO,
CO_NMT_internalState_t *operatingState,
uint32_t COB_ID_SYNCMessage,
uint32_t communicationCyclePeriod,
uint8_t synchronousCounterOverflowValue,
CO_CANmodule_t *CANdevRx,
uint16_t CANdevRxIdx,
CO_CANmodule_t *CANdevTx,
uint16_t CANdevTxIdx);
#if ((CO_CONFIG_SYNC) & CO_CONFIG_FLAG_CALLBACK_PRE) || defined CO_DOXYGEN
void CO_SYNC_initCallbackPre(
CO_SYNC_t *SYNC,
void *object,
void (*pFunctSignalPre)(void *object));
#endif
CO_ReturnError_t CO_SYNCsend(CO_SYNC_t *SYNC);
CO_SYNC_status_t CO_SYNC_process(
CO_SYNC_t *SYNC,
uint32_t timeDifference_us,
uint32_t ObjDict_synchronousWindowLength,
uint32_t *timerNext_us);
/* CO_SYNC */
#ifdef __cplusplus
}
#endif /*__cplusplus*/
#endif /* (CO_CONFIG_SYNC) & CO_CONFIG_SYNC_ENABLE */
#endif /* CO_SYNC_H */
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_SYNC_t::periodTime
uint32_t periodTime
Sync period time in [microseconds].
Definition: CO_SYNC.h:86
CO_SYNC_process
CO_SYNC_status_t CO_SYNC_process(CO_SYNC_t *SYNC, uint32_t timeDifference_us, uint32_t ObjDict_synchronousWindowLength, uint32_t *timerNext_us)
Process SYNC communication.
CO_SYNC_NONE
@ CO_SYNC_NONE
SYNC not received.
Definition: CO_SYNC.h:123
uint16_t
unsigned int uint16_t
UNSIGNED16 in CANopen (0006h), 16-bit unsigned integer.
Definition: CO_driver.h:153
CO_SYNC_t::counter
uint8_t counter
Counter of the SYNC message if counterOverflowValue is different than zero.
Definition: CO_SYNC.h:101
CO_SYNC_OUTSIDE_WINDOW
@ CO_SYNC_OUTSIDE_WINDOW
SYNC received outside SYNC window.
Definition: CO_SYNC.h:125
CO_ReturnError_t
CO_ReturnError_t
Return values of some CANopen functions.
Definition: CO_driver.h:488
CO_SYNC_t::CANdevRx
CO_CANmodule_t * CANdevRx
From CO_SYNC_init()
Definition: CO_SYNC.h:113
bool_t
unsigned char bool_t
Boolean data type for general use.
Definition: CO_driver.h:141
CO_SYNC_status_t
CO_SYNC_status_t
Return value for CO_SYNC_process.
Definition: CO_SYNC.h:122
CO_SYNC_t::periodTimeoutTime
uint32_t periodTimeoutTime
Sync period timeout time in [microseconds].
Definition: CO_SYNC.h:89
CO_SYNC_t::CANtxBuff
CO_CANtx_t * CANtxBuff
CAN transmit buffer inside CANdevTx.
Definition: CO_SYNC.h:116
CO_SYNC_initCallbackPre
void CO_SYNC_initCallbackPre(CO_SYNC_t *SYNC, void *object, void(*pFunctSignalPre)(void *object))
Initialize SYNC callback function.
CO_SYNC_RECEIVED
@ CO_SYNC_RECEIVED
SYNC received.
Definition: CO_SYNC.h:124
CO_SYNC_t::counterOverflowValue
uint8_t counterOverflowValue
Value from Synchronous counter overflow value variable from Object dictionary (index 0x1019)
Definition: CO_SYNC.h:92
CO_SYNC_t::receiveError
uint16_t receiveError
Set to nonzero value, if SYNC with wrong data length is received from CAN.
Definition: CO_SYNC.h:106
CO_SYNC_t::CANrxToggle
bool_t CANrxToggle
Variable toggles, if new SYNC message received from CAN bus.
Definition: CO_SYNC.h:99
CO_SYNCsend
CO_ReturnError_t CO_SYNCsend(CO_SYNC_t *SYNC)
Send SYNC message.
CO_SYNC_t::timer
uint32_t timer
Timer for the SYNC message in [microseconds].
Definition: CO_SYNC.h:104
CO_SYNC_t::COB_ID
uint16_t COB_ID
COB_ID of SYNC message.
Definition: CO_SYNC.h:83
CO_SYNC_t::curentSyncTimeIsInsideWindow
bool_t curentSyncTimeIsInsideWindow
True, if current time is inside synchronous window.
Definition: CO_SYNC.h:95
CO_EM_t
Emergency object.
Definition: CO_Emergency.h:369
CO_NMT_internalState_t
CO_NMT_internalState_t
Internal network state of the CANopen node.
Definition: CO_NMT_Heartbeat.h:77
CO_SYNC_t::isProducer
bool_t isProducer
True, if device is SYNC producer.
Definition: CO_SYNC.h:80
CO_SYNC_t::CANrxNew
volatile void * CANrxNew
Indicates, if new SYNC message received from CAN bus.
Definition: CO_SYNC.h:97
CO_SYNC_t::functSignalObjectPre
void * functSignalObjectPre
From CO_SYNC_initCallbackPre() or NULL.
Definition: CO_SYNC.h:111
CO_SYNC_init
CO_ReturnError_t CO_SYNC_init(CO_SYNC_t *SYNC, CO_EM_t *em, CO_SDO_t *SDO, CO_NMT_internalState_t *operatingState, uint32_t COB_ID_SYNCMessage, uint32_t communicationCyclePeriod, uint8_t synchronousCounterOverflowValue, CO_CANmodule_t *CANdevRx, uint16_t CANdevRxIdx, CO_CANmodule_t *CANdevTx, uint16_t CANdevTxIdx)
Initialize SYNC object.
CO_CANmodule_t
Complete CAN module object.
Definition: CO_driver.h:319
CO_SYNC_t::em
CO_EM_t * em
From CO_SYNC_init()
Definition: CO_SYNC.h:76
CO_SYNC_t::CANdevTx
CO_CANmodule_t * CANdevTx
From CO_SYNC_init()
Definition: CO_SYNC.h:115
CO_SYNC_t
SYNC producer and consumer object.
Definition: CO_SYNC.h:75
CO_SYNC_t::CANdevRxIdx
uint16_t CANdevRxIdx
From CO_SYNC_init()
Definition: CO_SYNC.h:114
CO_SYNC_t::operatingState
CO_NMT_internalState_t * operatingState
From CO_SYNC_init()
Definition: CO_SYNC.h:77
CO_CANtx_t
Configuration object for CAN transmit message for specific CANopenNode Object.
Definition: CO_driver.h:299
uint8_t
unsigned char uint8_t
UNSIGNED8 in CANopen (0005h), 8-bit unsigned integer.
Definition: CO_driver.h:151
CO_SYNC_t::CANdevTxIdx
uint16_t CANdevTxIdx
From CO_SYNC_init()
Definition: CO_SYNC.h:117