CANopen Master Documentation
Version 6.06.04
Loading...
Searching...
No Matches
com_defs.h File Reference

Detailed Description

The file com_defs.h holds global definitions, constants and structures for the CANopen Master protocol stack. The files 'canopen.h' and 'com_conf.h' are included by this header.

+ Include dependency graph for com_defs.h:

Macros

#define COM_VERSION_MAJOR   6
 
#define COM_VERSION_MINOR   06
 
#define COM_VERSION_BUILD   04
 
#define ComNetValid(a)   ( (a >= COM_NET_MAX) ? eCOM_ERR_NET_VALUE : eCOM_ERR_NONE)
 

Typedefs

typedef int32_t ComStatus_tv
 
typedef uint8_t ComSdoStatus_tv
 

Enumerations

enum  ComErr_e {
  eCOM_ERR_NONE = 0 ,
  eCOM_ERR_CAN = -1 ,
  eCOM_ERR_CAN_BITRATE = -2 ,
  eCOM_ERR_CAN_FUNCTION = -3 ,
  eCOM_ERR_PARM = -10 ,
  eCOM_ERR_NET = -20 ,
  eCOM_ERR_NET_VALUE = -21 ,
  eCOM_ERR_NODE = -30 ,
  eCOM_ERR_NODE_ID = -31 ,
  eCOM_ERR_NODE_DEFINED = -32 ,
  eCOM_ERR_NODE_UNDEFINED = -33 ,
  eCOM_ERR_COB = -40 ,
  eCOM_ERR_COB_ID_VALUE = -41 ,
  eCOM_ERR_COB_TYPE = -42 ,
  eCOM_ERR_COB_DLC = -43 ,
  eCOM_ERR_COB_TIMER = -44 ,
  eCOM_ERR_SERVICE = -50 ,
  eCOM_ERR_SERVICE_MODE = -52 ,
  eCOM_ERR_SERVICE_PARAM = -53 ,
  eCOM_ERR_SDO_CLIENT = -60 ,
  eCOM_ERR_SDO_CLIENT_VALUE = -61 ,
  eCOM_ERR_SDO_CLIENT_BUSY = -62 ,
  eCOM_ERR_PDO = -70 ,
  eCOM_ERR_PDO_NUMBER = -71
}
 
enum  ComBuf_e {
  eCOM_BUF_NMT = eCP_BUFFER_1 ,
  eCOM_BUF_SYNC = eCP_BUFFER_2 ,
  eCOM_BUF_EMCY_PROD = eCP_BUFFER_3 ,
  eCOM_BUF_NMT_HB_PROD = eCP_BUFFER_4 ,
  eCOM_BUF_NMT_HB_CONS = eCP_BUFFER_5 ,
  eCOM_BUF_LSS_CLN_RCV = eCP_BUFFER_8 ,
  eCOM_BUF_LSS_SRV_TRM = eCP_BUFFER_8 ,
  eCOM_BUF_LSS_CLN_TRM = eCP_BUFFER_9 ,
  eCOM_BUF_LSS_SRV_RCV = eCP_BUFFER_9 ,
  eCOM_BUF_MASTER_RCV = eCP_BUFFER_10 ,
  eCOM_BUF_MASTER_TRM = eCP_BUFFER_11 ,
  eCOM_BUF_TIME = eCP_BUFFER_12 ,
  eCOM_BUF_EMCY_CONS = eCP_BUFFER_13 ,
  eCOM_BUF_SDO_CLN_RCV = eCP_BUFFER_14 ,
  eCOM_BUF_SDO_CLN_TRM = eCOM_BUF_SDO_CLN_RCV + COM_SDO_CLIENT_MAX ,
  eCOM_BUF_PDO_PROD = eCOM_BUF_SDO_CLN_TRM + COM_SDO_CLIENT_MAX ,
  eCOM_BUF_GLOBAL_EXT_RCV ,
  eCOM_BUF_GLOBAL_STD_RCV
}
 
enum  ComSdo_e {
  eCOM_SDO_READ_OK ,
  eCOM_SDO_READ1_OK ,
  eCOM_SDO_READ2_OK ,
  eCOM_SDO_READ3_OK ,
  eCOM_SDO_READ4_OK ,
  eCOM_SDO_READ_SEG_OK ,
  eCOM_SDO_WRITE_OK ,
  eCOM_SDO_ERR_TOGGLE_BIT = 20 ,
  eCOM_SDO_ERR_TIMEOUT ,
  eCOM_SDO_ERR_COMMAND ,
  eCOM_SDO_ERR_BLOCK_SIZE ,
  eCOM_SDO_ERR_BLOCK_SEQUENCE ,
  eCOM_SDO_ERR_BLOCK_CRC ,
  eCOM_SDO_ERR_MEMORY ,
  eCOM_SDO_ERR_ACCESS_UNSUPPORTED ,
  eCOM_SDO_ERR_ACCESS_WO ,
  eCOM_SDO_ERR_ACCESS_RO ,
  eCOM_SDO_ERR_NO_OBJECT ,
  eCOM_SDO_ERR_MAPPING_OBJECT ,
  eCOM_SDO_ERR_MAPPING_LENGTH ,
  eCOM_SDO_ERR_GENERAL_PARAMETER ,
  eCOM_SDO_ERR_GENERAL_DEVICE ,
  eCOM_SDO_ERR_HARDWARE ,
  eCOM_SDO_ERR_DATATYPE ,
  eCOM_SDO_ERR_DATATYPE_HIGH ,
  eCOM_SDO_ERR_DATATYPE_LOW ,
  eCOM_SDO_ERR_NO_SUB_INDEX ,
  eCOM_SDO_ERR_VALUE_RANGE ,
  eCOM_SDO_ERR_VALUE_HIGH ,
  eCOM_SDO_ERR_VALUE_LOW ,
  eCOM_SDO_ERR_VALUE_MIN_MAX ,
  eCOM_SDO_ERR_GENERAL ,
  eCOM_SDO_ERR_DATA_STORE ,
  eCOM_SDO_ERR_DATA_STORE_LOCAL ,
  eCOM_SDO_ERR_DATA_STORE_STATE ,
  eCOM_SDO_ERR_OBJECT_DICTIONARY ,
  eCOM_SDO_ERR_NO_DATA ,
  eCOM_SDO_ERR_DEFER_RESPONSE ,
  eCOM_SDO_ERR_MAX
}
 
enum  ComNet_e {
  eCOM_NET_1 = 0 ,
  eCOM_NET_2 ,
  eCOM_NET_3 ,
  eCOM_NET_4 ,
  eCOM_NET_5 ,
  eCOM_NET_6 ,
  eCOM_NET_7 ,
  eCOM_NET_8
}
 

Macro Definition Documentation

◆ ComNetValid

#define ComNetValid (   a)    ( (a >= COM_NET_MAX) ? eCOM_ERR_NET_VALUE : eCOM_ERR_NONE)

Check valid network.

This macro returns an error code if the parameter is not within the valid network range.

Typedef Documentation

◆ ComSdoStatus_tv

Callback handler used by the object dictionary (see ComSdoHandler_Fn) return a value of type ComSdoStatus_tv, which is defined as data type uint8_t by default.

◆ ComStatus_tv

All functions of the CANopen Master Protocol Stack have a generic return value, which is defined as data type int32_t by default. A negative value of ComStatus_tv denotes an error, defined by the enumeration ComErr_e.

Enumeration Type Documentation

◆ ComBuf_e

enum ComBuf_e

Message buffer allocation.

Each CANopen service (i.e. identifier) is assigned to a specific message buffer in the CAN controller. For BasicCAN controllers the message buffers must be emulated in software (refer to CANpie).

Enumerator
eCOM_BUF_NMT 

Buffer 1 : NMT
Identifier: 000h (fixed)
Direction : Transmit / Receive

eCOM_BUF_SYNC 

Buffer 2 : SYNC
Identifier: 080h (variable)
Direction : Transmit / Receive

eCOM_BUF_EMCY_PROD 

Buffer 3 : EMCY producer
Identifier: 080h + Node-ID (variable)
Direction : Transmit

eCOM_BUF_NMT_HB_PROD 

Buffer 4 : Heartbeat producer
Identifier: 700h + Node-ID (fixed)
Direction : Transmit

eCOM_BUF_NMT_HB_CONS 

Buffer 5 : Heartbeat consumer
Identifier: 700h (masked)
Direction : Receive

eCOM_BUF_LSS_CLN_RCV 

Buffer 8 : LSS client
Identifier: 7E4h (fixed)
Direction : Receive

eCOM_BUF_LSS_CLN_TRM 

Buffer 9 : LSS client
Identifier: 7E5h (fixed)
Direction : Transmit

eCOM_BUF_MASTER_RCV 

Buffer 10 : NMT master
Identifier: 070h (masked)
Direction : Receive

eCOM_BUF_MASTER_TRM 

Buffer 11 : NMT master
Identifier: 072h, 073h, 075h, 076h
Direction : Transmit

eCOM_BUF_TIME 

Buffer 12 : TIME
Identifier: 100h (variable)
Direction : Transmit / Receive

eCOM_BUF_EMCY_CONS 

Buffer 13 : EMCY consumer
Identifier: 80h (masked)
Direction : Receive

eCOM_BUF_SDO_CLN_RCV 

SDO client receive, (Buffer 14)

eCOM_BUF_SDO_CLN_TRM 

SDO client transmit, (Buffer = 13 + COM_SDO_CLIENT_MAX)

eCOM_BUF_PDO_PROD 

Buffer for PDO transmission (Buffer = 12 + 2 * COM_SDO_CLIENT_MAX) The FIFO size of this buffer is configured by COM_PDO_TRM_FIFO_SIZE.

eCOM_BUF_GLOBAL_EXT_RCV 

Buffer for global message reception, extended frame (2.0B)

eCOM_BUF_GLOBAL_STD_RCV 

Buffer for global message reception, standard frame (2.0A)

◆ ComErr_e

enum ComErr_e

Error Codes of CANopen Master protocol stack.

All error codes of the CANopen Master protocol stack have the prefix eCOM_ERR_. Error return values are always negative, so it is quite simple to check in general if a functions fails.

Example:

{
// handle error here
}
@ eCOM_NET_3
Definition com_defs.h:729
@ eCOM_ERR_NONE
Definition com_defs.h:155
ComStatus_tv ComMgrStart(uint8_t ubNetV)
Start the CANopen Master.
Enumerator
eCOM_ERR_NONE 

No error

eCOM_ERR_CAN 

Generic CAN driver error

eCOM_ERR_CAN_BITRATE 

Setting of CAN bit-rate failed

eCOM_ERR_CAN_FUNCTION 

CAN function failed

eCOM_ERR_PARM 

Parameter out of range (generic)

eCOM_ERR_NET 

Generic Network error

eCOM_ERR_NET_VALUE 

Network index out of range, not valid

eCOM_ERR_NODE 

Generic Node error

eCOM_ERR_NODE_ID 

Node ID (device address) is not valid or out of range

eCOM_ERR_NODE_DEFINED 

Node is already defined

eCOM_ERR_NODE_UNDEFINED 

Node is not defined

eCOM_ERR_COB 

Generic COB error

eCOM_ERR_COB_ID_VALUE 

Identifier is out of range

eCOM_ERR_COB_TYPE 

COB type out of range

eCOM_ERR_COB_DLC 

COB DLC out of range

eCOM_ERR_COB_TIMER 

COB timer out of range

eCOM_ERR_SERVICE 

Generic Service error

eCOM_ERR_SERVICE_MODE 

Service mode error The service (NMT, SYNC, etc) is in a mode that does not allow this operation

eCOM_ERR_SERVICE_PARAM 

Service parameter error The service (NMT, SYNC, etc) does not accept this parameter

eCOM_ERR_SDO_CLIENT 

Generic SDO / USDO client error

eCOM_ERR_SDO_CLIENT_VALUE 

Value for SDO / USDO client is out of range

eCOM_ERR_SDO_CLIENT_BUSY 

All available SDO / USDO clients are busy

eCOM_ERR_PDO 

Generic PDO error

eCOM_ERR_PDO_NUMBER 

Number for PDO is out of range

◆ ComNet_e

enum ComNet_e

This enumeration defines logical network numbers for the CANopen Master protocol stack. The logical network number is assigned to a physical CAN interface by means of the ComMgrInit() function. Please note that the maximum value that can be used from this enumeration is limited by the configuration symbol COM_NET_MAX.

Enumerator
eCOM_NET_1 

CANopen Master network #1

eCOM_NET_2 

CANopen Master network #2

eCOM_NET_3 

CANopen Master network #3

eCOM_NET_4 

CANopen Master network #4

eCOM_NET_5 

CANopen Master network #5

eCOM_NET_6 

CANopen Master network #6

eCOM_NET_7 

CANopen Master network #7

eCOM_NET_8 

CANopen Master network #8

◆ ComSdo_e

enum ComSdo_e

Return code for SDO callbacks.

The following codes are used by callback functions for object dictionary access by Service Data Objects.

Enumerator
eCOM_SDO_READ_OK 

Generic read success (any number of bytes)

eCOM_SDO_READ1_OK 

Read success, 1 byte of data in expedited SDO

eCOM_SDO_READ2_OK 

Read success, 2 bytes of data in expedited SDO

eCOM_SDO_READ3_OK 

Read success, 3 bytes of data in expedited SDO

eCOM_SDO_READ4_OK 

Read success, 4 bytes of data in expedited SDO

eCOM_SDO_READ_SEG_OK 

Read success, start segmented SDO

eCOM_SDO_WRITE_OK 

Write success

eCOM_SDO_ERR_TOGGLE_BIT 

Toggle bit not alternated

eCOM_SDO_ERR_TIMEOUT 

SDO protocol timed out

eCOM_SDO_ERR_COMMAND 

Client/server command specifier not valid or unknown

eCOM_SDO_ERR_BLOCK_SIZE 

Invalid block size (block mode only)

eCOM_SDO_ERR_BLOCK_SEQUENCE 

Invalid sequence number (block mode only)

eCOM_SDO_ERR_BLOCK_CRC 

CRC error (block mode only)

eCOM_SDO_ERR_MEMORY 

Out of memory

eCOM_SDO_ERR_ACCESS_UNSUPPORTED 

Unsupported access to an object

eCOM_SDO_ERR_ACCESS_WO 

Attempt to read a write only object

eCOM_SDO_ERR_ACCESS_RO 

Attempt to write a read only object

eCOM_SDO_ERR_NO_OBJECT 

Object does not exist in the object dictionary

eCOM_SDO_ERR_MAPPING_OBJECT 

Object cannot be mapped to the PDO

eCOM_SDO_ERR_MAPPING_LENGTH 

The number and length of the objects to be mapped would exceed PDO length

eCOM_SDO_ERR_GENERAL_PARAMETER 

General parameter incompatibility reason

eCOM_SDO_ERR_GENERAL_DEVICE 

General internal incompatibility in the device

eCOM_SDO_ERR_HARDWARE 

Access failed due to an hardware error

eCOM_SDO_ERR_DATATYPE 

Data type does not match, length of service parameter does not match

eCOM_SDO_ERR_DATATYPE_HIGH 

Data type does not match, length of service parameter too high

eCOM_SDO_ERR_DATATYPE_LOW 

Data type does not match, length of service parameter too low

eCOM_SDO_ERR_NO_SUB_INDEX 

Sub-index does not exist

eCOM_SDO_ERR_VALUE_RANGE 

Invalid value for parameter (download only).

eCOM_SDO_ERR_VALUE_HIGH 

Value of parameter written too high (download only).

See also
SDO_ERR_VALUE_HIGH
eCOM_SDO_ERR_VALUE_LOW 

Value of parameter written too low (download only).

See also
SDO_ERR_VALUE_LOW
eCOM_SDO_ERR_VALUE_MIN_MAX 

Maximum value is less than minimum value.

See also
SDO_ERR_VALUE_MIN_MAX
eCOM_SDO_ERR_GENERAL 

General error

eCOM_SDO_ERR_DATA_STORE 

Data cannot be transferred or stored to the application.

eCOM_SDO_ERR_DATA_STORE_LOCAL 

Data cannot be transferred or stored to the application because of local control.

eCOM_SDO_ERR_DATA_STORE_STATE 

Data cannot be transferred or stored to the application because of the present device state.

See also
SDO_ERR_DATA_STORE_STATE
eCOM_SDO_ERR_OBJECT_DICTIONARY 

Object dictionary dynamic generation fails or no object dictionary is present (e.g. object dictionary is generated from file and generation fails because of an file error).

eCOM_SDO_ERR_NO_DATA 

Data actually not available for access