Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
b88b247
Initial commit
kzwicker Jun 2, 2026
d4718dd
current gear ratio
kzwicker Jun 2, 2026
1b0b2c2
use vehicle speed when deciding whether to regen brake
kzwicker Jun 2, 2026
d5c7e3e
Note where min speed came from
kzwicker Jun 2, 2026
cbbb7d7
explicitly promote integer just in case
kzwicker Jun 2, 2026
c5344f9
Automatic CANfigurator: Updated CAN files automatically
github-actions[bot] Jun 2, 2026
4c9c503
Automatic Clang-Format: Standardized formatting automatically
github-actions[bot] Jun 2, 2026
b4fda59
Adjust `disable_inverter` offset for current requests.
SlowThomas Jun 5, 2026
cb5e869
Data 6 does not exist in our version (v2.4 not v2.5)
dchansen06 Jun 7, 2026
9379b40
Remove logic relating to not real dti data 6
dchansen06 Jun 7, 2026
d776c65
Automatic CANfigurator: Updated CAN files automatically
github-actions[bot] Jun 7, 2026
42774e4
Nuke remaining dti data 6 ref
dchansen06 Jun 7, 2026
8bcbd1a
Enable regen on the branch to test regen
dchansen06 Jun 7, 2026
7e7f1a2
Automatic Clang-Format: Standardized formatting automatically
github-actions[bot] Jun 7, 2026
6d88e87
Use more explicit math for `WHEEL_RPM_TO_MPH_RATIO`
dchansen06 Jun 7, 2026
136e5c2
Cleanup actual calc
dchansen06 Jun 7, 2026
6884d0e
Never print buzz
dchansen06 Jun 7, 2026
3f178c9
Pi floats!
dchansen06 Jun 7, 2026
ffd0865
Ensure the brake lights stay on at least 100ms
dchansen06 Jun 9, 2026
bc696e2
Run brake and dash lights during startup delay
dchansen06 Jun 9, 2026
e04322a
Move driving critical decisions from brake f and brake r to just bse/f
dchansen06 Jun 9, 2026
acbbbb5
Send analog data (eg pedals) every 30 ms
dchansen06 Jun 10, 2026
7fbd756
Have hootl tests use bse instead of brake f
dchansen06 Jun 10, 2026
0669512
More power!
dchansen06 Jun 12, 2026
7c56baa
Automatic CANfigurator: Updated CAN files automatically
github-actions[bot] Jun 12, 2026
7858fd5
Adjust hard coded absolute non-configurable maximum
dchansen06 Jun 12, 2026
424609c
Incorporate brake pressure fix
dchansen06 Jun 12, 2026
113c1b9
Temp disable regen
dchansen06 Jun 12, 2026
145ff2a
Battery max reverse current at 30A
dchansen06 Jun 12, 2026
1502eda
The Unwronging of the Dash Panel Lights
kzwicker Jun 18, 2026
e7ae6bc
Automatic Clang-Format: Standardized formatting automatically
github-actions[bot] Jun 18, 2026
b0acb84
Revised scaling of TS voltage
kzwicker Jun 19, 2026
e6919a4
Switch to 10x scaling of the ACU Status 1 field for TS Voltage
dchansen06 Jun 19, 2026
b70f030
Automatic CANfigurator: Updated CAN files automatically
github-actions[bot] Jun 19, 2026
d7c83d8
fix ccu anyway
kzwicker Jun 19, 2026
d1bd0f7
Make everything 325 A regardless of brightness
dchansen06 Jun 20, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Autogen/CAN/Doc/GRCAN.CANdo
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ Message ID:
data type: u4
Torque Map:
bit_start: 36
comment: The torque map selected; torque map is the mapping of the throttle to the torque sent to each motor. 0 is max current amps, 1 is 50 / 100 / 150 / 200 / 250 / 275, 2 and later is tbd
comment: The torque map selected; torque map is the mapping of the throttle to the torque sent to each motor. 0 is max current amps, 1 is 100 / 200 / 250 / 300 / 325 / 350 Amps, 2 and later is tbd
data type: u4
Max Cell Temp:
bit_start: 40
Expand Down Expand Up @@ -668,7 +668,7 @@ Message ID:
units: Volts
scaled min: 0
scaled max: 655.35
map equation: "0.01x"
map equation: "0.1x"
Accumulator Current:
bit_start: 32
comment: Current output of accumulator
Expand Down
2 changes: 1 addition & 1 deletion Autogen/CAN/Doc/GRCAN_Charger.dbc
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ BO_ 2550588916 ACU_Charger_Control_to_Charger: 5 ACU

BO_ 2150631170 ACU_ACU_Status_1_to_CCU: 8 ACU
SG_ Accumulator_Voltage : 0|16@1+ (0.01,0) [0|655.35] "Volts" CCU
SG_ TS_Voltage : 16|16@1+ (0.01,0) [0|655.35] "Volts" CCU
SG_ TS_Voltage : 16|16@1+ (0.1,0) [0|655.35] "Volts" CCU
SG_ Accumulator_Current : 32|16@1- (0.01,0) [-327.68|327.67] "Amps" CCU
SG_ Accumulator_SOC : 48|8@1+ (0.3921568627,0) [0|100] "%" CCU
SG_ GLV_SOC : 56|8@1+ (0.3921568627,0) [0|100] "%" CCU
Expand Down
4 changes: 2 additions & 2 deletions Autogen/CAN/Doc/GRCAN_Primary.dbc
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ BO_ 2150629890 ACU_Ping_to_ECU: 4 ACU

BO_ 2150631170 ACU_ACU_Status_1_to_ECU: 8 ACU
SG_ Accumulator_Voltage : 0|16@1+ (0.01,0) [0|655.35] "Volts" ECU
SG_ TS_Voltage : 16|16@1+ (0.01,0) [0|655.35] "Volts" ECU
SG_ TS_Voltage : 16|16@1+ (0.1,0) [0|655.35] "Volts" ECU
SG_ Accumulator_Current : 32|16@1- (0.01,0) [-327.68|327.67] "Amps" ECU
SG_ Accumulator_SOC : 48|8@1+ (0.3921568627,0) [0|100] "%" ECU
SG_ GLV_SOC : 56|8@1+ (0.3921568627,0) [0|100] "%" ECU
Expand Down Expand Up @@ -515,7 +515,7 @@ CM_ SG_ 2149581568 Ping_Group_1 "[Byte 1 / Bits 8-15] ECU ping targets 8: ACU (1
CM_ SG_ 2149581568 Ping_Group_2 "[Byte 2 / Bits 16-23] ECU ping targets 16: Suspension FL (1: OK, 0: Timeout) 17: Suspension FR (1: OK, 0: Timeout) 18: Suspension RL (1: OK, 0: Timeout) 19: Suspension RR (1: OK, 0: Timeout) 20: InboardFloor FL (1: OK, 0: Timeout) 21: InboardFloor FR (1: OK, 0: Timeout) 22: InboardFloor RL (1: OK, 0: Timeout) 23: InboardFloor RR (1: OK, 0: Timeout)";
CM_ SG_ 2149581568 Ping_Group_3 "[Byte 3 / Bits 24-31] ECU ping targets 24: TireTemp FL (1: OK, 0: Timeout) 25: TireTemp FR (1: OK, 0: Timeout) 26: TireTemp RL (1: OK, 0: Timeout) 27: TireTemp RR (1: OK, 0: Timeout) 28: BrakeTemp FL (1: OK, 0: Timeout) 29: BrakeTemp FR (1: OK, 0: Timeout) 30: BrakeTemp RL (1: OK, 0: Timeout) 31: BrakeTemp RR (1: OK, 0: Timeout)";
CM_ SG_ 2149581568 Power_Level "Controls the AC current limits to each of the inverters Discrete Mapping, actual current values described by the torque map";
CM_ SG_ 2149581568 Torque_Map "The torque map selected; torque map is the mapping of the throttle to the torque sent to each motor. 0 is max current amps, 1 is 50 / 100 / 150 / 200 / 250 / 275, 2 and later is tbd";
CM_ SG_ 2149581568 Torque_Map "The torque map selected; torque map is the mapping of the throttle to the torque sent to each motor. 0 is max current amps, 1 is 100 / 200 / 250 / 300 / 325 / 350 Amps, 2 and later is tbd";
CM_ SG_ 2149581568 Max_Cell_Temp "the Temp of the hottest cell of the accumulator";
CM_ SG_ 2149581568 Accumulator_State_of_Chg "% charged of the Accumulator";
CM_ SG_ 2149581568 GLV_State_of_Chg "% charged of the Low Voltage Bat";
Expand Down
4 changes: 2 additions & 2 deletions Autogen/CAN/Inc/GRCAN_MSG_DATA.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ See diagram in StateMachine.h (Byte 0) */
31: BrakeTemp RR (1: OK, 0: Timeout) (Byte 3) */
uint8_t ping_group_3;
/** Controls the AC current limits to each of the inverters
Discrete Mapping, actual current values described by the torque map The torque map selected; torque map is the mapping of the throttle to the torque sent to each motor. 0 is max current amps, 1 is 50
/ 100 / 150 / 200 / 250 / 275, 2 and later is tbd (Byte 4) */
Discrete Mapping, actual current values described by the torque map The torque map selected; torque map is the mapping of the throttle to the torque sent to each motor. 0 is max current amps, 1 is 100
/ 200 / 250 / 300 / 325 / 350 Amps, 2 and later is tbd (Byte 4) */
uint8_t power_level_torque_map;
/** the Temp of the hottest cell of the accumulator (Byte 5) */
uint8_t max_cell_temp;
Expand Down
2 changes: 1 addition & 1 deletion CCU/Application/Src/StateUtils.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ void VCP_Oneliner(const CCU_StateData *state_data)
length = snprintf(buffer, sizeof(buffer), " | IR+ %s", state_data->IR_PLUS ? "Closed" : "Open");
VCP_Send(buffer, length);

length = snprintf(buffer, sizeof(buffer), " | %huV", state_data->Accumulator_Voltage / 100);
length = snprintf(buffer, sizeof(buffer), " | %huV", state_data->Accumulator_Voltage / 10);
VCP_Send(buffer, length);

length = snprintf(buffer, sizeof(buffer), " | SOC %hu%%", (uint8_t)(state_data->Accumulator_SOC * 20.0f / 51.0f));
Expand Down
3 changes: 3 additions & 0 deletions ECU/Application/Inc/CANdler.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <stdint.h>

#include "GRCAN_BUS_ID.h"
#include "GRCAN_CUSTOM_ID.h"
#include "GRCAN_MSG_ID.h"
#include "GRCAN_NODE_ID.h"
#include "StateData.h"
Expand All @@ -11,4 +12,6 @@

void ECU_CAN_MessageHandler(ECU_StateData *state_data, GRCAN_BUS_ID bus_id, GRCAN_MSG_ID msg_id, GRCAN_NODE_ID sender_id, uint8_t *data, uint32_t data_length);

void ECU_CAN_DTI_MessageHandler(ECU_StateData *state_data, GRCAN_CUSTOM_ID id, uint8_t *data, uint32_t data_length);

#endif
2 changes: 2 additions & 0 deletions ECU/Application/Inc/Lights.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
*
* @return void
*/
void BrakeLightControl(ECU_StateData *stateLump);
void dashLights(ECU_StateData *stateLump);
void lightControl(ECU_StateData *stateData);

#endif
4 changes: 1 addition & 3 deletions ECU/Application/Inc/StateData.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,7 @@ typedef volatile struct ECU_StateData {
bool ir_minus;
bool acu_software_latch;

bool bms_light;
bool imd_light;
bool tssi_fault;
bool SDC_startup_condition;

bool enable_regen;

Expand Down
7 changes: 3 additions & 4 deletions ECU/Application/Inc/StateUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ uint32_t MillisecondsSinceBoot(void);
#define MAX_APPS_IMPLAUSIBLE_TIME_MS 100
#define MAX_BUZZER_TIME_MS 1000

#define REGEN_MIN_SPEED_MPH 3.106856f // MPH
#define REGEN_MIN_SPEED_MPH 3.106856f // 5 KPH

#define MAX_CURRENT_AMPS 300.0f // Determined by Ryan
#define MAX_REVERSE_CURRENT_AMPS 20.0f // TODO: Change as appropriate
#define MAX_CURRENT_AMPS 375.0f // Determined by Ryan
#define MAX_REVERSE_CURRENT_AMPS 30.0f // TODO: Change as appropriate

#define ECU_STATUS_MSG_PERIOD_MILLIS (1000)
#define TRACTIVE_SYSTEM_MAX_PERMITTED_DISCHARGE_TIME_MILLIS (5000)
Expand Down Expand Up @@ -74,7 +74,6 @@ bool PressingBrake(volatile const ECU_StateData *stateData);
float CalcBrakePressure(volatile const ECU_StateData *stateData);
float CalcAccPedalTravel(volatile const ECU_StateData *stateData);
bool APPS_Plausible(volatile const ECU_StateData *stateData);
bool vehicle_is_moving(volatile const ECU_StateData *stateData);
/* Disable inverter for both DTI and Custom */
void disable_inverter(void);
void Send_VCP_APPS(const ECU_StateData *stateData, uint16_t apps1_raw, uint16_t apps2_raw);
Expand Down
31 changes: 29 additions & 2 deletions ECU/Application/Src/CANdler.c
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
#include "CANdler.h"

#include <math.h>
#include <stdint.h>

#include "GRCAN_BUS_ID.h"
#include "GRCAN_CUSTOM_ID.h"
#include "GRCAN_MSG_ID.h"
#include "GRCAN_NODE_ID.h"
#include "Logomatic.h"
#include "Pinging.h"
#include "StateData.h"
#include "bitManipulations.h"

#define WHEEL_RPM_TO_MPH_RATIO 0.0476f
#define WHEEL_RADIUS_INCHES 8.0f
#define WHEEL_CIRCUMFERENCE_INCHES (2.0f * (float)M_PI * WHEEL_RADIUS_INCHES)
#define WHEEL_RPM_TO_MPH_RATIO (WHEEL_CIRCUMFERENCE_INCHES / 63360.0f * 60.0f)
#define NUM_MOTOR_POLE_PAIRS 10
#define DRIVEN_SPROCKET_TEETH 51.0f
#define DRIVING_SPROCKET_TEETH 19.0f
#define GEAR_RATIO (51.0f / 19.0f)

void ReportBadMessageLength(GRCAN_BUS_ID bus_id, GRCAN_MSG_ID msg_id, GRCAN_NODE_ID sender_id)
{
Expand Down Expand Up @@ -63,7 +71,7 @@ void ECU_CAN_MessageHandler(ECU_StateData *state_data, GRCAN_BUS_ID bus_id, GRCA
GRCAN_ACU_STATUS_1_MSG *acu_status_1 = (GRCAN_ACU_STATUS_1_MSG *)data;
state_data->tractivebattery_soc = acu_status_1->accumulator_soc;
state_data->glv_soc = acu_status_1->glv_soc;
state_data->ts_voltage = acu_status_1->ts_voltage * 0.01f;
state_data->ts_voltage = acu_status_1->ts_voltage * 0.1f;
break;

case GRCAN_ACU_STATUS_2:
Expand Down Expand Up @@ -156,3 +164,22 @@ void ECU_CAN_MessageHandler(ECU_StateData *state_data, GRCAN_BUS_ID bus_id, GRCA
break;
}
}

void ECU_CAN_DTI_MessageHandler(ECU_StateData *state_data, GRCAN_CUSTOM_ID id, uint8_t *data, uint32_t data_length)
{
switch (id) {
case DTI_DATA_1_CAN_ID:
if (data_length != 8) {
ReportBadMessageLength(GRCAN_BUS_PRIMARY, (GRCAN_MSG_ID)id, GRCAN_DTI_Inv);
break;
}
int32_t erpm = ((uint32_t)data[0] << 24) | ((uint32_t)data[1] << 16) | ((uint32_t)data[2] << 8) | ((uint32_t)data[3]);
state_data->vehicle_speed_mph = (float)erpm * WHEEL_RPM_TO_MPH_RATIO / (NUM_MOTOR_POLE_PAIRS * GEAR_RATIO);
break;

default:
// don't really gaf
// ReportUnhandledMessage(GRCAN_BUS_PRIMARY, (GRCAN_MSG_ID)id, GRCAN_DTI_Inv);
break;
}
}
2 changes: 1 addition & 1 deletion ECU/Application/Src/CANutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ void SendECUAnalogDataOverCAN(const ECU_StateData *stateData)
uint32_t millis_since_boot = MillisecondsSinceBoot();

static uint32_t last_can_tcm_request_millis = 0;
if (millis_since_boot - last_can_tcm_request_millis > 100) {
if (millis_since_boot - last_can_tcm_request_millis > 30) {
GRCAN_ECU_ANALOG_DATA_MSG message = {.bspd_signal = stateData->bspd_signal,
.bse_signal = stateData->bse_signal,
.apps_1_signal = stateData->APPS1_Signal,
Expand Down
22 changes: 16 additions & 6 deletions ECU/Application/Src/Lights.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,19 @@

void BrakeLightControl(ECU_StateData *stateLump)
{
static uint32_t brake_light_start_millis;

if (PressingBrake(stateLump)) {
brake_light_start_millis = MillisecondsSinceBoot();
}

if (MillisecondsSinceBoot() - brake_light_start_millis < 100) {
LL_GPIO_SetOutputPin(BRAKE_LIGHT_GPIO_Port, BRAKE_LIGHT_Pin);
} else {
LL_GPIO_ResetOutputPin(BRAKE_LIGHT_GPIO_Port, BRAKE_LIGHT_Pin);
}
}

static bool SDCStartupCondition = true; // prevent false positive TSSI on startup
// PRECONDITION: IMD assumed to give valid readings before this is run
void TSSILightControl(ECU_StateData *stateLump)
{
Expand All @@ -30,16 +35,16 @@ void TSSILightControl(ECU_StateData *stateLump)
bool redCar;

// if we are before SDC is reset, don't red car unless there is an active failure
if (SDCStartupCondition) {
if (stateLump->SDC_startup_condition) {
redCar = false;

SDC_Level bms = bmsLevel(stateLump);
SDC_Level imd = imdLevel(stateLump);

if (bms == SDC_OK && imd == SDC_OK) {
SDCStartupCondition = false;
stateLump->SDC_startup_condition = false;
} else if (bms == SDC_ONGOING_FAILURE || imd == SDC_ONGOING_FAILURE) {
SDCStartupCondition = false;
stateLump->SDC_startup_condition = false;
redCar = true;
}
} else {
Expand Down Expand Up @@ -143,8 +148,13 @@ void dashLights(ECU_StateData *stateLump)

GRCAN_DASH_CONFIG_MSG message = {.led_latch_flags = (bms_nonlatch << 5) | (imd_nonlatch << 4) | (bspd_nonlatch << 3) | (bms_latch << 2) | (imd_latch << 1) | (bspd_latch << 0)};
*/
GRCAN_DASH_CONFIG_MSG message = {.led_latch_flags = (!bspdFailure(stateLump) << 5) | (!imdFailure(stateLump) << 4) | (!bmsFailure(stateLump) << 3) | (bspdFailure(stateLump) << 2) |
(imdFailure(stateLump) << 1) | (bmsFailure(stateLump) << 0)};
GRCAN_DASH_CONFIG_MSG message;
if (stateLump->SDC_startup_condition) {
message = (GRCAN_DASH_CONFIG_MSG){.led_latch_flags = (true << 5) | (true << 4) | (true << 3) | (false << 2) | (false << 1) | (false << 0)};
} else {
message = (GRCAN_DASH_CONFIG_MSG){.led_latch_flags = (!bspdFailure(stateLump) << 5) | (!imdFailure(stateLump) << 4) | (!bmsFailure(stateLump) << 3) | (bspdFailure(stateLump) << 2) |
(imdFailure(stateLump) << 1) | (bmsFailure(stateLump) << 0)};
}

message.led_latch_flags = ~message.led_latch_flags; // not to spec, needed as of the current iteration of the dash panel code
ECU_CAN_Send(GRCAN_BUS_PRIMARY, GRCAN_Dash_Panel, GRCAN_DASH_CONFIG, &message, sizeof(message));
Expand Down
24 changes: 12 additions & 12 deletions ECU/Application/Src/StateTicks.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ ECU_StateData stateLump = {
.ecu_state = GR_GLV_ON,
// Assume ACU good at boot
.acu_software_latch = 1,
// Startup at just above minimum power
.powerlevel = 1,
// Startup at minimum power
.powerlevel = 0,
// See CANdo specification
.torquemap = 1,
// APPS Deadzone
Expand All @@ -59,7 +59,8 @@ ECU_StateData stateLump = {
.apps_2_max = 1926,
// Regen
.regen_strength = 2,
.enable_regen = false};
.enable_regen = false,
.SDC_startup_condition = true};

static uint32_t millis_since_boot;
void ECU_State_Tick(void)
Expand Down Expand Up @@ -233,12 +234,11 @@ void ECU_Drive_Active(ECU_StateData *stateData)
LL_GPIO_ResetOutputPin(RTD_CONTROL_GPIO_Port, RTD_CONTROL_Pin);
} else {
LL_GPIO_SetOutputPin(RTD_CONTROL_GPIO_Port, RTD_CONTROL_Pin);
// LOGOMATIC("buzz!\n");
}

if (stateData->rtd_button_pressed) {
stateData->ecu_state = GR_PRECHARGE_COMPLETE;
if (vehicle_is_moving(stateData)) {
if (stateData->vehicle_speed_mph > 0) {
LOGOMATIC("Warning: Vehicle is moving during state transition.\n");
}
return;
Expand All @@ -260,29 +260,29 @@ void ECU_Drive_Active(ECU_StateData *stateData)

if (stateData->apps_bse_violation || !apps_plausible) {
torque_request = 0;
} else if (stateData->enable_regen && PressingBrake(stateData) && 0 > REGEN_MIN_SPEED_MPH) { // stateData->vehicle_speed_mph
} else if (stateData->enable_regen && PressingBrake(stateData) && stateData->vehicle_speed_mph > REGEN_MIN_SPEED_MPH) {
torque_request = -MIN_WITH_TYPES(CalcBrakePressure(stateData) / 5000.0f * stateData->regen_strength, 1.0f) * MAX_REVERSE_CURRENT_AMPS;
} else {
uint16_t max_current = 0;
// Chosen max current for different power level / torque maps
switch (stateData->powerlevel) {
case 0:
max_current = 50;
max_current = 325;
break;
case 1:
max_current = 100;
max_current = 325;
break;
case 2:
max_current = 150;
max_current = 325;
break;
case 3:
max_current = 200;
max_current = 325;
break;
case 4:
max_current = 250;
max_current = 325;
break;
case 5:
max_current = 275;
max_current = 325;
break;
default:
LOGOMATIC("Invalid power level: %d. Defaulting to no current.\n", stateData->powerlevel);
Expand Down
14 changes: 3 additions & 11 deletions ECU/Application/Src/StateUtils.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ bool PressingBrake(volatile const ECU_StateData *stateData)
}
#endif

return (stateData->Brake_F_Signal > stateData->brake_f_min) || (stateData->Brake_R_Signal > stateData->brake_r_min);
return stateData->bse_signal > stateData->brake_bse_min;
}

float CalcBrakePressure(volatile const ECU_StateData *stateData)
Expand All @@ -149,9 +149,7 @@ float CalcBrakePressure(volatile const ECU_StateData *stateData)
return 0;
#endif

float psi_front = stateData->Brake_F_Signal / 4096.0f * 5000.0f;
float psi_rear = stateData->Brake_R_Signal / 4096.0f * 5000.0f;
return fmaxf(psi_front, psi_rear);
return ((float)stateData->bse_signal - 654.09f) * 5000.0f / 2614.73f;
}

// TODO: reconsider deadzone
Expand All @@ -175,15 +173,9 @@ bool APPS_Plausible(volatile const ECU_StateData *stateData)
return error < 0.1f;
}

bool vehicle_is_moving(volatile const ECU_StateData *stateData)
{
const float tolerance = 0.1f; // In MPH
return stateData->vehicle_speed_mph > tolerance;
}

void disable_inverter(void)
{
GRCAN_INV_CMD_MSG inverter_msg = {.drive_enable = 0, .field_weakening = 0, .rpm_limit = 0, .set_ac_current = 0, .set_dc_current = 0};
GRCAN_INV_CMD_MSG inverter_msg = {.drive_enable = 0, .field_weakening = 0, .rpm_limit = 0, .set_ac_current = 32768, .set_dc_current = 32768};
ECU_CAN_Send(GRCAN_BUS_PRIMARY, GRCAN_GR_Inv, GRCAN_INV_CMD, &inverter_msg, sizeof(inverter_msg));
ECU_CAN_Send_DTI(DTI_CONTROL_12_CAN_ID, &inverter_msg.drive_enable, 1);
}
Expand Down
Loading
Loading