Просмотр исходного кода

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 лет назад
Родитель
Сommit
040695cec3
3 измененных файлов: 18 добавлений и 1 удалений
  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 Просмотреть файл

@@ -30,6 +30,8 @@
30 30
 
31 31
 bool pdb_dpm_led_pd_status = true;
32 32
 
33
+bool pdb_dpm_usb_comms = false;
34
+
33 35
 
34 36
 /* The current draw when the output is disabled */
35 37
 #define DPM_MIN_CURRENT PD_MA2PDI(100)
@@ -86,6 +88,9 @@ bool pdb_dpm_evaluate_capability(const union pd_msg *capabilities, union pd_msg
86 88
                         | PD_RDO_FV_CURRENT_SET(cfg->i)
87 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 95
                 /* Update requested voltage */
91 96
                 dpm_requested_voltage = cfg->v;
@@ -101,6 +106,9 @@ bool pdb_dpm_evaluate_capability(const union pd_msg *capabilities, union pd_msg
101 106
         | PD_RDO_FV_CURRENT_SET(DPM_MIN_CURRENT)
102 107
         | PD_RDO_NO_USB_SUSPEND | PD_RDO_CAP_MISMATCH
103 108
         | PD_RDO_OBJPOS_SET(1);
109
+    if (pdb_dpm_usb_comms) {
110
+        request->obj[0] |= PD_RDO_USB_COMMS;
111
+    }
104 112
 
105 113
     /* Update requested voltage */
106 114
     dpm_requested_voltage = PD_MV2PDV(5000);
@@ -140,6 +148,11 @@ void pdb_dpm_get_sink_capability(union pd_msg *cap)
140 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 156
     /* Set the Sink_Capabilities message header */
144 157
     cap->hdr = PD_MSGTYPE_SINK_CAPABILITIES | PD_DATAROLE_UFP | PD_SPECREV_2_0
145 158
         | PD_POWERROLE_SINK | PD_NUMOBJ(numobj);

+ 3
- 0
src/device_policy_manager.h Просмотреть файл

@@ -27,6 +27,9 @@
27 27
 /* Whether the DPM sets the LED to indicate the PD status */
28 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 35
  * Create a Request message based on the given Source_Capabilities message.

+ 2
- 1
src/main.c Просмотреть файл

@@ -90,8 +90,9 @@ static void start_pd(void)
90 90
  */
91 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 94
     pdb_dpm_led_pd_status = false;
95
+    pdb_dpm_usb_comms = true;
95 96
 
96 97
     /* Start the USB Power Delivery threads */
97 98
     start_pd();

Загрузка…
Отмена
Сохранить