Rev 800 | Rev 804 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 800 | Rev 801 | ||
|---|---|---|---|
| Line 55... | Line 55... | ||
| 55 | * |
55 | * |
| 56 | * Stores a CAN message frame. Flags that are unsupported have been |
56 | * Stores a CAN message frame. Flags that are unsupported have been |
| 57 | * excluded (RTR and standard id). |
57 | * excluded (RTR and standard id). |
| 58 | */ |
58 | */ |
| 59 | typedef struct { |
59 | typedef struct { |
| - | 60 | union { |
|
| 60 |
|
61 | uint32_t Id; /**< CAN extended ID (29 bits). */ |
| - | 62 | struct { |
|
| - | 63 | uint8_t Command; |
|
| - | 64 | uint8_t ModuleId; |
|
| - | 65 | uint8_t ModuleType; |
|
| - | 66 | uint8_t ClassAndDirection; |
|
| - | 67 | } Header; |
|
| - | 68 | }; |
|
| - | 69 | ||
| 61 | char Length; /**< Data length [0,8]. */ |
70 | char Length; /**< Data length [0,8]. */ |
| 62 | unsigned char Data[8]; /**< Data array. Only the first \c Length elements are valid. */ |
71 | unsigned char Data[8]; /**< Data array. Only the first \c Length elements are valid. */ |
| 63 | #if (STDCAN_FILTER) |
72 | #if (STDCAN_FILTER) |
| 64 | unsigned char Match; /**< Filter id that matched this message. */ |
73 | unsigned char Match; /**< Filter id that matched this message. */ |
| 65 | #endif |
74 | #endif |
| 66 | } StdCan_Msg_t; |
75 | } StdCan_Msg_t; |
| 67 | 76 | ||
| 68 | /** |
- | |
| 69 | * @brief Node descriptor. |
- | |
| 70 | * |
- | |
| 71 |
|
77 | #define StdCan_Ret_class(MSG) ((MSG.Header.ClassAndDirection >> 1) & 0x0F) |
| 72 | * TODO: Discuss the purpose and layout of Node_Desc_t. |
- | |
| 73 | */ |
- | |
| 74 | typedef struct { |
- | |
| 75 |
|
78 | #define StdCan_Set_class(MSG, CLASS) MSG.Header.ClassAndDirection &= 0x01; MSG.Header.ClassAndDirection |= (CLASS << 1); |
| 76 |
|
79 | #define StdCan_Ret_direction(MSG) (MSG.Header.ClassAndDirection & 0x01) |
| 77 | unsigned char Id; /**< Node ID. */ |
- | |
| 78 | } Node_Desc_t; |
- | |
| 79 | - | ||
| 80 |
|
80 | #define StdCan_Set_direction(MSG, DIR) MSG.Header.ClassAndDirection &= 0xfe; MSG.Header.ClassAndDirection |= DIR; |
| 81 | - | ||
| 82 | - | ||
| 83 | /** |
81 | /** |
| 84 | * @brief Initialize StdCan. |
82 | * @brief Initialize StdCan. |
| 85 | * |
83 | * |
| 86 | * Initializes the StdCan and lower layers and sends an Application Startup |
84 | * Initializes the StdCan and lower layers and sends an Application Startup |
| 87 | * Message. |
85 | * Message. |
| 88 | * |
86 | * |
| 89 | * @param node_desc |
- | |
| 90 | * Pointer to node descriptor, containing information about the type and |
- | |
| 91 | * version of the application that should be announced in startup and |
- | |
| 92 | * heartbeat messages. |
- | |
| 93 | */ |
87 | */ |
| 94 | StdCan_Ret_t StdCan_Init( |
88 | StdCan_Ret_t StdCan_Init(); |
| 95 | 89 | ||
| 96 | /** |
90 | /** |
| 97 | * @brief Get a message. |
91 | * @brief Get a message. |
| 98 | * |
92 | * |
| 99 | * Retrieves a message from the receive queue. |
93 | * Retrieves a message from the receive queue. |