-
Notifications
You must be signed in to change notification settings - Fork 275
/
throttle_can_protocol.h
158 lines (122 loc) Β· 3.63 KB
/
throttle_can_protocol.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
/**
* @file throttle_can_protocol.h
* @brief Throttle CAN Protocol.
*
*/
#ifndef _OSCC_THROTTLE_CAN_PROTOCOL_H_
#define _OSCC_THROTTLE_CAN_PROTOCOL_H_
#include <stdint.h>
#include "magic.h"
/*
* @brief CAN ID representing the range of throttle messages.
*
*/
#define OSCC_THROTTLE_CAN_ID_INDEX (0x90)
/*
* @brief Throttle enable message (CAN frame) ID.
*
*/
#define OSCC_THROTTLE_ENABLE_CAN_ID (0x90)
/*
* @brief Throttle disable message (CAN frame) ID.
*
*/
#define OSCC_THROTTLE_DISABLE_CAN_ID (0x91)
/*
* @brief Throttle command message (CAN frame) ID.
*
*/
#define OSCC_THROTTLE_COMMAND_CAN_ID (0x92)
/*
* @brief Throttle report message (CAN frame) ID.
*
*/
#define OSCC_THROTTLE_REPORT_CAN_ID (0x93)
/*
* @brief Throttle report message (CAN frame) length.
*
*/
#define OSCC_THROTTLE_REPORT_CAN_DLC (8)
/*
* @brief Throttle report message publishing frequency. [Hz]
*
*/
#define OSCC_REPORT_THROTTLE_PUBLISH_FREQ_IN_HZ (50)
/*
* @brief Enumeration of all possible throttle DTCs.
*
*/
enum
{
/* DTC bitfield position indicating an invalid sensor value. */
OSCC_THROTTLE_DTC_INVALID_SENSOR_VAL = 0,
/* DTC bitfield position indicating an operator override. */
OSCC_THROTTLE_DTC_OPERATOR_OVERRIDE,
/* Number of possible throttle DTCs. */
OSCC_THROTTLE_DTC_COUNT
};
#pragma pack(push)
#pragma pack(1)
/**
* @brief Throttle enable message.
*
* CAN frame ID: \ref OSCC_THROTTLE_ENABLE_CAN_ID
*
*/
typedef struct
{
uint8_t magic[2]; /*!< Magic number identifying CAN frame as from OSCC.
* Byte 0 should be \ref OSCC_MAGIC_BYTE_0.
* Byte 1 should be \ref OSCC_MAGIC_BYTE_1. */
uint8_t reserved[6]; /*!< Reserved. */
} oscc_throttle_enable_s;
/**
* @brief Throttle disable message.
*
* CAN frame ID: \ref OSCC_THROTTLE_DISABLE_CAN_ID
*
*/
typedef struct
{
uint8_t magic[2]; /*!< Magic number identifying CAN frame as from OSCC.
* Byte 0 should be \ref OSCC_MAGIC_BYTE_0.
* Byte 1 should be \ref OSCC_MAGIC_BYTE_1. */
uint8_t reserved[6]; /*!< Reserved. */
} oscc_throttle_disable_s;
/**
* @brief Throttle command message.
*
* CAN frame ID: \ref OSCC_THROTTLE_COMMAND_CAN_ID
*
*/
typedef struct
{
uint8_t magic[2]; /*!< Magic number identifying CAN frame as from OSCC.
* Byte 0 should be \ref OSCC_MAGIC_BYTE_0.
* Byte 1 should be \ref OSCC_MAGIC_BYTE_1. */
float torque_request; /* Torque request from 0.0 to 1.0 where 1.0 is 100% */
uint8_t reserved[2]; /*!< Reserved. */
} oscc_throttle_command_s;
/**
* @brief Throttle report message.
*
* CAN frame ID: \ref OSCC_THROTTLE_REPORT_CAN_ID
*
*/
typedef struct
{
uint8_t magic[2]; /*!< Magic number identifying CAN frame as from OSCC.
* Byte 0 should be \ref OSCC_MAGIC_BYTE_0.
* Byte 1 should be \ref OSCC_MAGIC_BYTE_1. */
uint8_t enabled; /*!< Throttle controls enabled state.
* Zero value means disabled (commands are ignored).
* Non-zero value means enabled (commands are sent to the vehicle). */
uint8_t operator_override; /*!< Driver override state.
* Zero value means there has been no operator override.
* Non-zero value means an operator has physically overridden
* the system. */
uint8_t dtcs; /*!< Bitfield of DTCs present in the module. */
uint8_t reserved[3]; /*!< Reserved. */
} oscc_throttle_report_s;
#pragma pack(pop)
#endif /* _OSCC_THROTTLE_CAN_PROTOCOL_H_ */