diff --git a/Core/Src/can_handler.c b/Core/Src/can_handler.c index 2cdbb42..0cdc4a9 100644 --- a/Core/Src/can_handler.c +++ b/Core/Src/can_handler.c @@ -1,14 +1,13 @@ #include "can_handler.h" #include "can.h" #include "ringbuffer.h" +#include "analyzer.h" #define NUM_INBOUND_CAN1_IDS 1 #define NUM_INBOUND_CAN2_IDS 1 ringbuffer_t can_receive_queue; - - static const uint16_t i can1_id_list[NUM_INBOUND_CAN1_IDS] = { //CANID_X, NULL @@ -42,4 +41,17 @@ uint8_t get_can_msg(can_msg_t* msg) if (ringbuffer_is_empty(&can_receive_queue)) return -1; ringbuffer_dequeue(&can_receive_queue, msg); + + // TODO list : + // 1. Charger connection flag - have Charger set up with following logic, add correct CAN ID + switch (msg->id) { + case CANID_X: + if (msg->data[0] == 0x01) { + bmsdata->is_charger_connected = true; + } else { + bmsdata->is_charger_connected = false; + } + break; + + return 0; } diff --git a/Core/Src/compute.c b/Core/Src/compute.c index 76804f3..0356974 100644 --- a/Core/Src/compute.c +++ b/Core/Src/compute.c @@ -71,8 +71,8 @@ int compute_send_charging_message(uint16_t voltage_to_set, acc_data_t* bms_data) bool compute_charger_connected() { - //TODO update pin - //return !(digitalRead(CHARGE_DETECT) == 1); + //TODO need to set up CAN msg that actually toggles this bool + return bmsdata->is_charger_connected; } //TODO add this back