Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Protecting input/output buffers of CH552 #148

Merged
merged 4 commits into from
Dec 7, 2023
Merged

Protecting input/output buffers of CH552 #148

merged 4 commits into from
Dec 7, 2023

Conversation

dehanj
Copy link
Member

@dehanj dehanj commented Nov 13, 2023

This is a fix for the issue that CH552 during certain circumstances can drop a bytes from UART -> USB.
Some other changes:

  • Implemented simple GPIO usage, for debugging. Left it in for future use but uninitialized.
  • Translated all comments (hence why the PR looks so messy).
  • Left comments at locations I see potential issues with, as a reminder for the future.

@dehanj dehanj requested a review from mchack-work November 13, 2023 14:12
@dehanj dehanj changed the title Protecting input/output buffers Protecting input/output buffers of CH552 Nov 14, 2023
CH554UART1SendByte(Ep2Buffer[USBBufOutPoint++]);
recievedData[USBBufOutPoint] = Ep2Buffer[USBBufOutPoint];
USBByteCount--;
memcpy(USB_output_buffer, Ep2Buffer, USBByteCount);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dehanj and I discussed wrapping this section inside USB_IE=0/USB_IE=1 to disable interrupts temporarily to protect Ep2Buffer and USBByteCount from being updated while we were copying data from it. It turns out that we're already answering NAK on USB at this time, so that's unneccessary. So it's OK by me to leave as is.

@mchack-work mchack-work merged commit 7019cd9 into main Dec 7, 2023
1 check passed
@mchack-work mchack-work deleted the ch552_gpio branch December 7, 2023 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants