3 Commits

Author SHA1 Message Date
  Clara Hobbs 705de993ea Update version number to 1.2.2 5 years ago
  Clara Hobbs f2a724463c Added LED status code for default USB power 5 years ago
  Clara Hobbs e9b9a6e260 Added LED description table to README 6 years ago
8 changed files with 52 additions and 9 deletions
  1. 12
    0
      README.md
  2. 1
    1
      docs/console_config.md
  3. 22
    6
      src/device_policy_manager.c
  4. 5
    0
      src/device_policy_manager.h
  5. 8
    0
      src/led.c
  6. 2
    0
      src/led.h
  7. 1
    1
      src/main.c
  8. 1
    1
      src/usbcfg.c

+ 12
- 0
README.md View File

@@ -169,3 +169,15 @@ configured voltage, the Sink will negotiate it, then turn on its output and
169 169
 blink the LED three times to indicate success.  If the supply cannot output
170 170
 enough power, the Sink will turn its LED on solid to indicate failure, and
171 171
 leave its output turned off.
172
+
173
+### Status LED descriptions
174
+
175
+LED State                  | Mode  | Meaning
176
+---------------------------|-------|---------------------------------------------------
177
+Fast blink (4 blink/sec)   | Sink  | Negotiating USB Power Delivery contract
178
+Medium blink (2 blink/sec) | Sink  | USB Power Delivery contract established, output on
179
+Off                        | Sink  | Output on
180
+On                         | Sink  | Unable to get configured power from source
181
+Long blink (1 blink/2 sec) | Sink  | Only default USB power is available (e.g. powered with USB A to C cable)
182
+Slow blink (1 blink/sec)   | Setup | Running in setup mode
183
+Fast blink (4 blink/sec)   | Setup | `identify` command run

+ 1
- 1
docs/console_config.md View File

@@ -1,6 +1,6 @@
1 1
 # PD Buddy Sink Serial Console Configuration Interface
2 2
 
3
-Version 1.2.1, 2018-05-28
3
+Version 1.2.2, 2018-06-03
4 4
 
5 5
 The PD Buddy Sink can be put into setup mode by holding the Setup button while
6 6
 plugging it into a computer.  In this mode, the device runs a configuration

+ 22
- 6
src/device_policy_manager.c View File

@@ -387,7 +387,7 @@ void pdbs_dpm_pd_start(struct pdb_config *cfg)
387 387
 /*
388 388
  * Set the output state, with LED indication.
389 389
  */
390
-static void dpm_output_set(struct pdbs_dpm_data *dpm_data, bool state)
390
+static void dpm_output_set(struct pdbs_dpm_data *dpm_data, bool state, bool led)
391 391
 {
392 392
     /* Update the present voltage */
393 393
     dpm_data->_present_voltage = dpm_data->_requested_voltage;
@@ -395,13 +395,13 @@ static void dpm_output_set(struct pdbs_dpm_data *dpm_data, bool state)
395 395
     /* Set the power output */
396 396
     if (state && dpm_data->output_enabled) {
397 397
         /* Turn the output on */
398
-        if (dpm_data->led_pd_status) {
398
+        if (dpm_data->led_pd_status && led) {
399 399
             chEvtSignal(pdbs_led_thread, PDBS_EVT_LED_OUTPUT_ON);
400 400
         }
401 401
         palSetLine(LINE_OUT_CTRL);
402 402
     } else {
403 403
         /* Turn the output off */
404
-        if (dpm_data->led_pd_status) {
404
+        if (dpm_data->led_pd_status && led) {
405 405
             chEvtSignal(pdbs_led_thread, PDBS_EVT_LED_OUTPUT_OFF);
406 406
         }
407 407
         palClearLine(LINE_OUT_CTRL);
@@ -416,12 +416,12 @@ void pdbs_dpm_transition_default(struct pdb_config *cfg)
416 416
     /* Pretend we requested 5 V */
417 417
     dpm_data->_requested_voltage = 5000;
418 418
     /* Turn the output off */
419
-    dpm_output_set(cfg->dpm_data, false);
419
+    dpm_output_set(cfg->dpm_data, false, true);
420 420
 }
421 421
 
422 422
 void pdbs_dpm_transition_min(struct pdb_config *cfg)
423 423
 {
424
-    dpm_output_set(cfg->dpm_data, false);
424
+    dpm_output_set(cfg->dpm_data, false, true);
425 425
 }
426 426
 
427 427
 void pdbs_dpm_transition_standby(struct pdb_config *cfg)
@@ -443,5 +443,21 @@ void pdbs_dpm_transition_requested(struct pdb_config *cfg)
443 443
     /* Cast the dpm_data to the right type */
444 444
     struct pdbs_dpm_data *dpm_data = cfg->dpm_data;
445 445
 
446
-    dpm_output_set(cfg->dpm_data, dpm_data->_capability_match);
446
+    dpm_output_set(cfg->dpm_data, dpm_data->_capability_match, true);
447
+}
448
+
449
+void pdbs_dpm_transition_typec(struct pdb_config *cfg)
450
+{
451
+    /* Cast the dpm_data to the right type */
452
+    struct pdbs_dpm_data *dpm_data = cfg->dpm_data;
453
+
454
+    /* If we only have default Type-C Current, set a special LED status */
455
+    if (dpm_data->led_pd_status
456
+            && dpm_data->typec_current == fusb_tcc_default) {
457
+        chEvtSignal(pdbs_led_thread, PDBS_EVT_LED_OUTPUT_OFF_NO_TYPEC);
458
+    }
459
+
460
+    /* Set the output, only setting the LED status if it wasn't set above */
461
+    dpm_output_set(cfg->dpm_data, dpm_data->_capability_match,
462
+            dpm_data->typec_current != fusb_tcc_default);
447 463
 }

+ 5
- 0
src/device_policy_manager.h View File

@@ -100,5 +100,10 @@ void pdbs_dpm_transition_standby(struct pdb_config *cfg);
100 100
  */
101 101
 void pdbs_dpm_transition_requested(struct pdb_config *cfg);
102 102
 
103
+/*
104
+ * Transition to the Type-C Current power level
105
+ */
106
+void pdbs_dpm_transition_typec(struct pdb_config *cfg);
107
+
103 108
 
104 109
 #endif /* PDBS_DEVICE_POLICY_MANAGER_H */

+ 8
- 0
src/led.c View File

@@ -101,6 +101,14 @@ static THD_FUNCTION(LED, arg) {
101 101
                     palToggleLine(LINE_LED);
102 102
                 }
103 103
                 break;
104
+            case PDBS_EVT_LED_LONG_BLINK:
105
+                timeout = LED_FAST;
106
+                if (i % 16 == 0) {
107
+                    palClearLine(LINE_LED);
108
+                } else {
109
+                    palSetLine(LINE_LED);
110
+                }
111
+                break;
104 112
             case PDBS_EVT_LED_FAST_BLINK_SLOW:
105 113
                 timeout = LED_FAST;
106 114
                 if (i == 0) {

+ 2
- 0
src/led.h View File

@@ -29,6 +29,7 @@
29 29
 #define PDBS_EVT_LED_MEDIUM_BLINK_OFF EVENT_MASK(3)
30 30
 #define PDBS_EVT_LED_SLOW_BLINK EVENT_MASK(4)
31 31
 #define PDBS_EVT_LED_FAST_BLINK_SLOW EVENT_MASK(5)
32
+#define PDBS_EVT_LED_LONG_BLINK EVENT_MASK(6)
32 33
 
33 34
 /* Semantic LED event names */
34 35
 #define PDBS_EVT_LED_CONFIG PDBS_EVT_LED_SLOW_BLINK
@@ -36,6 +37,7 @@
36 37
 #define PDBS_EVT_LED_NEGOTIATING PDBS_EVT_LED_FAST_BLINK
37 38
 #define PDBS_EVT_LED_OUTPUT_ON PDBS_EVT_LED_MEDIUM_BLINK_OFF
38 39
 #define PDBS_EVT_LED_OUTPUT_OFF PDBS_EVT_LED_ON
40
+#define PDBS_EVT_LED_OUTPUT_OFF_NO_TYPEC PDBS_EVT_LED_LONG_BLINK
39 41
 
40 42
 /* The LED thread object */
41 43
 extern thread_t *pdbs_led_thread;

+ 1
- 1
src/main.c View File

@@ -85,7 +85,7 @@ static struct pdb_config pdb_config = {
85 85
         pdbs_dpm_transition_min,
86 86
         pdbs_dpm_transition_standby,
87 87
         pdbs_dpm_transition_requested,
88
-        pdbs_dpm_transition_requested, /* transition_typec */
88
+        pdbs_dpm_transition_typec,
89 89
         NULL /* not_supported_received */
90 90
     },
91 91
     .dpm_data = &dpm_data

+ 1
- 1
src/usbcfg.c View File

@@ -201,7 +201,7 @@ static const uint8_t vcom_string2[] = {
201 201
 static const uint8_t vcom_string3[] = {
202 202
     USB_DESC_BYTE(12),                    /* bLength.                         */
203 203
     USB_DESC_BYTE(USB_DESCRIPTOR_STRING), /* bDescriptorType.                 */
204
-    '1', 0, '.', 0, '2', 0, '.', 0, '1', 0
204
+    '1', 0, '.', 0, '2', 0, '.', 0, '2', 0
205 205
 };
206 206
 
207 207
 /*

Loading…
Cancel
Save