std1.0.0-beta-7 SafeC docs

std :: hal::uart

Struct std::Uart

#include <std/hal/uart.h> source

generic<C: UartChip> struct Uart {
    &volatile unsigned int base;
    unsigned int baud;
    C chip;
}

Fields

§&volatile unsigned int basesource

MMIO base address

§unsigned int baudsource

configured baud rate

§C chipsource

Methods

§static struct Uart<C> new( &volatile unsigned int base, unsigned int baud, unsigned int clock_hz, )source · definition

Initialize the UART at base: 8N1 at baud from a clock_hz input clock (0 = leave the rate the firmware set). The chip type comes from the target.

§void write_byte(unsigned char c)source · definition

Send a single byte (blocks until TX ready).

§unsigned char read_byte()source · definition

Read a single byte (blocks until RX available).

§void write_str(const &char s)source · definition

Send a null-terminated string.

§int rx_ready() constsource · definition

Check if a byte is available to read. Returns 1 if ready.

§int tx_ready() constsource · definition

Check if transmitter is ready. Returns 1 if ready.