CANopenNode
CANopen protocol stack
Loading...
Searching...
No Matches
CO_TIME.h
Go to the documentation of this file.
1
21#ifndef CO_TIME_H
22#define CO_TIME_H
23
24#include "301/CO_driver.h"
25#include "301/CO_ODinterface.h"
27
28/* default configuration, see CO_config.h */
29#ifndef CO_CONFIG_TIME
30#define CO_CONFIG_TIME (CO_CONFIG_TIME_ENABLE | CO_CONFIG_GLOBAL_FLAG_CALLBACK_PRE | CO_CONFIG_GLOBAL_FLAG_OD_DYNAMIC)
31#endif
32
33#if (((CO_CONFIG_TIME)&CO_CONFIG_TIME_ENABLE) != 0) || defined CO_DOXYGEN
34
35#ifdef __cplusplus
36extern "C" {
37#endif
38
62#define CO_TIME_MSG_LENGTH 6U
67typedef struct {
76 volatile void* CANrxNew;
77#if (((CO_CONFIG_TIME)&CO_CONFIG_TIME_PRODUCER) != 0) || defined CO_DOXYGEN
82#endif
83#if (((CO_CONFIG_TIME)&CO_CONFIG_FLAG_CALLBACK_PRE) != 0) || defined CO_DOXYGEN
84 void (*pFunctSignalPre)(void* object);
86#endif
87#if (((CO_CONFIG_TIME)&CO_CONFIG_FLAG_OD_DYNAMIC) != 0) || defined CO_DOXYGEN
89#endif
90} CO_TIME_t;
91
107CO_ReturnError_t CO_TIME_init(CO_TIME_t* TIME, OD_entry_t* OD_1012_cobIdTimeStamp, CO_CANmodule_t* CANdevRx,
108 uint16_t CANdevRxIdx,
109#if (((CO_CONFIG_TIME)&CO_CONFIG_TIME_PRODUCER) != 0) || defined CO_DOXYGEN
110 CO_CANmodule_t* CANdevTx, uint16_t CANdevTxIdx,
111#endif
112 uint32_t* errInfo);
113
114#if (((CO_CONFIG_TIME)&CO_CONFIG_FLAG_CALLBACK_PRE) != 0) || defined CO_DOXYGEN
125void CO_TIME_initCallbackPre(CO_TIME_t* TIME, void* object, void (*pFunctSignalPre)(void* object));
126#endif
127
136static inline void
137CO_TIME_set(CO_TIME_t* TIME, uint32_t ms, uint16_t days, uint32_t producerInterval_ms) {
138 (void)producerInterval_ms; /* may be unused */
139
140 if (TIME != NULL) {
141 TIME->residual_us = 0;
142 TIME->ms = ms;
143 TIME->days = days;
144#if ((CO_CONFIG_TIME)&CO_CONFIG_TIME_PRODUCER) != 0
145 TIME->producerTimer_ms = TIME->producerInterval_ms = producerInterval_ms;
146#endif
147 }
148}
149
162bool_t CO_TIME_process(CO_TIME_t* TIME, bool_t NMTisPreOrOperational, uint32_t timeDifference_us);
163
164 /* CO_TIME */
165
166#ifdef __cplusplus
167}
168#endif /* __cplusplus */
169
170#endif /* (CO_CONFIG_TIME) & CO_CONFIG_TIME_ENABLE */
171
172#endif /* CO_TIME_H */
CANopen Network management and Heartbeat producer protocol.
CANopen Object Dictionary interface.
Interface between CAN hardware and CANopenNode.
bool_t CO_TIME_process(CO_TIME_t *TIME, bool_t NMTisPreOrOperational, uint32_t timeDifference_us)
Process TIME object.
#define CO_TIME_MSG_LENGTH
Length of the TIME message.
Definition CO_TIME.h:62
static void CO_TIME_set(CO_TIME_t *TIME, uint32_t ms, uint16_t days, uint32_t producerInterval_ms)
Set current time.
Definition CO_TIME.h:137
CO_ReturnError_t CO_TIME_init(CO_TIME_t *TIME, OD_entry_t *OD_1012_cobIdTimeStamp, CO_CANmodule_t *CANdevRx, uint16_t CANdevRxIdx, CO_CANmodule_t *CANdevTx, uint16_t CANdevTxIdx, uint32_t *errInfo)
Initialize TIME object.
void CO_TIME_initCallbackPre(CO_TIME_t *TIME, void *object, void(*pFunctSignalPre)(void *object))
Initialize TIME callback function.
#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
uint_fast8_t bool_t
Boolean data type for general use.
Definition CO_driver.h:126
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
TIME producer and consumer object.
Definition CO_TIME.h:67
uint32_t ms
Milliseconds after midnight.
Definition CO_TIME.h:69
OD_extension_t OD_1012_extension
Extension for OD object.
Definition CO_TIME.h:88
uint32_t producerTimer_ms
Sync producer timer.
Definition CO_TIME.h:79
bool_t isProducer
True, if device is TIME producer.
Definition CO_TIME.h:74
uint16_t residual_us
Residual microseconds calculated inside CO_TIME_process()
Definition CO_TIME.h:71
uint32_t producerInterval_ms
Interval for time producer in milli seconds.
Definition CO_TIME.h:78
volatile void * CANrxNew
Variable indicates, if new TIME message received from CAN bus.
Definition CO_TIME.h:76
void * functSignalObjectPre
From CO_TIME_initCallbackPre() or NULL.
Definition CO_TIME.h:85
CO_CANtx_t * CANtxBuff
CAN transmit buffer.
Definition CO_TIME.h:81
CO_CANmodule_t * CANdevTx
From CO_TIME_init()
Definition CO_TIME.h:80
uint16_t days
Number of days since January 1, 1984.
Definition CO_TIME.h:70
bool_t isConsumer
True, if device is TIME consumer.
Definition CO_TIME.h:72
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