Skip to content

Commit

Permalink
Merge pull request #111 from davefiddes/various-cleanups
Browse files Browse the repository at this point in the history
Various non-function affecting code cleanups
  • Loading branch information
damienmaguire authored Sep 27, 2024
2 parents 7d055fc + bc04191 commit 0f1153d
Show file tree
Hide file tree
Showing 20 changed files with 189 additions and 284 deletions.
29 changes: 12 additions & 17 deletions include/Can_OI.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,35 +21,30 @@
*/
#ifndef CAN_OI_H
#define CAN_OI_H
#include <libopencm3/stm32/crc.h>
#include <stdint.h>
#include "my_fp.h"

#include "inverter.h"
#include "canhardware.h"
#include <stdint.h>

class Can_OI: public Inverter
{
public:
void Task100Ms();
void DecodeCAN(int, uint32_t*);
void SetTorque(float torquePercent);
float GetMotorTemperature() { return motor_temp; }
float GetInverterTemperature() { return inv_temp; }
float GetInverterVoltage() { return voltage; }
float GetMotorSpeed() { return speed; }
int GetInverterState();
void SetCanInterface(CanHardware* c);
void Task100Ms() override;
void DecodeCAN(int, uint32_t*) override;
void SetTorque(float torquePercent) override;
float GetMotorTemperature() override { return motor_temp; }
float GetInverterTemperature() override { return inv_temp; }
float GetInverterVoltage() override { return voltage; }
float GetMotorSpeed() override { return speed; }
int GetInverterState() override;
void SetCanInterface(CanHardware* c) override;

private:
static int16_t speed;
static int16_t inv_temp;
static int16_t motor_temp;
static bool error;
static uint16_t voltage;

static uint8_t run100ms;
static uint32_t lastRecv;
static int16_t final_torque_request;

};

#endif // CAN_OI_H
11 changes: 7 additions & 4 deletions include/daisychainbms.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,18 @@

#ifndef DAISYCHAINBMS_H
#define DAISYCHAINBMS_H

#include "bms.h"
#include "canhardware.h"
#include <stdint.h>

class DaisychainBMS: public BMS
{
public:
virtual void SetCanInterface(CanHardware* c);
void DecodeCAN(int id, uint8_t * data);
float MaxChargeCurrent();
void Task100Ms();
void SetCanInterface(CanHardware* c) override;
void DecodeCAN(int id, uint8_t * data) override;
float MaxChargeCurrent() override;
void Task100Ms() override;
private:
bool BMSDataValid();
bool ChargeAllowed();
Expand Down
36 changes: 16 additions & 20 deletions include/i3LIM.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,29 @@
*/

#include <stdint.h>
#include "my_fp.h"
#include "params.h"
#include "stm32_can.h"
#include "chargerint.h"
#include "my_math.h"
#include "canhardware.h"
#include <stdint.h>

class i3LIMClass: public Chargerint
{

public:
void SetCanInterface(CanHardware* c);
void DecodeCAN(int id, uint32_t data[2]);
void Task10Ms();
void Task100Ms();
void Task200Ms();
bool DCFCRequest(bool RunCh);
bool ACRequest(bool RunCh);
void SetCanInterface(CanHardware* c) override;
void DecodeCAN(int id, uint32_t* data) override;
void Task10Ms() override;
void Task100Ms() override;
void Task200Ms() override;
bool DCFCRequest(bool RunCh) override;
bool ACRequest(bool RunCh) override;

private:
static void handle3B4(uint32_t data[2]);
static void handle29E(uint32_t data[2]);
static void handle2B2(uint32_t data[2]);
static void handle2EF(uint32_t data[2]);
static void handle272(uint32_t data[2]);
static void CCS_Pwr_Con();
static void Chg_Timers();
void handle3B4(uint32_t data[2]);
void handle29E(uint32_t data[2]);
void handle2B2(uint32_t data[2]);
void handle2EF(uint32_t data[2]);
void handle272(uint32_t data[2]);
void CCS_Pwr_Con();
void Chg_Timers();
};

#endif /* i3LIM_h */
9 changes: 0 additions & 9 deletions include/isa_shunt.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,6 @@ class ISA


private:
static unsigned long elapsedtime;
static double ampseconds;
static int milliseconds ;
static int seconds;
static int minutes;
static int hours;
static char buffer[9];
static char bigbuffer[90];

static void handle521(uint32_t data[2]);
static void handle522(uint32_t data[2]);
static void handle523(uint32_t data[2]);
Expand Down
15 changes: 9 additions & 6 deletions include/kangoobms.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,22 @@

#ifndef KANGOOBMS_H
#define KANGOOBMS_H

#include "bms.h"
#include "canhardware.h"
#include <stdint.h>


class KangooBMS: public BMS
{
public:
virtual void SetCanInterface(CanHardware* c);
void DecodeCAN(int id, uint8_t * data);
float MaxChargeCurrent();
float GetCurrent();
void Task100Ms();
void SetCanInterface(CanHardware* c) override;
void DecodeCAN(int id, uint8_t * data) override;
float MaxChargeCurrent() override;
void Task100Ms() override;

private:
bool BMSDataValid();
bool ChargeAllowed();
int messageCounter = 0;
int chargeCurrentLimit = 0;
int timeoutCounter = 0;
Expand Down
24 changes: 2 additions & 22 deletions include/leafbms.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,8 @@
class LeafBMS: public BMS
{
public:
virtual void SetCanInterface(CanHardware* can);
void DecodeCAN(int id, uint8_t * data);
static void RequestNextFrame(CanHardware* can);
static uint16_t GetCellVoltage(int idx);
static int GetCellStatus(int idx);
static const int NUMCELLS = 96;
static float Voltage;
static float Voltage2;
static int32_t Temperature;
static int32_t Amperes; // Floating point with current in Amperes
static int32_t SOC;
static int32_t KW;
static int32_t KWh;


private:
static uint8_t Crc8ForHCM(int n, uint8_t *msg);
static int bmsGrp;
static int bmsGrpIndex;
static uint8_t voltBytes[NUMCELLS * 2];
static uint8_t statusBits[NUMCELLS / 4];

void SetCanInterface(CanHardware* can) override;
void DecodeCAN(int id, uint8_t * data) override;
};

#endif // LEAFBMS_H
11 changes: 7 additions & 4 deletions include/simpbms.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,18 @@

#ifndef SIMPBMS_H
#define SIMPBMS_H

#include "bms.h"
#include "canhardware.h"
#include <stdint.h>

class SimpBMS: public BMS
{
public:
virtual void SetCanInterface(CanHardware* c);
void DecodeCAN(int id, uint8_t * data);
float MaxChargeCurrent();
void Task100Ms();
void SetCanInterface(CanHardware* c) override;
void DecodeCAN(int id, uint8_t * data) override;
float MaxChargeCurrent() override;
void Task100Ms() override;
private:
bool BMSDataValid();
bool ChargeAllowed();
Expand Down
113 changes: 0 additions & 113 deletions include/stm32_vcu.h

This file was deleted.

29 changes: 9 additions & 20 deletions include/teslaCharger.h
Original file line number Diff line number Diff line change
@@ -1,32 +1,21 @@

#ifndef teslaCharger_h
#define teslsCharger_h
#ifndef TESLACHARGER_H
#define TESLACHARGER_H

/* This library supports the various opensource tesla charger controllers e.g. PCS , Gen2/3 etc.
*/

#include <stdint.h>
#include "my_fp.h"
#include "params.h"
#include "chargerhw.h"
#include "my_math.h"
#include "canhardware.h"
#include <stdint.h>

class teslaCharger: public Chargerhw
{

public:
void DecodeCAN(int id, uint32_t data[2]);
void Task100Ms();
bool ControlCharge(bool RunCh, bool ACReq);
void SetCanInterface(CanHardware* c);
/*
static void handle108(uint32_t data[2]);
static bool HVreq;
static void Send100msMessages(bool ChRun, CanHardware* can);
*/
private:

void DecodeCAN(int id, uint32_t data[2]) override;
void Task100Ms() override;
bool ControlCharge(bool RunCh, bool ACReq) override;
void SetCanInterface(CanHardware* c) override;
};

#endif /* teslaCharger_h */
#endif /* TESLACHARGER_H */
Loading

0 comments on commit 0f1153d

Please sign in to comment.