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,
80 co_unsigned32_t ac = 0;
106 return co_dev_cfg_pdo_comm(dev, 0x1400 + num - 1, par);
116 return co_dev_cfg_pdo_map(dev, 0x1600 + num - 1, par);
152 co_unsigned32_t ac = 0;
178 return co_dev_cfg_pdo_comm(dev, 0x1800 + num - 1, par);
188 return co_dev_cfg_pdo_map(dev, 0x1a00 + num - 1, par);
193 co_unsigned8_t
n, uint8_t *buf,
size_t *pn)
202 for (
size_t i = 0; i < par->
n; i++) {
203 co_unsigned8_t len = par->
map[i] & 0xff;
208 uint8_t tmp[
sizeof(co_unsigned64_t)] = { 0 };
210 if (buf && pn && offset + len <= *pn * 8)
211 bcpyle(buf, offset, tmp, 0, len);
217 *pn = (offset + 7) / 8;
224 co_unsigned64_t *val, co_unsigned8_t *pn)
233 for (
size_t i = 0; i < par->
n; i++) {
234 co_unsigned8_t len = par->
map[i] & 0xff;
239 uint8_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 uint8_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];
270 co_unsigned16_t idx = (map >> 16) & 0xffff;
271 co_unsigned8_t subidx = (map >> 8) & 0xff;
272 co_unsigned8_t len = map & 0xff;
288 bcpyle(tmp, 0, buf, offset, len);
290 req->
size = (len + 7) / 8;
306 struct co_sdo_req *req, uint8_t *buf,
size_t *pn)
312 co_unsigned32_t ac = 0;
315 for (
size_t i = 0; i <
MIN(par->
n, 0x40u); i++) {
316 co_unsigned32_t map = par->
map[i];
317 co_unsigned16_t idx = (map >> 16) & 0xffff;
318 co_unsigned8_t subidx = (map >> 8) & 0xff;
319 co_unsigned8_t len = map & 0xff;
338 if (buf && pn && offset + len <= *pn * 8)
345 *pn = (offset + 7) / 8;
350 static co_unsigned32_t
351 co_dev_cfg_pdo_comm(
const co_dev_t *dev, co_unsigned16_t idx,
357 co_unsigned32_t ac = 0;
364 co_unsigned8_t
n = co_obj_get_val_u8(obj, 0x00);
369 if (par->
n >= 1 && !ac) {
377 if (par->
n >= 2 && !ac) {
385 if (par->
n >= 3 && !ac) {
394 if (par->
n >= 5 && !ac) {
402 if (par->
n >= 6 && !ac) {
412 static co_unsigned32_t
413 co_dev_cfg_pdo_map(
const co_dev_t *dev, co_unsigned16_t idx,
419 co_unsigned32_t ac = 0;
435 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_pdo_dn(const struct co_pdo_map_par *par, co_dev_t *dev, struct co_sdo_req *req, const uint8_t *buf, size_t n)
Writes mapped PDO values to the object dictionary through a local SDO download request.
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()...
void stle_u64(void *ptr, uint_least64_t x)
Stores a 64-bit unsigned integer in little-endian byte order.
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...
size_t size
The total size (in bytes) of the value to be uploaded/downloaded.
#define CO_ACCESS_WRITE
The object can be written.
uint_least64_t ldle_u64(const void *ptr)
Loads a 64-bit unsigned integer in little-endian byte order.
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.
void bcpyle(void *dst, int dstbit, const void *src, int srcbit, size_t n)
Copies n bits from a source to a destination buffer.
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.
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.
co_unsigned32_t co_pdo_unmap(const struct co_pdo_map_par *par, const uint8_t *buf, size_t n, co_unsigned64_t *val, co_unsigned8_t *pn)
Unmaps a PDO into its constituent values.
#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_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 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.
This header file is part of the CAN library; it contains the CAN frame declarations.
#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_pdo_map(const struct co_pdo_map_par *par, const co_unsigned64_t *val, co_unsigned8_t n, uint8_t *buf, size_t *pn)
Maps values into a PDO.
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.
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.
#define __unlikely(x)
Indicates to the compiler that the expression is most-likely false.
co_unsigned32_t co_pdo_up(const struct co_pdo_map_par *par, const co_dev_t *dev, struct co_sdo_req *req, uint8_t *buf, size_t *pn)
Reads mapped PDO values from the object dictionary through a local SDO upload request.
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...
This header file is part of the CANopen library; it contains the device description declarations...
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...
#define CO_SDO_AC_NO_SUB
SDO abort code: Sub-index does not exist.
size_t nbyte
The number of bytes available at buf.
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_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_sub_t * co_obj_find_sub(const co_obj_t *obj, co_unsigned8_t subidx)
Finds a sub-object in a CANopen object.
#define CAN_MAX_LEN
The maximum number of bytes in the payload of a CAN format frame.
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()...
co_unsigned16_t inhibit
Inhibit time.
This header file is part of the CANopen library; it contains the object dictionary declarations...
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.
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_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...