start switching to defmt
This commit is contained in:
@ -7,8 +7,9 @@ edition = "2021"
|
||||
cortex-m = { version = "0.7", features = ["critical-section-single-core"] }
|
||||
cortex-m-rt = "0.7"
|
||||
critical-section = "1"
|
||||
panic-rtt-target = { version = "0.2" }
|
||||
rtt-target = { version = "0.6" }
|
||||
defmt-rtt = "0.4"
|
||||
defmt = "1"
|
||||
panic-probe = { version = "1", features = ["defmt"] }
|
||||
embedded-hal = "1"
|
||||
embedded-hal-nb = "1"
|
||||
nb = "1"
|
||||
@ -16,7 +17,7 @@ embedded-io = "0.6"
|
||||
panic-halt = "1"
|
||||
accelerometer = "0.12"
|
||||
|
||||
va416xx-hal = { version = "0.5", features = ["va41630"] }
|
||||
va416xx-hal = { version = "0.5", features = ["va41630", "defmt"] }
|
||||
|
||||
[dependencies.vorago-peb1]
|
||||
path = "../../vorago-peb1"
|
||||
|
@ -2,10 +2,13 @@
|
||||
#![no_main]
|
||||
#![no_std]
|
||||
|
||||
// Import panic provider.
|
||||
use panic_probe as _;
|
||||
// Import logger.
|
||||
use defmt_rtt as _;
|
||||
|
||||
use cortex_m_rt::entry;
|
||||
use embedded_hal::delay::DelayNs;
|
||||
use panic_rtt_target as _;
|
||||
use rtt_target::{rprintln, rtt_init_print};
|
||||
use simple_examples::peb1;
|
||||
use va416xx_hal::{
|
||||
adc::{Adc, ChannelSelect, ChannelValue, MultiChannelSelect},
|
||||
@ -19,8 +22,7 @@ const ENABLE_BUF_PRINTOUT: bool = false;
|
||||
|
||||
#[entry]
|
||||
fn main() -> ! {
|
||||
rtt_init_print!();
|
||||
rprintln!("VA416xx ADC example");
|
||||
defmt::println!("VA416xx ADC example");
|
||||
|
||||
let mut dp = pac::Peripherals::take().unwrap();
|
||||
// Use the external clock connected to XTAL_N.
|
||||
@ -38,7 +40,7 @@ fn main() -> ! {
|
||||
let single_value = adc
|
||||
.trigger_and_read_single_channel(va416xx_hal::adc::ChannelSelect::TempSensor)
|
||||
.expect("reading single channel value failed");
|
||||
rprintln!(
|
||||
defmt::info!(
|
||||
"Read single ADC value on temperature sensor channel: {:?}",
|
||||
single_value
|
||||
);
|
||||
@ -46,8 +48,8 @@ fn main() -> ! {
|
||||
.sweep_and_read_range(0, 7, &mut read_buf)
|
||||
.expect("ADC range read failed");
|
||||
if ENABLE_BUF_PRINTOUT {
|
||||
rprintln!("ADC Range Read (0-8) read {} values", read_num);
|
||||
rprintln!("ADC Range Read (0-8): {:?}", read_buf);
|
||||
defmt::info!("ADC Range Read (0-8) read {} values", read_num);
|
||||
defmt::info!("ADC Range Read (0-8): {:?}", read_buf);
|
||||
}
|
||||
assert_eq!(read_num, 8);
|
||||
for (idx, ch_val) in read_buf.iter().enumerate() {
|
||||
@ -63,7 +65,7 @@ fn main() -> ! {
|
||||
)
|
||||
.expect("ADC multiselect read failed");
|
||||
if ENABLE_BUF_PRINTOUT {
|
||||
rprintln!("ADC Multiselect Read(0, 2 and 10): {:?}", &read_buf[0..3]);
|
||||
defmt::info!("ADC Multiselect Read(0, 2 and 10): {:?}", &read_buf[0..3]);
|
||||
}
|
||||
assert_eq!(read_buf[0].channel(), ChannelSelect::AnIn0);
|
||||
assert_eq!(read_buf[1].channel(), ChannelSelect::AnIn2);
|
||||
|
@ -2,15 +2,17 @@
|
||||
#![no_main]
|
||||
#![no_std]
|
||||
|
||||
// Import panic provider.
|
||||
use panic_probe as _;
|
||||
// Import logger.
|
||||
use defmt_rtt as _;
|
||||
|
||||
use cortex_m_rt::entry;
|
||||
use panic_rtt_target as _;
|
||||
use rtt_target::{rprintln, rtt_init_print};
|
||||
use va416xx_hal::{gpio::PinsG, pac};
|
||||
|
||||
#[entry]
|
||||
fn main() -> ! {
|
||||
rtt_init_print!();
|
||||
rprintln!("VA416xx HAL blinky example");
|
||||
defmt::println!("VA416xx HAL blinky example");
|
||||
|
||||
let mut dp = pac::Peripherals::take().unwrap();
|
||||
let portg = PinsG::new(&mut dp.sysconfig, dp.portg);
|
||||
|
@ -2,10 +2,13 @@
|
||||
#![no_main]
|
||||
#![no_std]
|
||||
|
||||
// Import panic provider.
|
||||
use panic_probe as _;
|
||||
// Import logger.
|
||||
use defmt_rtt as _;
|
||||
|
||||
use cortex_m_rt::entry;
|
||||
use embedded_hal::delay::DelayNs;
|
||||
use panic_rtt_target as _;
|
||||
use rtt_target::{rprintln, rtt_init_print};
|
||||
use simple_examples::peb1;
|
||||
use va416xx_hal::{adc::Adc, dac::Dac, pac, prelude::*, timer::CountdownTimer};
|
||||
|
||||
@ -25,8 +28,7 @@ const APP_MODE: AppMode = AppMode::DacAndAdc;
|
||||
|
||||
#[entry]
|
||||
fn main() -> ! {
|
||||
rtt_init_print!();
|
||||
rprintln!("VA416xx DAC/ADC example");
|
||||
defmt::println!("VA416xx DAC/ADC example");
|
||||
|
||||
let mut dp = pac::Peripherals::take().unwrap();
|
||||
// Use the external clock connected to XTAL_N.
|
||||
@ -53,7 +55,7 @@ fn main() -> ! {
|
||||
let mut current_val = 0;
|
||||
loop {
|
||||
if let Some(dac) = &dac {
|
||||
rprintln!("loading DAC with value {}", current_val);
|
||||
defmt::info!("loading DAC with value {}", current_val);
|
||||
dac.load_and_trigger_manually(current_val)
|
||||
.expect("loading DAC value failed");
|
||||
if current_val + DAC_INCREMENT >= 4096 {
|
||||
@ -70,7 +72,7 @@ fn main() -> ! {
|
||||
let ch_value = adc
|
||||
.trigger_and_read_single_channel(va416xx_hal::adc::ChannelSelect::AnIn0)
|
||||
.expect("reading ADC channel 0 failed");
|
||||
rprintln!("Received channel value {:?}", ch_value);
|
||||
defmt::info!("Received channel value {:?}", ch_value);
|
||||
}
|
||||
|
||||
delay_provider.delay_ms(500);
|
||||
|
@ -2,13 +2,16 @@
|
||||
#![no_main]
|
||||
#![no_std]
|
||||
|
||||
// Import panic provider.
|
||||
use panic_probe as _;
|
||||
// Import logger.
|
||||
use defmt_rtt as _;
|
||||
|
||||
use core::cell::Cell;
|
||||
|
||||
use cortex_m_rt::entry;
|
||||
use critical_section::Mutex;
|
||||
use embedded_hal::delay::DelayNs;
|
||||
use panic_rtt_target as _;
|
||||
use rtt_target::{rprintln, rtt_init_print};
|
||||
use simple_examples::peb1;
|
||||
use va416xx_hal::dma::{Dma, DmaCfg, DmaChannel, DmaCtrlBlock};
|
||||
use va416xx_hal::irq_router::enable_and_init_irq_router;
|
||||
@ -35,8 +38,7 @@ static mut DMA_DEST_BUF: [u16; 36] = [0; 36];
|
||||
|
||||
#[entry]
|
||||
fn main() -> ! {
|
||||
rtt_init_print!();
|
||||
rprintln!("VA416xx DMA example");
|
||||
defmt::println!("VA416xx DMA example");
|
||||
|
||||
let mut dp = pac::Peripherals::take().unwrap();
|
||||
// Use the external clock connected to XTAL_N.
|
||||
@ -119,7 +121,7 @@ fn transfer_example_8_bit(
|
||||
let mut dma_done = false;
|
||||
critical_section::with(|cs| {
|
||||
if DMA_ACTIVE_FLAG.borrow(cs).get() {
|
||||
rprintln!("DMA0 is active with 8 bit transfer");
|
||||
defmt::info!("DMA0 is active with 8 bit transfer");
|
||||
DMA_ACTIVE_FLAG.borrow(cs).set(false);
|
||||
}
|
||||
if DMA_DONE_FLAG.borrow(cs).get() {
|
||||
@ -127,7 +129,7 @@ fn transfer_example_8_bit(
|
||||
}
|
||||
});
|
||||
if dma_done {
|
||||
rprintln!("8-bit transfer done");
|
||||
defmt::info!("8-bit transfer done");
|
||||
break;
|
||||
}
|
||||
delay_ms.delay_ms(1);
|
||||
@ -177,7 +179,7 @@ fn transfer_example_16_bit(dma0: &mut DmaChannel, delay_ms: &mut CountdownTimer<
|
||||
let mut dma_done = false;
|
||||
critical_section::with(|cs| {
|
||||
if DMA_ACTIVE_FLAG.borrow(cs).get() {
|
||||
rprintln!("DMA0 is active with 16-bit transfer");
|
||||
defmt::info!("DMA0 is active with 16-bit transfer");
|
||||
DMA_ACTIVE_FLAG.borrow(cs).set(false);
|
||||
}
|
||||
if DMA_DONE_FLAG.borrow(cs).get() {
|
||||
@ -185,7 +187,7 @@ fn transfer_example_16_bit(dma0: &mut DmaChannel, delay_ms: &mut CountdownTimer<
|
||||
}
|
||||
});
|
||||
if dma_done {
|
||||
rprintln!("16-bit transfer done");
|
||||
defmt::info!("16-bit transfer done");
|
||||
break;
|
||||
}
|
||||
delay_ms.delay_ms(1);
|
||||
@ -237,7 +239,7 @@ fn transfer_example_32_bit(
|
||||
let mut dma_done = false;
|
||||
critical_section::with(|cs| {
|
||||
if DMA_ACTIVE_FLAG.borrow(cs).get() {
|
||||
rprintln!("DMA0 is active with 32-bit transfer");
|
||||
defmt::info!("DMA0 is active with 32-bit transfer");
|
||||
DMA_ACTIVE_FLAG.borrow(cs).set(false);
|
||||
}
|
||||
if DMA_DONE_FLAG.borrow(cs).get() {
|
||||
@ -245,7 +247,7 @@ fn transfer_example_32_bit(
|
||||
}
|
||||
});
|
||||
if dma_done {
|
||||
rprintln!("32-bit transfer done");
|
||||
defmt::info!("32-bit transfer done");
|
||||
break;
|
||||
}
|
||||
delay_ms.delay_ms(1);
|
||||
|
@ -2,11 +2,14 @@
|
||||
#![no_main]
|
||||
#![no_std]
|
||||
|
||||
// Import panic provider.
|
||||
use panic_probe as _;
|
||||
// Import logger.
|
||||
use defmt_rtt as _;
|
||||
|
||||
use accelerometer::{Accelerometer, RawAccelerometer};
|
||||
use cortex_m_rt::entry;
|
||||
use embedded_hal::delay::DelayNs;
|
||||
use panic_rtt_target as _;
|
||||
use rtt_target::{rprintln, rtt_init_print};
|
||||
use simple_examples::peb1;
|
||||
use va416xx_hal::{
|
||||
i2c,
|
||||
@ -25,9 +28,8 @@ const DISPLAY_MODE: DisplayMode = DisplayMode::Normalized;
|
||||
|
||||
#[entry]
|
||||
fn main() -> ! {
|
||||
rtt_init_print!();
|
||||
let mut dp = pac::Peripherals::take().unwrap();
|
||||
rprintln!("-- Vorago PEB1 accelerometer example --");
|
||||
defmt::println!("-- Vorago PEB1 accelerometer example --");
|
||||
// Use the external clock connected to XTAL_N.
|
||||
let clocks = dp
|
||||
.clkgen
|
||||
|
@ -4,8 +4,10 @@
|
||||
|
||||
use cortex_m_rt::entry;
|
||||
use embedded_hal::{delay::DelayNs, pwm::SetDutyCycle};
|
||||
use panic_rtt_target as _;
|
||||
use rtt_target::{rprintln, rtt_init_print};
|
||||
// Import panic provider.
|
||||
use panic_probe as _;
|
||||
// Import logger.
|
||||
use defmt_rtt as _;
|
||||
use simple_examples::peb1;
|
||||
use va416xx_hal::{
|
||||
gpio::PinsA,
|
||||
@ -17,8 +19,7 @@ use va416xx_hal::{
|
||||
|
||||
#[entry]
|
||||
fn main() -> ! {
|
||||
rtt_init_print!();
|
||||
rprintln!("-- VA108xx PWM example application--");
|
||||
defmt::println!("-- VA108xx PWM example application--");
|
||||
let mut dp = pac::Peripherals::take().unwrap();
|
||||
|
||||
// Use the external clock connected to XTAL_N.
|
||||
@ -52,7 +53,7 @@ fn main() -> ! {
|
||||
current_duty_cycle += 0.02;
|
||||
counter += 1;
|
||||
if counter % 10 == 0 {
|
||||
rprintln!("current duty cycle: {}", current_duty_cycle);
|
||||
defmt::info!("current duty cycle: {}", current_duty_cycle);
|
||||
}
|
||||
|
||||
reduced_pin
|
||||
@ -74,8 +75,8 @@ fn main() -> ! {
|
||||
upper_limit -= 0.01;
|
||||
pwmb.set_pwmb_lower_limit(get_duty_from_percent(lower_limit));
|
||||
pwmb.set_pwmb_upper_limit(get_duty_from_percent(upper_limit));
|
||||
rprintln!("Lower limit: {}", pwmb.pwmb_lower_limit());
|
||||
rprintln!("Upper limit: {}", pwmb.pwmb_upper_limit());
|
||||
defmt::info!("Lower limit: {}", pwmb.pwmb_lower_limit());
|
||||
defmt::info!("Upper limit: {}", pwmb.pwmb_upper_limit());
|
||||
}
|
||||
reduced_pin = ReducedPwmPin::<PwmA>::from(pwmb);
|
||||
}
|
||||
|
@ -2,9 +2,12 @@
|
||||
#![no_main]
|
||||
#![no_std]
|
||||
|
||||
// Import panic provider.
|
||||
use panic_probe as _;
|
||||
// Import logger.
|
||||
use defmt_rtt as _;
|
||||
|
||||
use cortex_m_rt::entry;
|
||||
use panic_rtt_target as _;
|
||||
use rtt_target::{rprintln, rtt_init_print};
|
||||
use va416xx_hal::pac;
|
||||
|
||||
// Mask for the LED
|
||||
@ -12,6 +15,7 @@ const LED_PG5: u32 = 1 << 5;
|
||||
|
||||
#[entry]
|
||||
fn main() -> ! {
|
||||
defmt::println!("VA416xx RTT Demo");
|
||||
let dp = pac::Peripherals::take().unwrap();
|
||||
// Enable all peripheral clocks
|
||||
dp.sysconfig
|
||||
@ -22,11 +26,9 @@ fn main() -> ! {
|
||||
.datamask()
|
||||
.modify(|_, w| unsafe { w.bits(LED_PG5) });
|
||||
|
||||
rtt_init_print!();
|
||||
rprintln!("VA416xx RTT Demo");
|
||||
let mut counter = 0;
|
||||
loop {
|
||||
rprintln!("{}: Hello, world!", counter);
|
||||
defmt::info!("{}: Hello, world!", counter);
|
||||
// Still toggle LED. If there are issues with the RTT log, the LED
|
||||
// blinking ensures that the application is actually running.
|
||||
dp.portg.togout().write(|w| unsafe { w.bits(LED_PG5) });
|
||||
|
@ -3,10 +3,13 @@
|
||||
//! If you do not use the loopback mode, MOSI and MISO need to be tied together on the board.
|
||||
#![no_main]
|
||||
#![no_std]
|
||||
// Import panic provider.
|
||||
use panic_probe as _;
|
||||
// Import logger.
|
||||
use defmt_rtt as _;
|
||||
|
||||
use cortex_m_rt::entry;
|
||||
use embedded_hal::spi::{Mode, SpiBus, MODE_0};
|
||||
use panic_rtt_target as _;
|
||||
use rtt_target::{rprintln, rtt_init_print};
|
||||
use simple_examples::peb1;
|
||||
use va416xx_hal::spi::{Spi, SpiClkConfig};
|
||||
use va416xx_hal::{
|
||||
@ -33,8 +36,7 @@ const FILL_WORD: u8 = 0x0f;
|
||||
|
||||
#[entry]
|
||||
fn main() -> ! {
|
||||
rtt_init_print!();
|
||||
rprintln!("-- VA108xx SPI example application--");
|
||||
defmt::println!("-- VA108xx SPI example application--");
|
||||
let cp = cortex_m::Peripherals::take().unwrap();
|
||||
let mut dp = pac::Peripherals::take().unwrap();
|
||||
// Use the external clock connected to XTAL_N.
|
||||
|
@ -1,13 +1,15 @@
|
||||
//! MS and Second counter implemented using the TIM0 and TIM1 peripheral
|
||||
#![no_main]
|
||||
#![no_std]
|
||||
// Import panic provider.
|
||||
use panic_probe as _;
|
||||
// Import logger.
|
||||
use defmt_rtt as _;
|
||||
|
||||
use core::cell::Cell;
|
||||
use cortex_m::asm;
|
||||
use cortex_m_rt::entry;
|
||||
use critical_section::Mutex;
|
||||
use panic_rtt_target as _;
|
||||
use rtt_target::{rprintln, rtt_init_print};
|
||||
use simple_examples::peb1;
|
||||
use va416xx_hal::{
|
||||
irq_router::enable_and_init_irq_router,
|
||||
@ -26,10 +28,9 @@ static SEC_COUNTER: Mutex<Cell<u32>> = Mutex::new(Cell::new(0));
|
||||
|
||||
#[entry]
|
||||
fn main() -> ! {
|
||||
rtt_init_print!();
|
||||
let mut dp = pac::Peripherals::take().unwrap();
|
||||
let mut last_ms = 0;
|
||||
rprintln!("-- Vorago system ticks using timers --");
|
||||
defmt::println!("-- Vorago system ticks using timers --");
|
||||
// Use the external clock connected to XTAL_N.
|
||||
let clocks = dp
|
||||
.clkgen
|
||||
@ -47,9 +48,9 @@ fn main() -> ! {
|
||||
if current_ms >= last_ms + 1000 {
|
||||
// To prevent drift.
|
||||
last_ms += 1000;
|
||||
rprintln!("MS counter: {}", current_ms);
|
||||
defmt::info!("MS counter: {}", current_ms);
|
||||
let second = critical_section::with(|cs| SEC_COUNTER.borrow(cs).get());
|
||||
rprintln!("Second counter: {}", second);
|
||||
defmt::info!("Second counter: {}", second);
|
||||
}
|
||||
asm::delay(1000);
|
||||
}
|
||||
|
@ -2,12 +2,14 @@
|
||||
// echo mode
|
||||
#![no_main]
|
||||
#![no_std]
|
||||
// Import panic provider.
|
||||
use panic_probe as _;
|
||||
// Import logger.
|
||||
use defmt_rtt as _;
|
||||
|
||||
use cortex_m_rt::entry;
|
||||
use embedded_hal_nb::serial::Read;
|
||||
use embedded_io::Write;
|
||||
use panic_rtt_target as _;
|
||||
use rtt_target::{rprintln, rtt_init_print};
|
||||
use simple_examples::peb1;
|
||||
use va416xx_hal::clock::ClkgenExt;
|
||||
use va416xx_hal::time::Hertz;
|
||||
@ -15,8 +17,7 @@ use va416xx_hal::{gpio::PinsG, pac, uart};
|
||||
|
||||
#[entry]
|
||||
fn main() -> ! {
|
||||
rtt_init_print!();
|
||||
rprintln!("-- VA416xx UART example application--");
|
||||
defmt::println!("-- VA416xx UART example application--");
|
||||
|
||||
let mut dp = pac::Peripherals::take().unwrap();
|
||||
|
||||
@ -45,12 +46,11 @@ fn main() -> ! {
|
||||
// Echo what is received on the serial link.
|
||||
match nb::block!(rx.read()) {
|
||||
Ok(recvd) => {
|
||||
if let Err(e) = embedded_hal_nb::serial::Write::write(&mut tx, recvd) {
|
||||
rprintln!("UART TX error: {:?}", e);
|
||||
}
|
||||
// Infallible operation.
|
||||
embedded_hal_nb::serial::Write::write(&mut tx, recvd).unwrap();
|
||||
}
|
||||
Err(e) => {
|
||||
rprintln!("UART RX error {:?}", e);
|
||||
defmt::info!("UART RX error {:?}", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,14 @@
|
||||
// Code to test the watchdog timer.
|
||||
#![no_main]
|
||||
#![no_std]
|
||||
// Import panic provider.
|
||||
use panic_probe as _;
|
||||
// Import logger.
|
||||
use defmt_rtt as _;
|
||||
|
||||
use core::cell::Cell;
|
||||
use cortex_m_rt::entry;
|
||||
use critical_section::Mutex;
|
||||
use panic_rtt_target as _;
|
||||
use rtt_target::{rprintln, rtt_init_print};
|
||||
use simple_examples::peb1;
|
||||
use va416xx_hal::irq_router::enable_and_init_irq_router;
|
||||
use va416xx_hal::pac::{self, interrupt};
|
||||
@ -29,8 +31,7 @@ const WDT_ROLLOVER_MS: u32 = 100;
|
||||
|
||||
#[entry]
|
||||
fn main() -> ! {
|
||||
rtt_init_print!();
|
||||
rprintln!("-- VA416xx WDT example application--");
|
||||
defmt::println!("-- VA416xx WDT example application--");
|
||||
let cp = cortex_m::Peripherals::take().unwrap();
|
||||
let mut dp = pac::Peripherals::take().unwrap();
|
||||
|
||||
@ -53,7 +54,7 @@ fn main() -> ! {
|
||||
}
|
||||
let interrupt_counter = critical_section::with(|cs| WDT_INTRPT_COUNT.borrow(cs).get());
|
||||
if interrupt_counter > last_interrupt_counter {
|
||||
rprintln!("interrupt counter has increased to {}", interrupt_counter);
|
||||
defmt::info!("interrupt counter has increased to {}", interrupt_counter);
|
||||
last_interrupt_counter = interrupt_counter;
|
||||
}
|
||||
match TEST_MODE {
|
||||
|
@ -3,7 +3,7 @@
|
||||
#![no_std]
|
||||
|
||||
use cortex_m_rt::entry;
|
||||
use panic_rtt_target as _;
|
||||
use panic_halt as _;
|
||||
|
||||
#[entry]
|
||||
fn main() -> ! {
|
||||
|
Reference in New Issue
Block a user