Skip to content

Commit 74ad3d6

Browse files
author
Commaremote
committed
GM: max param definitions
1 parent 38a9ea9 commit 74ad3d6

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

board/safety/safety_gm.h

+6-3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ const int GM_MAX_RATE_UP = 7;
1515
const int GM_MAX_RATE_DOWN = 17;
1616
const int GM_DRIVER_TORQUE_ALLOWANCE = 50;
1717
const int GM_DRIVER_TORQUE_FACTOR = 4;
18+
const int GM_MAX_GAS = 3072;
19+
const int GM_MAX_REGEN = 1404;
20+
const int GM_MAX_BRAKE = 255;
1821

1922
int gm_brake_prev = 0;
2023
int gm_gas_prev = 0;
@@ -143,7 +146,7 @@ static int gm_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) {
143146
int brake = ((rdlr & 0xF) << 8) + ((rdlr & 0xFF00) >> 8);
144147
brake = (0x1000 - brake) & 0xFFF;
145148
if (current_controls_allowed) {
146-
if (brake > 255) return 0;
149+
if (brake > GM_MAX_BRAKE) return 0;
147150
} else {
148151
if (brake != 0) return 0;
149152
}
@@ -207,11 +210,11 @@ static int gm_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) {
207210
int gas_regen = ((rdlr & 0x7F0000) >> 11) + ((rdlr & 0xF8000000) >> 27);
208211
int apply = rdlr & 1;
209212
if (current_controls_allowed) {
210-
if (gas_regen > 3072) return 0;
213+
if (gas_regen > GM_MAX_GAS) return 0;
211214
} else {
212215
// Disabled message is !engaed with gas
213216
// value that corresponds to max regen.
214-
if (apply || gas_regen != 1404) return 0;
217+
if (apply || gas_regen != GM_MAX_REGEN) return 0;
215218
}
216219
}
217220

0 commit comments

Comments
 (0)