diff --git a/.github/workflows/compile-all-inverters.yml b/.github/workflows/compile-all-inverters.yml index f9504af9..c7a017da 100644 --- a/.github/workflows/compile-all-inverters.yml +++ b/.github/workflows/compile-all-inverters.yml @@ -51,7 +51,7 @@ jobs: - SOFAR_CAN - SOLAX_CAN - SERIAL_LINK_TRANSMITTER - + - NISSANLEAF_CHARGER # Last element is not an inverter, but good to also test if charger compiles # This is the platform GitHub will use to run our workflow. runs-on: ubuntu-latest diff --git a/Software/Software.ino b/Software/Software.ino index 76d1780e..f92dc352 100644 --- a/Software/Software.ino +++ b/Software/Software.ino @@ -527,11 +527,8 @@ void receive_can() { // This section checks if we have a complete CAN message i receive_can_sma_tripower(rx_frame); #endif // Charger -#ifdef CHEVYVOLT_CHARGER - receive_can_chevyvolt_charger(rx_frame); -#endif -#ifdef NISSANLEAF_CHARGER - receive_can_nissanleaf_charger(rx_frame); +#if defined(CHEVYVOLT_CHARGER) || defined(NISSANLEAF_CHARGER) + receive_can_charger(rx_frame); #endif } else { // New extended frame #ifdef PYLON_CAN @@ -565,11 +562,8 @@ void send_can() { // Battery send_can_battery(); // Charger -#ifdef CHEVYVOLT_CHARGER - send_can_chevyvolt_charger(); -#endif -#ifdef NISSANLEAF_CHARGER - send_can_nissanleaf_charger(); +#if defined(CHEVYVOLT_CHARGER) || defined(NISSANLEAF_CHARGER) + send_can_charger(); #endif } diff --git a/Software/src/charger/CHARGERS.h b/Software/src/charger/CHARGERS.h index c2dd3fdc..5acfca63 100644 --- a/Software/src/charger/CHARGERS.h +++ b/Software/src/charger/CHARGERS.h @@ -1,7 +1,7 @@ #ifndef CHARGERS_H #define CHARGERS_H - #include "../../USER_SETTINGS.h" +#include "../lib/miwagner-ESP32-Arduino-CAN/ESP32CAN.h" // This include is annoying, consider defining a frame type in types.h #ifdef CHEVYVOLT_CHARGER #include "CHEVY-VOLT-CHARGER.h" @@ -11,4 +11,7 @@ #include "NISSAN-LEAF-CHARGER.h" #endif +void receive_can_charger(CAN_frame_t rx_frame); +void send_can_charger(); + #endif diff --git a/Software/src/charger/CHEVY-VOLT-CHARGER.cpp b/Software/src/charger/CHEVY-VOLT-CHARGER.cpp index 14f899e8..f9492f80 100644 --- a/Software/src/charger/CHEVY-VOLT-CHARGER.cpp +++ b/Software/src/charger/CHEVY-VOLT-CHARGER.cpp @@ -1,6 +1,7 @@ #include "../include.h" #ifdef CHEVYVOLT_CHARGER #include "../datalayer/datalayer.h" +#include "../devboard/utils/events.h" #include "../lib/miwagner-ESP32-Arduino-CAN/CAN_config.h" #include "../lib/miwagner-ESP32-Arduino-CAN/ESP32CAN.h" #include "CHEVY-VOLT-CHARGER.h" @@ -63,7 +64,7 @@ static CAN_frame_t charger_set_targets = {.FIR = {.B = .data = {0x40, 0x00, 0x00, 0x00}}; /* We are mostly sending out not receiving */ -void receive_can_chevyvolt_charger(CAN_frame_t rx_frame) { +void receive_can_charger(CAN_frame_t rx_frame) { uint16_t charger_stat_HVcur_temp = 0; uint16_t charger_stat_HVvol_temp = 0; uint16_t charger_stat_LVcur_temp = 0; @@ -115,7 +116,7 @@ void receive_can_chevyvolt_charger(CAN_frame_t rx_frame) { } } -void send_can_chevyvolt_charger() { +void send_can_charger() { unsigned long currentMillis = millis(); uint16_t Vol_temp = 0; diff --git a/Software/src/charger/CHEVY-VOLT-CHARGER.h b/Software/src/charger/CHEVY-VOLT-CHARGER.h index 260fa3c6..3feb5788 100644 --- a/Software/src/charger/CHEVY-VOLT-CHARGER.h +++ b/Software/src/charger/CHEVY-VOLT-CHARGER.h @@ -4,6 +4,8 @@ #include "../include.h" #include "../lib/miwagner-ESP32-Arduino-CAN/ESP32CAN.h" +#define CHARGER_SELECTED + /* Charger hardware limits * * Relative to runtime settings, expectations are: @@ -14,8 +16,4 @@ #define CHEVYVOLT_MAX_AMP 11.5 #define CHEVYVOLT_MAX_POWER 3300 -void update_values_can_chevyvolt_charger(); -void send_can_chevyvolt_charger(); -void receive_can_chevyvolt_charger(CAN_frame_t rx_frame); - #endif diff --git a/Software/src/charger/NISSAN-LEAF-CHARGER.cpp b/Software/src/charger/NISSAN-LEAF-CHARGER.cpp index d49a0d56..875c94de 100644 --- a/Software/src/charger/NISSAN-LEAF-CHARGER.cpp +++ b/Software/src/charger/NISSAN-LEAF-CHARGER.cpp @@ -1,6 +1,7 @@ #include "../include.h" -#ifdef NISSAN_LEAF_CHARGER +#ifdef NISSANLEAF_CHARGER #include "../datalayer/datalayer.h" +#include "../devboard/utils/events.h" #include "../lib/miwagner-ESP32-Arduino-CAN/CAN_config.h" #include "../lib/miwagner-ESP32-Arduino-CAN/ESP32CAN.h" #include "NISSAN-LEAF-CHARGER.h" @@ -144,7 +145,7 @@ static uint8_t calculate_checksum_nibble(CAN_frame_t* frame) { return sum; } -void receive_can_nissanleaf_charger(CAN_frame_t rx_frame) { +void receive_can_charger(CAN_frame_t rx_frame) { switch (rx_frame.MsgID) { case 0x679: // This message fires once when charging cable is plugged in @@ -181,7 +182,7 @@ void receive_can_nissanleaf_charger(CAN_frame_t rx_frame) { } } -void send_can_nissanleaf_charger() { +void send_can_charger() { unsigned long currentMillis = millis(); /* Send keepalive with mode every 10ms */ diff --git a/Software/src/charger/NISSAN-LEAF-CHARGER.h b/Software/src/charger/NISSAN-LEAF-CHARGER.h index 7ac88a46..3722ae3a 100644 --- a/Software/src/charger/NISSAN-LEAF-CHARGER.h +++ b/Software/src/charger/NISSAN-LEAF-CHARGER.h @@ -4,7 +4,6 @@ #include "../include.h" #include "../lib/miwagner-ESP32-Arduino-CAN/ESP32CAN.h" -void send_can_nissanleaf_charger(); -void receive_can_nissanleaf_charger(CAN_frame_t rx_frame); +#define CHARGER_SELECTED #endif diff --git a/Software/src/include.h b/Software/src/include.h index a43017ba..637805ad 100644 --- a/Software/src/include.h +++ b/Software/src/include.h @@ -12,6 +12,7 @@ #include "devboard/utils/types.h" #include "battery/BATTERIES.h" +#include "charger/CHARGERS.h" #include "inverter/INVERTERS.h" /* - ERROR CHECKS BELOW, DON'T TOUCH - */