Skip to content

Commit

Permalink
implemented outline of handling incoming CAN
Browse files Browse the repository at this point in the history
  • Loading branch information
Dylan Donahue committed Dec 19, 2023
1 parent 324464e commit ee1e0e9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
16 changes: 14 additions & 2 deletions Core/Src/can_handler.c
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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;
}
4 changes: 2 additions & 2 deletions Core/Src/compute.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ee1e0e9

Please sign in to comment.