mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-03 10:37:46 +00:00
machine: don't block the rp2xxx UART interrupt handler
Don't block forever if there's nothing to receive. On the other hand, process the entire FIFO, not just a single byte. This fixes an issue where the rp2350 would hang after programming through openocd, where the UART0 interrupt would be spuriously pending.
This commit is contained in:
@@ -67,7 +67,7 @@ func (uart *UART) Configure(config UARTConfig) error {
|
|||||||
uart.Interrupt.SetPriority(0x80)
|
uart.Interrupt.SetPriority(0x80)
|
||||||
uart.Interrupt.Enable()
|
uart.Interrupt.Enable()
|
||||||
|
|
||||||
// setup interrupt on receive
|
// Setup interrupt on receive.
|
||||||
uart.Bus.UARTIMSC.Set(rp.UART0_UARTIMSC_RXIM)
|
uart.Bus.UARTIMSC.Set(rp.UART0_UARTIMSC_RXIM)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@@ -153,7 +153,7 @@ func initUART(uart *UART) {
|
|||||||
// handleInterrupt should be called from the appropriate interrupt handler for
|
// handleInterrupt should be called from the appropriate interrupt handler for
|
||||||
// this UART instance.
|
// this UART instance.
|
||||||
func (uart *UART) handleInterrupt(interrupt.Interrupt) {
|
func (uart *UART) handleInterrupt(interrupt.Interrupt) {
|
||||||
for uart.Bus.UARTFR.HasBits(rp.UART0_UARTFR_RXFE) {
|
for !uart.Bus.UARTFR.HasBits(rp.UART0_UARTFR_RXFE) {
|
||||||
|
uart.Receive(byte((uart.Bus.UARTDR.Get() & 0xFF)))
|
||||||
}
|
}
|
||||||
uart.Receive(byte((uart.Bus.UARTDR.Get() & 0xFF)))
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user