Browse Source

Use the CURRENT_DEFN field of flags

Now the CURRENT_DEFN field of the flags halfword in the pdbs_config
object is actually used, both when printing configuration objects and
when setting a current.  It never takes any value other than 0 (_I) yet,
but this easily extends to power and resistance.
Clara Hobbs 7 years ago
parent
commit
477c06e544
2 changed files with 10 additions and 2 deletions
  1. 7
    2
      src/config.c
  2. 3
    0
      src/shell.c

+ 7
- 2
src/config.c View File

@@ -69,9 +69,14 @@ void pdbs_config_print(BaseSequentialStream *chp, const struct pdbs_config *cfg)
69 69
     }
70 70
     chprintf(chp, "\r\n");
71 71
 
72
-    /* Print voltages and current */
72
+    /* Print voltage */
73 73
     chprintf(chp, "v: %d.%02d V\r\n", PD_PDV_V(cfg->v), PD_PDV_CV(cfg->v));
74
-    chprintf(chp, "i: %d.%02d A\r\n", PD_PDI_A(cfg->i), PD_PDI_CA(cfg->i));
74
+    /* Print current-deriving setting */
75
+    switch (cfg->flags & PDBS_CONFIG_FLAGS_CURRENT_DEFN) {
76
+        case PDBS_CONFIG_FLAGS_CURRENT_DEFN_I:
77
+            chprintf(chp, "i: %d.%02d A\r\n", PD_PDI_A(cfg->i), PD_PDI_CA(cfg->i));
78
+            break;
79
+    }
75 80
     /* If either end of the range is non-zero, print the range */
76 81
     if (cfg->vmin != 0 || cfg->vmax != 0) {
77 82
         chprintf(chp, "vmin: %d.%02d V\r\n", PD_PDV_V(cfg->vmin),

+ 3
- 0
src/shell.c View File

@@ -316,6 +316,9 @@ static void cmd_set_i(BaseSequentialStream *chp, int argc, char *argv[])
316 316
     if (i >= PD_MA_MIN && i <= PD_MA_MAX && endptr > argv[0]) {
317 317
         /* Convert mA to the unit used by USB PD */
318 318
         tmpcfg.i = PD_MA2PDI(i);
319
+        /* Set the flags to say we're storing a current */
320
+        tmpcfg.flags &= ~PDBS_CONFIG_FLAGS_CURRENT_DEFN;
321
+        tmpcfg.flags |= PDBS_CONFIG_FLAGS_CURRENT_DEFN_I;
319 322
     } else {
320 323
         chprintf(chp, "Invalid current\r\n");
321 324
         return;

Loading…
Cancel
Save