Browse Source

Use a macro for the minimum current

Clara Hobbs 7 years ago
parent
commit
cbfd5b7e1b
1 changed files with 8 additions and 5 deletions
  1. 8
    5
      src/device_policy_manager.c

+ 8
- 5
src/device_policy_manager.c View File

28
 #include "fusb302b.h"
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
 /* Whether or not the power supply is unconstrained */
34
 /* Whether or not the power supply is unconstrained */
32
 static bool dpm_unconstrained_power;
35
 static bool dpm_unconstrained_power;
33
 
36
 
68
                     PD_SPECREV_2_0 | PD_POWERROLE_SINK | PD_NUMOBJ(1);
71
                     PD_SPECREV_2_0 | PD_POWERROLE_SINK | PD_NUMOBJ(1);
69
                 if (cfg->flags & PDB_CONFIG_FLAGS_GIVEBACK) {
72
                 if (cfg->flags & PDB_CONFIG_FLAGS_GIVEBACK) {
70
                     /* GiveBack enabled */
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
                         | PD_RDO_FV_CURRENT_SET(cfg->i)
75
                         | PD_RDO_FV_CURRENT_SET(cfg->i)
73
                         | PD_RDO_NO_USB_SUSPEND | PD_RDO_GIVEBACK
76
                         | PD_RDO_NO_USB_SUSPEND | PD_RDO_GIVEBACK
74
                         | PD_RDO_OBJPOS_SET(i + 1);
77
                         | PD_RDO_OBJPOS_SET(i + 1);
89
     /* Nothing matched (or no configuration), so get 5 V at low current */
92
     /* Nothing matched (or no configuration), so get 5 V at low current */
90
     request->hdr = PD_MSGTYPE_REQUEST | PD_DATAROLE_UFP |
93
     request->hdr = PD_MSGTYPE_REQUEST | PD_DATAROLE_UFP |
91
         PD_SPECREV_2_0 | PD_POWERROLE_SINK | PD_NUMOBJ(1);
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
         | PD_RDO_NO_USB_SUSPEND | PD_RDO_CAP_MISMATCH
97
         | PD_RDO_NO_USB_SUSPEND | PD_RDO_CAP_MISMATCH
95
         | PD_RDO_OBJPOS_SET(1);
98
         | PD_RDO_OBJPOS_SET(1);
96
 
99
 
110
     /* If we have no configuration or want something other than 5 V, add a PDO
113
     /* If we have no configuration or want something other than 5 V, add a PDO
111
      * for vSafe5V */
114
      * for vSafe5V */
112
     if (cfg == NULL || cfg->v != 100) {
115
     if (cfg == NULL || cfg->v != 100) {
113
-        /* 100 mA, 5 V, and higher capability. */
116
+        /* Minimum current, 5 V, and higher capability. */
114
         cap->obj[numobj++] = PD_PDO_TYPE_FIXED
117
         cap->obj[numobj++] = PD_PDO_TYPE_FIXED
115
             | PD_PDO_SNK_FIXED_VOLTAGE_SET(100)
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
     /* Add a PDO for the desired power. */
122
     /* Add a PDO for the desired power. */

Loading…
Cancel
Save