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
     }
69
     }
70
     chprintf(chp, "\r\n");
70
     chprintf(chp, "\r\n");
71
 
71
 
72
-    /* Print voltages and current */
72
+    /* Print voltage */
73
     chprintf(chp, "v: %d.%02d V\r\n", PD_PDV_V(cfg->v), PD_PDV_CV(cfg->v));
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
     /* If either end of the range is non-zero, print the range */
80
     /* If either end of the range is non-zero, print the range */
76
     if (cfg->vmin != 0 || cfg->vmax != 0) {
81
     if (cfg->vmin != 0 || cfg->vmax != 0) {
77
         chprintf(chp, "vmin: %d.%02d V\r\n", PD_PDV_V(cfg->vmin),
82
         chprintf(chp, "vmin: %d.%02d V\r\n", PD_PDV_V(cfg->vmin),

+ 3
- 0
src/shell.c View File

316
     if (i >= PD_MA_MIN && i <= PD_MA_MAX && endptr > argv[0]) {
316
     if (i >= PD_MA_MIN && i <= PD_MA_MAX && endptr > argv[0]) {
317
         /* Convert mA to the unit used by USB PD */
317
         /* Convert mA to the unit used by USB PD */
318
         tmpcfg.i = PD_MA2PDI(i);
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
     } else {
322
     } else {
320
         chprintf(chp, "Invalid current\r\n");
323
         chprintf(chp, "Invalid current\r\n");
321
         return;
324
         return;

Loading…
Cancel
Save