Pārlūkot izejas kodu

Use the PRLTX mailbox from the struct pdb_config

Clara Hobbs 7 gadus atpakaļ
vecāks
revīzija
5a6abeaa67
3 mainītis faili ar 8 papildinājumiem un 15 dzēšanām
  1. 6
    6
      lib/src/policy_engine.c
  2. 2
    6
      lib/src/protocol_tx.c
  3. 0
    3
      lib/src/protocol_tx.h

+ 6
- 6
lib/src/policy_engine.c Parādīt failu

@@ -153,7 +153,7 @@ static enum policy_engine_state pe_sink_eval_cap(struct pdb_config *cfg)
153 153
 static enum policy_engine_state pe_sink_select_cap(struct pdb_config *cfg)
154 154
 {
155 155
     /* Transmit the request */
156
-    chMBPost(&pdb_prltx_mailbox, (msg_t) last_dpm_request, TIME_IMMEDIATE);
156
+    chMBPost(&cfg->prl.tx_mailbox, (msg_t) last_dpm_request, TIME_IMMEDIATE);
157 157
     chEvtSignal(cfg->prl.tx_thread, PDB_EVT_PRLTX_MSG_TX);
158 158
     eventmask_t evt = chEvtWaitAny(PDB_EVT_PE_TX_DONE | PDB_EVT_PE_TX_ERR
159 159
             | PDB_EVT_PE_RESET);
@@ -427,7 +427,7 @@ static enum policy_engine_state pe_sink_get_source_cap(struct pdb_config *cfg)
427 427
     get_source_cap->hdr = PD_MSGTYPE_GET_SOURCE_CAP | PD_DATAROLE_UFP
428 428
         | PD_SPECREV_2_0 | PD_POWERROLE_SINK | PD_NUMOBJ(0);
429 429
     /* Transmit the Get_Source_Cap */
430
-    chMBPost(&pdb_prltx_mailbox, (msg_t) get_source_cap, TIME_IMMEDIATE);
430
+    chMBPost(&cfg->prl.tx_mailbox, (msg_t) get_source_cap, TIME_IMMEDIATE);
431 431
     chEvtSignal(cfg->prl.tx_thread, PDB_EVT_PRLTX_MSG_TX);
432 432
     eventmask_t evt = chEvtWaitAny(PDB_EVT_PE_TX_DONE | PDB_EVT_PE_TX_ERR
433 433
             | PDB_EVT_PE_RESET);
@@ -454,7 +454,7 @@ static enum policy_engine_state pe_sink_give_sink_cap(struct pdb_config *cfg)
454 454
     cfg->dpm.get_sink_capability(cfg, snk_cap);
455 455
 
456 456
     /* Transmit our capabilities */
457
-    chMBPost(&pdb_prltx_mailbox, (msg_t) snk_cap, TIME_IMMEDIATE);
457
+    chMBPost(&cfg->prl.tx_mailbox, (msg_t) snk_cap, TIME_IMMEDIATE);
458 458
     chEvtSignal(cfg->prl.tx_thread, PDB_EVT_PRLTX_MSG_TX);
459 459
     eventmask_t evt = chEvtWaitAny(PDB_EVT_PE_TX_DONE | PDB_EVT_PE_TX_ERR
460 460
             | PDB_EVT_PE_RESET);
@@ -521,7 +521,7 @@ static enum policy_engine_state pe_sink_soft_reset(struct pdb_config *cfg)
521 521
     accept->hdr = PD_MSGTYPE_ACCEPT | PD_DATAROLE_UFP | PD_SPECREV_2_0
522 522
         | PD_POWERROLE_SINK | PD_NUMOBJ(0);
523 523
     /* Transmit the Accept */
524
-    chMBPost(&pdb_prltx_mailbox, (msg_t) accept, TIME_IMMEDIATE);
524
+    chMBPost(&cfg->prl.tx_mailbox, (msg_t) accept, TIME_IMMEDIATE);
525 525
     chEvtSignal(cfg->prl.tx_thread, PDB_EVT_PRLTX_MSG_TX);
526 526
     eventmask_t evt = chEvtWaitAny(PDB_EVT_PE_TX_DONE | PDB_EVT_PE_TX_ERR
527 527
             | PDB_EVT_PE_RESET);
@@ -551,7 +551,7 @@ static enum policy_engine_state pe_sink_send_soft_reset(struct pdb_config *cfg)
551 551
     softrst->hdr = PD_MSGTYPE_SOFT_RESET | PD_DATAROLE_UFP | PD_SPECREV_2_0
552 552
         | PD_POWERROLE_SINK | PD_NUMOBJ(0);
553 553
     /* Transmit the soft reset */
554
-    chMBPost(&pdb_prltx_mailbox, (msg_t) softrst, TIME_IMMEDIATE);
554
+    chMBPost(&cfg->prl.tx_mailbox, (msg_t) softrst, TIME_IMMEDIATE);
555 555
     chEvtSignal(cfg->prl.tx_thread, PDB_EVT_PRLTX_MSG_TX);
556 556
     eventmask_t evt = chEvtWaitAny(PDB_EVT_PE_TX_DONE | PDB_EVT_PE_TX_ERR
557 557
             | PDB_EVT_PE_RESET);
@@ -612,7 +612,7 @@ static enum policy_engine_state pe_sink_send_reject(struct pdb_config *cfg)
612 612
         | PD_POWERROLE_SINK | PD_NUMOBJ(0);
613 613
 
614 614
     /* Transmit the message */
615
-    chMBPost(&pdb_prltx_mailbox, (msg_t) reject, TIME_IMMEDIATE);
615
+    chMBPost(&cfg->prl.tx_mailbox, (msg_t) reject, TIME_IMMEDIATE);
616 616
     chEvtSignal(cfg->prl.tx_thread, PDB_EVT_PRLTX_MSG_TX);
617 617
     eventmask_t evt = chEvtWaitAny(PDB_EVT_PE_TX_DONE | PDB_EVT_PE_TX_ERR
618 618
             | PDB_EVT_PE_RESET);

+ 2
- 6
lib/src/protocol_tx.c Parādīt failu

@@ -26,9 +26,6 @@
26 26
 #include "pd.h"
27 27
 
28 28
 
29
-/* Protocol layer TX thread mailbox */
30
-mailbox_t pdb_prltx_mailbox;
31
-
32 29
 /*
33 30
  * Protocol TX machine states
34 31
  *
@@ -81,7 +78,6 @@ static enum protocol_tx_state protocol_tx_phy_reset(struct pdb_config *cfg)
81 78
  */
82 79
 static enum protocol_tx_state protocol_tx_wait_message(struct pdb_config *cfg)
83 80
 {
84
-    (void) cfg;
85 81
     /* Wait for an event */
86 82
     eventmask_t evt = chEvtWaitAny(PDB_EVT_PRLTX_RESET | PDB_EVT_PRLTX_DISCARD
87 83
             | PDB_EVT_PRLTX_MSG_TX);
@@ -96,7 +92,7 @@ static enum protocol_tx_state protocol_tx_wait_message(struct pdb_config *cfg)
96 92
     /* If the policy engine is trying to send a message */
97 93
     if (evt & PDB_EVT_PRLTX_MSG_TX) {
98 94
         /* Get the message */
99
-        chMBFetch(&pdb_prltx_mailbox, (msg_t *) &protocol_tx_message, TIME_IMMEDIATE);
95
+        chMBFetch(&cfg->prl.tx_mailbox, (msg_t *) &protocol_tx_message, TIME_IMMEDIATE);
100 96
         /* If it's a Soft_Reset, reset the TX layer first */
101 97
         if (PD_MSGTYPE_GET(protocol_tx_message) == PD_MSGTYPE_SOFT_RESET
102 98
                 && PD_NUMOBJ_GET(protocol_tx_message) == 0) {
@@ -247,7 +243,7 @@ static THD_FUNCTION(ProtocolTX, vcfg) {
247 243
     enum protocol_tx_state state = PRLTxPHYReset;
248 244
 
249 245
     /* Initialize the mailbox */
250
-    chMBObjectInit(&pdb_prltx_mailbox, cfg->prl._tx_mailbox_queue, PDB_MSG_POOL_SIZE);
246
+    chMBObjectInit(&cfg->prl.tx_mailbox, cfg->prl._tx_mailbox_queue, PDB_MSG_POOL_SIZE);
251 247
 
252 248
     while (true) {
253 249
         switch (state) {

+ 0
- 3
lib/src/protocol_tx.h Parādīt failu

@@ -33,9 +33,6 @@
33 33
 #define PDB_EVT_PRLTX_DISCARD EVENT_MASK(3)
34 34
 #define PDB_EVT_PRLTX_MSG_TX EVENT_MASK(4)
35 35
 
36
-/* Protocol layer TX thread mailbox */
37
-extern mailbox_t pdb_prltx_mailbox;
38
-
39 36
 /* The ID to be used in transmission */
40 37
 extern int8_t pdb_prltx_messageidcounter;
41 38
 

Notiek ielāde…
Atcelt
Saglabāt