Bladeren bron

Use a macro for the minimum current

Clara Hobbs 7 jaren geleden
bovenliggende
commit
cbfd5b7e1b
1 gewijzigde bestanden met toevoegingen van 8 en 5 verwijderingen
  1. 8
    5
      src/device_policy_manager.c

+ 8
- 5
src/device_policy_manager.c Bestand weergeven

@@ -28,6 +28,9 @@
28 28
 #include "fusb302b.h"
29 29
 
30 30
 
31
+/* The current draw when the output is disabled */
32
+#define DPM_MIN_CURRENT PD_MA2PDI(100)
33
+
31 34
 /* Whether or not the power supply is unconstrained */
32 35
 static bool dpm_unconstrained_power;
33 36
 
@@ -68,7 +71,7 @@ bool pdb_dpm_evaluate_capability(const union pd_msg *capabilities, union pd_msg
68 71
                     PD_SPECREV_2_0 | PD_POWERROLE_SINK | PD_NUMOBJ(1);
69 72
                 if (cfg->flags & PDB_CONFIG_FLAGS_GIVEBACK) {
70 73
                     /* GiveBack enabled */
71
-                    request->obj[0] = PD_RDO_FV_MIN_CURRENT_SET(10)
74
+                    request->obj[0] = PD_RDO_FV_MIN_CURRENT_SET(DPM_MIN_CURRENT)
72 75
                         | PD_RDO_FV_CURRENT_SET(cfg->i)
73 76
                         | PD_RDO_NO_USB_SUSPEND | PD_RDO_GIVEBACK
74 77
                         | PD_RDO_OBJPOS_SET(i + 1);
@@ -89,8 +92,8 @@ bool pdb_dpm_evaluate_capability(const union pd_msg *capabilities, union pd_msg
89 92
     /* Nothing matched (or no configuration), so get 5 V at low current */
90 93
     request->hdr = PD_MSGTYPE_REQUEST | PD_DATAROLE_UFP |
91 94
         PD_SPECREV_2_0 | PD_POWERROLE_SINK | PD_NUMOBJ(1);
92
-    request->obj[0] = PD_RDO_FV_MAX_CURRENT_SET(10)
93
-        | PD_RDO_FV_CURRENT_SET(10)
95
+    request->obj[0] = PD_RDO_FV_MAX_CURRENT_SET(DPM_MIN_CURRENT)
96
+        | PD_RDO_FV_CURRENT_SET(DPM_MIN_CURRENT)
94 97
         | PD_RDO_NO_USB_SUSPEND | PD_RDO_CAP_MISMATCH
95 98
         | PD_RDO_OBJPOS_SET(1);
96 99
 
@@ -110,10 +113,10 @@ void pdb_dpm_get_sink_capability(union pd_msg *cap)
110 113
     /* If we have no configuration or want something other than 5 V, add a PDO
111 114
      * for vSafe5V */
112 115
     if (cfg == NULL || cfg->v != 100) {
113
-        /* 100 mA, 5 V, and higher capability. */
116
+        /* Minimum current, 5 V, and higher capability. */
114 117
         cap->obj[numobj++] = PD_PDO_TYPE_FIXED
115 118
             | PD_PDO_SNK_FIXED_VOLTAGE_SET(100)
116
-            | PD_PDO_SNK_FIXED_CURRENT_SET(10);
119
+            | PD_PDO_SNK_FIXED_CURRENT_SET(DPM_MIN_CURRENT);
117 120
     }
118 121
 
119 122
     /* Add a PDO for the desired power. */

Laden…
Annuleren
Opslaan