-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcan.h
46 lines (38 loc) · 1018 Bytes
/
can.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
44
45
46
/*
* file that defines structures that are common across all 3 of
* Waterloo Rocketry's CAN implementations
*/
#ifndef CAN_H_
#define CAN_H_
#include <stdint.h>
#include <stdbool.h>
#define CANLIB_VERSION "v0.7.0"
#define CANLIB_BIT_TIME_US 4
// Timing parameters
typedef struct {
// BaudRate Prescaler
uint8_t brp;
// Synchronization Jump Width
uint8_t sjw;
// sample once or three times
uint8_t sam;
// phase segment 1 bits
uint8_t seg1ph;
// phase segment 2 bits
uint8_t seg2ph;
// propagation time segment bits
uint8_t prseg;
// Phase segment 2 time select bit. If true, then use seg2ph,
// otherwise take minimum viable phase length
bool btlmode;
} can_timing_t;
// Things that are in a CAN message
typedef struct {
// Standard Identifier - 29 bits long
uint32_t sid;
// How many bytes are used in data
uint8_t data_len;
// the data you want to transmit
uint8_t data[8];
} can_msg_t;
#endif // CAN_H_