CANopenNode

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...
 

Detailed Description

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 :

TIME CONSUMER

CO_TIME_init() configuration :

Latest time value is stored in CO->TIME->Time variable.

TIME PRODUCER

CO_TIME_init() configuration :

Write time value in CO->TIME->Time variable, this will be sent at TIMECyclePeriod.

Function Documentation

◆ CO_TIME_init()

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.

Parameters
TIMEThis object will be initialized.
emEmergency object.
SDOSDO server object.
operatingStatePointer to variable indicating CANopen device NMT internal state.
COB_ID_TIMEMessageShould be intialized with CO_CAN_ID_TIME_STAMP
TIMECyclePeriodTIME period in ms (may also be used in consumer mode for timeout detection (1.5x period)).
CANdevRxCAN device for TIME reception.
CANdevRxIdxIndex of receive buffer in the above CAN device.
CANdevTxCAN device for TIME transmission.
CANdevTxIdxIndex of transmit buffer in the above CAN device.
Returns
CO_ReturnError_t: CO_ERROR_NO or CO_ERROR_ILLEGAL_ARGUMENT.

◆ CO_TIME_initCallbackPre()

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.

Parameters
TIMEThis object.
objectPointer to object, which will be passed to pFunctSignalPre(). Can be NULL
pFunctSignalPrePointer to the callback function. Not called if NULL.

◆ CO_TIME_process()

uint8_t CO_TIME_process ( CO_TIME_t TIME,
uint32_t  timeDifference_us 
)

Process TIME communication.

Function must be called cyclically.

Parameters
TIMEThis object.
timeDifference_usTime difference from previous function call in [microseconds].
Returns
0: No special meaning.
1: New TIME message recently received (consumer) / transmited (producer).