Skip to content

Commit df35499

Browse files
committed
Added "output forceon" and "output normal" commands for load testing without a host board
1 parent 03cd20c commit df35499

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

firmware/main/IBCCLISessionContext.cpp

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,11 @@ enum cmdid_t
4242
CMD_CALIBRATE,
4343
CMD_CAT,
4444
CMD_COMMIT,
45+
CMD_FORCEON,
4546
CMD_IIN,
46-
CMD_IOUT
47+
CMD_IOUT,
48+
CMD_NORMAL,
49+
CMD_OUTPUT
4750
};
4851

4952
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -68,6 +71,16 @@ static const clikeyword_t g_calibrateCommands[] =
6871
{nullptr, INVALID_COMMAND, nullptr, nullptr }
6972
};
7073

74+
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
75+
// "output"
76+
77+
static const clikeyword_t g_outputCommands[] =
78+
{
79+
{"forceon", CMD_FORCEON, nullptr, "Force the output on by backfeeding the enable line" },
80+
{"normal", CMD_NORMAL, nullptr, "Normal operation" },
81+
{nullptr, INVALID_COMMAND, nullptr, nullptr }
82+
};
83+
7184
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
7285
// Top level commands
7386

@@ -76,6 +89,7 @@ static const clikeyword_t g_rootCommands[] =
7689
{"calibrate", CMD_CALIBRATE, g_calibrateCommands, "Calibrate ADCs" },
7790
{"cat", CMD_CAT, nullptr, "meow" },
7891
{"commit", CMD_COMMIT, nullptr, "Commit pending calibrations to flash" },
92+
{"output", CMD_OUTPUT, g_outputCommands, "Control output" },
7993
{nullptr, INVALID_COMMAND, nullptr, nullptr }
8094
};
8195

@@ -112,6 +126,10 @@ void IBCCLISessionContext::OnExecute()
112126
OnCommit();
113127
break;
114128

129+
case CMD_OUTPUT:
130+
OnOutput();
131+
break;
132+
115133
default:
116134
m_stream->Printf("Unrecognized command\n");
117135
break;
@@ -192,3 +210,24 @@ void IBCCLISessionContext::OnCommit()
192210
g_kvs->StoreObjectIfNecessary(g_inputCurrentShuntOffset, (uint16_t)0, g_iincalObjectName);
193211
g_kvs->StoreObjectIfNecessary(g_outputCurrentShuntOffset, (uint16_t)0, g_ioutcalObjectName);
194212
}
213+
214+
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
215+
// "output"
216+
217+
void IBCCLISessionContext::OnOutput()
218+
{
219+
switch(m_command[1].m_commandID)
220+
{
221+
case CMD_FORCEON:
222+
g_outEnableFromLoad.SetMode(GPIOPin::MODE_OUTPUT, 0);
223+
g_outEnableFromLoad = 1;
224+
break;
225+
226+
case CMD_NORMAL:
227+
g_outEnableFromLoad.SetMode(GPIOPin::MODE_INPUT, 0);
228+
break;
229+
230+
default:
231+
break;
232+
}
233+
}

firmware/main/IBCCLISessionContext.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class IBCCLISessionContext : public CLISessionContext
5252
void OnCalibrate();
5353
void OnCalibrateInputCurrent();
5454
void OnCalibrateOutputCurrent();
55+
void OnOutput();
5556

5657
void OnCommit();
5758

0 commit comments

Comments
 (0)