Skip to content

Commit 352f79f

Browse files
committed
Fix TOGGLE error handling(#2)
On the error data should be ignored and do nothing on data toggle bit. felis#438 ---- If the IN data was error-free but there was a data toggle mismatch (the DATA0 or DATA1 PID send by the peripheral did not match the endpoint toggle value), the SIE sends the ACK handshake, but it does not complement the data toggle or assert the RCVDAVIRQ. The SIE sets HRSL = 0110 (Toggle Error) for this condition. This situation would happen if the peripheral received a corrupted ACK handshake from the previous IN transfer. In this case the host ignores the data in the RCVDATA FIFO, because it represents data that the peripheral mistakenly resent when it missed the last ACK handshake. By ACK-ing the transfer and not updating its own toggle bit, the SIE causes the peripheral to complement its toggle bit, thus forcing the data toggle mechanism back into sync. ---- MAX3421 Programming Guide p.13
1 parent 93a1d5e commit 352f79f

File tree

1 file changed

+0
-8
lines changed

1 file changed

+0
-8
lines changed

Usb.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,6 @@ uint8_t USB::ctrlReq(uint8_t addr, uint8_t ep, uint8_t bmReqType, uint8_t bReque
172172

173173
rcode = InTransfer(pep, nak_limit, &read, dataptr);
174174
if(rcode == hrTOGERR) {
175-
// yes, we flip it wrong here so that next time it is actually correct!
176-
pep->bmRcvToggle = (regRd(rHRSL) & bmSNDTOGRD) ? 0 : 1;
177175
continue;
178176
}
179177

@@ -239,9 +237,6 @@ uint8_t USB::InTransfer(EpInfo *pep, uint16_t nak_limit, uint16_t *nbytesptr, ui
239237
#endif
240238
rcode = dispatchPkt(tokIN, pep->epAddr, nak_limit); //IN packet to EP-'endpoint'. Function takes care of NAKS.
241239
if(rcode == hrTOGERR) {
242-
// yes, we flip it wrong here so that next time it is actually correct!
243-
pep->bmRcvToggle = (regRd(rHRSL) & bmRCVTOGRD) ? 0 : 1;
244-
regWr(rHCTL, (pep->bmRcvToggle) ? bmRCVTOG1 : bmRCVTOG0); //set toggle value
245240
continue;
246241
}
247242
if(rcode) {
@@ -363,9 +358,6 @@ uint8_t USB::OutTransfer(EpInfo *pep, uint16_t nak_limit, uint16_t nbytes, uint8
363358
//return ( rcode);
364359
break;
365360
case hrTOGERR:
366-
// yes, we flip it wrong here so that next time it is actually correct!
367-
pep->bmSndToggle = (regRd(rHRSL) & bmSNDTOGRD) ? 0 : 1;
368-
regWr(rHCTL, (pep->bmSndToggle) ? bmSNDTOG1 : bmSNDTOG0); //set toggle value
369361
break;
370362
default:
371363
goto breakout;

0 commit comments

Comments
 (0)