Skip to content

Commit 9862dcd

Browse files
committed
Fixed Latch pin logic, edited switchFaultStatus variable name, renamed IDLE state to RUNNING, and UART pins are no longer swapped
1 parent c83c7f9 commit 9862dcd

5 files changed

Lines changed: 19 additions & 27 deletions

File tree

include/LVSS.hpp

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ class LVSS : public CANDevice {
8484
};
8585
};
8686

87-
union switchData {
87+
/** Struct to hold the data for individual boards */
88+
union switchData_u {
8889
uint16_t battCurrent;
8990
uint16_t hibCurrent;
9091
uint16_t tmsCurrent;
@@ -97,18 +98,10 @@ class LVSS : public CANDevice {
9798
int16_t switch2Temp;
9899
};
99100

100-
union switchFaults {
101-
uint16_t switchFaultVal;
102-
struct {
103-
uint16_t currentFault : 1;
104-
uint16_t temperatureFault : 1;
105-
};
106-
};
107-
108101
/** FSM State declaration */
109102
enum class State {
110103
INITIALIZATION = 0u,
111-
IDLE = 1u,
104+
RUNNING = 1u,
112105
};
113106

114107
/**
@@ -140,9 +133,8 @@ class LVSS : public CANDevice {
140133

141134
ACS71240 acs71240;
142135

143-
switchData PowerSwitchState;
144-
145-
switchFaults SwitchFaults;
136+
/** Holds data for individual boards */
137+
switchData_u PowerSwitchState;
146138

147139
/** Tracks signal from VCU */
148140
uint16_t VCUBoardSig = 0;
@@ -151,7 +143,7 @@ class LVSS : public CANDevice {
151143
uint16_t battPackCurrent = 0x00;
152144

153145
/** Tracks power switch fault */
154-
uint16_t switchFaultstatus = 0x00;
146+
uint16_t switchFaultStatus = 0x00;
155147

156148
/**
157149
* The current state of the LVSS
@@ -177,7 +169,7 @@ class LVSS : public CANDevice {
177169
/**
178170
* Checks LVSS values
179171
*
180-
* State: State::IDLE
172+
* State: State::RUNNING
181173
*/
182174
void runningState();
183175

@@ -241,7 +233,7 @@ class LVSS : public CANDevice {
241233
/** Transfer data */
242234
DATA_LINK_START_KEY_21XX(0x00, 0x02),
243235
DATA_LINK_21XX(0x00, 0x01, CO_TUNSIGNED16, &battPackCurrent),
244-
DATA_LINK_21XX(0x00, 0x02, CO_TUNSIGNED16, &switchFaultstatus),
236+
DATA_LINK_21XX(0x00, 0x02, CO_TUNSIGNED16, &switchFaultStatus),
245237

246238
DATA_LINK_START_KEY_21XX(0x01, 0x04),
247239
DATA_LINK_21XX(0x01, 0x01, CO_TUNSIGNED16, &PowerSwitchState.battCurrent),

include/dev/TPS2HB35BQ.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ class TPS2HB35BQ {
4040
};
4141

4242
enum LatchMode {
43-
LATCHED = 0x00,
44-
AUTO_RETRY = 0x01
43+
LATCHED = 0x00, // If there is a fault the power switch will shut off and stay off
44+
AUTO_RETRY = 0x01 // If there is a fault the power switch will shut off and try to turn back on until there is no longer a fault
4545
};
4646

4747
void setPowerSwitchStates(bool powerSwitchOneEnabled, bool powerSwitchTwoEnabled);

src/LVSS.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ void LVSS::process() {
2828
initState();
2929
break;
3030

31-
case State::IDLE:
31+
case State::RUNNING:
3232
runningState();
3333
break;
3434
}
@@ -44,7 +44,7 @@ void LVSS::initState() {
4444
VICOR_FAULT_ACTIVE_STATE = vicorFT.readPin();
4545

4646
if (time::millis() >= 101 && VICOR_FAULT_ACTIVE_STATE == IO::GPIO::State::LOW) {
47-
state = State::IDLE;
47+
state = State::RUNNING;
4848
isNewState = true;
4949
}
5050
}
@@ -79,7 +79,7 @@ void LVSS::runningState() {
7979

8080
if (PowerSwitchState.battCurrent == -1 || PowerSwitchState.tmsCurrent == -1 || PowerSwitchState.accCurrent == -1) {
8181
log::LOGGER.log(log::Logger::LogLevel::INFO, "Power Switch Error\r\n");
82-
switchFaultstatus = INTMAX_MIN;
82+
switchFaultStatus = INTMAX_MIN;
8383
}
8484

8585
log::LOGGER.log(log::Logger::LogLevel::DEBUG,
@@ -96,7 +96,7 @@ void LVSS::runningState() {
9696

9797
if (PowerSwitchState.hibCurrent == -1 || PowerSwitchState.hudlCurrent == -1 || PowerSwitchState.gubCurrent == -1) {
9898
log::LOGGER.log(log::Logger::LogLevel::INFO, "Power Switch Error\r\n");
99-
switchFaultstatus = INTMAX_MIN;
99+
switchFaultStatus = INTMAX_MIN;
100100
}
101101

102102
log::LOGGER.log(log::Logger::LogLevel::DEBUG,
@@ -112,7 +112,7 @@ void LVSS::runningState() {
112112
if (PowerSwitchState.switch0Temp == -1 || PowerSwitchState.switch1Temp == -1
113113
|| PowerSwitchState.switch2Temp == -1) {
114114
log::LOGGER.log(log::Logger::LogLevel::INFO, "Power Switch Error\r\n");
115-
switchFaultstatus = 1;
115+
switchFaultStatus = INTMAX_MIN;
116116
}
117117

118118
log::LOGGER.log(log::Logger::LogLevel::DEBUG,
@@ -121,6 +121,6 @@ void LVSS::runningState() {
121121
PowerSwitchState.switch1Temp,
122122
PowerSwitchState.switch2Temp);
123123

124-
log::LOGGER.log(log::Logger::LogLevel::INFO, "Vicor Current: %d\r\n", acs71240.readCurrent());
124+
log::LOGGER.log(log::Logger::LogLevel::DEBUG, "Vicor Current: %d\r\n", acs71240.readCurrent());
125125
}
126126
} // namespace LVSS

src/dev/TPS2HB35BQ.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ void TPS2HB35BQ::setDiagStateEnabled(bool state) {
3333

3434
void TPS2HB35BQ::setLatch(LatchMode mode) {
3535
if (mode == LatchMode::LATCHED) {
36-
latchPin.writePin(IO::GPIO::State::LOW);
37-
} else if (mode == LatchMode::AUTO_RETRY) {
3836
latchPin.writePin(IO::GPIO::State::HIGH);
37+
} else if (mode == LatchMode::AUTO_RETRY) {
38+
latchPin.writePin(IO::GPIO::State::LOW);
3939
}
4040
}
4141

targets/REV3-LVSS/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ int main() {
4444
EVT::core::platform::init();
4545

4646
// Setup UART
47-
IO::UART& uart = IO::getUART<IO::Pin::UART_TX, IO::Pin::UART_RX>(9600, true);
47+
IO::UART& uart = IO::getUART<IO::Pin::UART_TX, IO::Pin::UART_RX>(9600);
4848
log::LOGGER.setUART(&uart);
4949
log::LOGGER.setLogLevel(log::Logger::LogLevel::INFO);
5050

0 commit comments

Comments
 (0)