openwch / arduino_core_ch32

Core library for CH32duino
218 stars 35 forks source link

Implement Serial.available() function #79

Closed tanakamasayuki closed 3 weeks ago

tanakamasayuki commented 1 month ago

-1 means if(Serial.available()) is always true. Returns reception status.

maxint-rd commented 1 month ago

That's an interesting PR. Seems like you took a much simpler approach than my convoluted attempt to reintroduce the receive buffer to enable available() and peek(). Nice!

tanakamasayuki commented 1 month ago

https://gist.github.com/tanakamasayuki/56251790ad3c06a9837895054fd2f15e

I actually want to use reception interrupts. It's currently being tested.

maxint-rd commented 1 month ago

I actually want to use reception interrupts.

Excellent! I'm looking forward to do some testing of your code as soon as I can find the time.

For my I2C slave implementation I managed to enable interrupts. For enabling Serial.peek() that would be a welcome improvement, as my feeble attempt without interrupts certainly limits data reception.