Browse Source

Use the PRLTX mailbox from the struct pdb_config

Clara Hobbs 7 years ago
parent
commit
5a6abeaa67
3 changed files with 8 additions and 15 deletions
  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 View File

153
 static enum policy_engine_state pe_sink_select_cap(struct pdb_config *cfg)
153
 static enum policy_engine_state pe_sink_select_cap(struct pdb_config *cfg)
154
 {
154
 {
155
     /* Transmit the request */
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
     chEvtSignal(cfg->prl.tx_thread, PDB_EVT_PRLTX_MSG_TX);
157
     chEvtSignal(cfg->prl.tx_thread, PDB_EVT_PRLTX_MSG_TX);
158
     eventmask_t evt = chEvtWaitAny(PDB_EVT_PE_TX_DONE | PDB_EVT_PE_TX_ERR
158
     eventmask_t evt = chEvtWaitAny(PDB_EVT_PE_TX_DONE | PDB_EVT_PE_TX_ERR
159
             | PDB_EVT_PE_RESET);
159
             | PDB_EVT_PE_RESET);
427
     get_source_cap->hdr = PD_MSGTYPE_GET_SOURCE_CAP | PD_DATAROLE_UFP
427
     get_source_cap->hdr = PD_MSGTYPE_GET_SOURCE_CAP | PD_DATAROLE_UFP
428
         | PD_SPECREV_2_0 | PD_POWERROLE_SINK | PD_NUMOBJ(0);
428
         | PD_SPECREV_2_0 | PD_POWERROLE_SINK | PD_NUMOBJ(0);
429
     /* Transmit the Get_Source_Cap */
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
     chEvtSignal(cfg->prl.tx_thread, PDB_EVT_PRLTX_MSG_TX);
431
     chEvtSignal(cfg->prl.tx_thread, PDB_EVT_PRLTX_MSG_TX);
432
     eventmask_t evt = chEvtWaitAny(PDB_EVT_PE_TX_DONE | PDB_EVT_PE_TX_ERR
432
     eventmask_t evt = chEvtWaitAny(PDB_EVT_PE_TX_DONE | PDB_EVT_PE_TX_ERR
433
             | PDB_EVT_PE_RESET);
433
             | PDB_EVT_PE_RESET);
454
     cfg->dpm.get_sink_capability(cfg, snk_cap);
454
     cfg->dpm.get_sink_capability(cfg, snk_cap);
455
 
455
 
456
     /* Transmit our capabilities */
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
     chEvtSignal(cfg->prl.tx_thread, PDB_EVT_PRLTX_MSG_TX);
458
     chEvtSignal(cfg->prl.tx_thread, PDB_EVT_PRLTX_MSG_TX);
459
     eventmask_t evt = chEvtWaitAny(PDB_EVT_PE_TX_DONE | PDB_EVT_PE_TX_ERR
459
     eventmask_t evt = chEvtWaitAny(PDB_EVT_PE_TX_DONE | PDB_EVT_PE_TX_ERR
460
             | PDB_EVT_PE_RESET);
460
             | PDB_EVT_PE_RESET);
521
     accept->hdr = PD_MSGTYPE_ACCEPT | PD_DATAROLE_UFP | PD_SPECREV_2_0
521
     accept->hdr = PD_MSGTYPE_ACCEPT | PD_DATAROLE_UFP | PD_SPECREV_2_0
522
         | PD_POWERROLE_SINK | PD_NUMOBJ(0);
522
         | PD_POWERROLE_SINK | PD_NUMOBJ(0);
523
     /* Transmit the Accept */
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
     chEvtSignal(cfg->prl.tx_thread, PDB_EVT_PRLTX_MSG_TX);
525
     chEvtSignal(cfg->prl.tx_thread, PDB_EVT_PRLTX_MSG_TX);
526
     eventmask_t evt = chEvtWaitAny(PDB_EVT_PE_TX_DONE | PDB_EVT_PE_TX_ERR
526
     eventmask_t evt = chEvtWaitAny(PDB_EVT_PE_TX_DONE | PDB_EVT_PE_TX_ERR
527
             | PDB_EVT_PE_RESET);
527
             | PDB_EVT_PE_RESET);
551
     softrst->hdr = PD_MSGTYPE_SOFT_RESET | PD_DATAROLE_UFP | PD_SPECREV_2_0
551
     softrst->hdr = PD_MSGTYPE_SOFT_RESET | PD_DATAROLE_UFP | PD_SPECREV_2_0
552
         | PD_POWERROLE_SINK | PD_NUMOBJ(0);
552
         | PD_POWERROLE_SINK | PD_NUMOBJ(0);
553
     /* Transmit the soft reset */
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
     chEvtSignal(cfg->prl.tx_thread, PDB_EVT_PRLTX_MSG_TX);
555
     chEvtSignal(cfg->prl.tx_thread, PDB_EVT_PRLTX_MSG_TX);
556
     eventmask_t evt = chEvtWaitAny(PDB_EVT_PE_TX_DONE | PDB_EVT_PE_TX_ERR
556
     eventmask_t evt = chEvtWaitAny(PDB_EVT_PE_TX_DONE | PDB_EVT_PE_TX_ERR
557
             | PDB_EVT_PE_RESET);
557
             | PDB_EVT_PE_RESET);
612
         | PD_POWERROLE_SINK | PD_NUMOBJ(0);
612
         | PD_POWERROLE_SINK | PD_NUMOBJ(0);
613
 
613
 
614
     /* Transmit the message */
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
     chEvtSignal(cfg->prl.tx_thread, PDB_EVT_PRLTX_MSG_TX);
616
     chEvtSignal(cfg->prl.tx_thread, PDB_EVT_PRLTX_MSG_TX);
617
     eventmask_t evt = chEvtWaitAny(PDB_EVT_PE_TX_DONE | PDB_EVT_PE_TX_ERR
617
     eventmask_t evt = chEvtWaitAny(PDB_EVT_PE_TX_DONE | PDB_EVT_PE_TX_ERR
618
             | PDB_EVT_PE_RESET);
618
             | PDB_EVT_PE_RESET);

+ 2
- 6
lib/src/protocol_tx.c View File

26
 #include "pd.h"
26
 #include "pd.h"
27
 
27
 
28
 
28
 
29
-/* Protocol layer TX thread mailbox */
30
-mailbox_t pdb_prltx_mailbox;
31
-
32
 /*
29
 /*
33
  * Protocol TX machine states
30
  * Protocol TX machine states
34
  *
31
  *
81
  */
78
  */
82
 static enum protocol_tx_state protocol_tx_wait_message(struct pdb_config *cfg)
79
 static enum protocol_tx_state protocol_tx_wait_message(struct pdb_config *cfg)
83
 {
80
 {
84
-    (void) cfg;
85
     /* Wait for an event */
81
     /* Wait for an event */
86
     eventmask_t evt = chEvtWaitAny(PDB_EVT_PRLTX_RESET | PDB_EVT_PRLTX_DISCARD
82
     eventmask_t evt = chEvtWaitAny(PDB_EVT_PRLTX_RESET | PDB_EVT_PRLTX_DISCARD
87
             | PDB_EVT_PRLTX_MSG_TX);
83
             | PDB_EVT_PRLTX_MSG_TX);
96
     /* If the policy engine is trying to send a message */
92
     /* If the policy engine is trying to send a message */
97
     if (evt & PDB_EVT_PRLTX_MSG_TX) {
93
     if (evt & PDB_EVT_PRLTX_MSG_TX) {
98
         /* Get the message */
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
         /* If it's a Soft_Reset, reset the TX layer first */
96
         /* If it's a Soft_Reset, reset the TX layer first */
101
         if (PD_MSGTYPE_GET(protocol_tx_message) == PD_MSGTYPE_SOFT_RESET
97
         if (PD_MSGTYPE_GET(protocol_tx_message) == PD_MSGTYPE_SOFT_RESET
102
                 && PD_NUMOBJ_GET(protocol_tx_message) == 0) {
98
                 && PD_NUMOBJ_GET(protocol_tx_message) == 0) {
247
     enum protocol_tx_state state = PRLTxPHYReset;
243
     enum protocol_tx_state state = PRLTxPHYReset;
248
 
244
 
249
     /* Initialize the mailbox */
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
     while (true) {
248
     while (true) {
253
         switch (state) {
249
         switch (state) {

+ 0
- 3
lib/src/protocol_tx.h View File

33
 #define PDB_EVT_PRLTX_DISCARD EVENT_MASK(3)
33
 #define PDB_EVT_PRLTX_DISCARD EVENT_MASK(3)
34
 #define PDB_EVT_PRLTX_MSG_TX EVENT_MASK(4)
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
 /* The ID to be used in transmission */
36
 /* The ID to be used in transmission */
40
 extern int8_t pdb_prltx_messageidcounter;
37
 extern int8_t pdb_prltx_messageidcounter;
41
 
38
 

Loading…
Cancel
Save