Skip to content

Commit c83c7f9

Browse files
GitHub BuildGitHub Build
authored andcommitted
Applied Formatting Changes During GitHub Build
1 parent a2dceb2 commit c83c7f9

9 files changed

Lines changed: 164 additions & 130 deletions

File tree

include/LVSS.hpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@
4343
}
4444
// clang-format on
4545

46-
namespace IO = EVT::core::IO;
47-
namespace DEV = EVT::core::DEV;
46+
namespace IO = EVT::core::IO;
47+
namespace DEV = EVT::core::DEV;
4848
namespace time = EVT::core::time;
4949

5050
namespace LVSS {
@@ -57,13 +57,13 @@ static constexpr uint8_t POWER_SWITCHES_SIZE = 3;
5757
*/
5858
class LVSS : public CANDevice {
5959
public:
60-
static constexpr uint8_t NODE_ID = 1;
61-
static constexpr uint8_t VCU_NODE_ID = 0;
60+
static constexpr uint8_t NODE_ID = 1;
61+
static constexpr uint8_t VCU_NODE_ID = 0;
6262
static constexpr uint8_t TPDO_NODE_ID = 1;
6363

6464
IO::GPIO& vicorFT;
65-
static constexpr IO::Pin vicorFaultPin = IO::Pin::PB_4;
66-
static constexpr IO::Pin vicorSNS = IO::Pin::PA_4;
65+
static constexpr IO::Pin vicorFaultPin = IO::Pin::PB_4;
66+
static constexpr IO::Pin vicorSNS = IO::Pin::PA_4;
6767
IO::GPIO::State VICOR_FAULT_ACTIVE_STATE = IO::GPIO::State::HIGH;
6868

6969
/** Union bit field to hold a bit representing which boards are on/off */
@@ -72,17 +72,17 @@ class LVSS : public CANDevice {
7272
struct {
7373
// Power Switch 0
7474
uint8_t batt : 1;
75-
uint8_t hib : 1;
75+
uint8_t hib : 1;
7676

7777
// Power Switch 1
78-
uint8_t tms : 1;
78+
uint8_t tms : 1;
7979
uint8_t hudl : 1;
8080

8181
// Power Switch 2
8282
uint8_t gub : 1;
8383
uint8_t acc : 1;
8484
};
85-
} ;
85+
};
8686

8787
union switchData {
8888
uint16_t battCurrent;
@@ -100,15 +100,15 @@ class LVSS : public CANDevice {
100100
union switchFaults {
101101
uint16_t switchFaultVal;
102102
struct {
103-
uint16_t currentFault : 1;
103+
uint16_t currentFault : 1;
104104
uint16_t temperatureFault : 1;
105105
};
106106
};
107107

108108
/** FSM State declaration */
109109
enum class State {
110110
INITIALIZATION = 0u,
111-
IDLE = 1u,
111+
IDLE = 1u,
112112
};
113113

114114
/**
@@ -202,7 +202,7 @@ class LVSS : public CANDevice {
202202

203203
RECEIVE_PDO_MAPPING_START_KEY_16XX(0x00, 0x01),
204204
{
205-
.Key = CO_KEY(0x1600 + 0x00, 0x01, CO_OBJ_D___R_),
205+
.Key = CO_KEY(0x1600 + 0x00, 0x01, CO_OBJ_D___R_),
206206
.Type = CO_TUNSIGNED32,
207207
.Data = (CO_DATA) CO_LINK(0x2200 + 0x00, 0x00 + 0x01, PDO_MAPPING_UNSIGNED16),
208208
},
@@ -267,5 +267,5 @@ class LVSS : public CANDevice {
267267
};
268268
};
269269

270-
}// namespace LVSS
270+
} // namespace LVSS
271271
#endif

include/dev/ACS71240.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include <EVT/io/ADC.hpp>
55
#include <EVT/utils/log.hpp>
66

7-
namespace IO = EVT::core::IO;
7+
namespace IO = EVT::core::IO;
88
namespace DEV = EVT::core::DEV;
99
namespace log = EVT::core::log;
1010

@@ -21,17 +21,17 @@ class ACS71240 {
2121
ACS71240(IO::ADC& adc0);
2222

2323
/**
24-
* Get the current detected by the ACS71240
25-
*
26-
* @return The current in mA
27-
*/
24+
* Get the current detected by the ACS71240
25+
*
26+
* @return The current in mA
27+
*/
2828
int32_t readCurrent();
2929

3030
private:
3131
/** ADC instance for getting input voltage */
3232
IO::ADC& ADC;
3333
};
3434

35-
}// namespace LVSS
35+
} // namespace LVSS
3636

3737
#endif

include/dev/TPS2HB35BQ.hpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,19 @@ class TPS2HB35BQ {
2828
* @param diagSelect1 Mux select pin for diagnostics, see setDiagnostics
2929
* @param diagSelect2 Mux select pin for diagnostics, see setDiagnostics
3030
*/
31-
TPS2HB35BQ(IO::GPIO& en1, IO::GPIO& en2, IO::GPIO& latch, IO::GPIO& diagEn,
32-
IO::GPIO& diagSelect1, IO::GPIO& diagSelect2, IO::ADC& senseOut, uint32_t rsns = 330);
31+
TPS2HB35BQ(IO::GPIO& en1, IO::GPIO& en2, IO::GPIO& latch, IO::GPIO& diagEn, IO::GPIO& diagSelect1,
32+
IO::GPIO& diagSelect2, IO::ADC& senseOut, uint32_t rsns = 330);
3333

3434
enum DiagMode {
35-
OFF = 0x00,
35+
OFF = 0x00,
3636
FAULT_STATUS = 0x01,
37-
CH1CURRENT = 0x02,
38-
CH2CURRENT = 0x03,
39-
TEMP = 0x04
37+
CH1CURRENT = 0x02,
38+
CH2CURRENT = 0x03,
39+
TEMP = 0x04
4040
};
4141

4242
enum LatchMode {
43-
LATCHED = 0x00,
43+
LATCHED = 0x00,
4444
AUTO_RETRY = 0x01
4545
};
4646

@@ -62,10 +62,10 @@ class TPS2HB35BQ {
6262
int32_t getTempandFault();
6363

6464
/**
65-
* Set the latch mode of the power switch
66-
*
67-
* @param mode The latch mode to set
68-
*/
65+
* Set the latch mode of the power switch
66+
*
67+
* @param mode The latch mode to set
68+
*/
6969
void setLatch(LatchMode mode);
7070

7171
/**
@@ -98,10 +98,10 @@ class TPS2HB35BQ {
9898
/** ADC Counts */
9999
uint32_t counts = 0;
100100

101-
uint32_t rsns = 330; // Resistor that sets the current limit
102-
uint32_t kcl = 140; // Current Limit Ratio
103-
uint32_t icl = 9000; // Current Limit Value in milliamps
104-
int32_t TemperatureLim = 135000;// Temperature Limit of 135 millicelsius
101+
uint32_t rsns = 330; // Resistor that sets the current limit
102+
uint32_t kcl = 140; // Current Limit Ratio
103+
uint32_t icl = 9000; // Current Limit Value in milliamps
104+
int32_t TemperatureLim = 135000; // Temperature Limit of 135 millicelsius
105105

106106
/**
107107
* Controls the diagnostic enable pin
@@ -126,5 +126,5 @@ class TPS2HB35BQ {
126126
void setDiagnostics(DiagMode diag_mode);
127127
};
128128

129-
}// namespace LVSS
129+
} // namespace LVSS
130130
#endif

src/LVSS.cpp

Lines changed: 37 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ CO_OBJ_T* LVSS::getObjectDictionary() {
1414
return &objectDictionary[0];
1515
}
1616

17-
LVSS::LVSS(TPS2HB35BQ* powerSwitches[POWER_SWITCHES_SIZE], IO::GPIO& vicorFT, ACS71240 acs71240) : vicorFT(vicorFT), boardEN({0}), acs71240(acs71240), state(State::INITIALIZATION) {
17+
LVSS::LVSS(TPS2HB35BQ* powerSwitches[POWER_SWITCHES_SIZE], IO::GPIO& vicorFT, ACS71240 acs71240)
18+
: vicorFT(vicorFT), boardEN({0}), acs71240(acs71240), state(State::INITIALIZATION) {
1819
for (int i = 0; i < POWER_SWITCHES_SIZE; i++) {
1920
this->powerSwitches[i] = powerSwitches[i];
2021
}
@@ -43,7 +44,7 @@ void LVSS::initState() {
4344
VICOR_FAULT_ACTIVE_STATE = vicorFT.readPin();
4445

4546
if (time::millis() >= 101 && VICOR_FAULT_ACTIVE_STATE == IO::GPIO::State::LOW) {
46-
state = State::IDLE;
47+
state = State::IDLE;
4748
isNewState = true;
4849
}
4950
}
@@ -57,49 +58,69 @@ void LVSS::runningState() {
5758
/* Assigns the VCU signal to the union bit field */
5859
this->boardEN.val = VCUBoardSig;
5960

60-
log::LOGGER.log(log::Logger::LogLevel::DEBUG, "Battery: %d\r\nHIB: %d\r\nTMS: %d\r\nHUDL: %d\r\nACC: %d\r\nGUB: %d\r\n", boardEN.batt, boardEN.hib, boardEN.tms, boardEN.hudl, boardEN.acc, boardEN.gub);
61+
log::LOGGER.log(log::Logger::LogLevel::DEBUG,
62+
"Battery: %d\r\nHIB: %d\r\nTMS: %d\r\nHUDL: %d\r\nACC: %d\r\nGUB: %d\r\n",
63+
boardEN.batt,
64+
boardEN.hib,
65+
boardEN.tms,
66+
boardEN.hudl,
67+
boardEN.acc,
68+
boardEN.gub);
6169

6270
/* Turn on boards */
63-
powerSwitches[0]->setPowerSwitchStates(boardEN.batt, boardEN.hib);// Turn on Battery and HIB
64-
powerSwitches[1]->setPowerSwitchStates(boardEN.tms, boardEN.hudl);// Turn on TMS and HUDL
65-
powerSwitches[2]->setPowerSwitchStates(boardEN.acc, boardEN.gub); // Turn on Acc and GUB
71+
powerSwitches[0]->setPowerSwitchStates(boardEN.batt, boardEN.hib); // Turn on Battery and HIB
72+
powerSwitches[1]->setPowerSwitchStates(boardEN.tms, boardEN.hudl); // Turn on TMS and HUDL
73+
powerSwitches[2]->setPowerSwitchStates(boardEN.acc, boardEN.gub); // Turn on Acc and GUB
6674

6775
/* Current Checking */
6876
PowerSwitchState.battCurrent = powerSwitches[0]->getCurrent(1);
69-
PowerSwitchState.tmsCurrent = powerSwitches[1]->getCurrent(1);
70-
PowerSwitchState.accCurrent = powerSwitches[2]->getCurrent(1);
77+
PowerSwitchState.tmsCurrent = powerSwitches[1]->getCurrent(1);
78+
PowerSwitchState.accCurrent = powerSwitches[2]->getCurrent(1);
7179

7280
if (PowerSwitchState.battCurrent == -1 || PowerSwitchState.tmsCurrent == -1 || PowerSwitchState.accCurrent == -1) {
7381
log::LOGGER.log(log::Logger::LogLevel::INFO, "Power Switch Error\r\n");
7482
switchFaultstatus = INTMAX_MIN;
7583
}
7684

77-
log::LOGGER.log(log::Logger::LogLevel::DEBUG, "Switch 0 Channel 1: %d\r\nSwitch 1 Channel 1: %d\r\nSwitch 2 Channel 1: %d\r\n", PowerSwitchState.battCurrent, PowerSwitchState.tmsCurrent, PowerSwitchState.accCurrent);
85+
log::LOGGER.log(log::Logger::LogLevel::DEBUG,
86+
"Switch 0 Channel 1: %d\r\nSwitch 1 Channel 1: %d\r\nSwitch 2 Channel 1: %d\r\n",
87+
PowerSwitchState.battCurrent,
88+
PowerSwitchState.tmsCurrent,
89+
PowerSwitchState.accCurrent);
7890

79-
time::wait(2);// Power switches require the ADC to wait a min of 165 micro seconds before sampling SNS pin again
91+
time::wait(2); // Power switches require the ADC to wait a min of 165 micro seconds before sampling SNS pin again
8092

81-
PowerSwitchState.hibCurrent = powerSwitches[0]->getCurrent(2);
93+
PowerSwitchState.hibCurrent = powerSwitches[0]->getCurrent(2);
8294
PowerSwitchState.hudlCurrent = powerSwitches[1]->getCurrent(2);
83-
PowerSwitchState.gubCurrent = powerSwitches[2]->getCurrent(2);
95+
PowerSwitchState.gubCurrent = powerSwitches[2]->getCurrent(2);
8496

8597
if (PowerSwitchState.hibCurrent == -1 || PowerSwitchState.hudlCurrent == -1 || PowerSwitchState.gubCurrent == -1) {
8698
log::LOGGER.log(log::Logger::LogLevel::INFO, "Power Switch Error\r\n");
8799
switchFaultstatus = INTMAX_MIN;
88100
}
89101

90-
log::LOGGER.log(log::Logger::LogLevel::DEBUG, "Switch 0 Channel 2: %d\r\nSwitch 1 Channel 2: %d\r\nSwitch 2 Channel 2: %d\r\n", PowerSwitchState.hibCurrent, PowerSwitchState.hudlCurrent, PowerSwitchState.gubCurrent);
102+
log::LOGGER.log(log::Logger::LogLevel::DEBUG,
103+
"Switch 0 Channel 2: %d\r\nSwitch 1 Channel 2: %d\r\nSwitch 2 Channel 2: %d\r\n",
104+
PowerSwitchState.hibCurrent,
105+
PowerSwitchState.hudlCurrent,
106+
PowerSwitchState.gubCurrent);
91107

92108
PowerSwitchState.switch0Temp = powerSwitches[0]->getTempandFault();
93109
PowerSwitchState.switch1Temp = powerSwitches[1]->getTempandFault();
94110
PowerSwitchState.switch2Temp = powerSwitches[2]->getTempandFault();
95111

96-
if (PowerSwitchState.switch0Temp == -1 || PowerSwitchState.switch1Temp == -1 || PowerSwitchState.switch2Temp == -1) {
112+
if (PowerSwitchState.switch0Temp == -1 || PowerSwitchState.switch1Temp == -1
113+
|| PowerSwitchState.switch2Temp == -1) {
97114
log::LOGGER.log(log::Logger::LogLevel::INFO, "Power Switch Error\r\n");
98115
switchFaultstatus = 1;
99116
}
100117

101-
log::LOGGER.log(log::Logger::LogLevel::DEBUG, "Switch 0 Temperature: %d\r\nSwitch 1 Temperature: %d\r\nSwitch 2 Temperature: %d\r\n", PowerSwitchState.switch0Temp, PowerSwitchState.switch1Temp, PowerSwitchState.switch2Temp);
118+
log::LOGGER.log(log::Logger::LogLevel::DEBUG,
119+
"Switch 0 Temperature: %d\r\nSwitch 1 Temperature: %d\r\nSwitch 2 Temperature: %d\r\n",
120+
PowerSwitchState.switch0Temp,
121+
PowerSwitchState.switch1Temp,
122+
PowerSwitchState.switch2Temp);
102123

103124
log::LOGGER.log(log::Logger::LogLevel::INFO, "Vicor Current: %d\r\n", acs71240.readCurrent());
104125
}
105-
}// namespace LVSS
126+
} // namespace LVSS

src/dev/ACS71240.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace LVSS {
55
ACS71240::ACS71240(IO::ADC& adc0) : ADC(adc0) {}
66

77
int32_t ACS71240::readCurrent() {
8-
//Gets adcCounts from adc
8+
// Gets adcCounts from adc
99
int32_t adcCounts = ADC.readRaw();
1010

1111
//(((adcCounts - average adc counts) * 3.3) / (4096 * 0.044)) * 1000
@@ -14,4 +14,4 @@ int32_t ACS71240::readCurrent() {
1414
return current;
1515
}
1616

17-
}// namespace LVSS
17+
} // namespace LVSS

src/dev/TPS2HB35BQ.cpp

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
namespace LVSS {
44

5-
TPS2HB35BQ::TPS2HB35BQ(IO::GPIO& en1, IO::GPIO& en2, IO::GPIO& latch, IO::GPIO& diagEn, IO::GPIO& diagSelect1, IO::GPIO& diagSelect2, IO::ADC& adc, uint32_t rsns)
6-
: en1(en1), en2(en2), latchPin(latch), diagEn(diagEn), diagSelect1(diagSelect1), diagSelect2(diagSelect2), senseOut(adc) {
5+
TPS2HB35BQ::TPS2HB35BQ(IO::GPIO& en1, IO::GPIO& en2, IO::GPIO& latch, IO::GPIO& diagEn, IO::GPIO& diagSelect1,
6+
IO::GPIO& diagSelect2, IO::ADC& adc, uint32_t rsns)
7+
: en1(en1), en2(en2), latchPin(latch), diagEn(diagEn), diagSelect1(diagSelect1), diagSelect2(diagSelect2),
8+
senseOut(adc) {
79
setDiagnostics(DiagMode::OFF);
810
}
911

@@ -73,9 +75,9 @@ void TPS2HB35BQ::setDiagnostics(DiagMode diag_mode) {
7375

7476
uint32_t TPS2HB35BQ::getCurrent(uint8_t channelSelect) {
7577
if (channelSelect == 1) {
76-
setDiagnostics(DiagMode::CH1CURRENT);// Set diagnostic mode to sense current
78+
setDiagnostics(DiagMode::CH1CURRENT); // Set diagnostic mode to sense current
7779
} else {
78-
setDiagnostics(DiagMode::CH2CURRENT);// Set diagnostic mode to sense current
80+
setDiagnostics(DiagMode::CH2CURRENT); // Set diagnostic mode to sense current
7981
}
8082

8183
counts = readSenseOut();
@@ -85,33 +87,33 @@ uint32_t TPS2HB35BQ::getCurrent(uint8_t channelSelect) {
8587
}
8688

8789
/* volts = (ADC Counts * 3300 kilovolts) / 4096 */
88-
uint32_t millivolts = (counts * 3300) / 4096;// Turn ADC counts into milli volts
89-
uint32_t milliamps = millivolts / rsns; // Turn milli volts into milli amps
90+
uint32_t millivolts = (counts * 3300) / 4096; // Turn ADC counts into milli volts
91+
uint32_t milliamps = millivolts / rsns; // Turn milli volts into milli amps
9092

9193
/* If current is greater than the current limit latch the sns pin */
9294
if (milliamps >= icl) {
9395
setDiagnostics(DiagMode::OFF);
94-
setLatch(LatchMode::LATCHED);// Latch power switches
96+
setLatch(LatchMode::LATCHED); // Latch power switches
9597
return INTMAX_MIN;
9698
}
9799

98100
return milliamps;
99101
}
100102

101103
int32_t TPS2HB35BQ::getTempandFault() {
102-
setDiagnostics(DiagMode::TEMP);// Set diagnostic mode to sense temperature
104+
setDiagnostics(DiagMode::TEMP); // Set diagnostic mode to sense temperature
103105
counts = readSenseOut();
104106

105107
if (counts >= 4095) {
106108
setDiagnostics(DiagMode::OFF);
107-
setLatch(LatchMode::LATCHED);// Latch power switches
109+
setLatch(LatchMode::LATCHED); // Latch power switches
108110
}
109111

110-
uint32_t milliVolts = (counts * 3300) / 4096; // Turn ADC counts into milli volts
111-
int32_t microAmps = (milliVolts * 1000) / rsns;// Turn milli volts into micro amps
112+
uint32_t milliVolts = (counts * 3300) / 4096; // Turn ADC counts into milli volts
113+
int32_t microAmps = (milliVolts * 1000) / rsns; // Turn milli volts into micro amps
112114

113115
/* ( Isns (mA) - 0.85 mA ) / (dIsnst/dT) + 25 celsius */
114-
int32_t milliCelsius = (microAmps - 850) / 11 + 25000;// Returns temperature in milli celsius
116+
int32_t milliCelsius = (microAmps - 850) / 11 + 25000; // Returns temperature in milli celsius
115117

116118
if (milliCelsius >= TemperatureLim) {
117119
return INTMAX_MIN;
@@ -121,10 +123,10 @@ int32_t TPS2HB35BQ::getTempandFault() {
121123
}
122124

123125
void TPS2HB35BQ::setLimits(uint32_t ohms, uint32_t ratio, uint32_t milliamps, int32_t millicelsius) {
124-
rsns = ohms;
125-
kcl = ratio;
126-
icl = milliamps;
126+
rsns = ohms;
127+
kcl = ratio;
128+
icl = milliamps;
127129
TemperatureLim = millicelsius;
128130
}
129131

130-
}// namespace LVSS
132+
} // namespace LVSS

0 commit comments

Comments
 (0)