...
- A CAN Signal can be defined without any CAN communication knowledge. No information about sending or receiving information is needed during configuration.
Code Block | ||||
---|---|---|---|---|
| ||||
#include "can_sig.h" enum { [1] /* ---------------- SIGNAL ENUMERATIONS --------------- */ S_NODESTATUS = 0, S_CPULOAD, S_MAX, }; const CANSIG_PARA CanSig[CANSIG_N] = { [2] /* ---------------- SIGNAL NODESTATUS ----------------- */ {CANSIG_UNCHANGED, [3A] /* Initial Status */ 1, [B] /* Width in Bytes */ 0, [C] /* Initial Value */ #if (CANSIG_CALLBACK_EN > 0) StatusChange}, [D] /* Callback Function: User Defined */ #else }, #endif /* ----------------- SIGNAL CPULOAD ------------------- */ {CANSIG_UNCHANGED, [3A] /* Initial Status */ 1, [B] /* Width in Bytes */ 0, [C] /* Initial Value */ #if (CANSIG_CALLBACK_EN > 0) 0} [D] /* No Callback */ #else }, #endif #else }, #endif }; |
...
}; |
Panel | ||||
---|---|---|---|---|
| ||||
1] Enumeration is used to simpilfy CAN Signal definitions and to ensure a consistent Message-to-Signal mapping. 2] CAN Signal configuration is done as a global constant to save RAM space and get a write-protected configuration. Also, the configuration data will be read while using the CAN Signal Layer. 3] The following will explain the required configuration for each Signal. A] States the Initial Status of each signal. B] States the width in bytes of the CAN signal. The Value here affects the Message Configuration's DLC & Number of Link parameters. C] States the Initial Value for Each signal. D] The Callback Function definition can be omitted by configuring the CANSIG_CALLBACK_EN parameter to 0 in |
Message Configuration
Anchor | ||||
---|---|---|---|---|
|
...
- A CAN Message can be defined without any knowledge of the information generated and/or the usage of the payload. Only the mapping of the payload (and it's respective parts) must be known.
...
Code Block | ||||
---|---|---|---|---|
| ||||
#include "can_msg.h" enum { [1] /* --------------- MESSAGE ENUMERATIONS --------------- */ M_STATUS = 0, M_COMMAND, M_MAX }; const CANMSG_PARA CanMsg[CANMSG_N] = [2] { /* ------------------ MESSAGE STATUS ------------------ */ { 0x123L, [3A] /* CAN-Identifier */ CANMSG_TX, [B] /* Message Type */ 2, [C] /* DLC of Message */ 2, /* No. of Links */ { { S_NODESTATUS, [D] /* Signal ID */ 0 }, [E] /* Byte Position */ { S_CPULOAD, /* Signal ID */ 2 } /* Byte Position */ }, }, /* ----------------- MESSAGE COMMAND ------------------ */ { 0x122L, [4A] /* CAN-Identifier */ CANMSG_RX, [B] /* Message Type */ 1, [C] /* DLC of Message */ 1, /* No. of Links */ { { S_NODESTATUS, [D] /* Signal ID */ 0 } [E] /* Byte Position */ } } }; |
...