ch552: Fix race condition

- Move "EndpointXUploadBusy = 1" to before USB transfer is started to fix
  race with USB transfer complete interrupt.
This commit is contained in:
Jonas Thörnblad 2025-02-25 10:49:12 +01:00
parent 8f2f312531
commit 0b75d25431
No known key found for this signature in database
GPG Key ID: 2D318AD00A326F95

View File

@ -1375,9 +1375,9 @@ void main()
CdcRxBuf,
CdcRxBufLength);
Endpoint2UploadBusy = 1; // Set busy flag
UEP2_T_LEN = CdcRxBufLength; // Set the number of data bytes that Endpoint 2 is ready to send
UEP2_CTRL = (UEP2_CTRL & ~MASK_UEP_T_RES) | UEP_T_RES_ACK; // Answer ACK
Endpoint2UploadBusy = 1; // Set busy flag
CdcDataAvailable = 0;
CdcRxBufLength = 0;
@ -1396,9 +1396,9 @@ void main()
HidRxBuf,
HidRxBufLength);
Endpoint3UploadBusy = 1; // Set busy flag
UEP3_T_LEN = MAX_PACKET_SIZE; // Set the number of data bytes that Endpoint 3 is ready to send
UEP3_CTRL = (UEP3_CTRL & ~MASK_UEP_T_RES) | UEP_T_RES_ACK; // Answer ACK
Endpoint3UploadBusy = 1; // Set busy flag
HidDataAvailable = 0;
@ -1422,9 +1422,9 @@ void main()
TkeyCtrlRxBufLength);
}
Endpoint4UploadBusy = 1; // Set busy flag
UEP4_T_LEN = MAX_PACKET_SIZE; // Set the number of data bytes that Endpoint 4 is ready to send
UEP4_CTRL = (UEP4_CTRL & ~MASK_UEP_T_RES) | UEP_T_RES_ACK; // Answer ACK
Endpoint4UploadBusy = 1; // Set busy flag
TkeyCtrlDataAvailable = 0;
TkeyCtrlRxBufLength = 0;