Custom_Element is the structure
defined in user_define.h.Custom_Element is also shown in Figure 2-6.
Origin Identifier indicates the
origin of the message. The following are the examples of Origin Identifier
(CAN_ID_LENGTH =0,SPI_ID_LENGTH =4).
- Example 1: CAN interface receive
and transmit
- When the CAN-SPI bridge
receives a CAN message, the ID from CAN frame is Origin
Identifier, indicating where the message comes from.
- When the CAN-SPI bridge
transmits a CAN message, Origin Identifier is ignored
(CAN_ID_LENGTH is set to 0 default).
- Example 2: SPI Interface Receive
and Transmit (SPI protocol transmission)
- When the CAN-SPI bridge
receives an SPI message (SPI protocol transmission),
DEFAULT_SPI_ORIGIN_ID is the Origin Identifier since the SPI does
not have an ID.
- When the CAN-SPI bridge
transmits the SPI message(SPI protocol transmission), Origin
Identifier is a 4-byte ID in SPI data (SPI_ID_LENGTH is set to
four as the default), indicating where the message came from.
- Example 3 - SPI interface
receives and transmits (SPI transparent transmission)
- When the CAN-SPI bridge
receives an SPI message (SPI transparent transmission)
DEFAULT_SPI_ORIGIN_ID is the Origin Identifier since SPI does not
have an ID.
- When the CAN-SPI bridge
transmits the SPI message (SPI transparent transmission), Origin
Identifier is ignored. (Transparent transmission does not have
an ID area).
Destination Identifier
indicates the destination of the message.
- Example 1 - CAN interface receive
and transmit
- When a CAN-SPI bridge
receives a CAN message, DEFAULT_CAN_DESTINATION_ID is the Destination
Identifier since CAN_ID_LENGTH is set to 0 as the default. SPI
transmit does not require an ID.
- When the CAN-SPI bridge
transmits a CAN message, Destination Identifier is the CAN ID in
CAN frame. In this example, 11 bit or 29 bit are both supported.
- Example 2 - SPI interface receive
and transmit (SPI protocol transmission)
- When the CAN-SPI bridge
receives an SPI message (SPI protocol transmission), 4-byte ID from the
SPI data is Destination Identifier(SPI _ID_LENGTH is set to 4 default).
CAN transmit requires ID information.
- When the CAN-SPI bridge
transmits an SPI message (SPI protocol transmission), Destination
Identifier is ignored since SPI transmit does not require an
ID.
- Example 3 - SPI interface receive
and transmit (SPI transparent transmission)
- When the CAN-SPI bridge
receives an SPI message (SPI transparent transmission),
DEFAULT_SPI_DESTINATION_ID is the Destination Identifier
(Transparent transmission does not have ID area). CAN transmit requires
ID information.
- When the CAN-SPI bridge
transmits a SPI message (SPI transparent transmission), Destination
Identifier is ignored since SPI transmit does not require an
ID.
/*user-defined information storage structure */
typedef struct {
/*! Origin Identifier, indicating the origin of the message */
uint32_t origin_id;
/*! Destination Identifier, indicating the destination of the message */
uint32_t destination_id;
/*! Data Length Code */
uint8_t dlc;
/*! Data bytes */
uint8_t data[TRANSMIT_DATA_LENGTH];
} Custom_Element;