Lely core libraries  2.3.4
pdo.h File Reference
#include <lely/co/type.h>
Include dependency graph for pdo.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  co_pdo_comm_par
 A PDO communication parameter record. More...
 
struct  co_pdo_map_par
 A PDO mapping parameter record. More...
 

Macros

#define CO_NUM_PDOS   512
 The maximum number of Receive/Transmit-PDOs.
 
#define CO_PDO_NUM_MAPS   0x40u
 The maximum number of mapped application objects in a single PDO. More...
 
#define CO_PDO_COBID_VALID   UINT32_C(0x80000000)
 The bit in the PDO COB-ID specifying whether the PDO exists and is valid.
 
#define CO_PDO_COBID_RTR   UINT32_C(0x40000000)
 The bit in the PDO COB-ID specifying whether RTR is allowed.
 
#define CO_PDO_COBID_FRAME   UINT32_C(0x20000000)
 The bit in the PDO COB-ID specifying whether to use an 11-bit (0) or 29-bit (1) CAN-ID.
 
#define CO_PDO_MAP_SAM_MPDO   0xfe
 The value of sub-index 0 of the PDO mapping parameter record indicating a a source address mode multiplex PDO (SAM-MPDO).
 
#define CO_PDO_MAP_DAM_MPDO   0xff
 The value of sub-index 0 of the PDO mapping parameter record indicating a a destination address mode multiplex PDO (DAM-MPDO).
 
#define CO_DEFSTRUCT_PDO_COMM_PAR   0x0020
 The data type (and object index) of a PDO communication parameter record.
 
#define CO_PDO_COMM_PAR_INIT
 The static initializer from struct co_pdo_comm_par.
 
#define CO_DEFSTRUCT_PDO_MAP_PAR   0x0021
 The data type (and object index) of a PDO mapping parameter record.
 
#define CO_PDO_MAP_PAR_INIT
 The static initializer from struct co_pdo_map_par.
 

Functions

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. More...
 
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. More...
 
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 - 15FF (RPDO communication parameter). More...
 
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 (RPDO mapping parameter). More...
 
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. More...
 
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. More...
 
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 - 19FF (TPDO communication parameter). More...
 
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 (TPDO mapping parameter). More...
 
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 transmitted with a SAM-MPDO. More...
 
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..1FFF) and can be mapped to a local object with a SAM-MPDO. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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 local SDO upload request. More...
 

Detailed Description

This header file is part of the CANopen library; it contains the Process Data Object (PDO) declarations.

Author
J. S. Seldenthuis jseld.nosp@m.enth.nosp@m.uis@l.nosp@m.ely..nosp@m.com

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Definition in file pdo.h.

Macro Definition Documentation

◆ CO_PDO_NUM_MAPS

#define CO_PDO_NUM_MAPS   0x40u

The maximum number of mapped application objects in a single PDO.

This value is also the highest sub-index in the PDO mapping parameter object.

Definition at line 34 of file pdo.h.

Function Documentation

◆ 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.

Parameters
deva pointer to a CANopen device.
idxthe object index.
subidxthe object sub-index.
Returns
0 if the object is valid and can be mapped, or an SDO abort code on error.

Definition at line 51 of file pdo.c.

◆ 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.

This function disables the RPDO before configuring the parameters and re-enables it on success.

Parameters
deva pointer to a CANopen device.
numthe PDO number (in the range [1..512]).
comma pointer to the communication parameters.
mapa pointer to the mapping parameters.
Returns
0 on success, or an SDO abort code on error.
See also
co_dev_cfg_rpdo_comm(), co_dev_cfg_rpdo_map()

Definition at line 80 of file pdo.c.

◆ 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 - 15FF (RPDO communication parameter).

Parameters
deva pointer to a CANopen device.
numthe PDO number (in the range [1..512]).
para pointer to the communication parameters.
Returns
0 on success, or an SDO abort code on error.

Definition at line 106 of file pdo.c.

◆ 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 (RPDO mapping parameter).

It is the responsibility of the caller to disable the RPDO before changing the mapping.

Parameters
deva pointer to a CANopen device.
numthe PDO number (in the range [1..512]).
para pointer to the mapping parameters.
Returns
0 on success, or an SDO abort code on error.

Definition at line 116 of file pdo.c.

◆ 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.

Parameters
deva pointer to a CANopen device.
idxthe object index.
subidxthe object sub-index.
Returns
0 if the object is valid and can be mapped, or an SDO abort code on error.

Definition at line 130 of file pdo.c.

◆ 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.

This function disables the TPDO before configuring the parameters and re-enables it on success.

Parameters
deva pointer to a CANopen device.
numthe PDO number (in the range [1..512]).
comma pointer to the communication parameters.
mapa pointer to the mapping parameters.
Returns
0 on success, or an SDO abort code on error.
See also
co_dev_cfg_tpdo_comm(), co_dev_cfg_tpdo_map()

Definition at line 153 of file pdo.c.

◆ 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 - 19FF (TPDO communication parameter).

Parameters
deva pointer to a CANopen device.
numthe PDO number (in the range [1..512]).
para pointer to the communication parameters.
Returns
0 on success, or an SDO abort code on error.

Definition at line 179 of file pdo.c.

◆ 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 (TPDO mapping parameter).

It is the responsibility of the caller to disable the TPDO before changing the mapping.

Parameters
deva pointer to a CANopen device.
numthe PDO number (in the range [1..512]).
para pointer to the mapping parameters.
Returns
0 on success, or an SDO abort code on error.

Definition at line 189 of file pdo.c.

◆ 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 transmitted with a SAM-MPDO.

Note that this function does not check if the object is valid and can be mapped into a TPDO.

Parameters
deva pointer to a CANopen device.
idxthe object index.
subidxthe object sub-index.
Returns
1 if the object was found in the object scanner list, and 0 if not.
See also
co_dev_chk_tpdo()

Definition at line 203 of file pdo.c.

◆ 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..1FFF) and can be mapped to a local object with a SAM-MPDO.

Note that this function does not check if the local object is valid and can be mapped to an RPDO.

Parameters
deva pointer to a CANopen device.
idthe remote node-ID (in the range [1..127]).
idxthe remote object index.
subidxthe remote object sub-index.
pidxthe address at which to store the local object index (can be NULL).
psubidxthe address at which to store the object sub-index (can be NULL).
Returns
1 if the remote object was found in the object dispatching list, and 0 if not.
See also
co_dev_chk_rpdo()

Definition at line 245 of file pdo.c.

◆ 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.

Parameters
para pointer to the PDO mapping parameters.
vala pointer to the values to map.
nthe number of values at val.
bufthe address at which to store the mapped values (can be NULL).
pnthe address of a value containing the size (in bytes) of the buffer at buf. On exit, if pn is not NULL, *pn contains the number of bytes that would have been written had the buffer at buf been sufficiently large.
Returns
0 on success, or an SDO abort code on error.
See also
co_pdo_unmap()

Definition at line 299 of file pdo.c.

◆ 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.

Parameters
para pointer to the PDO mapping parameters.
bufa pointer to the mapped values.
nthe number of bytes at buf.
valthe address at which to store the unmapped values (can be NULL).
pnthe address of a value containing the size (in number of values) of the buffer at val. On exit, if pn is not NULL, *pn contains the number of values that would have been written had the buffer at val been sufficiently large.
Returns
0 on success, or an SDO abort code on error.
See also
co_pdo_map()

Definition at line 333 of file pdo.c.

◆ 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.

Parameters
para pointer to the PDO mapping parameters.
deva pointer to a CANopen device.
reqa pointer to the CANopen SDO download request used for writing to the object dictionary.
bufa pointer to the mapped values.
nthe number of bytes at buf.
chka flag indicating whether co_dev_chk_rpdo() should be invoked before writing values to the object dictionary.
Returns
0 on success, or an SDO abort code on error.
See also
co_dev_chk_rpdo(), co_dev_map_sam_mpdo()

Definition at line 368 of file pdo.c.

◆ 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.

Note that this function does not support multiplex PDOs (see co_sam_mpdo_up()).

Parameters
para pointer to the PDO mapping parameters.
deva pointer to a CANopen device.
reqa pointer to the CANopen SDO upload request used for reading from the object dictionary.
bufthe address at which to store the mapped values (can be NULL).
pnthe address of a value containing the size (in bytes) of the buffer at buf. On exit, if pn is not NULL, *pn contains the number of bytes that would have been written had the buffer at buf been sufficiently large.
chka flag indicating whether co_dev_chk_tpdo() should be invoked before reading values from the object dictionary.
Returns
0 on success, or an SDO abort code on error.
See also
co_dev_chk_tpdo()

Definition at line 432 of file pdo.c.

◆ 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 local SDO upload request.

Parameters
deva pointer to a CANopen device.
idxthe object index.
subidxthe object sub-index.
reqa pointer to the CANopen SDO upload request used for reading from the object dictionary.
bufthe address at which to store the mapped value (can be NULL).
Returns
0 on success, or an SDO abort code on error.
See also
co_dev_chk_tpdo(), co_dev_chk_sam_mpdo()

Definition at line 483 of file pdo.c.