瀏覽代碼

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 7 年之前
父節點
當前提交
acaa00aa54
共有 5 個檔案被更改,包括 35 行新增35 行删除
  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 查看文件

@@ -71,7 +71,7 @@ bool pdbs_dpm_evaluate_capability(struct pdb_config *cfg,
71 71
 
72 72
     /* Make the LED blink to indicate ongoing power negotiations */
73 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 77
     /* Get whether or not the power supply is constrained */
@@ -232,7 +232,7 @@ bool pdbs_dpm_evaluate_typec_current(struct pdb_config *cfg,
232 232
 void pdbs_dpm_pd_start(struct pdb_config *cfg)
233 233
 {
234 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,13 +248,13 @@ static void dpm_output_set(bool state)
248 248
     if (state && pdb_dpm_output_enabled) {
249 249
         /* Turn the output on */
250 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 253
         palSetLine(LINE_OUT_CTRL);
254 254
     } else {
255 255
         /* Turn the output off */
256 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 259
         palClearLine(LINE_OUT_CTRL);
260 260
     }

+ 12
- 12
src/led.c 查看文件

@@ -32,7 +32,7 @@
32 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 38
  * LED blinker thread.
@@ -41,7 +41,7 @@ static THD_WORKING_AREA(waLED, 128);
41 41
 static THD_FUNCTION(LED, arg) {
42 42
     (void) arg;
43 43
     /* LED starts turned off */
44
-    eventmask_t state = PDB_EVT_LED_OFF;
44
+    eventmask_t state = PDBS_EVT_LED_OFF;
45 45
     /* The event just received */
46 46
     eventmask_t newstate;
47 47
     /* Timeout.  TIME_INFINITE for steady modes, other values for blinking
@@ -66,15 +66,15 @@ static THD_FUNCTION(LED, arg) {
66 66
         }
67 67
 
68 68
         switch (state) {
69
-            case PDB_EVT_LED_OFF:
69
+            case PDBS_EVT_LED_OFF:
70 70
                 timeout = TIME_INFINITE;
71 71
                 palClearLine(LINE_LED);
72 72
                 break;
73
-            case PDB_EVT_LED_ON:
73
+            case PDBS_EVT_LED_ON:
74 74
                 timeout = TIME_INFINITE;
75 75
                 palSetLine(LINE_LED);
76 76
                 break;
77
-            case PDB_EVT_LED_FAST_BLINK:
77
+            case PDBS_EVT_LED_FAST_BLINK:
78 78
                 timeout = LED_FAST;
79 79
                 if (i == 0) {
80 80
                     palSetLine(LINE_LED);
@@ -82,7 +82,7 @@ static THD_FUNCTION(LED, arg) {
82 82
                     palToggleLine(LINE_LED);
83 83
                 }
84 84
                 break;
85
-            case PDB_EVT_LED_MEDIUM_BLINK_OFF:
85
+            case PDBS_EVT_LED_MEDIUM_BLINK_OFF:
86 86
                 timeout = LED_MEDIUM;
87 87
                 if (i == 0) {
88 88
                     palSetLine(LINE_LED);
@@ -93,7 +93,7 @@ static THD_FUNCTION(LED, arg) {
93 93
                     timeout = TIME_INFINITE;
94 94
                 }
95 95
                 break;
96
-            case PDB_EVT_LED_SLOW_BLINK:
96
+            case PDBS_EVT_LED_SLOW_BLINK:
97 97
                 timeout = LED_SLOW;
98 98
                 if (i == 0) {
99 99
                     palSetLine(LINE_LED);
@@ -101,7 +101,7 @@ static THD_FUNCTION(LED, arg) {
101 101
                     palToggleLine(LINE_LED);
102 102
                 }
103 103
                 break;
104
-            case PDB_EVT_LED_FAST_BLINK_SLOW:
104
+            case PDBS_EVT_LED_FAST_BLINK_SLOW:
105 105
                 timeout = LED_FAST;
106 106
                 if (i == 0) {
107 107
                     palSetLine(LINE_LED);
@@ -110,7 +110,7 @@ static THD_FUNCTION(LED, arg) {
110 110
                 } else {
111 111
                     palClearLine(LINE_LED);
112 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 115
                 break;
116 116
             default:
@@ -122,8 +122,8 @@ static THD_FUNCTION(LED, arg) {
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 查看文件

@@ -16,34 +16,34 @@
16 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 22
 #include <ch.h>
23 23
 
24 24
 
25 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 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 40
 /* The LED thread object */
41
-extern thread_t *pdb_led_thread;
41
+extern thread_t *pdbs_led_thread;
42 42
 
43 43
 /*
44 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 查看文件

@@ -92,7 +92,7 @@ static void setup(void)
92 92
     pdb_init(&pdb_config);
93 93
 
94 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 97
     /* Disconnect from USB */
98 98
     usbDisconnectBus(serusbcfg.usbp);
@@ -143,7 +143,7 @@ int main(void) {
143 143
     pdb_msg_pool_init();
144 144
 
145 145
     /* Create the LED thread. */
146
-    pdb_led_run();
146
+    pdbs_led_run();
147 147
 
148 148
     /* Start I2C2 to make communication with the PHY possible */
149 149
     i2cStart(&I2CD2, &i2c2config);

+ 1
- 1
src/shell.c 查看文件

@@ -313,7 +313,7 @@ static void cmd_identify(BaseSequentialStream *chp, int argc, char *argv[])
313 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 319
 static void cmd_output(BaseSequentialStream *chp, int argc, char *argv[])

Loading…
取消
儲存