Expand description
Provides userspace with access to a serial interface.
§Setup
You need a device that provides the hil::uart::UART
trait.
ⓘ
let console = static_init!(
Console<usart::USART>,
Console::new(&usart::USART0,
115200,
&mut console::WRITE_BUF,
&mut console::READ_BUF,
board_kernel.create_grant(&grant_cap)));
hil::uart::UART::set_client(&usart::USART0, console);
§Usage
The user must perform three steps in order to write a buffer:
// (Optional) Set a callback to be invoked when the buffer has been written
subscribe(CONSOLE_DRIVER_NUM, 1, my_callback);
// Share the buffer from userspace with the driver
allow(CONSOLE_DRIVER_NUM, buffer, buffer_len_in_bytes);
// Initiate the transaction
command(CONSOLE_DRIVER_NUM, 1, len_to_write_in_bytes)
When the buffer has been written successfully, the buffer is released from
the driver. Successive writes must call allow
each time a buffer is to be
written.
Structs§
Constants§
- Default size for the read and write buffers used by the console. Boards may pass different-size buffers if needed.