|
@@ -42,6 +42,7 @@
|
42
|
42
|
#include "usbcfg.h"
|
43
|
43
|
#include "storage.h"
|
44
|
44
|
#include "led.h"
|
|
45
|
+#include "device_policy_manager.h"
|
45
|
46
|
#include "policy_engine.h"
|
46
|
47
|
#include "pd.h"
|
47
|
48
|
|
|
@@ -244,6 +245,33 @@ static void cmd_identify(BaseSequentialStream *chp, int argc, char *argv[])
|
244
|
245
|
chEvtSignal(pdb_led_thread, PDB_EVT_LED_IDENTIFY);
|
245
|
246
|
}
|
246
|
247
|
|
|
248
|
+static void cmd_output(BaseSequentialStream *chp, int argc, char *argv[])
|
|
249
|
+{
|
|
250
|
+ if (argc == 0) {
|
|
251
|
+ /* With no arguments, print the output status */
|
|
252
|
+ if (pdb_dpm_output_enabled) {
|
|
253
|
+ chprintf(chp, "enabled\r\n");
|
|
254
|
+ } else {
|
|
255
|
+ chprintf(chp, "disabled\r\n");
|
|
256
|
+ }
|
|
257
|
+ } else if (argc == 1) {
|
|
258
|
+ /* Set the output status and re-negotiate power */
|
|
259
|
+ if (strcmp(argv[0], "enable") == 0) {
|
|
260
|
+ pdb_dpm_output_enabled = true;
|
|
261
|
+ chEvtSignal(pdb_pe_thread, PDB_EVT_PE_GET_SOURCE_CAP);
|
|
262
|
+ } else if (strcmp(argv[0], "disable") == 0) {
|
|
263
|
+ pdb_dpm_output_enabled = false;
|
|
264
|
+ chEvtSignal(pdb_pe_thread, PDB_EVT_PE_GET_SOURCE_CAP);
|
|
265
|
+ } else {
|
|
266
|
+ /* Or, if the argument was invalid, print a usage message */
|
|
267
|
+ chprintf(chp, "Usage: output [enable|disable]\r\n");
|
|
268
|
+ }
|
|
269
|
+ } else {
|
|
270
|
+ /* If there are too many arguments, print a usage message */
|
|
271
|
+ chprintf(chp, "Usage: output [enable|disable]\r\n");
|
|
272
|
+ }
|
|
273
|
+}
|
|
274
|
+
|
247
|
275
|
/*
|
248
|
276
|
* List of shell commands
|
249
|
277
|
*/
|
|
@@ -261,6 +289,7 @@ static const struct pdb_shell_cmd commands[] = {
|
261
|
289
|
{"set_i", cmd_set_i, "Set the current in milliamps"},
|
262
|
290
|
/* TODO {"set_v_range", cmd_set_v_range, "Set the minimum and maximum voltage in millivolts"},*/
|
263
|
291
|
{"identify", cmd_identify, "Blink the LED to identify the device"},
|
|
292
|
+ {"output", cmd_output, "Get or set the output status"},
|
264
|
293
|
{NULL, NULL, NULL}
|
265
|
294
|
};
|
266
|
295
|
|