35 static co_unsigned32_t co_dev_cfg_pdo_comm(
const co_dev_t *dev,
38 static co_unsigned32_t co_dev_cfg_pdo_map(
const co_dev_t *dev,
77 co_unsigned32_t ac = 0;
100 if (!num || num > 512)
103 return co_dev_cfg_pdo_comm(dev, 0x1400 + num - 1, par);
110 if (!num || num > 512)
113 return co_dev_cfg_pdo_map(dev, 0x1600 + num - 1, par);
146 co_unsigned32_t ac = 0;
169 if (!num || num > 512)
172 return co_dev_cfg_pdo_comm(dev, 0x1800 + num - 1, par);
179 if (!num || num > 512)
182 return co_dev_cfg_pdo_map(dev, 0x1a00 + num - 1, par);
187 co_unsigned8_t
n, uint_least8_t *buf,
size_t *pn)
192 if (par->
n > 0x40 || n != par->
n)
196 for (
size_t i = 0; i < par->
n; i++) {
197 co_unsigned32_t map = par->
map[i];
201 co_unsigned8_t len = map & 0xff;
205 uint_least8_t tmp[
sizeof(co_unsigned64_t)] = { 0 };
207 if (buf && pn && offset + len <= *pn * 8)
208 bcpyle(buf, offset, tmp, 0, len);
214 *pn = (offset + 7) / 8;
221 size_t n, co_unsigned64_t *val, co_unsigned8_t *pn)
230 for (
size_t i = 0; i < par->
n; i++) {
231 co_unsigned32_t map = par->
map[i];
235 co_unsigned8_t len = map & 0xff;
236 if (offset + len > n * 8)
239 uint_least8_t tmp[
sizeof(co_unsigned64_t)] = { 0 };
240 bcpyle(tmp, 0, buf, offset, len);
241 if (val && pn && i < *pn)
255 struct co_sdo_req *req,
const uint_least8_t *buf,
size_t n)
265 co_unsigned32_t ac = 0;
268 for (
size_t i = 0; i <
MIN(par->
n, 0x40u); i++) {
269 co_unsigned32_t map = par->
map[i];
273 co_unsigned16_t idx = (map >> 16) & 0xffff;
274 co_unsigned8_t subidx = (map >> 8) & 0xff;
275 co_unsigned8_t len = map & 0xff;
278 if (offset + len > n * 8)
291 bcpyle(tmp, 0, buf, offset, len);
293 req->
size = (len + 7) / 8;
309 struct co_sdo_req *req, uint_least8_t *buf,
size_t *pn)
315 co_unsigned32_t ac = 0;
318 for (
size_t i = 0; i <
MIN(par->
n, 0x40u); i++) {
319 co_unsigned32_t map = par->
map[i];
323 co_unsigned16_t idx = (map >> 16) & 0xffff;
324 co_unsigned8_t subidx = (map >> 8) & 0xff;
325 co_unsigned8_t len = map & 0xff;
344 if (buf && pn && offset + len <= *pn * 8)
351 *pn = (offset + 7) / 8;
356 static co_unsigned32_t
357 co_dev_cfg_pdo_comm(
const co_dev_t *dev, co_unsigned16_t idx,
363 co_unsigned32_t ac = 0;
370 co_unsigned8_t
n = co_obj_get_val_u8(obj, 0x00);
375 if (par->
n >= 1 && !ac) {
383 if (par->
n >= 2 && !ac) {
391 if (par->
n >= 3 && !ac) {
400 if (par->
n >= 5 && !ac) {
408 if (par->
n >= 6 && !ac) {
418 static co_unsigned32_t
419 co_dev_cfg_pdo_map(
const co_dev_t *dev, co_unsigned16_t idx,
425 co_unsigned32_t ac = 0;
441 for (co_unsigned8_t i = 1; i <= par->
n; i++) {
A CANopen SDO upload/download request.
A PDO mapping parameter record.
#define CO_SDO_AC_NO_READ
SDO abort code: Attempt to read a write only object.
co_unsigned8_t sync
SYNC start value.
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...
co_unsigned32_t co_sub_dn_ind_val(co_sub_t *sub, co_unsigned16_t type, const void *val)
Invokes the download indication function of a CANopen sub-object, registered with co_sub_set_dn_ind()...
size_t size
The total size (in bytes) of the value to be uploaded/downloaded.
#define CO_ACCESS_WRITE
The object can be written.
void co_sdo_req_clear(struct co_sdo_req *req)
Clears a CANopen SDO upload/download request, including its buffer.
co_unsigned8_t n
Number of mapped objects in PDO.
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.
#define CO_ACCESS_TPDO
The object can be mapped to a TPDO.
A PDO communication parameter record.
#define MIN(a, b)
Returns the minimum of a and b.
co_unsigned32_t cobid
COB-ID.
This header file is part of the CANopen library; it contains the Service Data Object (SDO) declaratio...
#define CO_ACCESS_RPDO
The object can be mapped to an RPDO.
int co_sub_get_pdo_mapping(const co_sub_t *sub)
Returns 1 if it is possible to map the specified CANopen sub-object into a PDO, and 0 if not...
unsigned int co_sub_get_access(const co_sub_t *sub)
Returns the access type of a CANopen sub-object.
#define CO_ACCESS_READ
The object can be read.
#define CO_DEFTYPE_UNSIGNED32
The data type (and object index) of a 32-bit unsigned integer.
co_unsigned16_t event
Event timer.
int co_sdo_req_first(const struct co_sdo_req *req)
Returns 1 if the specified request includes the first segment, and 0 otherwise.
void bcpyle(uint_least8_t *dst, int dstbit, const uint_least8_t *src, int srcbit, size_t n)
Copies n bits from a source to a destination buffer.
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.
#define CO_DEFTYPE_UNSIGNED16
The data type (and object index) of a 16-bit unsigned integer.
This header file is part of the utilities library; it contains the byte order (endianness) function d...
int co_type_is_basic(co_unsigned16_t type)
Returns 1 if the specified (static) data type is a basic type, and 0 if not.
This is the internal header file of the CANopen library.
co_unsigned32_t co_dev_get_dummy(const co_dev_t *dev)
Returns the data types supported by a CANopen device for mapping dummy entries in PDOs (one bit for e...
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.
co_unsigned32_t co_sub_up_ind(const co_sub_t *sub, struct co_sdo_req *req)
Invokes the upload indication function of a CANopen sub-object, registered with co_sub_set_up_ind().
#define CAN_MAX_LEN
The maximum number of bytes in the payload of a CAN format frame.
#define CO_PDO_COBID_VALID
The bit in the PDO COB-ID specifying whether the PDO exists and is valid.
co_unsigned8_t n
Highest sub-index supported.
#define CO_SDO_AC_PDO_LEN
SDO abort code: The number and length of the objects to be mapped would exceed the PDO length...
#define CO_DEFTYPE_UNSIGNED8
The data type (and object index) of an 8-bit unsigned integer.
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.
void stle_u64(uint_least8_t dst[8], uint_least64_t x)
Stores a 64-bit unsigned integer in little-endian byte order.
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...
#define CO_SDO_AC_NO_WRITE
SDO abort code: Attempt to write a read only object.
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.
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.
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...
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...
co_sub_t * co_dev_find_sub(const co_dev_t *dev, co_unsigned16_t idx, co_unsigned8_t subidx)
Finds a sub-object in the object dictionary of a CANopen device.
#define CO_SDO_AC_NO_SUB
SDO abort code: Sub-index does not exist.
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.
size_t nbyte
The number of bytes available at buf.
This header file is part of the CANopen library; it contains the device description declarations...
const void * buf
A pointer to the next bytes to be uploaded/downloaded.
co_unsigned32_t map[0x40]
An array of objects to be mapped.
co_sub_t * co_obj_find_sub(const co_obj_t *obj, co_unsigned8_t subidx)
Finds a sub-object in a CANopen object.
co_unsigned32_t co_sub_dn_ind(co_sub_t *sub, struct co_sdo_req *req)
Invokes the download indication function of a CANopen sub-object, registered with co_sub_set_dn_ind()...
This header file is part of the CAN library; it contains the CAN frame declarations.
uint_least64_t ldle_u64(const uint_least8_t src[8])
Loads a 64-bit unsigned integer in little-endian byte order.
co_unsigned16_t inhibit
Inhibit time.
This header file is part of the CANopen library; it contains the object dictionary declarations...
co_obj_t * co_dev_find_obj(const co_dev_t *dev, co_unsigned16_t idx)
Finds an object in the object dictionary of a CANopen device.
co_unsigned8_t trans
Transmission type.
int co_sdo_req_last(const struct co_sdo_req *req)
Returns 1 if the specified request includes the last segment, and 0 otherwise.
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.
#define CO_SDO_AC_NO_PDO
SDO abort code: Object cannot be mapped to the PDO.
#define CO_SDO_AC_NO_OBJ
SDO abort code: Object does not exist in the object dictionary.
This header file is part of the CANopen library; it contains the Process Data Object (PDO) declaratio...