Interrupt driven serial #201
Open
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.
Note: This PR replaces PR #145, which was accidentally closed after renaming the branch.
TLDR: support for interrupt driven serial and dual serial usage of Serial1 and Serial2.
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.