Skip to content

Commit

Permalink
fix(uart): zephyr shell broken
Browse files Browse the repository at this point in the history
implement UARTTXINTR, and also clear UARTRXINTR when the Rx FIFO becomes empty.

wokwi/wokwi-features#516
  • Loading branch information
urish committed Oct 5, 2023
1 parent 8e75254 commit edf8449
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/peripherals/uart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const TXE = 1 << 8;
const UARTEN = 1 << 0;

// Interrupt bits
const UARTTXINTR = 1 << 5;
const UARTRXINTR = 1 << 4;

export interface IUARTDMAChannels {
Expand Down Expand Up @@ -109,6 +110,8 @@ export class RPUART extends BasePeripheral implements Peripheral {
}

checkInterrupts() {
// TODO We should actually implement a proper FIFO for TX
this.interruptStatus |= UARTTXINTR;
this.rp2040.setInterrupt(this.irq, !!(this.interruptStatus & this.interruptMask));
}

Expand All @@ -125,8 +128,10 @@ export class RPUART extends BasePeripheral implements Peripheral {
const value = this.rxFIFO.pull();
if (!this.rxFIFO.empty) {
this.interruptStatus |= UARTRXINTR;
this.checkInterrupts();
} else {
this.interruptStatus &= ~UARTRXINTR;
}
this.checkInterrupts();
return value;
}
case UARTFR:
Expand Down

0 comments on commit edf8449

Please sign in to comment.