Lely core libraries  2.2.5
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_PDO_COBID_VALID UINT32_C(0x80000000)
29 
31 #define CO_PDO_COBID_RTR UINT32_C(0x40000000)
32 
37 #define CO_PDO_COBID_FRAME UINT32_C(0x20000000)
38 
40 #define CO_DEFSTRUCT_PDO_COMM_PAR 0x0020
41 
45  co_unsigned8_t n;
47  co_unsigned32_t cobid;
49  co_unsigned8_t trans;
51  co_unsigned16_t inhibit;
52  co_unsigned8_t reserved;
54  co_unsigned16_t event;
56  co_unsigned8_t sync;
57 };
58 
60 #define CO_PDO_COMM_PAR_INIT \
61  { \
62  6, CO_PDO_COBID_VALID, 0, 0, 0, 0, 0 \
63  }
64 
66 #define CO_DEFSTRUCT_PDO_MAP_PAR 0x0021
67 
71  co_unsigned8_t n;
73  co_unsigned32_t map[0x40];
74 };
75 
77 // clang-format off
78 #define CO_PDO_MAP_PAR_INIT \
79  { \
80  0, \
81  { \
82  0, 0, 0, 0, 0, 0, 0, 0, \
83  0, 0, 0, 0, 0, 0, 0, 0, \
84  0, 0, 0, 0, 0, 0, 0, 0, \
85  0, 0, 0, 0, 0, 0, 0, 0, \
86  0, 0, 0, 0, 0, 0, 0, 0, \
87  0, 0, 0, 0, 0, 0, 0, 0, \
88  0, 0, 0, 0, 0, 0, 0, 0, \
89  0, 0, 0, 0, 0, 0, 0, 0 \
90  } \
91  }
92 // clang-format on
93 
94 // The CANopen SDO upload/download request from lely/co/sdo.h.
95 struct co_sdo_req;
96 
97 #ifdef __cplusplus
98 extern "C" {
99 #endif
100 
111 co_unsigned32_t co_dev_chk_rpdo(const co_dev_t *dev, co_unsigned16_t idx,
112  co_unsigned8_t subidx);
113 
128 co_unsigned32_t co_dev_cfg_rpdo(const co_dev_t *dev, co_unsigned16_t num,
129  const struct co_pdo_comm_par *comm,
130  const struct co_pdo_map_par *map);
131 
142 co_unsigned32_t co_dev_cfg_rpdo_comm(const co_dev_t *dev, co_unsigned16_t num,
143  const struct co_pdo_comm_par *par);
144 
156 co_unsigned32_t co_dev_cfg_rpdo_map(const co_dev_t *dev, co_unsigned16_t num,
157  const struct co_pdo_map_par *par);
158 
170 co_unsigned32_t co_dev_chk_tpdo(const co_dev_t *dev, co_unsigned16_t idx,
171  co_unsigned8_t subidx);
172 
187 co_unsigned32_t co_dev_cfg_tpdo(const co_dev_t *dev, co_unsigned16_t num,
188  const struct co_pdo_comm_par *comm,
189  const struct co_pdo_map_par *map);
190 
201 co_unsigned32_t co_dev_cfg_tpdo_comm(const co_dev_t *dev, co_unsigned16_t num,
202  const struct co_pdo_comm_par *par);
203 
215 co_unsigned32_t co_dev_cfg_tpdo_map(const co_dev_t *dev, co_unsigned16_t num,
216  const struct co_pdo_map_par *par);
217 
234 co_unsigned32_t co_pdo_map(const struct co_pdo_map_par *par,
235  const co_unsigned64_t *val, co_unsigned8_t n,
236  uint_least8_t *buf, size_t *pn);
237 
254 co_unsigned32_t co_pdo_unmap(const struct co_pdo_map_par *par,
255  const uint_least8_t *buf, size_t n, co_unsigned64_t *val,
256  co_unsigned8_t *pn);
257 
271 co_unsigned32_t co_pdo_dn(const struct co_pdo_map_par *par, co_dev_t *dev,
272  struct co_sdo_req *req, const uint_least8_t *buf, size_t n);
273 
290 co_unsigned32_t co_pdo_up(const struct co_pdo_map_par *par, const co_dev_t *dev,
291  struct co_sdo_req *req, uint_least8_t *buf, size_t *pn);
292 
293 #ifdef __cplusplus
294 }
295 #endif
296 
297 #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:166
co_pdo_comm_par::sync
co_unsigned8_t sync
SYNC start value.
Definition: pdo.h:56
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:140
co_pdo_comm_par::n
co_unsigned8_t n
Highest sub-index supported.
Definition: pdo.h:45
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:71
co_pdo_comm_par::event
co_unsigned16_t event
Event timer.
Definition: pdo.h:54
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)
Reads mapped PDO values from the object dictionary through a local SDO upload request.
Definition: pdo.c:308
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:107
co_pdo_comm_par
A PDO communication parameter record.
Definition: pdo.h:43
co_pdo_comm_par::trans
co_unsigned8_t trans
Transmission type.
Definition: pdo.h:49
type.h
co_pdo_map_par::n
co_unsigned8_t n
Number of mapped objects in PDO.
Definition: pdo.h:71
co_sdo_req
A CANopen SDO upload/download request.
Definition: sdo.h:178
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:176
co_pdo_comm_par::inhibit
co_unsigned16_t inhibit
Inhibit time.
Definition: pdo.h:51
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:186
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:42
__co_dev
A CANopen device.
Definition: dev.c:41
co_sdo_req::buf
const void * buf
A pointer to the next bytes to be uploaded/downloaded.
Definition: sdo.h:186
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:97
co_pdo_comm_par::cobid
co_unsigned32_t cobid
COB-ID.
Definition: pdo.h:47
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)
Writes mapped PDO values to the object dictionary through a local SDO download request.
Definition: pdo.c:254
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:117
co_pdo_map_par
A PDO mapping parameter record.
Definition: pdo.h:69
co_pdo_map_par::map
co_unsigned32_t map[0x40]
An array of objects to be mapped.
Definition: pdo.h:73
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:220