Files | |
file | CO_SYNC.h |
CANopen Synchronisation protocol. | |
Data Structures | |
struct | CO_SYNC_t |
SYNC producer and consumer object. More... | |
Enumerations | |
enum | CO_SYNC_status_t { CO_SYNC_NONE = 0, CO_SYNC_RECEIVED = 1, CO_SYNC_OUTSIDE_WINDOW = 2 } |
Return value for CO_SYNC_process. More... | |
Functions | |
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. More... | |
void | CO_SYNC_initCallbackPre (CO_SYNC_t *SYNC, void *object, void(*pFunctSignalPre)(void *object)) |
Initialize SYNC callback function. More... | |
CO_ReturnError_t | CO_SYNCsend (CO_SYNC_t *SYNC) |
Send SYNC message. More... | |
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. More... | |
CANopen Synchronisation protocol.
For CAN identifier see CO_Default_CAN_ID_t
SYNC message is used for synchronization of the nodes on network. One node can be SYNC producer, others can be SYNC consumers. Synchronous TPDOs are transmitted after the CANopen SYNC message. Synchronous received PDOs are accepted(copied to OD) immediatelly after the reception of the next SYNC message.
By default SYNC message has no data. If Synchronous counter overflow value from Object dictionary (index 0x1019) is different than 0, SYNC message has one data byte: counter incremented by 1 with every SYNC transmission.
According to CANopen, synchronous RPDOs must be processed after reception of the next sync messsage. For that reason, there is a double receive buffer for each synchronous RPDO. At the moment, when SYNC is received or transmitted, internal variable CANrxToggle toggles. That variable is then used by synchronous RPDO to determine, which of the two buffers is used for RPDO reception and which for RPDO processing.
enum CO_SYNC_status_t |
Return value for CO_SYNC_process.
Enumerator | |
---|---|
CO_SYNC_NONE | SYNC not received. |
CO_SYNC_RECEIVED | SYNC received. |
CO_SYNC_OUTSIDE_WINDOW | SYNC received outside SYNC window. |
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.
Function must be called in the communication reset section.
SYNC | This object will be initialized. |
em | Emergency object. |
SDO | SDO server object. |
operatingState | Pointer to variable indicating CANopen device NMT internal state. |
COB_ID_SYNCMessage | From Object dictionary (index 0x1005). |
communicationCyclePeriod | From Object dictionary (index 0x1006). |
synchronousCounterOverflowValue | From Object dictionary (index 0x1019). |
CANdevRx | CAN device for SYNC reception. |
CANdevRxIdx | Index of receive buffer in the above CAN device. |
CANdevTx | CAN device for SYNC transmission. |
CANdevTxIdx | Index of transmit buffer in the above CAN device. |
void CO_SYNC_initCallbackPre | ( | CO_SYNC_t * | SYNC, |
void * | object, | ||
void(*)(void *object) | pFunctSignalPre | ||
) |
Initialize SYNC callback function.
Function initializes optional callback function, which should immediately start processing of CO_SYNC_process() function. Callback is called after SYNC message is received from the CAN bus.
SYNC | 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. |
CO_ReturnError_t CO_SYNCsend | ( | CO_SYNC_t * | SYNC | ) |
Send SYNC message.
This function prepares and sends a SYNC object. The application should only call this if direct control of SYNC transmission is needed, otherwise use CO_SYNC_process().
SYNC | SYNC object. |
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.
Function must be called cyclically.
SYNC | This object. | |
timeDifference_us | Time difference from previous function call in [microseconds]. | |
ObjDict_synchronousWindowLength | Synchronous window length variable from Object dictionary (index 0x1007). | |
[out] | timerNext_us | info to OS - see CO_process_SYNC_PDO(). |