Browse Source

Use semantic LED event names

Clara Hobbs 7 years ago
parent
commit
d5bbd8b2f6
4 changed files with 13 additions and 6 deletions
  1. 4
    4
      src/device_policy_manager.c
  2. 7
    0
      src/led.h
  3. 1
    1
      src/main.c
  4. 1
    1
      src/shell.c

+ 4
- 4
src/device_policy_manager.c View File

@@ -48,7 +48,7 @@ bool pdb_dpm_evaluate_capability(const union pd_msg *capabilities, union pd_msg
48 48
     uint8_t numobj = PD_NUMOBJ_GET(capabilities);
49 49
 
50 50
     /* Make the LED blink to indicate ongoing power negotiations */
51
-    chEvtSignal(pdb_led_thread, PDB_EVT_LED_FAST_BLINK);
51
+    chEvtSignal(pdb_led_thread, PDB_EVT_LED_NEGOTIATING);
52 52
 
53 53
     /* Get whether or not the power supply is constrained */
54 54
     dpm_unconstrained_power = capabilities->obj[0] & PD_PDO_SRC_FIXED_UNCONSTRAINED;
@@ -189,7 +189,7 @@ bool pdb_dpm_evaluate_typec_current(void)
189 189
 
190 190
 void pdb_dpm_pd_start(void)
191 191
 {
192
-    chEvtSignal(pdb_led_thread, PDB_EVT_LED_FAST_BLINK);
192
+    chEvtSignal(pdb_led_thread, PDB_EVT_LED_NEGOTIATING);
193 193
 }
194 194
 
195 195
 void pdb_dpm_sink_standby(void)
@@ -211,11 +211,11 @@ void pdb_dpm_output_set(bool state)
211 211
     /* Set the power output */
212 212
     if (state) {
213 213
         /* Turn the output on */
214
-        chEvtSignal(pdb_led_thread, PDB_EVT_LED_MEDIUM_BLINK_OFF);
214
+        chEvtSignal(pdb_led_thread, PDB_EVT_LED_OUTPUT_ON);
215 215
         palSetLine(LINE_OUT_CTRL);
216 216
     } else {
217 217
         /* Turn the output off */
218
-        chEvtSignal(pdb_led_thread, PDB_EVT_LED_ON);
218
+        chEvtSignal(pdb_led_thread, PDB_EVT_LED_OUTPUT_OFF);
219 219
         palClearLine(LINE_OUT_CTRL);
220 220
     }
221 221
 }

+ 7
- 0
src/led.h View File

@@ -30,6 +30,13 @@
30 30
 #define PDB_EVT_LED_SLOW_BLINK EVENT_MASK(4)
31 31
 #define PDB_EVT_LED_FAST_BLINK_SLOW EVENT_MASK(5)
32 32
 
33
+/* Semantic LED event names */
34
+#define PDB_EVT_LED_CONFIG PDB_EVT_LED_SLOW_BLINK
35
+#define PDB_EVT_LED_IDENTIFY PDB_EVT_LED_FAST_BLINK_SLOW
36
+#define PDB_EVT_LED_NEGOTIATING PDB_EVT_LED_FAST_BLINK
37
+#define PDB_EVT_LED_OUTPUT_ON PDB_EVT_LED_MEDIUM_BLINK_OFF
38
+#define PDB_EVT_LED_OUTPUT_OFF PDB_EVT_LED_ON
39
+
33 40
 /* The LED thread object */
34 41
 extern thread_t *pdb_led_thread;
35 42
 

+ 1
- 1
src/main.c View File

@@ -67,7 +67,7 @@ static const I2CConfig i2c2config = {
67 67
 static void setup(void)
68 68
 {
69 69
     /* Indicate that we're in setup mode */
70
-    chEvtSignal(pdb_led_thread, PDB_EVT_LED_SLOW_BLINK);
70
+    chEvtSignal(pdb_led_thread, PDB_EVT_LED_CONFIG);
71 71
 
72 72
     /* Disconnect from USB */
73 73
     usbDisconnectBus(serusbcfg.usbp);

+ 1
- 1
src/shell.c View File

@@ -224,7 +224,7 @@ static void cmd_identify(BaseSequentialStream *chp, int argc, char *argv[])
224 224
         return;
225 225
     }
226 226
 
227
-    chEvtSignal(pdb_led_thread, PDB_EVT_LED_FAST_BLINK_SLOW);
227
+    chEvtSignal(pdb_led_thread, PDB_EVT_LED_IDENTIFY);
228 228
 }
229 229
 
230 230
 static const struct pdb_shell_cmd commands[] = {

Loading…
Cancel
Save