Files | |
file | CO_TIME.h |
CANopen Time-stamp protocol. | |
Data Structures | |
struct | CO_TIME_t |
TIME producer and consumer object. More... | |
Functions | |
CO_ReturnError_t | CO_TIME_init (CO_TIME_t *TIME, CO_EM_t *em, CO_SDO_t *SDO, CO_NMT_internalState_t *operatingState, uint32_t COB_ID_TIMEMessage, uint32_t TIMECyclePeriod, CO_CANmodule_t *CANdevRx, uint16_t CANdevRxIdx, CO_CANmodule_t *CANdevTx, uint16_t CANdevTxIdx) |
Initialize TIME object. More... | |
void | CO_TIME_initCallbackPre (CO_TIME_t *TIME, void *object, void(*pFunctSignalPre)(void *object)) |
Initialize TIME callback function. More... | |
uint8_t | CO_TIME_process (CO_TIME_t *TIME, uint32_t timeDifference_us) |
Process TIME communication. More... | |
CANopen Time-stamp protocol.
For CAN identifier see CO_Default_CAN_ID_t
TIME message is used for time synchronization of the nodes on network. One node should be TIME producer, others can be TIME consumers. This is configured with COB_ID_TIME object 0x1012 :
CO_TIME_init() configuration :
Latest time value is stored in CO->TIME->Time
variable.
CO_TIME_init() configuration :
Write time value in CO->TIME->Time
variable, this will be sent at TIMECyclePeriod.
CO_ReturnError_t CO_TIME_init | ( | CO_TIME_t * | TIME, |
CO_EM_t * | em, | ||
CO_SDO_t * | SDO, | ||
CO_NMT_internalState_t * | operatingState, | ||
uint32_t | COB_ID_TIMEMessage, | ||
uint32_t | TIMECyclePeriod, | ||
CO_CANmodule_t * | CANdevRx, | ||
uint16_t | CANdevRxIdx, | ||
CO_CANmodule_t * | CANdevTx, | ||
uint16_t | CANdevTxIdx | ||
) |
Initialize TIME object.
Function must be called in the communication reset section.
TIME | This object will be initialized. |
em | Emergency object. |
SDO | SDO server object. |
operatingState | Pointer to variable indicating CANopen device NMT internal state. |
COB_ID_TIMEMessage | Should be intialized with CO_CAN_ID_TIME_STAMP |
TIMECyclePeriod | TIME period in ms (may also be used in consumer mode for timeout detection (1.5x period)). |
CANdevRx | CAN device for TIME reception. |
CANdevRxIdx | Index of receive buffer in the above CAN device. |
CANdevTx | CAN device for TIME transmission. |
CANdevTxIdx | Index of transmit buffer in the above CAN device. |
void CO_TIME_initCallbackPre | ( | CO_TIME_t * | TIME, |
void * | object, | ||
void(*)(void *object) | pFunctSignalPre | ||
) |
Initialize TIME callback function.
Function initializes optional callback function, which should immediately start processing of CO_TIME_process() function. Callback is called after TIME message is received from the CAN bus.
TIME | This object. |
object | Pointer to object, which will be passed to pFunctSignalPre(). Can be NULL |
pFunctSignalPre | Pointer to the callback function. Not called if NULL. |
Process TIME communication.
Function must be called cyclically.
TIME | This object. |
timeDifference_us | Time difference from previous function call in [microseconds]. |