CANopen Slave Documentation
Version 6.16.04
Loading...
Searching...
No Matches
canpie.h File Reference

Detailed Description

This file holds constants and structures used within CANpie FD. All functions, structures, defines and constants in CANpie FD have the prefix "Cp". The following table shows the used nomenclature:

CANpie code Nomenclature
Core functions CpCore<Name>
Message access functions CpMsg<Name>
Structures Cp<Name>_ts
Definitions CP_<NAME>
Enumerations eCP_<NAME>
+ Include dependency graph for canpie.h:

Data Structures

struct  CpTime_s
 
struct  CpCanMsg_s
 
struct  CpHdi_s
 
struct  CpStatistic_s
 
struct  CpState_s
 

Macros

#define CP_AUTOBAUD   0
 
#define CP_BUFFER_MAX   8
 
#define CP_CAN_FD   0
 
#define CP_CAN_MSG_MACRO   0
 
#define CP_CAN_MSG_MARKER   0
 
#define CP_CAN_MSG_TIME   0
 
#define CP_CAN_MSG_USER   1
 
#define CP_CHANNEL_MAX   1
 
#define CP_SMALL_CODE   0
 
#define CP_STATISTIC   0
 
#define CP_VERSION_MAJOR   3
 
#define CP_VERSION_MINOR   10
 
#define CP_MASK_STD_FRAME   ((uint32_t) 0x000007FF)
 
#define CP_MASK_EXT_FRAME   ((uint32_t) 0x1FFFFFFF)
 
#define CP_MASK_MSG_FORMAT   ((uint8_t) 0x03)
 
#define CP_MSG_CTRL_EXT_BIT   ((uint8_t) 0x01)
 
#define CP_MSG_CTRL_FDF_BIT   ((uint8_t) 0x02)
 
#define CP_MSG_CTRL_RTR_BIT   ((uint8_t) 0x04)
 
#define CP_MSG_CTRL_OVR_BIT   ((uint8_t) 0x08)
 
#define CP_MSG_CTRL_RPC_BIT   ((uint8_t) 0x10)
 
#define CP_MSG_CTRL_BRS_BIT   ((uint8_t) 0x40)
 
#define CP_MSG_CTRL_ESI_BIT   ((uint8_t) 0x80)
 
#define CP_MSG_FORMAT_CBFF   ((uint8_t) 0x00)
 
#define CP_MSG_FORMAT_CEFF   (CP_MSG_CTRL_EXT_BIT)
 
#define CP_MSG_FORMAT_FBFF   (CP_MSG_CTRL_FDF_BIT)
 
#define CP_MSG_FORMAT_FEFF   (CP_MSG_CTRL_FDF_BIT | CP_MSG_CTRL_EXT_BIT)
 
#define CP_DATA_SIZE   ( 8)
 

Enumerations

enum  CpErr_e {
  eCP_ERR_NONE = 0 ,
  eCP_ERR_GENERIC = 1 ,
  eCP_ERR_HARDWARE = 2 ,
  eCP_ERR_INIT_FAIL = 3 ,
  eCP_ERR_INIT_READY = 4 ,
  eCP_ERR_INIT_MISSING = 5 ,
  eCP_ERR_RCV_EMPTY = 6 ,
  eCP_ERR_RCV_OVERRUN = 7 ,
  eCP_ERR_TRM_FULL = 8 ,
  eCP_ERR_CAN_MESSAGE = 10 ,
  eCP_ERR_CAN_ID = 11 ,
  eCP_ERR_CAN_DLC = 12 ,
  eCP_ERR_FIFO_EMPTY = 20 ,
  eCP_ERR_FIFO_WAIT = 21 ,
  eCP_ERR_FIFO_FULL = 22 ,
  eCP_ERR_FIFO_SIZE = 23 ,
  eCP_ERR_FIFO_PARAM = 24 ,
  eCP_ERR_BUS_PASSIVE = 30 ,
  eCP_ERR_BUS_OFF = 31 ,
  eCP_ERR_BUS_WARNING = 32 ,
  eCP_ERR_CHANNEL = 40 ,
  eCP_ERR_REGISTER = 41 ,
  eCP_ERR_BITRATE = 42 ,
  eCP_ERR_BUFFER = 43 ,
  eCP_ERR_PARAM = 44 ,
  eCP_ERR_NOT_SUPPORTED = 50
}
 
enum  CpCallback_e {
  eCP_CALLBACK_PROCESSED = 0 ,
  eCP_CALLBACK_PUSH_FIFO
}
 
enum  CpBitrate_e {
  eCP_BITRATE_NONE = -1 ,
  eCP_BITRATE_10K = 0 ,
  eCP_BITRATE_20K = 1 ,
  eCP_BITRATE_50K = 2 ,
  eCP_BITRATE_100K = 3 ,
  eCP_BITRATE_125K = 4 ,
  eCP_BITRATE_250K = 5 ,
  eCP_BITRATE_500K = 6 ,
  eCP_BITRATE_800K = 7 ,
  eCP_BITRATE_1M = 8 ,
  eCP_BITRATE_2M = 10 ,
  eCP_BITRATE_4M = 11 ,
  eCP_BITRATE_5M = 12 ,
  eCP_BITRATE_AUTO = 9 ,
  eCP_BITRATE_MAX = eCP_BITRATE_AUTO
}
 
enum  CpChannel_e {
  eCP_CHANNEL_NONE = 0 ,
  eCP_CHANNEL_1 ,
  eCP_CHANNEL_2 ,
  eCP_CHANNEL_3 ,
  eCP_CHANNEL_4 ,
  eCP_CHANNEL_5 ,
  eCP_CHANNEL_6 ,
  eCP_CHANNEL_7 ,
  eCP_CHANNEL_8
}
 
enum  CpMode_e {
  eCP_MODE_INIT = 0 ,
  eCP_MODE_STOP = 0 ,
  eCP_MODE_OPERATION = 1 ,
  eCP_MODE_START = 1 ,
  eCP_MODE_LISTEN_ONLY = 2 ,
  eCP_MODE_SLEEP = 3 ,
  eCP_MODE_SELF_TEST = 4
}
 
enum  CpState_e {
  eCP_STATE_INIT = 0 ,
  eCP_STATE_STOPPED = 0 ,
  eCP_STATE_SLEEPING = 1 ,
  eCP_STATE_BUS_ACTIVE = 2 ,
  eCP_STATE_BUS_WARN = 3 ,
  eCP_STATE_BUS_PASSIVE = 4 ,
  eCP_STATE_BUS_OFF = 5 ,
  eCP_STATE_PHY_FAULT = 10 ,
  eCP_STATE_PHY_H = 11 ,
  eCP_STATE_PHY_L = 12
}
 
enum  CpErrType_e {
  eCP_ERR_TYPE_NONE = 0 ,
  eCP_ERR_TYPE_BIT0 ,
  eCP_ERR_TYPE_BIT1 ,
  eCP_ERR_TYPE_STUFF ,
  eCP_ERR_TYPE_FORM ,
  eCP_ERR_TYPE_CRC ,
  eCP_ERR_TYPE_ACK
}
 
enum  CpBuffer_e {
  eCP_BUFFER_1 = 0 ,
  eCP_BUFFER_2 ,
  eCP_BUFFER_3 ,
  eCP_BUFFER_4 ,
  eCP_BUFFER_5 ,
  eCP_BUFFER_6 ,
  eCP_BUFFER_7 ,
  eCP_BUFFER_8 ,
  eCP_BUFFER_9 ,
  eCP_BUFFER_10 ,
  eCP_BUFFER_11 ,
  eCP_BUFFER_12 ,
  eCP_BUFFER_13 ,
  eCP_BUFFER_14 ,
  eCP_BUFFER_15 ,
  eCP_BUFFER_16
}
 
enum  CpBufferDir_e {
  eCP_BUFFER_DIR_RCV = 0 ,
  eCP_BUFFER_DIR_TRM
}
 
enum  CpRpc_e {
  eCP_RPC_NOOP = 0 ,
  eCP_RPC_MODE ,
  eCP_RPC_BITRATE ,
  eCP_RPC_MAX
}
 

Macro Definition Documentation

◆ CP_DATA_SIZE

#define CP_DATA_SIZE   ( 8)

The symbol CP_DATA_SIZE defines the maximum number of bytes which are transferred inside the data field of a CAN message. For classic CAN frames the maximum number of bytes is 8, for CAN FD frames the maximum number of bytes is 64.

Enumeration Type Documentation

◆ CpBitrate_e

Fixed bit-rates.

The values of the enumeration CpBitrate_e are used as parameter for the function CpCoreBitrate().

Enumerator
eCP_BITRATE_NONE 

No bit-rate defined

eCP_BITRATE_10K 

bit-rate 10 kBit/s

eCP_BITRATE_20K 

bit-rate 20 kBit/s

eCP_BITRATE_50K 

bit-rate 50 kBit/s

eCP_BITRATE_100K 

bit-rate 100 kBit/s

eCP_BITRATE_125K 

bit-rate 125 kBit/s

eCP_BITRATE_250K 

bit-rate 250 kBit/s

eCP_BITRATE_500K 

bit-rate 500 kBit/s

eCP_BITRATE_800K 

bit-rate 800 kBit/s

eCP_BITRATE_1M 

bit-rate 1 MBit/s

eCP_BITRATE_2M 

bit-rate 2 MBit/s (ISO CAN FD, data phase)

eCP_BITRATE_4M 

bit-rate 4 MBit/s (ISO CAN FD, data phase)

eCP_BITRATE_5M 

bit-rate 5 MBit/s (ISO CAN FD, data phase)

eCP_BITRATE_AUTO 

Use automatic bit-rate detection

◆ CpBuffer_e

enum CpBuffer_e

Buffer definition.

The enumeration CpBuffer_e is used to define a message buffer inside a FullCAN controller. The index for the first buffer starts at 0.

Enumerator
eCP_BUFFER_1 

Buffer number 1

eCP_BUFFER_2 

Buffer number 2

eCP_BUFFER_3 

Buffer number 3 ..

eCP_BUFFER_16 

Buffer number 16

◆ CpBufferDir_e

Buffer direction definition.

The enumeration CpBufferDir_e is used to define the direction of a message buffer (transmit or receive). The enumeration values are used by the function CpCoreBufferConfig().

Enumerator
eCP_BUFFER_DIR_RCV 

Message buffer direction is receive

eCP_BUFFER_DIR_TRM 

Message buffer direction is transmit

◆ CpCallback_e

Callback Return Codes.

These return values are used by the callback functions that can be installed by the function CpCoreIntFunctions().

Example

uint8_t MyCallback(CpCanMsg_ts * ptsCanMsgV, uint8_t ubBufferIdxV)
{
// Do something with IDs < 100
if( CpMsgGetIdentifier(ptsCanMsgV) < 100)
{
//.....
}
// Put all other messages into the FIFO
}
@ eCP_CALLBACK_PROCESSED
Definition canpie.h:619
@ eCP_CALLBACK_PUSH_FIFO
Definition canpie.h:624
uint32_t CpMsgGetIdentifier(const CpCanMsg_ts *ptsCanMsgV)
Get Identifier Value.
CAN message structure.
Definition canpie.h:1005


Enumerator
eCP_CALLBACK_PROCESSED 

Message was processed by callback and should not inserted in the FIFO

eCP_CALLBACK_PUSH_FIFO 

Message was not processed by callback and must be inserted in the FIFO

◆ CpChannel_e

Channel definition.

The physical CAN interfaces are numbered from 1 .. N (N: total number of physical CAN interfaces on the target system). The enumeration CpChannel_e lists up to 8 physical interfaces. The enumeration value eCP_CHANNEL_NONE denotes an invalid channel value.

Enumerator
eCP_CHANNEL_NONE 

CAN interface invalid

eCP_CHANNEL_1 

CAN interface 1

eCP_CHANNEL_2 

CAN interface 2

eCP_CHANNEL_3 

CAN interface 3

eCP_CHANNEL_4 

CAN interface 4

eCP_CHANNEL_5 

CAN interface 5

eCP_CHANNEL_6 

CAN interface 6

eCP_CHANNEL_7 

CAN interface 7

eCP_CHANNEL_8 

CAN interface 8

◆ CpErr_e

enum CpErr_e

CANpie Error codes.

All functions that may cause an error condition will return an error code. The CANpie error codes are within the value range from 0 to 127. The designer of the core functions might extend the error code table with hardware specific error codes, which must be in the range from 128 to 255.

Enumerator
eCP_ERR_NONE 

No error (00dec / 00hex)

eCP_ERR_GENERIC 

Error not specified (01dec / 01hex)

eCP_ERR_HARDWARE 

Hardware failure (02dec / 02hex)

eCP_ERR_INIT_FAIL 

Initialisation failure (03dec / 03hex)

eCP_ERR_INIT_READY 

Channel is initialised, ready to run (04dec / 04hex)

eCP_ERR_INIT_MISSING 

CAN channel was not initialised (05dec / 05hex)

eCP_ERR_RCV_EMPTY 

Receive buffer is empty (06dec / 06hex)

eCP_ERR_RCV_OVERRUN 

Receive buffer overrun (07dec / 07hex)

eCP_ERR_TRM_FULL 

Transmit buffer is full (08dec / 08hex)

eCP_ERR_CAN_MESSAGE 

CAN message has wrong format (10dec / 0Ahex)

eCP_ERR_CAN_ID 

CAN identifier not valid (11dec / 0Bhex)

eCP_ERR_CAN_DLC 

CAN data length code not valid (12dec / 0Chex)

eCP_ERR_FIFO_EMPTY 

FIFO is empty (20dec / 14hex)

eCP_ERR_FIFO_WAIT 

Message is waiting in FIFO (21dec / 15hex)

eCP_ERR_FIFO_FULL 

FIFO is full (22dec / 16hex)

eCP_ERR_FIFO_SIZE 

FIFO size is out of range (23dec / 17hex)

eCP_ERR_FIFO_PARAM 

Parameter of FIFO function is out of range (24dec / 18hex)

eCP_ERR_BUS_PASSIVE 

Controller is in error passive (30dec / 1Ehex)

eCP_ERR_BUS_OFF 

Controller is in bus off (31dec / 1Fhex)

eCP_ERR_BUS_WARNING 

Controller is in warning status (32dec / 20hex)

eCP_ERR_CHANNEL 

Channel out of range (40dec / 28hex)

eCP_ERR_REGISTER 

Register address out of range (41dec / 29hex)

eCP_ERR_BITRATE 

bit-rate out of range (42dec / 2Ahex)

eCP_ERR_BUFFER 

Buffer number out of range (43dec / 2Bhex)

eCP_ERR_PARAM 

Parameter number out of range (44dec / 2Chex)

eCP_ERR_NOT_SUPPORTED 

Function is not supported (50dec / 32hex)

◆ CpErrType_e

Error type.

These values are used as return value for the function CpCoreCanState().

Enumerator
eCP_ERR_TYPE_NONE 

No error

eCP_ERR_TYPE_BIT0 

Bit 0 error

eCP_ERR_TYPE_BIT1 

Bit 1 error

eCP_ERR_TYPE_STUFF 

Stuff error

eCP_ERR_TYPE_FORM 

Format error

eCP_ERR_TYPE_CRC 

CRC error

eCP_ERR_TYPE_ACK 

Acknowledge error

◆ CpMode_e

enum CpMode_e

Mode of CAN controller.

These values are used as parameter for the function CpCoreCanMode() in order to change the state of the CAN controller.

Enumerator
eCP_MODE_INIT 

Set controller in 'Initialization' mode (no reception or transmission possible)

eCP_MODE_OPERATION 

Set controller into 'Operation' mode

eCP_MODE_LISTEN_ONLY 

Set controller into 'Listen-only' mode

eCP_MODE_SLEEP 

Set controller into 'Sleep' (power-down) mode

eCP_MODE_SELF_TEST 

Set controller into 'Self-test' mode

◆ CpRpc_e

enum CpRpc_e

Remote Procedure Call definition.

The enumeration CpRpc_e is used to define different Remote Procedure Calls. The enumeration values are used by the function CpMsgRpcType() to identify a Remote Procedure Call upon reception.

Enumerator
eCP_RPC_NOOP 

RPC for no operation

eCP_RPC_MODE 

RPC for CpCoreCanMode()

eCP_RPC_BITRATE 

RPC for CpCoreBitrate()

◆ CpState_e

enum CpState_e

State of CAN controller.

These values are used as return value for the function CpCoreCanState().

Enumerator
eCP_STATE_INIT 

CAN controller is in stopped mode

eCP_STATE_SLEEPING 

CAN controller is in Sleep mode

eCP_STATE_BUS_ACTIVE 

CAN controller is error active

eCP_STATE_BUS_WARN 

CAN controller is active, warning level is reached

eCP_STATE_BUS_PASSIVE 

CAN controller is error passive

eCP_STATE_BUS_OFF 

CAN controller went into Bus Off

eCP_STATE_PHY_FAULT 

General failure of physical layer detected (if supported by hardware)

eCP_STATE_PHY_H 

Fault on CAN-H detected (Low Speed CAN)

eCP_STATE_PHY_L 

Fault on CAN-L detected (Low Speed CAN)