feat: init commit
This commit is contained in:
36
Software/Core/Src/can.c
Normal file
36
Software/Core/Src/can.c
Normal file
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* can.c
|
||||
*
|
||||
* Created on: Jun 12, 2025
|
||||
* Author: janek
|
||||
*/
|
||||
|
||||
#include "can.h"
|
||||
|
||||
rx_acc acc_status = {};
|
||||
extern int ts_on;
|
||||
extern int ams_last_tick;
|
||||
extern int r2d_progress;
|
||||
dash_tx_t dash_tx;
|
||||
|
||||
void can_init(CAN_HandleTypeDef* hcan){
|
||||
ftcan_init(hcan);
|
||||
ftcan_add_filter(0x00, 0x00); // no filter
|
||||
}
|
||||
|
||||
void can_send(){
|
||||
uint8_t data[1];
|
||||
data[0] = dash_tx.dash_send;
|
||||
ftcan_transmit(CAN_ID_TX, data, 1);
|
||||
}
|
||||
|
||||
void ftcan_msg_received_cb(uint16_t id, size_t datalen, const uint8_t* data){
|
||||
if(id == CAN_ID_RX_AMS){
|
||||
ams_last_tick = HAL_GetTick();
|
||||
acc_status.ams_status.ams_rx = data[0];
|
||||
acc_status.led_status.ams_led = data[7];
|
||||
}
|
||||
if(id == CAN_ID_RX_R2D){
|
||||
r2d_progress = data[1] & 0x0F;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user