mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-06 03:53:42 +00:00
rp2040: allow writing to the UART inside interrupts
Writing to the UART takes time and that may not be a good idea inside an interrupt, but it is essential for debugging sometimes (especially since USB-CDC typically doesn't work inside an interrupt). This fixes UART support in interrupts for the RP2040 at least. You can test it with `-serial=uart` and connecting a USB-UART adapter to the right pins.
This commit is contained in:
committed by
Ron Evans
parent
37531930b8
commit
632e5f9872
@@ -104,7 +104,9 @@ func (uart *UART) SetBaudRate(br uint32) {
|
||||
func (uart *UART) writeByte(c byte) error {
|
||||
// wait until buffer is not full
|
||||
for uart.Bus.UARTFR.HasBits(rp.UART0_UARTFR_TXFF) {
|
||||
gosched()
|
||||
if !interrupt.In() {
|
||||
gosched()
|
||||
}
|
||||
}
|
||||
|
||||
// write data
|
||||
@@ -114,7 +116,9 @@ func (uart *UART) writeByte(c byte) error {
|
||||
|
||||
func (uart *UART) flush() {
|
||||
for uart.Bus.UARTFR.HasBits(rp.UART0_UARTFR_BUSY) {
|
||||
gosched()
|
||||
if !interrupt.In() {
|
||||
gosched()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user