fixed compilation errors

This commit is contained in:
bitscuit 2023-04-22 15:15:31 +02:00
parent bc0dc33e95
commit 516e190634
1 changed files with 8 additions and 5 deletions

View File

@ -51,11 +51,14 @@ char tc_state = TC_OK; /* Status of the Torque Controller *
uint8_t apps_value = 0; /* Value of the APPS sensor (0-255) */
uint8_t bpps_value = 0; /* Value of the BPPS sensor (0-255) */
uint64_t time_last_apps_bpps = 0; /* Timestamp of last message for APPS and BPPS values */
#define APPS_BPPS_TIMEOUT 200 /* If no values are received for this time, enter safe state */
#define APPS_THRESHOLD 10 /* Threshold for APPS values below which it is considered not activated */
#define RTD_INACTIVE 0b0
#define RTD_ACTIVE 0b1
char rtd_state = RTD_INACTIVE; /* Whether or not RTD is actived */
uint64_t time_last_rtd_state = 0; /* Timestamp of last message for Boot Sequence State stuff */
#define RTD_TIMEOUT 200 /* If no state information is received for this time, enter safe state */
uint64_t time_last_can_mc_send_enable = 0; /* Timestamp of last enable/disable message that was sent to motorcontrollers (because they have timeout safety shit) */
uint64_t time_last_can_mc_send_erpm = 0; /* Timestamp of last erpm message that was sent to motorcontrollers (to limit amount of messages) */
@ -261,7 +264,7 @@ void can_mc_send_drive_allowed(char allowed) {
can_mc.write(mr);
/* Update state */
time_last_can_mc_send_enable = millis()
time_last_can_mc_send_enable = millis();
}
void can_mc_send_erpm(int32_t erpm_l, int32_t erpm_r) {
@ -286,7 +289,7 @@ void can_mc_send_erpm(int32_t erpm_l, int32_t erpm_r) {
can_mc.write(mr);
/* Update state */
time_last_can_mc_send_erpm = millis()
time_last_can_mc_send_erpm = millis();
}
/* Subroutine to check if new heartbeat message needs to be sent and transmits it if needed */
@ -365,7 +368,7 @@ void analyse_drive_data() {
/* Subroutine to update invertors */
void update_drives() {
/* Check timeouts */
if (millis() > time_last_rtd + RTD_TIMEOUT) enter_safe_state(FAULT_RTD_TIMEOUT);
if (millis() > time_last_rtd_state + RTD_TIMEOUT) enter_safe_state(FAULT_RTD_TIMEOUT);
if (millis() > time_last_apps_bpps + APPS_BPPS_TIMEOUT) enter_safe_state(FAULT_APPS_BPPS_TIMEOUT);
/* Check if needs to send enable message */
@ -406,8 +409,8 @@ void update_brakelight() {
char output = (bpps_value > BPPS_THRESHOLD) ? BRAKELIGHT_ON : BRAKELIGHT_OFF;
/* When fault: blink brakelight */
if (tc_state != TS_OK) {
output = (millis() & 0xFF < 50) ? BRAKELIGHT_ON : BRAKELIGHT_OFF;
if (tc_state != TC_OK) {
output = ((millis() & 0xFF) < 50) ? BRAKELIGHT_ON : BRAKELIGHT_OFF;
}
digitalWrite(PIN_BRAKELIGHT, output);