openwch / arduino_core_ch32

Core library for CH32duino
269 stars 52 forks source link

Interrupt driven serial1 #145

Open maxint-rd opened 2 months ago

maxint-rd commented 2 months ago

This PR reintroduces a read buffer for reading serial1 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 was tested mainly on the CH32V003 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 interface.

maxint-rd commented 2 months ago

@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.