Skip to content

Commit 7f970a4

Browse files
eliasnaurdeadprogram
authored andcommitted
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.
1 parent ebf70ab commit 7f970a4

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/machine/machine_rp2_uart.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func (uart *UART) Configure(config UARTConfig) error {
6767
uart.Interrupt.SetPriority(0x80)
6868
uart.Interrupt.Enable()
6969

70-
// setup interrupt on receive
70+
// Setup interrupt on receive.
7171
uart.Bus.UARTIMSC.Set(rp.UART0_UARTIMSC_RXIM)
7272

7373
return nil
@@ -153,7 +153,7 @@ func initUART(uart *UART) {
153153
// handleInterrupt should be called from the appropriate interrupt handler for
154154
// this UART instance.
155155
func (uart *UART) handleInterrupt(interrupt.Interrupt) {
156-
for uart.Bus.UARTFR.HasBits(rp.UART0_UARTFR_RXFE) {
156+
for !uart.Bus.UARTFR.HasBits(rp.UART0_UARTFR_RXFE) {
157+
uart.Receive(byte((uart.Bus.UARTDR.Get() & 0xFF)))
157158
}
158-
uart.Receive(byte((uart.Bus.UARTDR.Get() & 0xFF)))
159159
}

0 commit comments

Comments
 (0)