-
Notifications
You must be signed in to change notification settings - Fork 62
Interrupt driven Serial1 and Serial2 #145
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
Open
maxint-rd
wants to merge
9
commits into
openwch:main
Choose a base branch
from
maxint-rd:Interrupt-driven-Serial1
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This was referenced Sep 12, 2024
@vuhazu tested and confirmed it works for CH32x035, @atollminsk tested and confirmed it works for CH32V208WB. @atollminsk tested and confirmed it works for CH32V203C8T6. tested to also work on CH32V307VCT6. |
This was referenced Sep 29, 2024
This was referenced Oct 8, 2024
zer0ohm
added a commit
to zer0ohm/arduino_core_ch32v003
that referenced
this pull request
Dec 11, 2024
Open
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR reintroduces a read buffer for reading Serial1 and Serial2 input using a hardware interrupt.
The read buffer allows for proper implementation of serial.available() and serial.peek().
It also prevents loosing serial input data received when the processor is doing something else.
This PR includes changes proposed in PR #180.
This PR was tested mainly on the CH32V003, CH32X033 and confirmed to also work on the CH32X035. Other processors may work as well, but have not been tested. The current implementation only supports the Serial1 and Serial2 interfaces.
The CH32X033 was used to test interrupt driven Serial1 and Serial2 as single interfaces and as dual interface. The X033/X035 have 4 x UART Serial, but the CH32X033F8P6 (in the TSSOP20 package) only has usable pins for Serial1 and Serial2 (RX1_1=PA11, TX1_1=PA10 / RX2=PA3, TX2=PA2).
Using Serial1 and/or Serial2 on CH32X033 requires the board definition added by PR #171.
To configure the number of instances enabled, change the definition in variant_CH32X933F8P.h.
That header file defines these constants:
SERIAL_UART_INSTANCES - the number of UART instances enabled (1 or 2 for CH32X033)
SERIAL_UART_INSTANCE - the UART instance selected for Serial (either 1 or 2 for CH32X033)
When SERIAL_UART_INSTANCES is 2, SERIAL_UART_INSTANCE is not defined and both Serial1 and Serial2 are available.