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
     uint8_t numobj = PD_NUMOBJ_GET(capabilities);
48
     uint8_t numobj = PD_NUMOBJ_GET(capabilities);
49
 
49
 
50
     /* Make the LED blink to indicate ongoing power negotiations */
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
     /* Get whether or not the power supply is constrained */
53
     /* Get whether or not the power supply is constrained */
54
     dpm_unconstrained_power = capabilities->obj[0] & PD_PDO_SRC_FIXED_UNCONSTRAINED;
54
     dpm_unconstrained_power = capabilities->obj[0] & PD_PDO_SRC_FIXED_UNCONSTRAINED;
189
 
189
 
190
 void pdb_dpm_pd_start(void)
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
 void pdb_dpm_sink_standby(void)
195
 void pdb_dpm_sink_standby(void)
211
     /* Set the power output */
211
     /* Set the power output */
212
     if (state) {
212
     if (state) {
213
         /* Turn the output on */
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
         palSetLine(LINE_OUT_CTRL);
215
         palSetLine(LINE_OUT_CTRL);
216
     } else {
216
     } else {
217
         /* Turn the output off */
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
         palClearLine(LINE_OUT_CTRL);
219
         palClearLine(LINE_OUT_CTRL);
220
     }
220
     }
221
 }
221
 }

+ 7
- 0
src/led.h View File

30
 #define PDB_EVT_LED_SLOW_BLINK EVENT_MASK(4)
30
 #define PDB_EVT_LED_SLOW_BLINK EVENT_MASK(4)
31
 #define PDB_EVT_LED_FAST_BLINK_SLOW EVENT_MASK(5)
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
 /* The LED thread object */
40
 /* The LED thread object */
34
 extern thread_t *pdb_led_thread;
41
 extern thread_t *pdb_led_thread;
35
 
42
 

+ 1
- 1
src/main.c View File

67
 static void setup(void)
67
 static void setup(void)
68
 {
68
 {
69
     /* Indicate that we're in setup mode */
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
     /* Disconnect from USB */
72
     /* Disconnect from USB */
73
     usbDisconnectBus(serusbcfg.usbp);
73
     usbDisconnectBus(serusbcfg.usbp);

+ 1
- 1
src/shell.c View File

224
         return;
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
 static const struct pdb_shell_cmd commands[] = {
230
 static const struct pdb_shell_cmd commands[] = {

Loading…
Cancel
Save