mirror of
https://github.com/dalathegreat/Battery-Emulator.git
synced 2025-10-03 17:59:27 +02:00
Start of CANFD refactoring
This commit is contained in:
parent
126c19e534
commit
e183602f44
4 changed files with 14 additions and 10 deletions
|
@ -524,7 +524,15 @@ void receive_canfd() { // This section checks if we have a complete CAN-FD mess
|
|||
#ifdef DEBUG_CANFD_DATA
|
||||
print_canfd_frame(frame);
|
||||
#endif
|
||||
receive_canfd_battery(frame);
|
||||
CAN_frame rx_frame;
|
||||
rx_frame.ID = frame.id;
|
||||
rx_frame.ext_ID = frame.ext;
|
||||
rx_frame.DLC = frame.len;
|
||||
for (uint8_t i = 0; i < rx_frame.DLC && i < 64; i++) {
|
||||
rx_frame.data.u8[i] = frame.data[i];
|
||||
}
|
||||
//message incoming, pass it on to the handler
|
||||
receive_can(&rx_frame, CAN_ADDON_FD_MCP2518);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -540,7 +548,7 @@ void receive_can_native() { // This section checks if we have a complete CAN me
|
|||
rx_frame.ext_ID = true;
|
||||
}
|
||||
rx_frame.DLC = rx_frame_native.FIR.B.DLC;
|
||||
for (uint8_t i = 0; i < rx_frame.DLC; i++) {
|
||||
for (uint8_t i = 0; i < rx_frame.DLC && i < 8; i++) {
|
||||
rx_frame.data.u8[i] = rx_frame_native.data.u8[i];
|
||||
}
|
||||
//message incoming, pass it on to the handler
|
||||
|
@ -575,7 +583,7 @@ void receive_can_addonMCP2515() { // This section checks if we have a complete
|
|||
rx_frame_can_addonMCP2515.FIR.B.FF = MCP2515Frame.ext ? CAN_frame_ext : CAN_frame_std;
|
||||
rx_frame_can_addonMCP2515.FIR.B.RTR = MCP2515Frame.rtr ? CAN_RTR : CAN_no_RTR;
|
||||
rx_frame_can_addonMCP2515.FIR.B.DLC = MCP2515Frame.len;
|
||||
for (uint8_t i = 0; i < MCP2515Frame.len; i++) {
|
||||
for (uint8_t i = 0; i < MCP2515Frame.len && i < 8; i++) {
|
||||
rx_frame_can_addonMCP2515.data.u8[i] = MCP2515Frame.data[i];
|
||||
}
|
||||
|
||||
|
@ -919,7 +927,6 @@ void transmit_can(CAN_frame* tx_frame, int interface) {
|
|||
MCP2518Frame.id = tx_frame->ID;
|
||||
MCP2518Frame.ext = tx_frame->ext_ID ? CAN_frame_ext : CAN_frame_std;
|
||||
MCP2518Frame.len = tx_frame->DLC;
|
||||
MCP2518Frame.rtr = false;
|
||||
for (uint8_t i = 0; i < MCP2518Frame.len; i++) {
|
||||
MCP2518Frame.data[i] = tx_frame->data.u8[i];
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ CAN_ADDON_FD_MCP2518 = Add-on CAN-FD MCP2518 connected to GPIO pins
|
|||
*/
|
||||
|
||||
volatile CAN_Configuration can_config = {
|
||||
.battery = CAN_NATIVE, // Which CAN is your battery connected to?
|
||||
.battery = CAN_ADDON_FD_MCP2518, // Which CAN is your battery connected to?
|
||||
.inverter = CAN_NATIVE, // Which CAN is your inverter connected to? (No need to configure incase you use RS485)
|
||||
.battery_double = CAN_ADDON_MCP2515, // (OPTIONAL) Which CAN is your second battery connected to?
|
||||
.charger = CAN_NATIVE // (OPTIONAL) Which CAN is your charger connected to?
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
//#define KIA_E_GMP_BATTERY
|
||||
//#define KIA_HYUNDAI_HYBRID_BATTERY
|
||||
//#define MG_5_BATTERY
|
||||
//#define NISSAN_LEAF_BATTERY
|
||||
#define NISSAN_LEAF_BATTERY
|
||||
//#define PYLON_BATTERY
|
||||
//#define RENAULT_KANGOO_BATTERY
|
||||
//#define RENAULT_ZOE_GEN1_BATTERY
|
||||
|
@ -49,7 +49,7 @@
|
|||
//#define CONTACTOR_CONTROL //Enable this line to have pins 25,32,33 handle automatic precharge/contactor+/contactor- closing sequence
|
||||
//#define PWM_CONTACTOR_CONTROL //Enable this line to use PWM logic for contactors, which lower power consumption and heat generation
|
||||
//#define DUAL_CAN //Enable this line to activate an isolated secondary CAN Bus using add-on MCP2515 controller (Needed for some inverters / double battery)
|
||||
//#define CAN_FD //Enable this line to activate an isolated secondary CAN-FD bus using add-on MCP2517FD controller (Needed for some batteries)
|
||||
#define CAN_FD //Enable this line to activate an isolated secondary CAN-FD bus using add-on MCP2517FD controller (Needed for some batteries)
|
||||
//#define SERIAL_LINK_RECEIVER //Enable this line to receive battery data over RS485 pins from another Lilygo (This LilyGo interfaces with inverter)
|
||||
//#define SERIAL_LINK_TRANSMITTER //Enable this line to send battery data over RS485 pins to another Lilygo (This LilyGo interfaces with battery)
|
||||
#define WEBSERVER //Enable this line to enable WiFi, and to run the webserver. See USER_SETTINGS.cpp for the Wifi settings.
|
||||
|
|
|
@ -79,9 +79,6 @@
|
|||
#endif
|
||||
|
||||
void receive_can_battery(CAN_frame rx_frame);
|
||||
#ifdef CAN_FD
|
||||
void receive_canfd_battery(CANFDMessage frame);
|
||||
#endif
|
||||
|
||||
void update_values_battery();
|
||||
void send_can_battery();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue