Browse Source

Correctly state via PD whether we can do USB comms

When running in Setup mode, the Sink is capable of USB communications.
Now it's honest about that in the Request and Sink_Capabilities
messages.
Clara Hobbs 7 years ago
parent
commit
040695cec3
3 changed files with 18 additions and 1 deletions
  1. 13
    0
      src/device_policy_manager.c
  2. 3
    0
      src/device_policy_manager.h
  3. 2
    1
      src/main.c

+ 13
- 0
src/device_policy_manager.c View File

30
 
30
 
31
 bool pdb_dpm_led_pd_status = true;
31
 bool pdb_dpm_led_pd_status = true;
32
 
32
 
33
+bool pdb_dpm_usb_comms = false;
34
+
33
 
35
 
34
 /* The current draw when the output is disabled */
36
 /* The current draw when the output is disabled */
35
 #define DPM_MIN_CURRENT PD_MA2PDI(100)
37
 #define DPM_MIN_CURRENT PD_MA2PDI(100)
86
                         | PD_RDO_FV_CURRENT_SET(cfg->i)
88
                         | PD_RDO_FV_CURRENT_SET(cfg->i)
87
                         | PD_RDO_NO_USB_SUSPEND | PD_RDO_OBJPOS_SET(i + 1);
89
                         | PD_RDO_NO_USB_SUSPEND | PD_RDO_OBJPOS_SET(i + 1);
88
                 }
90
                 }
91
+                if (pdb_dpm_usb_comms) {
92
+                    request->obj[0] |= PD_RDO_USB_COMMS;
93
+                }
89
 
94
 
90
                 /* Update requested voltage */
95
                 /* Update requested voltage */
91
                 dpm_requested_voltage = cfg->v;
96
                 dpm_requested_voltage = cfg->v;
101
         | PD_RDO_FV_CURRENT_SET(DPM_MIN_CURRENT)
106
         | PD_RDO_FV_CURRENT_SET(DPM_MIN_CURRENT)
102
         | PD_RDO_NO_USB_SUSPEND | PD_RDO_CAP_MISMATCH
107
         | PD_RDO_NO_USB_SUSPEND | PD_RDO_CAP_MISMATCH
103
         | PD_RDO_OBJPOS_SET(1);
108
         | PD_RDO_OBJPOS_SET(1);
109
+    if (pdb_dpm_usb_comms) {
110
+        request->obj[0] |= PD_RDO_USB_COMMS;
111
+    }
104
 
112
 
105
     /* Update requested voltage */
113
     /* Update requested voltage */
106
     dpm_requested_voltage = PD_MV2PDV(5000);
114
     dpm_requested_voltage = PD_MV2PDV(5000);
140
         cap->obj[0] |= PD_PDO_SNK_FIXED_UNCONSTRAINED;
148
         cap->obj[0] |= PD_PDO_SNK_FIXED_UNCONSTRAINED;
141
     }
149
     }
142
 
150
 
151
+    /* Set the USB communications capable flag. */
152
+    if (pdb_dpm_usb_comms) {
153
+        cap->obj[0] |= PD_PDO_SNK_FIXED_USB_COMMS;
154
+    }
155
+
143
     /* Set the Sink_Capabilities message header */
156
     /* Set the Sink_Capabilities message header */
144
     cap->hdr = PD_MSGTYPE_SINK_CAPABILITIES | PD_DATAROLE_UFP | PD_SPECREV_2_0
157
     cap->hdr = PD_MSGTYPE_SINK_CAPABILITIES | PD_DATAROLE_UFP | PD_SPECREV_2_0
145
         | PD_POWERROLE_SINK | PD_NUMOBJ(numobj);
158
         | PD_POWERROLE_SINK | PD_NUMOBJ(numobj);

+ 3
- 0
src/device_policy_manager.h View File

27
 /* Whether the DPM sets the LED to indicate the PD status */
27
 /* Whether the DPM sets the LED to indicate the PD status */
28
 extern bool pdb_dpm_led_pd_status;
28
 extern bool pdb_dpm_led_pd_status;
29
 
29
 
30
+/* Whether the device is capable of USB communications */
31
+extern bool pdb_dpm_usb_comms;
32
+
30
 
33
 
31
 /*
34
 /*
32
  * Create a Request message based on the given Source_Capabilities message.
35
  * Create a Request message based on the given Source_Capabilities message.

+ 2
- 1
src/main.c View File

90
  */
90
  */
91
 static void setup(void)
91
 static void setup(void)
92
 {
92
 {
93
-    /* Set the DPM to not set the LED to show PD status */
93
+    /* Configure the DPM to play nice with the shell */
94
     pdb_dpm_led_pd_status = false;
94
     pdb_dpm_led_pd_status = false;
95
+    pdb_dpm_usb_comms = true;
95
 
96
 
96
     /* Start the USB Power Delivery threads */
97
     /* Start the USB Power Delivery threads */
97
     start_pd();
98
     start_pd();

Loading…
Cancel
Save