Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ OBJSL = $(BINARY).o hwinit.o stm32scheduler.o params.o terminal.o terminal_prj.
chademo.o amperaheater.o amperacharger.o subaruvehicle.o iomatrix.o bmw_sbox.o NissanPDM.o teslaCharger.o extCharger.o vag_sbox.o \
daisychainbms.o simpbms.o outlanderCharger.o Can_OBD2.o cansdo.o TeslaDCDC.o BMW_E31.o F30_Lever.o \
CPC.o ElconCharger.o RearOutlanderinverter.o linbus.o VWCoolantHeater.o JLR_G1.o JLR_G2.o Foccci.o digipot.o\
OutlanderHeartBeat.o E65_Lever.o leafbms.o V_Classic.o kangoobms.o OutlanderCanHeater.o VWAirHeater.o\
MGCoolantHeater.o NissLeafMng.o preheater.o MGgen2V2Lcharger.o
OutlanderHeartBeat.o E65_Lever.o leafbms.o V_Classic.o kangoobms.o OutlanderCanHeater.o VWAirHeater.o\
MGCoolantHeater.o NissLeafMng.o preheater.o MGgen2V2Lcharger.o Gear_9x1.o vw_mlb_charger.o vag_utils.o\
Comment on lines +47 to +48
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
OutlanderHeartBeat.o E65_Lever.o leafbms.o V_Classic.o kangoobms.o OutlanderCanHeater.o VWAirHeater.o\
MGCoolantHeater.o NissLeafMng.o preheater.o MGgen2V2Lcharger.o Gear_9x1.o vw_mlb_charger.o vag_utils.o\
OutlanderHeartBeat.o E65_Lever.o leafbms.o V_Classic.o kangoobms.o OutlanderCanHeater.o VWAirHeater.o \
MGCoolantHeater.o NissLeafMng.o preheater.o MGgen2V2Lcharger.o Gear_9x1.o vw_mlb_charger.o vag_utils.o \



OBJS = $(patsubst %.o,$(OUT_DIR)/%.o, $(OBJSL))
Expand Down
42 changes: 42 additions & 0 deletions include/Gear_9x1.h
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file has an indentation level of 3, which is not really standard.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also I wonder if Gear_9x1 is a good name for the files. Just from the name I wouldn't really know what it is for.

Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* This file is part of the Zombieverter project.
*
* Copyright (C) 2024 Mitch Elliott
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef Gear_9x1_h
#define Gear_9x1_h
Comment on lines +20 to +21
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#ifndef Gear_9x1_h
#define Gear_9x1_h
#ifndef GEAR_9X1_H
#define GEAR_9X1_H

Typically you write the include guard in all upper-case (most defines for that matter).


#include "shifter.h"

class Gear_9x1: public Shifter
{
public:

void Task10Ms();
void Task100Ms();
void DecodeCAN(int, uint32_t*);
bool GetGear(Shifter::Sgear& outGear);//if shifter class knows gear return true and set dir
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
bool GetGear(Shifter::Sgear& outGear);//if shifter class knows gear return true and set dir
bool GetGear(Shifter::Sgear& outGear); // if shifter class knows gear return true and set dir

void SetCanInterface(CanHardware* c);

private:
Shifter::Sgear gear;
};


#endif // Gear_9x1_INCLUDED


Comment on lines +40 to +42
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#endif // Gear_9x1_INCLUDED
#endif // GEAR_9X1_H

14 changes: 8 additions & 6 deletions include/param_prj.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
#define PARAM_LIST \
PARAM_ENTRY(CAT_SETUP, Inverter, INVMODES, 0, 8, 0, 5 ) \
PARAM_ENTRY(CAT_SETUP, Vehicle, VEHMODES, 0, 8, 0, 6 ) \
PARAM_ENTRY(CAT_SETUP, GearLvr, SHIFTERS, 0, 4, 0, 108 ) \
PARAM_ENTRY(CAT_SETUP, GearLvr, SHIFTERS, 0, 5, 0, 108 ) \
PARAM_ENTRY(CAT_SETUP, Transmission, TRNMODES, 0, 1, 0, 78 ) \
PARAM_ENTRY(CAT_SETUP, interface, CHGINT, 0, 4, 0, 39 ) \
PARAM_ENTRY(CAT_SETUP, chargemodes, CHGMODS, 0, 7, 0, 37 ) \
PARAM_ENTRY(CAT_SETUP, chargemodes, CHGMODS, 0, 8, 0, 37 ) \
PARAM_ENTRY(CAT_SETUP, BMS_Mode, BMSMODES, 0, 5, 0, 90 ) \
PARAM_ENTRY(CAT_SETUP, ShuntType, SHNTYPE, 0, 4, 0, 88 ) \
PARAM_ENTRY(CAT_SETUP, InverterCan, CAN_DEV, 0, 1, 0, 70 ) \
Expand Down Expand Up @@ -270,7 +270,7 @@
"12=DCFCRequest, 13=BrakeVacPump, 14=CoolingFan, 15=HvActive, 16=ShiftLockNO, 17=PreHeatOut, 18=PwmTim3, 19=CpSpoof,"\
"20=GS450pump, 21=PwmTempGauge, 22=PwmSocGauge"
#define APINFUNCS "0=None, 1=ProxPilot, 2=BrakeVacSensor, 3=HeaterPot"
#define SHIFTERS "0=None, 1=BMW_F30, 2=JLR_G1, 3=JLR_G2, 4=BMW_E65"
#define SHIFTERS "0=None, 1=BMW_F30, 2=JLR_G1, 3=JLR_G2, 4=BMW_E65, 5=Porsche_PDK"
#define SHNTYPE "0=None, 1=ISA, 2=SBOX, 3=VAG. 4=ISA_udcsw"
#define DMODES "0=CLOSED, 1=OPEN, 2=ERROR, 3=INVALID"
#define POTMODES "0=SingleChannel, 1=DualChannel"
Expand Down Expand Up @@ -298,7 +298,7 @@
#define CDMSTAT "1=Charging, 2=Malfunction, 4=ConnLock, 8=BatIncomp, 16=SystemMalfunction, 32=Stop"
#define HTTYPE "0=None, 1=Ampera, 2=VWCoolant, 3=VWAir, 4=OutlanderCan, 5=MGCoolant"
#define HTCTRL "0=Disable, 1=Enable, 2=Timer"
#define CHGMODS "0=Off, 1=EXT_DIGI, 2=Volt_Ampera, 3=Leaf_PDM, 4=TeslaOI, 5=Out_lander, 6=Elcon, 7=MGgen2"
#define CHGMODS "0=Off, 1=EXT_DIGI, 2=Volt_Ampera, 3=Leaf_PDM, 4=TeslaOI, 5=Out_lander, 6=Elcon, 7=MGgen2, 8=MLBEvo"
#define CHGCTRL "0=Enable, 1=Disable, 2=Timer"
#define CHGINT "0=Unused, 1=i3LIM, 2=Chademo, 3=CPC, 4=Foccci"
#define CAN3SPD "0=k33.3, 1=k500, 2=k100"
Expand Down Expand Up @@ -388,7 +388,8 @@ enum ChargeModes
TeslaOI = 4,
Out_lander = 5,
Elcon = 6,
MGgen2=7
MGgen2 = 7,
MLBevo = 8
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
MLBevo = 8
MLBevo = 8,

It's good practise to give the last entry a comma as well, so you don't have to change it when adding an entry.

};

enum ChargeInterfaces
Expand Down Expand Up @@ -433,7 +434,8 @@ enum ShifterModes
BMWF30 = 1,
JLRG1 = 2,
JLRG2 =3,
BMWE65 =4
BMWE65 =4,
PorschePDK =5
Comment on lines +437 to +438
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
BMWE65 =4,
PorschePDK =5
BMWE65 = 4,
PorschePDK = 5,


};

Expand Down
36 changes: 36 additions & 0 deletions include/vag_utils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* This file is part of the ZombieVeter project.
*
* Copyright (C) 2020 Johannes Huebner <[email protected]>
* 2021-2022 Damien Maguire <[email protected]>
* 2024 Mitch Elliott
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef VAG_UTILS_H
#define VAG_UTILS_H

#include <stdint.h>
#include "my_fp.h"
#include "my_math.h"

namespace vag_utils
{
uint8_t vw_crc_calc(uint8_t* inputBytes, uint8_t length, uint16_t address);
uint8_t vw_crc_calc_MQB(uint8_t* inputBytes, uint8_t length, uint16_t address);
}

#endif
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#endif
#endif /* VAG_UTILS_H */


151 changes: 151 additions & 0 deletions include/vw_mlb_charger.h
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file has an indentation level of 6.

Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

/*
* This file is part of the ZombieVerter project.
*
* Copyright (C) 2024 Mitch Elliott
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef vw_mlb_charger_h
#define vw_mlb_charger_h
Comment on lines +20 to +21
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#ifndef vw_mlb_charger_h
#define vw_mlb_charger_h
#ifndef VW_MLB_CHARGER_H
#define VW_MLB_CHARGER_H


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

class VWMLBClass: public Chargerhw
{
public:
bool ControlCharge(bool RunCh, bool ACReq);
void SetCanInterface(CanHardware*);
void DecodeCAN(int id, uint32_t data[2]);
void Task1Ms();
void Task10Ms();
void Task100Ms();
void Task200Ms();


private:
//void CommandStates();
void Simulate();
void TagParams();
void CalcValues100ms();
void msg3C0();
void msg1A1(); // BMS_02 0x1A1
void msg2B1(); // MSG_TME_02 0x2B1
void msg39D(); // BMS_03 0x39D
void msg485(); // NavData_02 0x485
void msg509(); // BMS_10 0x509
void msg552(); // HVEM_05 0x552
void msg583(); // ZV_02 0x583
void msg59E(); // BMS_06 0x59E
void msg5AC(); // HVEM_02 0x5AC
void msg64F(); // BCM1_04 0x64F
void msg663(); // NVEM_02 0x663
void msg1A555548(); // ORU_01 0x1A555548
void msg1A5555AD(); // Authentic_Time_01 0x1A5555AD
void msg96A955EB(); // BMS_09 0x96A955EB
void msg96A954A6(); // BMS_11 0x96A954A6
void msg9A555539(); // BMS_16 0x9A555539
void msg9A555552(); // BMS_27 0x9A555552
void msg040(); // Airbag_01 0x40
void msg184(); // ZV_01 0x184
void msg191(); // BMS_01 0x191
void msg1A2(); // ESP_15 0x1A2
void msg2AE(); // DCDC_01 0x2AE
void msg37C(); // EM1_HYB_11 0x37C
void msg503(); // HVK_01 0x503
void msg578(); // BMS_DC_01 0x578
void msg5A2(); // BMS_04 0x5A2
void msg5CA(); // BMS_07 0x5CA
void msg5CD(); // DCDC_03 0x5CD
uint8_t Airbag_01[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
uint8_t Authentic_Time_01[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
uint8_t BCM1_04[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
uint8_t BMS_01[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
uint8_t BMS_02[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
uint8_t BMS_03[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
uint8_t BMS_04[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
uint8_t BMS_06[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
uint8_t BMS_07[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
uint8_t BMS_09[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
uint8_t BMS_10[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
uint8_t BMS_11[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
uint8_t BMS_16[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
uint8_t BMS_27[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
uint8_t BMS_DC_01[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
uint8_t EM_HYB_11[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
uint8_t ESP_15[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
uint8_t Dimmung_01[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
uint8_t DCDC_01[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
uint8_t DCDC_02[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
uint8_t DCDC_03[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
uint8_t HVK_01[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
uint8_t HVEM_02[8] = {0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
uint8_t HVEM_05[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
uint8_t Klemmen_Status_01[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
uint8_t MSG_TME_02[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
uint8_t NVEM_02[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
uint8_t ORU_01[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
uint8_t ZV_02[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
uint8_t HVLM_06[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
uint8_t HVLM_04[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
uint8_t LAD_01[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
uint8_t HVLM_03[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
uint8_t LAD_02[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
uint8_t HVLM_10[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
uint8_t HVLM_11[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
uint8_t HVLM_08[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
uint8_t HVLM_15[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
uint8_t LAD_06[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
uint8_t ZV_01[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
uint8_t vag_cnt3C0 = 0x00;
uint8_t vag_cnt040 = 0x00;
uint8_t vag_cnt184 = 0x00;
uint8_t vag_cnt191 = 0x00;
uint8_t vag_cnt1A2 = 0x00;
uint8_t vag_cnt37C = 0x00;
uint8_t vag_cnt2AE = 0x00;
uint8_t vag_cnt503 = 0x00;
uint8_t vag_cnt578 = 0x00;
uint8_t vag_cnt5A2 = 0x00;
uint8_t vag_cnt5CA = 0x00;
uint8_t vag_cnt5CD = 0x00;
};

class VWMLBintClass: 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);


protected:
// CanHardware* can;

};

#endif /* vw_mlb_charger_h */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#endif /* vw_mlb_charger_h */
#endif /* VW_MLB_CHARGER_H */

89 changes: 89 additions & 0 deletions src/Gear_9x1.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/*
* This file is part of the Zombieverter project.
*
* Copyright (C) 2024 Mitch Elliott
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include "Gear_9x1.h"

uint8_t Gear9x1LeverPos = 0x78; // Gear Lever Position on Init
uint8_t Gear9x1TipSport = 0; // Tip +/- Sport Postion
uint8_t Gear9x1Checksum = 0; // Checksum Value for Plausibilty
uint8_t Gear9x1Counter = 0; // Counter Value

void Gear_9x1::SetCanInterface(CanHardware* c)
{
can = c;
can->RegisterUserMessage(0x133);// 9x1 based shifter CAN message: WHL_01
}


void Gear_9x1::DecodeCAN(int id, uint32_t* data)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function has an indentation level of 2.

{
uint8_t *bytes = (uint8_t *)data;
if (id == 0x133)
{
Gear9x1LeverPos = bytes[0];
Gear9x1Counter = (bytes[1] >> 4); // Mapping for later to determine signal validity
Gear9x1TipSport = (bytes[1] & (0x0FU)); // +/- sport movement
Gear9x1Checksum = bytes[6]; // Mapping for later to determine signal validity

switch (Gear9x1LeverPos)
{
case 0x78: // Park
{
this->gear = PARK;
}
break;
Comment on lines +47 to +50
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{
this->gear = PARK;
}
break;
this->gear = PARK;
break;

This is a bit of an odd syntax IMO. Usually you don't use curly brackets in switch-case statements. Also the break; is outside of the brackets, which is odd too.

case 0x87: // Reverse
{
this->gear = REVERSE;
}
break;
case 0x96: // Neutral
{
this->gear = NEUTRAL;
}
break;
case 0xA5: // Drive
{
this->gear = DRIVE;
}
break;
case 0x1E: // Manual/ Tip
{
this->gear = DRIVE;
}
break;
}
}
}

void Gear_9x1::Task10Ms()
{

}

void Gear_9x1::Task100Ms()
{

}

bool Gear_9x1::GetGear(Shifter::Sgear& outGear)
{
outGear = gear; //send the shifter pos
return true; //Let caller know we set a valid gear
Comment on lines +87 to +88
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
outGear = gear; //send the shifter pos
return true; //Let caller know we set a valid gear
outGear = gear; // send the shifter pos
return true; // Let caller know we set a valid gear

}
Loading