Files | |
file | CO_PDO.h |
CANopen Process Data Object protocol. | |
Data Structures | |
struct | CO_RPDOCommPar_t |
RPDO communication parameter. More... | |
struct | CO_RPDOMapPar_t |
RPDO mapping parameter. More... | |
struct | CO_TPDOCommPar_t |
TPDO communication parameter. More... | |
struct | CO_TPDOMapPar_t |
TPDO mapping parameter. More... | |
struct | CO_RPDO_t |
RPDO object. More... | |
struct | CO_TPDO_t |
TPDO object. More... | |
Functions | |
CO_ReturnError_t | CO_RPDO_init (CO_RPDO_t *RPDO, CO_EM_t *em, CO_SDO_t *SDO, CO_SYNC_t *SYNC, CO_NMT_internalState_t *operatingState, uint8_t nodeId, uint16_t defaultCOB_ID, uint8_t restrictionFlags, const CO_RPDOCommPar_t *RPDOCommPar, const CO_RPDOMapPar_t *RPDOMapPar, uint16_t idx_RPDOCommPar, uint16_t idx_RPDOMapPar, CO_CANmodule_t *CANdevRx, uint16_t CANdevRxIdx) |
Initialize RPDO object. More... | |
void | CO_RPDO_initCallbackPre (CO_RPDO_t *RPDO, void *object, void(*pFunctSignalPre)(void *object)) |
Initialize RPDO callback function. More... | |
CO_ReturnError_t | CO_TPDO_init (CO_TPDO_t *TPDO, CO_EM_t *em, CO_SDO_t *SDO, CO_SYNC_t *SYNC, CO_NMT_internalState_t *operatingState, uint8_t nodeId, uint16_t defaultCOB_ID, uint8_t restrictionFlags, const CO_TPDOCommPar_t *TPDOCommPar, const CO_TPDOMapPar_t *TPDOMapPar, uint16_t idx_TPDOCommPar, uint16_t idx_TPDOMapPar, CO_CANmodule_t *CANdevTx, uint16_t CANdevTxIdx) |
Initialize TPDO object. More... | |
uint8_t | CO_TPDOisCOS (CO_TPDO_t *TPDO) |
Verify Change of State of the PDO. More... | |
CO_ReturnError_t | CO_TPDOsend (CO_TPDO_t *TPDO) |
Send TPDO message. More... | |
void | CO_RPDO_process (CO_RPDO_t *RPDO, bool_t syncWas) |
Process received PDO messages. More... | |
void | CO_TPDO_process (CO_TPDO_t *TPDO, bool_t syncWas, uint32_t timeDifference_us, uint32_t *timerNext_us) |
Process transmitting PDO messages. More... | |
CANopen Process Data Object protocol.
Process data objects are used for real-time data transfer with no protocol overhead.
TPDO with specific identifier is transmitted by one device and recieved by zero or more devices as RPDO. PDO communication parameters(COB-ID, transmission type, etc.) are in Object Dictionary at index 0x1400+ and 0x1800+. PDO mapping parameters (size and contents of the PDO) are in Object Dictionary at index 0x1600+ and 0x1A00+.
Features of the PDO as implemented here, in CANopenNode:
CO_ReturnError_t CO_RPDO_init | ( | CO_RPDO_t * | RPDO, |
CO_EM_t * | em, | ||
CO_SDO_t * | SDO, | ||
CO_SYNC_t * | SYNC, | ||
CO_NMT_internalState_t * | operatingState, | ||
uint8_t | nodeId, | ||
uint16_t | defaultCOB_ID, | ||
uint8_t | restrictionFlags, | ||
const CO_RPDOCommPar_t * | RPDOCommPar, | ||
const CO_RPDOMapPar_t * | RPDOMapPar, | ||
uint16_t | idx_RPDOCommPar, | ||
uint16_t | idx_RPDOMapPar, | ||
CO_CANmodule_t * | CANdevRx, | ||
uint16_t | CANdevRxIdx | ||
) |
Initialize RPDO object.
Function must be called in the communication reset section.
RPDO | This object will be initialized. |
em | Emergency object. |
SDO | SDO server object. |
SYNC | void pointer to SYNC object or NULL. |
operatingState | Pointer to variable indicating CANopen device NMT internal state. |
nodeId | CANopen Node ID of this device. If default COB_ID is used, value will be added. |
defaultCOB_ID | Default COB ID for this PDO (without NodeId). See CO_Default_CAN_ID_t |
restrictionFlags | Flag bits indicates, how PDO communication and mapping parameters are handled:
|
RPDOCommPar | Pointer to RPDO communication parameter record from Object dictionary (index 0x1400+). |
RPDOMapPar | Pointer to RPDO mapping parameter record from Object dictionary (index 0x1600+). |
idx_RPDOCommPar | Index in Object Dictionary. |
idx_RPDOMapPar | Index in Object Dictionary. |
CANdevRx | CAN device for PDO reception. |
CANdevRxIdx | Index of receive buffer in the above CAN device. |
void CO_RPDO_initCallbackPre | ( | CO_RPDO_t * | RPDO, |
void * | object, | ||
void(*)(void *object) | pFunctSignalPre | ||
) |
Initialize RPDO callback function.
Function initializes optional callback function, which should immediately start processing of CO_RPDO_process() function. Callback is called after RPDO message is received from the CAN bus.
RPDO | 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_TPDO_init | ( | CO_TPDO_t * | TPDO, |
CO_EM_t * | em, | ||
CO_SDO_t * | SDO, | ||
CO_SYNC_t * | SYNC, | ||
CO_NMT_internalState_t * | operatingState, | ||
uint8_t | nodeId, | ||
uint16_t | defaultCOB_ID, | ||
uint8_t | restrictionFlags, | ||
const CO_TPDOCommPar_t * | TPDOCommPar, | ||
const CO_TPDOMapPar_t * | TPDOMapPar, | ||
uint16_t | idx_TPDOCommPar, | ||
uint16_t | idx_TPDOMapPar, | ||
CO_CANmodule_t * | CANdevTx, | ||
uint16_t | CANdevTxIdx | ||
) |
Initialize TPDO object.
Function must be called in the communication reset section.
TPDO | This object will be initialized. |
em | Emergency object. |
SDO | SDO object. |
SYNC | void pointer to SYNC object or NULL. |
operatingState | Pointer to variable indicating CANopen device NMT internal state. |
nodeId | CANopen Node ID of this device. If default COB_ID is used, value will be added. |
defaultCOB_ID | Default COB ID for this PDO (without NodeId). See CO_Default_CAN_ID_t |
restrictionFlags | Flag bits indicates, how PDO communication and mapping parameters are handled:
|
TPDOCommPar | Pointer to TPDO communication parameter record from Object dictionary (index 0x1400+). |
TPDOMapPar | Pointer to TPDO mapping parameter record from Object dictionary (index 0x1600+). |
idx_TPDOCommPar | Index in Object Dictionary. |
idx_TPDOMapPar | Index in Object Dictionary. |
CANdevTx | CAN device used for PDO transmission. |
CANdevTxIdx | Index of transmit buffer in the above CAN device. |
Verify Change of State of the PDO.
Function verifies if variable mapped to TPDO has changed its value. Verified are only variables, which has set attribute CO_ODA_TPDO_DETECT_COS in #CO_SDO_OD_attributes_t.
Function may be called by application just before CO_TPDO_process() function, for example: TPDOx->sendRequest = CO_TPDOisCOS(TPDOx); CO_TPDO_process(TPDOx, ....
TPDO | TPDO object. |
CO_ReturnError_t CO_TPDOsend | ( | CO_TPDO_t * | TPDO | ) |
Send TPDO message.
Function prepares TPDO data from Object Dictionary variables. It should not be called by application, it is called from CO_TPDO_process().
TPDO | TPDO object. |
Process received PDO messages.
Function must be called cyclically in any NMT state. It copies data from RPDO to Object Dictionary variables if: new PDO receives and PDO is valid and NMT operating state is operational. It does not verify transmission type.
RPDO | This object. |
syncWas | True, if CANopen SYNC message was just received or transmitted. |
void CO_TPDO_process | ( | CO_TPDO_t * | TPDO, |
bool_t | syncWas, | ||
uint32_t | timeDifference_us, | ||
uint32_t * | timerNext_us | ||
) |
Process transmitting PDO messages.
Function must be called cyclically in any NMT state. It prepares and sends TPDO if necessary. If Change of State needs to be detected, function CO_TPDOisCOS() must be called before.
TPDO | This object. | |
syncWas | True, if CANopen SYNC message was just received or transmitted. | |
timeDifference_us | Time difference from previous function call in [microseconds]. | |
[out] | timerNext_us | info to OS - see CO_process_SYNC_PDO(). |