3 Commits

Autor SHA1 Mensagem Data
  Clara Hobbs 705de993ea Update version number to 1.2.2 6 anos atrás
  Clara Hobbs f2a724463c Added LED status code for default USB power 6 anos atrás
  Clara Hobbs e9b9a6e260 Added LED description table to README 6 anos atrás
8 arquivos alterados com 52 adições e 9 exclusões
  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 Ver arquivo

169
 blink the LED three times to indicate success.  If the supply cannot output
169
 blink the LED three times to indicate success.  If the supply cannot output
170
 enough power, the Sink will turn its LED on solid to indicate failure, and
170
 enough power, the Sink will turn its LED on solid to indicate failure, and
171
 leave its output turned off.
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 Ver arquivo

1
 # PD Buddy Sink Serial Console Configuration Interface
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
 The PD Buddy Sink can be put into setup mode by holding the Setup button while
5
 The PD Buddy Sink can be put into setup mode by holding the Setup button while
6
 plugging it into a computer.  In this mode, the device runs a configuration
6
 plugging it into a computer.  In this mode, the device runs a configuration

+ 22
- 6
src/device_policy_manager.c Ver arquivo

387
 /*
387
 /*
388
  * Set the output state, with LED indication.
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
     /* Update the present voltage */
392
     /* Update the present voltage */
393
     dpm_data->_present_voltage = dpm_data->_requested_voltage;
393
     dpm_data->_present_voltage = dpm_data->_requested_voltage;
395
     /* Set the power output */
395
     /* Set the power output */
396
     if (state && dpm_data->output_enabled) {
396
     if (state && dpm_data->output_enabled) {
397
         /* Turn the output on */
397
         /* Turn the output on */
398
-        if (dpm_data->led_pd_status) {
398
+        if (dpm_data->led_pd_status && led) {
399
             chEvtSignal(pdbs_led_thread, PDBS_EVT_LED_OUTPUT_ON);
399
             chEvtSignal(pdbs_led_thread, PDBS_EVT_LED_OUTPUT_ON);
400
         }
400
         }
401
         palSetLine(LINE_OUT_CTRL);
401
         palSetLine(LINE_OUT_CTRL);
402
     } else {
402
     } else {
403
         /* Turn the output off */
403
         /* Turn the output off */
404
-        if (dpm_data->led_pd_status) {
404
+        if (dpm_data->led_pd_status && led) {
405
             chEvtSignal(pdbs_led_thread, PDBS_EVT_LED_OUTPUT_OFF);
405
             chEvtSignal(pdbs_led_thread, PDBS_EVT_LED_OUTPUT_OFF);
406
         }
406
         }
407
         palClearLine(LINE_OUT_CTRL);
407
         palClearLine(LINE_OUT_CTRL);
416
     /* Pretend we requested 5 V */
416
     /* Pretend we requested 5 V */
417
     dpm_data->_requested_voltage = 5000;
417
     dpm_data->_requested_voltage = 5000;
418
     /* Turn the output off */
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
 void pdbs_dpm_transition_min(struct pdb_config *cfg)
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
 void pdbs_dpm_transition_standby(struct pdb_config *cfg)
427
 void pdbs_dpm_transition_standby(struct pdb_config *cfg)
443
     /* Cast the dpm_data to the right type */
443
     /* Cast the dpm_data to the right type */
444
     struct pdbs_dpm_data *dpm_data = cfg->dpm_data;
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 Ver arquivo

100
  */
100
  */
101
 void pdbs_dpm_transition_requested(struct pdb_config *cfg);
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
 #endif /* PDBS_DEVICE_POLICY_MANAGER_H */
109
 #endif /* PDBS_DEVICE_POLICY_MANAGER_H */

+ 8
- 0
src/led.c Ver arquivo

101
                     palToggleLine(LINE_LED);
101
                     palToggleLine(LINE_LED);
102
                 }
102
                 }
103
                 break;
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
             case PDBS_EVT_LED_FAST_BLINK_SLOW:
112
             case PDBS_EVT_LED_FAST_BLINK_SLOW:
105
                 timeout = LED_FAST;
113
                 timeout = LED_FAST;
106
                 if (i == 0) {
114
                 if (i == 0) {

+ 2
- 0
src/led.h Ver arquivo

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

+ 1
- 1
src/main.c Ver arquivo

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

+ 1
- 1
src/usbcfg.c Ver arquivo

201
 static const uint8_t vcom_string3[] = {
201
 static const uint8_t vcom_string3[] = {
202
     USB_DESC_BYTE(12),                    /* bLength.                         */
202
     USB_DESC_BYTE(12),                    /* bLength.                         */
203
     USB_DESC_BYTE(USB_DESCRIPTOR_STRING), /* bDescriptorType.                 */
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
 /*

Carregando…
Cancelar
Salvar