Browse Source

Use tx_messageidcounter in the new struct

Apparently one of the threads was using too much stack space??  This
will require investigtion later, but for now increasing their stack
space fixed some weird problems I was having with this patch.
Clara Hobbs 6 years ago
parent
commit
ac3fa561ec
5 changed files with 11 additions and 15 deletions
  1. 3
    3
      lib/include/pdb_prl.h
  2. 1
    1
      lib/src/hard_reset.c
  3. 1
    1
      lib/src/protocol_rx.c
  4. 6
    8
      lib/src/protocol_tx.c
  5. 0
    2
      lib/src/protocol_tx.h

+ 3
- 3
lib/include/pdb_prl.h View File

25
 
25
 
26
 
26
 
27
 struct pdb_prl {
27
 struct pdb_prl {
28
-    THD_WORKING_AREA(_rx_wa, 128);
28
+    THD_WORKING_AREA(_rx_wa, 256);
29
     thread_t *rx_thread;
29
     thread_t *rx_thread;
30
-    THD_WORKING_AREA(_tx_wa, 128);
30
+    THD_WORKING_AREA(_tx_wa, 256);
31
     thread_t *tx_thread;
31
     thread_t *tx_thread;
32
-    THD_WORKING_AREA(_hardrst_wa, 128);
32
+    THD_WORKING_AREA(_hardrst_wa, 256);
33
     thread_t *hardrst_thread;
33
     thread_t *hardrst_thread;
34
 
34
 
35
     mailbox_t tx_mailbox;
35
     mailbox_t tx_mailbox;

+ 1
- 1
lib/src/hard_reset.c View File

50
 
50
 
51
     /* Reset the stored message IDs */
51
     /* Reset the stored message IDs */
52
     cfg->prl._rx_messageid = 0;
52
     cfg->prl._rx_messageid = 0;
53
-    pdb_prltx_messageidcounter = 0;
53
+    cfg->prl._tx_messageidcounter = 0;
54
 
54
 
55
     /* Reset the Protocol RX machine */
55
     /* Reset the Protocol RX machine */
56
     chEvtSignal(cfg->prl.rx_thread, PDB_EVT_PRLRX_RESET);
56
     chEvtSignal(cfg->prl.rx_thread, PDB_EVT_PRLRX_RESET);

+ 1
- 1
lib/src/protocol_rx.c View File

80
 static enum protocol_rx_state protocol_rx_reset(struct pdb_config *cfg)
80
 static enum protocol_rx_state protocol_rx_reset(struct pdb_config *cfg)
81
 {
81
 {
82
     /* Reset MessageIDCounter */
82
     /* Reset MessageIDCounter */
83
-    pdb_prltx_messageidcounter = 0;
83
+    cfg->prl._tx_messageidcounter = 0;
84
 
84
 
85
     /* Clear stored MessageID */
85
     /* Clear stored MessageID */
86
     cfg->prl._rx_messageid = -1;
86
     cfg->prl._rx_messageid = -1;

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

47
 
47
 
48
 /* The message we're currently working on transmitting */
48
 /* The message we're currently working on transmitting */
49
 static union pd_msg *protocol_tx_message = NULL;
49
 static union pd_msg *protocol_tx_message = NULL;
50
-/* The ID to be used in transmission */
51
-int8_t pdb_prltx_messageidcounter = 0;
52
 
50
 
53
 
51
 
54
 /*
52
 /*
110
 static enum protocol_tx_state protocol_tx_reset(struct pdb_config *cfg)
108
 static enum protocol_tx_state protocol_tx_reset(struct pdb_config *cfg)
111
 {
109
 {
112
     /* Clear MessageIDCounter */
110
     /* Clear MessageIDCounter */
113
-    pdb_prltx_messageidcounter = 0;
111
+    cfg->prl._tx_messageidcounter = 0;
114
 
112
 
115
     /* Tell the Protocol RX thread to reset */
113
     /* Tell the Protocol RX thread to reset */
116
     chEvtSignal(cfg->prl.rx_thread, PDB_EVT_PRLRX_RESET);
114
     chEvtSignal(cfg->prl.rx_thread, PDB_EVT_PRLRX_RESET);
137
 
135
 
138
     /* Set the correct MessageID in the message */
136
     /* Set the correct MessageID in the message */
139
     protocol_tx_message->hdr &= ~PD_HDR_MESSAGEID;
137
     protocol_tx_message->hdr &= ~PD_HDR_MESSAGEID;
140
-    protocol_tx_message->hdr |= pdb_prltx_messageidcounter << PD_HDR_MESSAGEID_SHIFT;
138
+    protocol_tx_message->hdr |= (cfg->prl._tx_messageidcounter % 8) << PD_HDR_MESSAGEID_SHIFT;
141
 
139
 
142
     /* Send the message to the PHY */
140
     /* Send the message to the PHY */
143
     fusb_send_message(protocol_tx_message);
141
     fusb_send_message(protocol_tx_message);
190
     /* Check that the message is correct */
188
     /* Check that the message is correct */
191
     if (PD_MSGTYPE_GET(&goodcrc) == PD_MSGTYPE_GOODCRC
189
     if (PD_MSGTYPE_GET(&goodcrc) == PD_MSGTYPE_GOODCRC
192
             && PD_NUMOBJ_GET(&goodcrc) == 0
190
             && PD_NUMOBJ_GET(&goodcrc) == 0
193
-            && PD_MESSAGEID_GET(&goodcrc) == pdb_prltx_messageidcounter) {
191
+            && PD_MESSAGEID_GET(&goodcrc) == cfg->prl._tx_messageidcounter) {
194
         return PRLTxMessageSent;
192
         return PRLTxMessageSent;
195
     } else {
193
     } else {
196
         return PRLTxTransmissionError;
194
         return PRLTxTransmissionError;
201
 {
199
 {
202
     (void) cfg;
200
     (void) cfg;
203
     /* Increment MessageIDCounter */
201
     /* Increment MessageIDCounter */
204
-    pdb_prltx_messageidcounter = (pdb_prltx_messageidcounter + 1) % 8;
202
+    cfg->prl._tx_messageidcounter = (cfg->prl._tx_messageidcounter + 1) % 8;
205
 
203
 
206
     /* Tell the policy engine that we failed */
204
     /* Tell the policy engine that we failed */
207
     chEvtSignal(pdb_pe_thread, PDB_EVT_PE_TX_ERR);
205
     chEvtSignal(pdb_pe_thread, PDB_EVT_PE_TX_ERR);
214
 {
212
 {
215
     (void) cfg;
213
     (void) cfg;
216
     /* Increment MessageIDCounter */
214
     /* Increment MessageIDCounter */
217
-    pdb_prltx_messageidcounter = (pdb_prltx_messageidcounter + 1) % 8;
215
+    cfg->prl._tx_messageidcounter = (cfg->prl._tx_messageidcounter + 1) % 8;
218
 
216
 
219
     /* Tell the policy engine that we succeeded */
217
     /* Tell the policy engine that we succeeded */
220
     chEvtSignal(pdb_pe_thread, PDB_EVT_PE_TX_DONE);
218
     chEvtSignal(pdb_pe_thread, PDB_EVT_PE_TX_DONE);
228
     (void) cfg;
226
     (void) cfg;
229
     /* If we were working on sending a message, increment MessageIDCounter */
227
     /* If we were working on sending a message, increment MessageIDCounter */
230
     if (protocol_tx_message != NULL) {
228
     if (protocol_tx_message != NULL) {
231
-        pdb_prltx_messageidcounter = (pdb_prltx_messageidcounter + 1) % 8;
229
+        cfg->prl._tx_messageidcounter = (cfg->prl._tx_messageidcounter + 1) % 8;
232
     }
230
     }
233
 
231
 
234
     return PRLTxPHYReset;
232
     return PRLTxPHYReset;

+ 0
- 2
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
-/* The ID to be used in transmission */
37
-extern int8_t pdb_prltx_messageidcounter;
38
 
36
 
39
 /*
37
 /*
40
  * Start the Protocol TX thread
38
  * Start the Protocol TX thread

Loading…
Cancel
Save