Lely core libraries  2.3.4
pdo.h
Go to the documentation of this file.
1 
22 #ifndef LELY_CO_PDO_H_
23 #define LELY_CO_PDO_H_
24 
25 #include <lely/co/type.h>
26 
28 #define CO_NUM_PDOS 512
29 
34 #define CO_PDO_NUM_MAPS 0x40u
35 
37 #define CO_PDO_COBID_VALID UINT32_C(0x80000000)
38 
40 #define CO_PDO_COBID_RTR UINT32_C(0x40000000)
41 
46 #define CO_PDO_COBID_FRAME UINT32_C(0x20000000)
47 
52 #define CO_PDO_MAP_SAM_MPDO 0xfe
53 
58 #define CO_PDO_MAP_DAM_MPDO 0xff
59 
61 #define CO_DEFSTRUCT_PDO_COMM_PAR 0x0020
62 
66  co_unsigned8_t n;
68  co_unsigned32_t cobid;
70  co_unsigned8_t trans;
72  co_unsigned16_t inhibit;
73  co_unsigned8_t reserved;
75  co_unsigned16_t event;
77  co_unsigned8_t sync;
78 };
79 
81 #define CO_PDO_COMM_PAR_INIT \
82  { \
83  6, CO_PDO_COBID_VALID, 0, 0, 0, 0, 0 \
84  }
85 
87 #define CO_DEFSTRUCT_PDO_MAP_PAR 0x0021
88 
92  co_unsigned8_t n;
94  co_unsigned32_t map[CO_PDO_NUM_MAPS];
95 };
96 
98 // clang-format off
99 #define CO_PDO_MAP_PAR_INIT \
100  { \
101  0, \
102  { \
103  0, 0, 0, 0, 0, 0, 0, 0, \
104  0, 0, 0, 0, 0, 0, 0, 0, \
105  0, 0, 0, 0, 0, 0, 0, 0, \
106  0, 0, 0, 0, 0, 0, 0, 0, \
107  0, 0, 0, 0, 0, 0, 0, 0, \
108  0, 0, 0, 0, 0, 0, 0, 0, \
109  0, 0, 0, 0, 0, 0, 0, 0, \
110  0, 0, 0, 0, 0, 0, 0, 0 \
111  } \
112  }
113 // clang-format on
114 
115 // The CANopen SDO upload/download request from lely/co/sdo.h.
116 struct co_sdo_req;
117 
118 #ifdef __cplusplus
119 extern "C" {
120 #endif
121 
132 co_unsigned32_t co_dev_chk_rpdo(const co_dev_t *dev, co_unsigned16_t idx,
133  co_unsigned8_t subidx);
134 
149 co_unsigned32_t co_dev_cfg_rpdo(const co_dev_t *dev, co_unsigned16_t num,
150  const struct co_pdo_comm_par *comm,
151  const struct co_pdo_map_par *map);
152 
163 co_unsigned32_t co_dev_cfg_rpdo_comm(const co_dev_t *dev, co_unsigned16_t num,
164  const struct co_pdo_comm_par *par);
165 
177 co_unsigned32_t co_dev_cfg_rpdo_map(const co_dev_t *dev, co_unsigned16_t num,
178  const struct co_pdo_map_par *par);
179 
191 co_unsigned32_t co_dev_chk_tpdo(const co_dev_t *dev, co_unsigned16_t idx,
192  co_unsigned8_t subidx);
193 
208 co_unsigned32_t co_dev_cfg_tpdo(const co_dev_t *dev, co_unsigned16_t num,
209  const struct co_pdo_comm_par *comm,
210  const struct co_pdo_map_par *map);
211 
222 co_unsigned32_t co_dev_cfg_tpdo_comm(const co_dev_t *dev, co_unsigned16_t num,
223  const struct co_pdo_comm_par *par);
224 
236 co_unsigned32_t co_dev_cfg_tpdo_map(const co_dev_t *dev, co_unsigned16_t num,
237  const struct co_pdo_map_par *par);
238 
252 int co_dev_chk_sam_mpdo(const co_dev_t *dev, co_unsigned16_t idx,
253  co_unsigned8_t subidx);
254 
275 int co_dev_map_sam_mpdo(const co_dev_t *dev, co_unsigned8_t id,
276  co_unsigned16_t idx, co_unsigned8_t subidx,
277  co_unsigned16_t *pidx, co_unsigned8_t *psubidx);
278 
295 co_unsigned32_t co_pdo_map(const struct co_pdo_map_par *par,
296  const co_unsigned64_t *val, co_unsigned8_t n,
297  uint_least8_t *buf, size_t *pn);
298 
315 co_unsigned32_t co_pdo_unmap(const struct co_pdo_map_par *par,
316  const uint_least8_t *buf, size_t n, co_unsigned64_t *val,
317  co_unsigned8_t *pn);
318 
336 co_unsigned32_t co_pdo_dn(const struct co_pdo_map_par *par, co_dev_t *dev,
337  struct co_sdo_req *req, const uint_least8_t *buf, size_t n,
338  int chk);
339 
361 co_unsigned32_t co_pdo_up(const struct co_pdo_map_par *par, const co_dev_t *dev,
362  struct co_sdo_req *req, uint_least8_t *buf, size_t *pn,
363  int chk);
364 
380 co_unsigned32_t co_sam_mpdo_up(const co_dev_t *dev, co_unsigned16_t idx,
381  co_unsigned8_t subidx, struct co_sdo_req *req,
382  uint_least8_t buf[4]);
383 
384 #ifdef __cplusplus
385 }
386 #endif
387 
388 #endif // !LELY_CO_PDO_H_
co_dev_cfg_tpdo_comm
co_unsigned32_t co_dev_cfg_tpdo_comm(const co_dev_t *dev, co_unsigned16_t num, const struct co_pdo_comm_par *par)
Configures the communication parameters of a Transmit-PDO service by updating CANopen object 1800 - 1...
Definition: pdo.c:179
co_pdo_comm_par::sync
co_unsigned8_t sync
SYNC start value.
Definition: pdo.h:77
co_dev_cfg_tpdo
co_unsigned32_t co_dev_cfg_tpdo(const co_dev_t *dev, co_unsigned16_t num, const struct co_pdo_comm_par *comm, const struct co_pdo_map_par *map)
Configures the communication and parameters of a Transmit-PDO service.
Definition: pdo.c:153
co_dev_map_sam_mpdo
int co_dev_map_sam_mpdo(const co_dev_t *dev, co_unsigned8_t id, co_unsigned16_t idx, co_unsigned8_t subidx, co_unsigned16_t *pidx, co_unsigned8_t *psubidx)
Checks if the specified remote object is part of the object dispatching list (objects 1FD0....
Definition: pdo.c:245
co_pdo_comm_par::n
co_unsigned8_t n
Highest sub-index supported.
Definition: pdo.h:66
co_dev_cfg_rpdo
co_unsigned32_t co_dev_cfg_rpdo(const co_dev_t *dev, co_unsigned16_t num, const struct co_pdo_comm_par *comm, const struct co_pdo_map_par *map)
Configures the communication and parameters of a Receive-PDO service.
Definition: pdo.c:80
co_pdo_comm_par::event
co_unsigned16_t event
Event timer.
Definition: pdo.h:75
co_dev_cfg_rpdo_map
co_unsigned32_t co_dev_cfg_rpdo_map(const co_dev_t *dev, co_unsigned16_t num, const struct co_pdo_map_par *par)
Configures the mapping parameters of a Receive-PDO service by updating CANopen object 1600 - 17FF (RP...
Definition: pdo.c:116
co_pdo_dn
co_unsigned32_t co_pdo_dn(const struct co_pdo_map_par *par, co_dev_t *dev, struct co_sdo_req *req, const uint_least8_t *buf, size_t n, int chk)
Writes mapped PDO values to the object dictionary through a local SDO download request.
Definition: pdo.c:368
co_pdo_comm_par
A PDO communication parameter record.
Definition: pdo.h:64
co_pdo_comm_par::trans
co_unsigned8_t trans
Transmission type.
Definition: pdo.h:70
co_dev_chk_sam_mpdo
int co_dev_chk_sam_mpdo(const co_dev_t *dev, co_unsigned16_t idx, co_unsigned8_t subidx)
Checks if the specified object is part of the object scanner list (objects 1FA0..1FCF) and can be tra...
Definition: pdo.c:203
type.h
co_pdo_map_par::n
co_unsigned8_t n
Number of mapped objects in PDO.
Definition: pdo.h:92
co_pdo_map_par::map
co_unsigned32_t map[CO_PDO_NUM_MAPS]
An array of objects to be mapped.
Definition: pdo.h:94
co_sdo_req
A CANopen SDO upload/download request.
Definition: sdo.h:181
co_pdo_up
co_unsigned32_t co_pdo_up(const struct co_pdo_map_par *par, const co_dev_t *dev, struct co_sdo_req *req, uint_least8_t *buf, size_t *pn, int chk)
Reads mapped PDO values from the object dictionary through a local SDO upload request.
Definition: pdo.c:432
co_dev_cfg_tpdo_map
co_unsigned32_t co_dev_cfg_tpdo_map(const co_dev_t *dev, co_unsigned16_t num, const struct co_pdo_map_par *par)
Configures the mapping parameters of a Transmit-PDO service by updating CANopen object 1A00 - 1BFF (T...
Definition: pdo.c:189
co_pdo_comm_par::inhibit
co_unsigned16_t inhibit
Inhibit time.
Definition: pdo.h:72
co_pdo_map
co_unsigned32_t co_pdo_map(const struct co_pdo_map_par *par, const co_unsigned64_t *val, co_unsigned8_t n, uint_least8_t *buf, size_t *pn)
Maps values into a PDO.
Definition: pdo.c:299
CO_PDO_NUM_MAPS
#define CO_PDO_NUM_MAPS
The maximum number of mapped application objects in a single PDO.
Definition: pdo.h:34
co_dev_chk_rpdo
co_unsigned32_t co_dev_chk_rpdo(const co_dev_t *dev, co_unsigned16_t idx, co_unsigned8_t subidx)
Checks if the specified object is valid and can be mapped into a Receive-PDO.
Definition: pdo.c:51
co_sam_mpdo_up
co_unsigned32_t co_sam_mpdo_up(const co_dev_t *dev, co_unsigned16_t idx, co_unsigned8_t subidx, struct co_sdo_req *req, uint_least8_t buf[4])
Reads the value of the specified SAM-MPDO-mapped object from the local object dictionary through a lo...
Definition: pdo.c:483
__co_dev
A CANopen device.
Definition: dev.h:30
co_sdo_req::buf
const void * buf
A pointer to the next bytes to be uploaded/downloaded.
Definition: sdo.h:189
co_dev_cfg_rpdo_comm
co_unsigned32_t co_dev_cfg_rpdo_comm(const co_dev_t *dev, co_unsigned16_t num, const struct co_pdo_comm_par *par)
Configures the communication parameters of a Receive-PDO service by updating CANopen object 1400 - 15...
Definition: pdo.c:106
co_pdo_comm_par::cobid
co_unsigned32_t cobid
COB-ID.
Definition: pdo.h:68
co_dev_chk_tpdo
co_unsigned32_t co_dev_chk_tpdo(const co_dev_t *dev, co_unsigned16_t idx, co_unsigned8_t subidx)
Checks if the specified object is valid and can be mapped into a Transmit-PDO.
Definition: pdo.c:130
co_pdo_map_par
A PDO mapping parameter record.
Definition: pdo.h:90
co_pdo_unmap
co_unsigned32_t co_pdo_unmap(const struct co_pdo_map_par *par, const uint_least8_t *buf, size_t n, co_unsigned64_t *val, co_unsigned8_t *pn)
Unmaps a PDO into its constituent values.
Definition: pdo.c:333