Expand description

A defmt target for logging messages over a serial interface. The serial interface must implement e.g. embedded_hal::serial::Write.

The received defmt-frames can be read using e.g. socat and defmt-print, so that you can set it up as cargo runner. See the example-artemis for how to do that.

You can also use it to have defmt work on std/hosted OSes, see example-std.

#![no_std]
#![no_main]


use panic_probe as _;
use cortex_m::asm;
use cortex_m_rt::entry;
use ambiq_hal::{self as hal, prelude::*};
use defmt;
use defmt_serial as _;

#[entry]
fn main() -> ! {
    let mut dp = hal::pac::Peripherals::take().unwrap();
    let pins = hal::gpio::Pins::new(dp.GPIO);

    // set up serial
    let mut serial = hal::uart::Uart0::new(dp.UART0, pins.tx0, pins.rx0);
    defmt_serial::defmt_serial(serial);

    defmt::info!("Hello from defmt!");

    loop {
        asm::wfi();
    }
}

Functions

Assign a serial peripheral to received defmt-messages.