|
@@ -47,8 +47,6 @@ enum protocol_tx_state {
|
47
|
47
|
|
48
|
48
|
/* The message we're currently working on transmitting */
|
49
|
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,7 +108,7 @@ static enum protocol_tx_state protocol_tx_wait_message(struct pdb_config *cfg)
|
110
|
108
|
static enum protocol_tx_state protocol_tx_reset(struct pdb_config *cfg)
|
111
|
109
|
{
|
112
|
110
|
/* Clear MessageIDCounter */
|
113
|
|
- pdb_prltx_messageidcounter = 0;
|
|
111
|
+ cfg->prl._tx_messageidcounter = 0;
|
114
|
112
|
|
115
|
113
|
/* Tell the Protocol RX thread to reset */
|
116
|
114
|
chEvtSignal(cfg->prl.rx_thread, PDB_EVT_PRLRX_RESET);
|
|
@@ -137,7 +135,7 @@ static enum protocol_tx_state protocol_tx_construct_message(struct pdb_config *c
|
137
|
135
|
|
138
|
136
|
/* Set the correct MessageID in the message */
|
139
|
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
|
140
|
/* Send the message to the PHY */
|
143
|
141
|
fusb_send_message(protocol_tx_message);
|
|
@@ -190,7 +188,7 @@ static enum protocol_tx_state protocol_tx_match_messageid(struct pdb_config *cfg
|
190
|
188
|
/* Check that the message is correct */
|
191
|
189
|
if (PD_MSGTYPE_GET(&goodcrc) == PD_MSGTYPE_GOODCRC
|
192
|
190
|
&& PD_NUMOBJ_GET(&goodcrc) == 0
|
193
|
|
- && PD_MESSAGEID_GET(&goodcrc) == pdb_prltx_messageidcounter) {
|
|
191
|
+ && PD_MESSAGEID_GET(&goodcrc) == cfg->prl._tx_messageidcounter) {
|
194
|
192
|
return PRLTxMessageSent;
|
195
|
193
|
} else {
|
196
|
194
|
return PRLTxTransmissionError;
|
|
@@ -201,7 +199,7 @@ static enum protocol_tx_state protocol_tx_transmission_error(struct pdb_config *
|
201
|
199
|
{
|
202
|
200
|
(void) cfg;
|
203
|
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
|
204
|
/* Tell the policy engine that we failed */
|
207
|
205
|
chEvtSignal(pdb_pe_thread, PDB_EVT_PE_TX_ERR);
|
|
@@ -214,7 +212,7 @@ static enum protocol_tx_state protocol_tx_message_sent(struct pdb_config *cfg)
|
214
|
212
|
{
|
215
|
213
|
(void) cfg;
|
216
|
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
|
217
|
/* Tell the policy engine that we succeeded */
|
220
|
218
|
chEvtSignal(pdb_pe_thread, PDB_EVT_PE_TX_DONE);
|
|
@@ -228,7 +226,7 @@ static enum protocol_tx_state protocol_tx_discard_message(struct pdb_config *cfg
|
228
|
226
|
(void) cfg;
|
229
|
227
|
/* If we were working on sending a message, increment MessageIDCounter */
|
230
|
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
|
232
|
return PRLTxPHYReset;
|