-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathecanDefinitions.h
43 lines (35 loc) · 1.15 KB
/
ecanDefinitions.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// This file contains the constant definitions as well as the required
// data structures to work with on the ECAN module
#ifndef _ECAN_DEFINITIONS_H_
#define _ECAN_DEFINITIONS_H_
#ifdef __cplusplus
extern "C"{
#endif
#include "stdint.h"
// Message Types either a data message or a remote transmit request
enum can_msg_type {
CAN_MSG_DATA = 0,
CAN_MSG_RTR
};
// CAN frame type: either extended (29-bit header) or standard (11-bit header)
enum can_frame_type {
CAN_FRAME_EXT = 0,
CAN_FRAME_STD
};
// Data structures
typedef struct {
uint32_t id; // The 11-bit or 29-bit message ID
uint8_t buffer; // An internal-use variable referring to buffer this message was received into/sent from.
uint8_t message_type; // The message type. See can_msg_type.
uint8_t frame_type; // The frame type. See can_frame_type.
uint8_t payload[8]; // The message payload. Stores between 0 and 8 bytes of data.
uint8_t validBytes; // Indicates how many bytes are valid within payload.
} tCanMessage;
typedef union {
tCanMessage message;
uint8_t bytes[sizeof(tCanMessage)];
} CanUnion;
#ifdef __cplusplus
}
#endif
#endif /* _ECAN_DEFINITIONS_H_ */