Skip to content

Commit

Permalink
Pushing some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
walkermburns committed Feb 9, 2024
1 parent 590d055 commit 911650f
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
8 changes: 4 additions & 4 deletions lib/interfaces/include/AMSInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class AMSInterface
AMSInterface(sw_ok_pin, DEFAULT_INIT_TEMP, DEFAULT_INIT_VOLTAGE, DEFAULT_TEMP_ALPHA, DEFAULT_VOLTAGE_ALPHA) {};

/* Initialize the heartbeat timer */
void init();
void init(unsigned long curr_millis);

/* Write to Main ECU */

Expand All @@ -51,8 +51,8 @@ class AMSInterface
void set_state_ok_high(bool ok_high);

/* Monitor AMS state */
void set_heartbeat();
bool heartbeat_received();
void set_heartbeat(unsigned long curr_millis);
bool heartbeat_received(unsigned long curr_millis);
bool is_below_pack_charge_critical_low_thresh();
bool is_below_pack_charge_critical_total_thresh();
bool pack_charge_is_critical();
Expand All @@ -62,7 +62,7 @@ class AMSInterface
float get_filtered_min_cell_voltage();

/* Retrieve CAN */
void retrieve_status_CAN(CAN_message_t &recvd_msg, unsigned long cur_millis);
void retrieve_status_CAN(unsigned long millis, CAN_message_t &recvd_msg);
void retrieve_temp_CAN(CAN_message_t &recvd_msg);
void retrieve_voltage_CAN(CAN_message_t &recvd_msg);

Expand Down
2 changes: 1 addition & 1 deletion lib/interfaces/include/HytechCANInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ void process_ring_buffer(BufferType &rx_buffer, const InterfaceType &interfaces,

// AMS msg receives
case ID_BMS_STATUS:
interfaces.ams_interface->retrieve_status_CAN(recvd_msg, curr_millis);
interfaces.ams_interface->retrieve_status_CAN(curr_millis, recvd_msg);
break;
case ID_BMS_TEMPERATURES:
interfaces.ams_interface->retrieve_temp_CAN(recvd_msg);
Expand Down
6 changes: 3 additions & 3 deletions lib/interfaces/src/AMSInterface.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include "AMSInterface.h"

/* Pin mode output to watchdog reset */
void AMSInterface::init() {
void AMSInterface::init(unsigned long curr_millis) {

set_heartbeat();
set_heartbeat(curr_millis);

}

Expand Down Expand Up @@ -68,7 +68,7 @@ float AMSInterface::get_filtered_min_cell_voltage() {
}

/* Retrieve CAN messages */
void AMSInterface::retrieve_status_CAN(CAN_message_t &recvd_msg, unsigned long curr_millis) {
void AMSInterface::retrieve_status_CAN(unsigned long curr_millis, CAN_message_t &recvd_msg) {
bms_status_.load(recvd_msg.buf);
set_heartbeat(curr_millis);
}
Expand Down
3 changes: 2 additions & 1 deletion lib/systems/src/SafetySystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ void SafetySystem::software_shutdown(const SysTick_s &tick) {

// If AMS heartbeat is not received within reasonable interval
// Set software is not ok
if (!ams_->heartbeat_received()) {
unsigned long millis = (unsigned long) tick.millis;
if (!ams_->heartbeat_received(millis)) {
software_is_ok = false;
}
if (software_is_ok)
Expand Down
4 changes: 2 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ void setup() {
/* Initialize interface */
main_ecu.init(); // initial shutdown circuit readings,
wd_interface.init(curr_tick); // initialize wd kick time
ams_interface.init(); // initialize last heartbeat time
ams_interface.init(curr_tick.millis); // initialize last heartbeat time

/* Initialize system */
safety_system.init(); // write software_ok high, write wd_input high, set software ok state true
Expand Down Expand Up @@ -179,7 +179,7 @@ void tick_all_interfaces(const SysTick_s& current_system_tick) {
}

void tick_all_systems(const SysTick_s& current_system_tick) {

// tick pedals system
pedals_system.tick(
current_system_tick,
Expand Down

0 comments on commit 911650f

Please sign in to comment.