-
Notifications
You must be signed in to change notification settings - Fork 74
/
Copy pathOutlanderHeartBeat.cpp
93 lines (81 loc) · 2.17 KB
/
OutlanderHeartBeat.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/*
* This file is part of the ZombieVerter project.
*
* Copyright (C) 2021-2023 Johannes Huebner <dev@johanneshuebner.com>
* Damien Maguire <info@evbmw.com>
*
* 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 <OutlanderHeartBeat.h>
/* Control of the Mitsubishi Outlander PHEV on board charger (OBC) and DCDC Converter. */
bool EnableEVSE = false;
bool CanConfigure = false;
bool DualCan = false;
CanHardware* can1;
CanHardware* can2;
void OutlanderHeartBeat::SetCanInterface(CanHardware* c)
{
if(CanConfigure == false)
{
can1 = c;
CanConfigure = true;
}
else if(can1 != c)
{
can2 = c;
DualCan = true;
}
}
void OutlanderHeartBeat::Task100Ms()
{
int opmode = Param::GetInt(Param::opmode);
uint8_t bytes[8];
bytes[0] = 0x00;
bytes[1] = 0x00;
bytes[2] = 0x00;
bytes[3] = 0x00;
bytes[4] = 0x00;
bytes[5] = 0x00;
bytes[6] = 0x00;
bytes[7] = 0x00;
if (MOD_CHARGE == opmode)
{
if (EnableEVSE)
{
bytes[2] = 0xB6;//oxb6 in byte 3 enables charger
}
}
else if (MOD_RUN == opmode)
{
bytes[2] = 0x14;
bytes[3] = 0x39;
bytes[4] = 0x8F;
bytes[5] = 0xFE;
bytes[6] = 0xC;
bytes[7] = 0x10;
}
if (MOD_CHARGE == opmode || MOD_RUN == opmode)
{
can1->Send(0x285, (uint32_t*)bytes, 8);
if(DualCan)
{
can2->Send(0x285, (uint32_t*)bytes, 8);
}
}
}
void OutlanderHeartBeat::SetPullInEVSE(bool pullInEVSE)
{
EnableEVSE = pullInEVSE;
}