Module capsules_core::console

source ·
Expand description

Provides userspace with access to a serial interface.


You need a device that provides the hil::uart::UART trait.

let console = static_init!(
                 &mut console::WRITE_BUF,
                 &mut console::READ_BUF,
hil::uart::UART::set_client(&usart::USART0, console);


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.



  • Default size for the read and write buffers used by the console. Boards may pass different-size buffers if needed.