Implementation

Processes

main loop

Figure 4: program flow in main.c

Figure 5: <target>_appl.c/callApplication()

Interpretation of CANopen requests

Figure 6 shows the handling of CANopen SDO requests.

Figure 6: bl_canopen.c/doCANopen()

Data structures

CanMsgRx_T

CanMsgRx_T defines the structure of the CAN message receive buffer. The structure is applied in the CAN driver. Empty buffer entries are marked by the value FFFFh in the structure element StdId.

typedef struct {     UNSIGNED16 StdId;           /**< identifier of the CAN message */     UNSIGNED8 DLC;              /**< number of data bytes */     union{         UNSIGNED32 u32Data[2];  /**< data as 2x32 bit values */         UNSIGNED16 u16Data[4];  /**< data as 4x16 bit values */         UNSIGNED8 u8Data[8];    /**< data as 8x8 bit values */     } Msg; } CanMsgRx_T;

CanMsgTx_T

CanMsgTx_T defines the structure of the CAN message transmit buffer. The structure is applied in the CAN driver.

typedef struct {     UNSIGNED8 DLC;              /**< number of data bytes */     union{         UNSIGNED32 u32Data[2];  /**< data as 2x32 bit values */         UNSIGNED16 u16Data[4];  /**< data as 4x16 bit values */         UNSIGNED8 u8Data[8];    /**< data as 8x8 bit values */     } Msg; } CanMsgTx_T;

Complete transmit message can be stored in the program flash to optimize the code size of Paulus. Because the node-ID is configurable the node-ID is not part of this structure. The CAN driver generates the cob-ID automatically according to the pre-defined connection set defined in /CiA-301/.

Example:

static const CanMsgTx_T bootupMsg = { 1, { u32Data[0] = 0ul, 0ul }};

SdoRequest_T

This structure contains all CAN message information for an expedited SDO transfer.

typedef struct {     UNSIGNED32 request;       /**< first 4 bytes of the CAN messages, */                               /**< includes the command specifier, index */                               /**< and sub-index of the SDO request */     CanMsgTx_T response;      /**< SDO response */ } SdoRequest_T;

The element request is structured as follow:

byte 3

byte 2

byte 1

byte 0

sub-index

index, msb

index, lsb

command specifier

Example: