atomvm_gleam/uart

Types

Options for open / open_default.

See uart_opts().

pub type Config {
  Config(
    tx: option.Option(Int),
    rx: option.Option(Int),
    rts: option.Option(Int),
    cts: option.Option(Int),
    speed: option.Option(Int),
    data_bits: option.Option(Int),
    stop_bits: option.Option(Int),
    event_queue_len: option.Option(Int),
    flow_control: option.Option(FlowControl),
    parity: option.Option(Parity),
  )
}

Constructors

Errors from the UART driver.

pub type Error {
  Failed
  NotSupported
  Badarg
  Timeout
  Ealready
  Other(String)
}

Constructors

  • Failed
  • NotSupported
  • Badarg
  • Timeout
  • Ealready
  • Other(String)

Flow control mode.

pub type FlowControl {
  NoFlow
  Hardware
  Software
}

Constructors

  • NoFlow
  • Hardware
  • Software

Parity mode.

pub type Parity {
  NoParity
  Even
  Odd
}

Constructors

  • NoParity
  • Even
  • Odd

Opaque UART driver handle (pid() from uart:open/2).

pub type Uart

Values

pub fn close(uart: Uart) -> Result(Nil, Error)

Close the UART driver.

See uart:close/1.

pub fn default_config() -> Config

Empty config (driver defaults).

pub fn error_to_string(error: Error) -> String

Format an Error for logging.

pub fn open(name: String, config: Config) -> Result(Uart, Error)

Open a named UART peripheral ("UART0" / "UART1" / "UART2" / "USB_SERIAL_JTAG").

See uart:open/2.

pub fn open_default(config: Config) -> Result(Uart, Error)

Open the default UART with the given options.

See uart:open/1.

pub fn read(
  uart: Uart,
  timeout_ms: Int,
) -> Result(BitArray, Error)

Read available data, waiting up to timeout_ms.

See uart:read/2.

pub fn usb_serial_jtag_name() -> String

Peripheral name for ESP32 USB-Serial-JTAG ("USB_SERIAL_JTAG").

Pass to open on chips that expose the built-in USB-Serial-JTAG peripheral (for example ESP32-C3/C5/C6/C61/H2/S3/P4).

See Module uart.

pub fn write(uart: Uart, data: BitArray) -> Result(Nil, Error)

Write data to the UART.

See uart:write/2.

✨ Search Document