NTURT Zephyr v0.0.1
NTURT common library for Zephyr RTOS
Loading...
Searching...
No Matches
CANopen

CANopen support. More...

+ Collaboration diagram for CANopen:

Data Structures

struct  canopen_od_init
 Struct for initializing OD entries. More...
 

Macros

#define CO_EMC_NTURT   0xFF10
 CANopen error code for reporting NTURT errors.
 
#define TPDO_DATA(data, idx, subidx, ...)
 Specify the telemetry data to be published to TPDOs.
 
#define CANOPEN_TM_TO_TPDO_DEFINE(_name, _period, _min_separation, _watermark, flag, ...)
 Define a telemetry group that publishes data to TPDOs.
 
#define OD_TO_AGG_DATA(subidx, type, convert, member)
 Specify the data in an OD entry to be aggregated. Used in OD_TO_MSG_ENTRY.
 
#define CANOPEN_OD_TO_AGG_DEFINE(_idx, _agg, _agg_type, ...)
 Define a mapping from OD writes (PDO or SDO) to updates of typed data aggregation.
 
#define OD_TO_MSG_DATA(subidx, type, convert, member)
 Specify the data in an OD entry to be aggregated. Used in OD_TO_MSG_ENTRY.
 
#define OD_TO_MSG_ENTRY(idx, ...)
 Specify an OD entry to be aggregated. Used in CANOPEN_OD_TO_MSG_DEFINE.
 
#define CANOPEN_OD_TO_MSG_DEFINE(_msg, _init_val, _period, _min_separation, _watermark, _flag, ...)
 Define a data aggregration for aggregating OD writes (PDO or SDO) to message _msg .
 

Enumerations

enum  canopen_node_id {
  NODE_ID_VCU = 0x01 , NODE_ID_SENSORS = 0x02 , NODE_ID_RPI = 0x04 , NODE_ID_IMU = 0x08 ,
  NODE_ID_GPS , NODE_ID_ACC = 0x10 , NODE_ID_INV_FL , NODE_ID_INV_FR ,
  NODE_ID_INV_RL , NODE_ID_INV_RR
}
 CANopen node ID. More...
 

Functions

void canopen_tm_publish (uint32_t addr, const void *data, size_t size, void *user_data)
 Publishing function for CANOPEN_TM_TO_TPDO_DEFINE.
 

Detailed Description

CANopen support.

Macro Definition Documentation

◆ CANOPEN_OD_TO_AGG_DEFINE

#define CANOPEN_OD_TO_AGG_DEFINE ( _idx,
_agg,
_agg_type,
... )

#include <nturt/canbus/canopen.h>

Value:
static ODR_t _OD_TO_AGG_WRITE(_idx)(OD_stream_t * stream, const void *buf, \
OD_size_t size, \
OD_size_t *size_written) { \
ODR_t ret = OD_writeOriginal(stream, buf, size, size_written); \
if (ret != ODR_OK) { \
return ret; \
} \
\
switch (stream->subIndex) { \
FOR_EACH_FIXED_ARG(_OD_TO_AGG_WRITE_CASE, (;), (_agg, _agg_type), \
__VA_ARGS__); \
\
default: \
break; \
} \
\
return ODR_OK; \
} \
\
STRUCT_SECTION_ITERABLE(canopen_od_init, _OD_INIT(_idx)) = { \
.idx = _idx, \
.extension = \
{ \
.read = OD_readOriginal, \
.write = _OD_TO_AGG_WRITE(_idx), \
}, \
}
Struct for initializing OD entries.
Definition canopen.h:299

Define a mapping from OD writes (PDO or SDO) to updates of typed data aggregation.

Parameters
[in]_idxIndex of the OD entry.
[in]...Data to be aggregated, must be specified by OD_TO_AGG_DATA.

◆ CANOPEN_OD_TO_MSG_DEFINE

#define CANOPEN_OD_TO_MSG_DEFINE ( _msg,
_init_val,
_period,
_min_separation,
_watermark,
_flag,
... )

#include <nturt/canbus/canopen.h>

Value:
MSG_AGG_TO_MSG_DEFINE(_OD_TO_MSG_AGG(_msg), _msg, _init_val, _period, \
_min_separation, _watermark, _flag, \
_OD_TO_MSG_MEMBERS(__VA_ARGS__)); \
\
N_FOR_EACH_FIXED_ARG(_OD_TO_MSG_WRITE_DEFINE, (;), _msg, __VA_ARGS__);
#define MSG_AGG_TO_MSG_DEFINE(name, msg, init_val, period, min_separation, watermark, flag,...)
Define a data aggregration for aggregating into message msg . May be specified as static to limit the...
Definition msg.h:59

Define a data aggregration for aggregating OD writes (PDO or SDO) to message _msg .

Parameters
[in]_msgMessage to aggregate.
[in]_init_valInitial value of the message, must be a specified by AGG_DATA_INIT.
[in]_periodPeriod of data publishing.
[in]_min_separationMinimum separation time between two data publishing.
[in]_watermarkWatermark to wait for late-arriving members.
[in]_flagFlag of the aggregation. The same ones and rules as flag in AGG_DEFINE.
[in]...OD entries to be aggregated, must be specified by OD_TO_MSG_ENTRY.

◆ CANOPEN_TM_TO_TPDO_DEFINE

#define CANOPEN_TM_TO_TPDO_DEFINE ( _name,
_period,
_min_separation,
_watermark,
flag,
... )

#include <nturt/canbus/canopen.h>

Value:
FOR_EACH(_TO_TPDO_ALIAS_DEFINE, (;), __VA_ARGS__); \
\
TM_GROUP_DEFINE(_TO_TPDO_NAME(_name), _period, _min_separation, _watermark, \
flag, canopen_tm_publish, NULL, \
FOR_EACH(_TO_TPDO_GROUP_DATA, (, ), __VA_ARGS__))
void canopen_tm_publish(uint32_t addr, const void *data, size_t size, void *user_data)
Publishing function for CANOPEN_TM_TO_TPDO_DEFINE.

Define a telemetry group that publishes data to TPDOs.

Parameters
[in]_nameName of the telemetry group.
[in]_periodPeriod of data publishing.
[in]_min_separationMinimum separation time between two data publishing.
[in]_watermarkWatermark to wait for late-arriving members.
[in]flagFlag of the aggregation. The same ones and rules as flag in AGG_DEFINE.
[in]...Telemetry data to be published to PDOs, must be specified by TPDO_DATA.

◆ CO_EMC_NTURT

#define CO_EMC_NTURT   0xFF10

#include <nturt/canbus/canopen.h>

CANopen error code for reporting NTURT errors.

◆ OD_TO_AGG_DATA

#define OD_TO_AGG_DATA ( subidx,
type,
convert,
member )

#include <nturt/canbus/canopen.h>

Value:
(subidx, type, convert, member)

Specify the data in an OD entry to be aggregated. Used in OD_TO_MSG_ENTRY.

Parameters
[in]subidxSubindex of the data in the OD entry. If the entry is of type VAR, this must be 0.
[in]typeType of the data.
[in]convertFunction to convert the raw data into physical data, which is useful if the raw data have different scale or offset. If no conversion is needed, use Zephyr IDENTITY.
[in]memberMember of typed data aggregation to update.

◆ OD_TO_MSG_DATA

#define OD_TO_MSG_DATA ( subidx,
type,
convert,
member )

#include <nturt/canbus/canopen.h>

Value:
(subidx, type, convert, member)

Specify the data in an OD entry to be aggregated. Used in OD_TO_MSG_ENTRY.

Parameters
[in]subidxSubindex of the data in the OD entry. If the entry is of type VAR, this must be 0.
[in]typeType of the data.
[in]convertFunction to convert the raw data into physical data, which is useful if the raw data have different scale or offset. If no conversion is needed, use Zephyr IDENTITY.
[in]memberMember in the message that the data corresponds to and will be updated to when the OD data is received, must be specified by AGG_MEMBER.

◆ OD_TO_MSG_ENTRY

#define OD_TO_MSG_ENTRY ( idx,
... )

#include <nturt/canbus/canopen.h>

Value:
(idx, __VA_ARGS__)

Specify an OD entry to be aggregated. Used in CANOPEN_OD_TO_MSG_DEFINE.

Parameters
[in]idxIndex of the OD entry.
[in]...Data to be aggregated, must be specified by OD_TO_MSG_DATA.

◆ TPDO_DATA

#define TPDO_DATA ( data,
idx,
subidx,
... )

#include <nturt/canbus/canopen.h>

Value:
(data, idx, subidx, (COND_CODE_1(__VA_OPT__(1), (__VA_ARGS__), (0))))

Specify the telemetry data to be published to TPDOs.

Parameters
[in]dataTelemetry data defined by TM_DATA_DEFINE.
[in]idxIndex of the OD entry that corresponds to the data.
[in]subidxSubindex of the OD entry that corresponds to the data. If the entry is of type VAR, this must be 0.
[in]...Optional flags of the data, the same ones and rules as AGG_MEMBER.

Enumeration Type Documentation

◆ canopen_node_id

#include <nturt/canbus/canopen.h>

CANopen node ID.

Enumerator
NODE_ID_VCU 
NODE_ID_SENSORS 
NODE_ID_RPI 
NODE_ID_IMU 
NODE_ID_GPS 
NODE_ID_ACC 
NODE_ID_INV_FL 
NODE_ID_INV_FR 
NODE_ID_INV_RL 
NODE_ID_INV_RR 

Function Documentation

◆ canopen_tm_publish()

void canopen_tm_publish ( uint32_t addr,
const void * data,
size_t size,
void * user_data )

#include <nturt/canbus/canopen.h>

Publishing function for CANOPEN_TM_TO_TPDO_DEFINE.

Warning
Internal use only.