Battery-Emulator/Software/SOLAX-CAN.h
2023-08-27 14:16:08 +03:00

46 lines
No EOL
1.3 KiB
C

#ifndef SOLAX_CAN_H
#define SOLAX_CAN_H
#include <Arduino.h>
#include "ESP32CAN.h"
#include "config.h"
//#define DUAL_CAN //Enable this line to activate an isolated secondary CAN Bus using add-on MCP2515 controller (Needed for FoxESS inverters)
#ifdef DUAL_CAN
#include "ACAN2515.h" //If this file is missing, install the ACAN2515 library
extern ACAN2515 can;
#endif
extern uint16_t SOC;
extern uint16_t StateOfHealth;
extern uint16_t battery_voltage;
extern uint16_t battery_current;
extern uint16_t capacity_Wh;
extern uint16_t remaining_capacity_Wh;
extern uint16_t max_target_discharge_power;
extern uint16_t max_target_charge_power;
extern uint16_t bms_status;
extern uint16_t bms_char_dis_status;
extern uint16_t stat_batt_power;
extern uint16_t temperature_min;
extern uint16_t temperature_max;
extern uint16_t CANerror;
extern uint16_t min_volt_solax_can;
extern uint16_t max_volt_solax_can;
extern uint16_t cell_max_voltage;
extern uint16_t cell_min_voltage;
extern uint8_t inverterAllowsContactorClosing;
// Timeout in milliseconds
#define SolaxTimeout 2000
//SOLAX BMS States Definition
#define BATTERY_ANNOUNCE 0
#define WAITING_FOR_CONTACTOR 1
#define CONTACTOR_CLOSED 2
#define FAULT_SOLAX 3
#define UPDATING_FW 4
void update_values_can_solax();
void receive_can_solax(CAN_frame_t rx_frame);
#endif