CO_PDO.h
Go to the documentation of this file.
#ifndef CO_PDO_H
#define CO_PDO_H
#include "301/CO_driver.h"
#include "301/CO_SDOserver.h"
#include "301/CO_Emergency.h"
#include "301/CO_NMT_Heartbeat.h"
#include "301/CO_SYNC.h"
/* default configuration, see CO_config.h */
#ifndef CO_CONFIG_PDO
#define CO_CONFIG_PDO (CO_CONFIG_RPDO_ENABLE | \
CO_CONFIG_TPDO_ENABLE | \
CO_CONFIG_PDO_SYNC_ENABLE)
#endif
#if ((CO_CONFIG_PDO) & (CO_CONFIG_RPDO_ENABLE | CO_CONFIG_TPDO_ENABLE)) || defined CO_DOXYGEN
#ifdef __cplusplus
extern "C" {
#endif
typedef struct{
uint8_t maxSubIndex;
uint32_t COB_IDUsedByRPDO;
uint8_t transmissionType;
}CO_RPDOCommPar_t;
typedef struct{
uint8_t numberOfMappedObjects;
uint32_t mappedObject1;
uint32_t mappedObject2;
uint32_t mappedObject3;
uint32_t mappedObject4;
uint32_t mappedObject5;
uint32_t mappedObject6;
uint32_t mappedObject7;
uint32_t mappedObject8;
}CO_RPDOMapPar_t;
typedef struct{
uint8_t maxSubIndex;
uint32_t COB_IDUsedByTPDO;
uint8_t transmissionType;
uint16_t inhibitTime;
uint8_t compatibilityEntry;
uint16_t eventTimer;
uint8_t SYNCStartValue;
}CO_TPDOCommPar_t;
typedef struct{
uint8_t numberOfMappedObjects;
uint32_t mappedObject1;
uint32_t mappedObject2;
uint32_t mappedObject3;
uint32_t mappedObject4;
uint32_t mappedObject5;
uint32_t mappedObject6;
uint32_t mappedObject7;
uint32_t mappedObject8;
}CO_TPDOMapPar_t;
typedef struct{
CO_EM_t *em;
CO_SDO_t *SDO;
const CO_RPDOCommPar_t *RPDOCommPar;
const CO_RPDOMapPar_t *RPDOMapPar;
CO_NMT_internalState_t *operatingState;
uint8_t nodeId;
uint16_t defaultCOB_ID;
uint8_t restrictionFlags;
bool_t valid;
uint8_t dataLength;
uint8_t *mapPointer[8];
#if ((CO_CONFIG_PDO) & CO_CONFIG_PDO_SYNC_ENABLE) || defined CO_DOXYGEN
CO_SYNC_t *SYNC;
bool_t synchronous;
volatile void *CANrxNew[2];
uint8_t CANrxData[2][8];
#else
volatile void *CANrxNew[1];
uint8_t CANrxData[1][8];
#endif
#if ((CO_CONFIG_PDO) & CO_CONFIG_FLAG_CALLBACK_PRE) || defined CO_DOXYGEN
void (*pFunctSignalPre)(void *object);
void *functSignalObjectPre;
#endif
CO_CANmodule_t *CANdevRx;
uint16_t CANdevRxIdx;
}CO_RPDO_t;
typedef struct{
CO_EM_t *em;
CO_SDO_t *SDO;
const CO_TPDOCommPar_t *TPDOCommPar;
const CO_TPDOMapPar_t *TPDOMapPar;
CO_NMT_internalState_t *operatingState;
uint8_t nodeId;
uint16_t defaultCOB_ID;
uint8_t restrictionFlags;
bool_t valid;
uint8_t dataLength;
uint8_t sendRequest;
uint8_t *mapPointer[8];
uint32_t inhibitTimer;
uint32_t eventTimer;
uint8_t sendIfCOSFlags;
#if ((CO_CONFIG_PDO) & CO_CONFIG_PDO_SYNC_ENABLE) || defined CO_DOXYGEN
uint8_t syncCounter;
CO_SYNC_t *SYNC;
#endif
CO_CANmodule_t *CANdevTx;
CO_CANtx_t *CANtxBuff;
uint16_t CANdevTxIdx;
}CO_TPDO_t;
CO_ReturnError_t CO_RPDO_init(
CO_RPDO_t *RPDO,
CO_EM_t *em,
CO_SDO_t *SDO,
#if ((CO_CONFIG_PDO) & CO_CONFIG_PDO_SYNC_ENABLE) || defined CO_DOXYGEN
CO_SYNC_t *SYNC,
#endif
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);
#if ((CO_CONFIG_PDO) & CO_CONFIG_FLAG_CALLBACK_PRE) || defined CO_DOXYGEN
void CO_RPDO_initCallbackPre(
CO_RPDO_t *RPDO,
void *object,
void (*pFunctSignalPre)(void *object));
#endif
CO_ReturnError_t CO_TPDO_init(
CO_TPDO_t *TPDO,
CO_EM_t *em,
CO_SDO_t *SDO,
#if ((CO_CONFIG_PDO) & CO_CONFIG_PDO_SYNC_ENABLE) || defined CO_DOXYGEN
CO_SYNC_t *SYNC,
#endif
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);
uint8_t CO_TPDOisCOS(CO_TPDO_t *TPDO);
CO_ReturnError_t CO_TPDOsend(CO_TPDO_t *TPDO);
void CO_RPDO_process(CO_RPDO_t *RPDO, bool_t syncWas);
void CO_TPDO_process(
CO_TPDO_t *TPDO,
bool_t syncWas,
uint32_t timeDifference_us,
uint32_t *timerNext_us);
/* CO_PDO */
#ifdef __cplusplus
}
#endif /*__cplusplus*/
#endif /* (CO_CONFIG_PDO) & (CO_CONFIG_RPDO_ENABLE | CO_CONFIG_TPDO_ENABLE) */
#endif /* CO_PDO_H */
uint32_t
unsigned long int uint32_t
UNSIGNED32 in CANopen (0007h), 32-bit unsigned integer.
Definition: CO_driver.h:155
CO_driver.h
Interface between CAN hardware and CANopenNode.
CO_RPDOCommPar_t::COB_IDUsedByRPDO
uint32_t COB_IDUsedByRPDO
Communication object identifier for message received.
Definition: CO_PDO.h:87
CO_TPDOCommPar_t::compatibilityEntry
uint8_t compatibilityEntry
Not used.
Definition: CO_PDO.h:142
CO_RPDOMapPar_t::mappedObject4
uint32_t mappedObject4
Same.
Definition: CO_PDO.h:111
CO_TPDOMapPar_t::mappedObject5
uint32_t mappedObject5
Same.
Definition: CO_PDO.h:169
CO_RPDO_t::functSignalObjectPre
void * functSignalObjectPre
From CO_RPDO_initCallbackPre() or NULL.
Definition: CO_PDO.h:210
CO_TPDOMapPar_t::mappedObject8
uint32_t mappedObject8
Same.
Definition: CO_PDO.h:172
CO_TPDOCommPar_t::SYNCStartValue
uint8_t SYNCStartValue
Used with numbered SYNC messages.
Definition: CO_PDO.h:150
CO_RPDO_t
RPDO object.
Definition: CO_PDO.h:179
CO_RPDO_t::em
CO_EM_t * em
From CO_RPDO_init()
Definition: CO_PDO.h:180
CO_RPDO_t::nodeId
uint8_t nodeId
From CO_RPDO_init()
Definition: CO_PDO.h:185
CO_TPDOCommPar_t::inhibitTime
uint16_t inhibitTime
Minimum time between transmissions of the PDO in 100micro seconds.
Definition: CO_PDO.h:140
CO_TPDO_t::sendRequest
uint8_t sendRequest
If application set this flag, PDO will be later sent by function CO_TPDO_process().
Definition: CO_PDO.h:234
CO_TPDO_t::defaultCOB_ID
uint16_t defaultCOB_ID
From CO_TPDO_init()
Definition: CO_PDO.h:227
CO_TPDO_t::CANdevTxIdx
uint16_t CANdevTxIdx
From CO_TPDO_init()
Definition: CO_PDO.h:252
uint16_t
unsigned int uint16_t
UNSIGNED16 in CANopen (0006h), 16-bit unsigned integer.
Definition: CO_driver.h:153
CO_RPDO_t::SDO
CO_SDO_t * SDO
From CO_RPDO_init()
Definition: CO_PDO.h:181
CO_RPDO_t::operatingState
CO_NMT_internalState_t * operatingState
From CO_RPDO_init()
Definition: CO_PDO.h:184
CO_ReturnError_t
CO_ReturnError_t
Return values of some CANopen functions.
Definition: CO_driver.h:488
CO_TPDO_process
void CO_TPDO_process(CO_TPDO_t *TPDO, bool_t syncWas, uint32_t timeDifference_us, uint32_t *timerNext_us)
Process transmitting PDO messages.
CO_RPDOMapPar_t
RPDO mapping parameter.
Definition: CO_PDO.h:100
CO_RPDOMapPar_t::mappedObject1
uint32_t mappedObject1
Location and size of the mapped object.
Definition: CO_PDO.h:108
CO_TPDO_t::TPDOMapPar
const CO_TPDOMapPar_t * TPDOMapPar
From CO_TPDO_init()
Definition: CO_PDO.h:224
bool_t
unsigned char bool_t
Boolean data type for general use.
Definition: CO_driver.h:141
CO_TPDOMapPar_t::mappedObject6
uint32_t mappedObject6
Same.
Definition: CO_PDO.h:170
CO_RPDO_t::restrictionFlags
uint8_t restrictionFlags
From CO_RPDO_init()
Definition: CO_PDO.h:187
CO_RPDOMapPar_t::mappedObject6
uint32_t mappedObject6
Same.
Definition: CO_PDO.h:113
CO_RPDOCommPar_t::transmissionType
uint8_t transmissionType
Transmission type.
Definition: CO_PDO.h:93
CO_TPDOCommPar_t::eventTimer
uint16_t eventTimer
Time between periodic transmissions of the PDO in milliseconds.
Definition: CO_PDO.h:145
CO_RPDOCommPar_t::maxSubIndex
uint8_t maxSubIndex
Equal to 2.
Definition: CO_PDO.h:81
CO_RPDO_process
void CO_RPDO_process(CO_RPDO_t *RPDO, bool_t syncWas)
Process received PDO messages.
CO_TPDO_t::SDO
CO_SDO_t * SDO
From CO_TPDO_init()
Definition: CO_PDO.h:222
CO_TPDO_t::operatingState
CO_NMT_internalState_t * operatingState
From CO_TPDO_init()
Definition: CO_PDO.h:225
CO_TPDOCommPar_t::COB_IDUsedByTPDO
uint32_t COB_IDUsedByTPDO
Communication object identifier for transmitting message.
Definition: CO_PDO.h:129
CO_TPDOsend
CO_ReturnError_t CO_TPDOsend(CO_TPDO_t *TPDO)
Send TPDO message.
CO_TPDO_t::SYNC
CO_SYNC_t * SYNC
From CO_TPDO_init()
Definition: CO_PDO.h:248
CO_RPDO_t::synchronous
bool_t synchronous
True, if PDO synchronous (transmissionType <= 240)
Definition: CO_PDO.h:197
CO_RPDOMapPar_t::mappedObject3
uint32_t mappedObject3
Same.
Definition: CO_PDO.h:110
CO_TPDOisCOS
uint8_t CO_TPDOisCOS(CO_TPDO_t *TPDO)
Verify Change of State of the PDO.
CO_SDOserver.h
CANopen Service Data Object - server protocol.
CO_SYNC.h
CANopen Synchronisation protocol.
CO_RPDOMapPar_t::numberOfMappedObjects
uint8_t numberOfMappedObjects
Actual number of mapped objects from 0 to 8.
Definition: CO_PDO.h:103
CO_RPDOMapPar_t::mappedObject2
uint32_t mappedObject2
Same.
Definition: CO_PDO.h:109
CO_TPDOMapPar_t::mappedObject2
uint32_t mappedObject2
Same.
Definition: CO_PDO.h:166
CO_TPDO_t::inhibitTimer
uint32_t inhibitTimer
Inhibit timer used for inhibit PDO sending translated to microseconds.
Definition: CO_PDO.h:238
CO_TPDOMapPar_t::mappedObject1
uint32_t mappedObject1
Location and size of the mapped object.
Definition: CO_PDO.h:165
CO_RPDO_t::defaultCOB_ID
uint16_t defaultCOB_ID
From CO_RPDO_init()
Definition: CO_PDO.h:186
CO_TPDOMapPar_t::numberOfMappedObjects
uint8_t numberOfMappedObjects
Actual number of mapped objects from 0 to 8.
Definition: CO_PDO.h:160
CO_TPDOMapPar_t::mappedObject7
uint32_t mappedObject7
Same.
Definition: CO_PDO.h:171
CO_TPDO_t::nodeId
uint8_t nodeId
From CO_TPDO_init()
Definition: CO_PDO.h:226
CO_RPDOMapPar_t::mappedObject5
uint32_t mappedObject5
Same.
Definition: CO_PDO.h:112
CO_TPDO_t::restrictionFlags
uint8_t restrictionFlags
From CO_TPDO_init()
Definition: CO_PDO.h:228
CO_RPDO_t::dataLength
uint8_t dataLength
Data length of the received PDO message.
Definition: CO_PDO.h:191
CO_RPDO_t::CANdevRx
CO_CANmodule_t * CANdevRx
From CO_RPDO_init()
Definition: CO_PDO.h:212
CO_TPDO_t::CANtxBuff
CO_CANtx_t * CANtxBuff
CAN transmit buffer inside CANdev.
Definition: CO_PDO.h:251
CO_RPDOCommPar_t
RPDO communication parameter.
Definition: CO_PDO.h:80
CO_TPDO_t::em
CO_EM_t * em
From CO_TPDO_init()
Definition: CO_PDO.h:221
CO_CONFIG_PDO
#define CO_CONFIG_PDO
Configuration of PDO.
Definition: CO_config.h:453
CO_RPDOMapPar_t::mappedObject8
uint32_t mappedObject8
Same.
Definition: CO_PDO.h:115
CO_RPDO_t::SYNC
CO_SYNC_t * SYNC
From CO_RPDO_init()
Definition: CO_PDO.h:195
CO_TPDO_t::TPDOCommPar
const CO_TPDOCommPar_t * TPDOCommPar
From CO_TPDO_init()
Definition: CO_PDO.h:223
CO_TPDO_t::syncCounter
uint8_t syncCounter
SYNC counter used for PDO sending.
Definition: CO_PDO.h:247
CO_EM_t
Emergency object.
Definition: CO_Emergency.h:369
CO_TPDOCommPar_t
TPDO communication parameter.
Definition: CO_PDO.h:122
CO_TPDOMapPar_t::mappedObject3
uint32_t mappedObject3
Same.
Definition: CO_PDO.h:167
CO_NMT_internalState_t
CO_NMT_internalState_t
Internal network state of the CANopen node.
Definition: CO_NMT_Heartbeat.h:77
CO_NMT_Heartbeat.h
CANopen Network management and Heartbeat producer protocol.
CO_TPDOCommPar_t::transmissionType
uint8_t transmissionType
Transmission type.
Definition: CO_PDO.h:137
CO_TPDO_t::valid
bool_t valid
True, if PDO is enabled and valid.
Definition: CO_PDO.h:229
CO_TPDOMapPar_t::mappedObject4
uint32_t mappedObject4
Same.
Definition: CO_PDO.h:168
CO_Emergency.h
CANopen Emergency protocol.
CO_RPDO_initCallbackPre
void CO_RPDO_initCallbackPre(CO_RPDO_t *RPDO, void *object, void(*pFunctSignalPre)(void *object))
Initialize RPDO callback function.
CO_TPDOMapPar_t
TPDO mapping parameter.
Definition: CO_PDO.h:157
CO_CANmodule_t
Complete CAN module object.
Definition: CO_driver.h:319
CO_RPDO_init
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.
CO_TPDO_t::eventTimer
uint32_t eventTimer
Event timer used for PDO sending translated to microseconds.
Definition: CO_PDO.h:240
CO_TPDOCommPar_t::maxSubIndex
uint8_t maxSubIndex
Equal to 6.
Definition: CO_PDO.h:123
CO_RPDO_t::RPDOMapPar
const CO_RPDOMapPar_t * RPDOMapPar
From CO_RPDO_init()
Definition: CO_PDO.h:183
CO_SYNC_t
SYNC producer and consumer object.
Definition: CO_SYNC.h:75
CO_TPDO_t::dataLength
uint8_t dataLength
Data length of the transmitting PDO message.
Definition: CO_PDO.h:231
CO_RPDO_t::CANdevRxIdx
uint16_t CANdevRxIdx
From CO_RPDO_init()
Definition: CO_PDO.h:213
CO_RPDO_t::valid
bool_t valid
True, if PDO is enabled and valid.
Definition: CO_PDO.h:189
CO_TPDO_init
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.
CO_TPDO_t::CANdevTx
CO_CANmodule_t * CANdevTx
From CO_TPDO_init()
Definition: CO_PDO.h:250
CO_RPDO_t::RPDOCommPar
const CO_RPDOCommPar_t * RPDOCommPar
From CO_RPDO_init()
Definition: CO_PDO.h:182
CO_CANtx_t
Configuration object for CAN transmit message for specific CANopenNode Object.
Definition: CO_driver.h:299
CO_TPDO_t
TPDO object.
Definition: CO_PDO.h:220
CO_TPDO_t::sendIfCOSFlags
uint8_t sendIfCOSFlags
Each flag bit is connected with one mapPointer.
Definition: CO_PDO.h:244
uint8_t
unsigned char uint8_t
UNSIGNED8 in CANopen (0005h), 8-bit unsigned integer.
Definition: CO_driver.h:151
CO_RPDOMapPar_t::mappedObject7
uint32_t mappedObject7
Same.
Definition: CO_PDO.h:114