Browse Source

Rename the LED stuff from PDB to PDBS

It's not general-purpose PD Buddy code, but rather PD Buddy Sink code.
Therefore it gets the pdbs namespace.
Clara Hobbs 6 years ago
parent
commit
acaa00aa54
5 changed files with 35 additions and 35 deletions
  1. 4
    4
      src/device_policy_manager.c
  2. 12
    12
      src/led.c
  3. 16
    16
      src/led.h
  4. 2
    2
      src/main.c
  5. 1
    1
      src/shell.c

+ 4
- 4
src/device_policy_manager.c View File

71
 
71
 
72
     /* Make the LED blink to indicate ongoing power negotiations */
72
     /* Make the LED blink to indicate ongoing power negotiations */
73
     if (pdb_dpm_led_pd_status) {
73
     if (pdb_dpm_led_pd_status) {
74
-        chEvtSignal(pdb_led_thread, PDB_EVT_LED_NEGOTIATING);
74
+        chEvtSignal(pdbs_led_thread, PDBS_EVT_LED_NEGOTIATING);
75
     }
75
     }
76
 
76
 
77
     /* Get whether or not the power supply is constrained */
77
     /* Get whether or not the power supply is constrained */
232
 void pdbs_dpm_pd_start(struct pdb_config *cfg)
232
 void pdbs_dpm_pd_start(struct pdb_config *cfg)
233
 {
233
 {
234
     if (pdb_dpm_led_pd_status) {
234
     if (pdb_dpm_led_pd_status) {
235
-        chEvtSignal(pdb_led_thread, PDB_EVT_LED_NEGOTIATING);
235
+        chEvtSignal(pdbs_led_thread, PDBS_EVT_LED_NEGOTIATING);
236
     }
236
     }
237
 }
237
 }
238
 
238
 
248
     if (state && pdb_dpm_output_enabled) {
248
     if (state && pdb_dpm_output_enabled) {
249
         /* Turn the output on */
249
         /* Turn the output on */
250
         if (pdb_dpm_led_pd_status) {
250
         if (pdb_dpm_led_pd_status) {
251
-            chEvtSignal(pdb_led_thread, PDB_EVT_LED_OUTPUT_ON);
251
+            chEvtSignal(pdbs_led_thread, PDBS_EVT_LED_OUTPUT_ON);
252
         }
252
         }
253
         palSetLine(LINE_OUT_CTRL);
253
         palSetLine(LINE_OUT_CTRL);
254
     } else {
254
     } else {
255
         /* Turn the output off */
255
         /* Turn the output off */
256
         if (pdb_dpm_led_pd_status) {
256
         if (pdb_dpm_led_pd_status) {
257
-            chEvtSignal(pdb_led_thread, PDB_EVT_LED_OUTPUT_OFF);
257
+            chEvtSignal(pdbs_led_thread, PDBS_EVT_LED_OUTPUT_OFF);
258
         }
258
         }
259
         palClearLine(LINE_OUT_CTRL);
259
         palClearLine(LINE_OUT_CTRL);
260
     }
260
     }

+ 12
- 12
src/led.c View File

32
 #define LED_FAST_BLINKS 8
32
 #define LED_FAST_BLINKS 8
33
 
33
 
34
 
34
 
35
-thread_t *pdb_led_thread;
35
+thread_t *pdbs_led_thread;
36
 
36
 
37
 /*
37
 /*
38
  * LED blinker thread.
38
  * LED blinker thread.
41
 static THD_FUNCTION(LED, arg) {
41
 static THD_FUNCTION(LED, arg) {
42
     (void) arg;
42
     (void) arg;
43
     /* LED starts turned off */
43
     /* LED starts turned off */
44
-    eventmask_t state = PDB_EVT_LED_OFF;
44
+    eventmask_t state = PDBS_EVT_LED_OFF;
45
     /* The event just received */
45
     /* The event just received */
46
     eventmask_t newstate;
46
     eventmask_t newstate;
47
     /* Timeout.  TIME_INFINITE for steady modes, other values for blinking
47
     /* Timeout.  TIME_INFINITE for steady modes, other values for blinking
66
         }
66
         }
67
 
67
 
68
         switch (state) {
68
         switch (state) {
69
-            case PDB_EVT_LED_OFF:
69
+            case PDBS_EVT_LED_OFF:
70
                 timeout = TIME_INFINITE;
70
                 timeout = TIME_INFINITE;
71
                 palClearLine(LINE_LED);
71
                 palClearLine(LINE_LED);
72
                 break;
72
                 break;
73
-            case PDB_EVT_LED_ON:
73
+            case PDBS_EVT_LED_ON:
74
                 timeout = TIME_INFINITE;
74
                 timeout = TIME_INFINITE;
75
                 palSetLine(LINE_LED);
75
                 palSetLine(LINE_LED);
76
                 break;
76
                 break;
77
-            case PDB_EVT_LED_FAST_BLINK:
77
+            case PDBS_EVT_LED_FAST_BLINK:
78
                 timeout = LED_FAST;
78
                 timeout = LED_FAST;
79
                 if (i == 0) {
79
                 if (i == 0) {
80
                     palSetLine(LINE_LED);
80
                     palSetLine(LINE_LED);
82
                     palToggleLine(LINE_LED);
82
                     palToggleLine(LINE_LED);
83
                 }
83
                 }
84
                 break;
84
                 break;
85
-            case PDB_EVT_LED_MEDIUM_BLINK_OFF:
85
+            case PDBS_EVT_LED_MEDIUM_BLINK_OFF:
86
                 timeout = LED_MEDIUM;
86
                 timeout = LED_MEDIUM;
87
                 if (i == 0) {
87
                 if (i == 0) {
88
                     palSetLine(LINE_LED);
88
                     palSetLine(LINE_LED);
93
                     timeout = TIME_INFINITE;
93
                     timeout = TIME_INFINITE;
94
                 }
94
                 }
95
                 break;
95
                 break;
96
-            case PDB_EVT_LED_SLOW_BLINK:
96
+            case PDBS_EVT_LED_SLOW_BLINK:
97
                 timeout = LED_SLOW;
97
                 timeout = LED_SLOW;
98
                 if (i == 0) {
98
                 if (i == 0) {
99
                     palSetLine(LINE_LED);
99
                     palSetLine(LINE_LED);
101
                     palToggleLine(LINE_LED);
101
                     palToggleLine(LINE_LED);
102
                 }
102
                 }
103
                 break;
103
                 break;
104
-            case PDB_EVT_LED_FAST_BLINK_SLOW:
104
+            case PDBS_EVT_LED_FAST_BLINK_SLOW:
105
                 timeout = LED_FAST;
105
                 timeout = LED_FAST;
106
                 if (i == 0) {
106
                 if (i == 0) {
107
                     palSetLine(LINE_LED);
107
                     palSetLine(LINE_LED);
110
                 } else {
110
                 } else {
111
                     palClearLine(LINE_LED);
111
                     palClearLine(LINE_LED);
112
                     timeout = TIME_INFINITE;
112
                     timeout = TIME_INFINITE;
113
-                    chEvtSignal(pdb_led_thread, PDB_EVT_LED_SLOW_BLINK);
113
+                    chEvtSignal(pdbs_led_thread, PDBS_EVT_LED_SLOW_BLINK);
114
                 }
114
                 }
115
                 break;
115
                 break;
116
             default:
116
             default:
122
     }
122
     }
123
 }
123
 }
124
 
124
 
125
-void pdb_led_run(void)
125
+void pdbs_led_run(void)
126
 {
126
 {
127
-    pdb_led_thread = chThdCreateStatic(waLED, sizeof(waLED), PDBS_PRIO_LED, LED,
128
-            NULL);
127
+    pdbs_led_thread = chThdCreateStatic(waLED, sizeof(waLED), PDBS_PRIO_LED,
128
+            LED, NULL);
129
 }
129
 }

+ 16
- 16
src/led.h View File

16
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
  */
17
  */
18
 
18
 
19
-#ifndef PDB_LED_H
20
-#define PDB_LED_H
19
+#ifndef PDBS_LED_H
20
+#define PDBS_LED_H
21
 
21
 
22
 #include <ch.h>
22
 #include <ch.h>
23
 
23
 
24
 
24
 
25
 /* Events for the LED thread */
25
 /* Events for the LED thread */
26
-#define PDB_EVT_LED_OFF EVENT_MASK(0)
27
-#define PDB_EVT_LED_ON EVENT_MASK(1)
28
-#define PDB_EVT_LED_FAST_BLINK EVENT_MASK(2)
29
-#define PDB_EVT_LED_MEDIUM_BLINK_OFF EVENT_MASK(3)
30
-#define PDB_EVT_LED_SLOW_BLINK EVENT_MASK(4)
31
-#define PDB_EVT_LED_FAST_BLINK_SLOW EVENT_MASK(5)
26
+#define PDBS_EVT_LED_OFF EVENT_MASK(0)
27
+#define PDBS_EVT_LED_ON EVENT_MASK(1)
28
+#define PDBS_EVT_LED_FAST_BLINK EVENT_MASK(2)
29
+#define PDBS_EVT_LED_MEDIUM_BLINK_OFF EVENT_MASK(3)
30
+#define PDBS_EVT_LED_SLOW_BLINK EVENT_MASK(4)
31
+#define PDBS_EVT_LED_FAST_BLINK_SLOW EVENT_MASK(5)
32
 
32
 
33
 /* Semantic LED event names */
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
34
+#define PDBS_EVT_LED_CONFIG PDBS_EVT_LED_SLOW_BLINK
35
+#define PDBS_EVT_LED_IDENTIFY PDBS_EVT_LED_FAST_BLINK_SLOW
36
+#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_OFF PDBS_EVT_LED_ON
39
 
39
 
40
 /* The LED thread object */
40
 /* The LED thread object */
41
-extern thread_t *pdb_led_thread;
41
+extern thread_t *pdbs_led_thread;
42
 
42
 
43
 /*
43
 /*
44
  * Start the LED thread
44
  * Start the LED thread
45
  */
45
  */
46
-void pdb_led_run(void);
46
+void pdbs_led_run(void);
47
 
47
 
48
 
48
 
49
-#endif /* PDB_LED_H */
49
+#endif /* PDBS_LED_H */

+ 2
- 2
src/main.c View File

92
     pdb_init(&pdb_config);
92
     pdb_init(&pdb_config);
93
 
93
 
94
     /* Indicate that we're in setup mode */
94
     /* Indicate that we're in setup mode */
95
-    chEvtSignal(pdb_led_thread, PDB_EVT_LED_CONFIG);
95
+    chEvtSignal(pdbs_led_thread, PDBS_EVT_LED_CONFIG);
96
 
96
 
97
     /* Disconnect from USB */
97
     /* Disconnect from USB */
98
     usbDisconnectBus(serusbcfg.usbp);
98
     usbDisconnectBus(serusbcfg.usbp);
143
     pdb_msg_pool_init();
143
     pdb_msg_pool_init();
144
 
144
 
145
     /* Create the LED thread. */
145
     /* Create the LED thread. */
146
-    pdb_led_run();
146
+    pdbs_led_run();
147
 
147
 
148
     /* Start I2C2 to make communication with the PHY possible */
148
     /* Start I2C2 to make communication with the PHY possible */
149
     i2cStart(&I2CD2, &i2c2config);
149
     i2cStart(&I2CD2, &i2c2config);

+ 1
- 1
src/shell.c View File

313
         return;
313
         return;
314
     }
314
     }
315
 
315
 
316
-    chEvtSignal(pdb_led_thread, PDB_EVT_LED_IDENTIFY);
316
+    chEvtSignal(pdbs_led_thread, PDBS_EVT_LED_IDENTIFY);
317
 }
317
 }
318
 
318
 
319
 static void cmd_output(BaseSequentialStream *chp, int argc, char *argv[])
319
 static void cmd_output(BaseSequentialStream *chp, int argc, char *argv[])

Loading…
Cancel
Save