Skip to content

Lab 7 Tasks

Requested Functions

  • int uart_config(uint16_t base, uint32_t baud, uint8_t line_control)
  • int uart_enable_fifo(uint16_t base)
  • int uart_enable_rx_interrupt(uint16_t base)
  • int uart_set_loopback(uint16_t base, int enabled)
  • int uart_send_byte(uint16_t base, uint8_t byte)
  • int uart_read_byte(uint16_t base, uint8_t *byte)
  • int uart_subscribe(uint8_t irq, lcom_irq_t *out)
  • int uart_unsubscribe(lcom_irq_t *irq)

Guided Gaps

  • Validate base port and baud rate.
  • Compute divisor from the UART base clock.
  • Preserve line-control bits around divisor-latch access.
  • Add timeouts for send/read waits.
  • Keep loopback setup independent from normal configuration.

IMPORTANT

Always restore line-control state after touching the divisor latch. Otherwise later reads and writes may go to the wrong logical register.

Common Mistakes

  • Forgetting divisor-latch access before writing the divisor.
  • Forgetting to clear divisor-latch access after configuration.
  • Sending without checking transmitter-ready.
  • Treating "no byte" as "received byte 0".

Next: checks and references.

Course/docs licensed CC BY 4.0. Code licensed MIT.