Use FaSTTUBe CAN Abstraction Layer
This commit is contained in:
@ -6,6 +6,8 @@
|
||||
#include "ts_state_machine.h"
|
||||
#include "util.h"
|
||||
|
||||
#include "FT_CAN_AL.h"
|
||||
|
||||
ShuntData shunt_data;
|
||||
|
||||
void shunt_init() {
|
||||
@ -25,20 +27,11 @@ void shunt_check() {
|
||||
ts_sm_set_error_source(TS_ERROR_SOURCE_SHUNT, is_error);
|
||||
}
|
||||
|
||||
void shunt_handle_can_msg(CAN_RxHeaderTypeDef *header, uint8_t *data) {
|
||||
void shunt_handle_can_msg(uint16_t id, const uint8_t *data) {
|
||||
// All result messages contain a big-endian 6-byte integer
|
||||
data[7] = 0;
|
||||
data[8] = 0;
|
||||
uint64_t result;
|
||||
memcpy(&result, data, 8);
|
||||
result = ntohll(result);
|
||||
// Top two bytes should always be zero in our usecase (or 0xFF for a signed
|
||||
// number)
|
||||
if ((result >> 4) != 0 && (result >> 4) != 0xFFFF) {
|
||||
set_error_led();
|
||||
}
|
||||
uint64_t result = ftcan_unmarshal_unsigned(&data, 6);
|
||||
|
||||
switch (header->StdId) {
|
||||
switch (id) {
|
||||
case CAN_ID_SHUNT_CURRENT:
|
||||
shunt_data.current = result;
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user