From 2f503ac3b144158270e01db7d44ad85bb6b083b6 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sat, 18 Dec 2021 15:00:54 +0100 Subject: [PATCH] update blinky led example, bump HAL dependency --- Cargo.toml | 2 +- examples/blinky-leds.rs | 38 +++++++++++++++++++++++++------------- examples/max11619-adc.rs | 4 ++-- 3 files changed, 28 insertions(+), 16 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 4b59bc6..232f85e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,7 +18,7 @@ dummy-pin = "0.1.1" max116xx-10bit = "0.2.1" [dependencies.va108xx-hal] -version = "0.4.2" +version = "0.4.3" features = ["rt"] [features] diff --git a/examples/blinky-leds.rs b/examples/blinky-leds.rs index 7df72fa..b6d1192 100644 --- a/examples/blinky-leds.rs +++ b/examples/blinky-leds.rs @@ -9,7 +9,7 @@ use cortex_m_rt::entry; use embedded_hal::digital::v2::ToggleableOutputPin; use panic_halt as _; -use va108xx_hal::{gpio::pins::PinsA, pac, prelude::*}; +use va108xx_hal::{gpio::pins::PinsA, pac, prelude::*, timer::set_up_ms_timer}; use vorago_reb1::leds::Leds; // REB LED pin definitions. All on port A @@ -64,23 +64,30 @@ fn main() -> ! { let mut led1 = pins.pa10.into_push_pull_output(); let mut led2 = pins.pa7.into_push_pull_output(); let mut led3 = pins.pa6.into_push_pull_output(); + let mut delay = set_up_ms_timer( + &mut dp.SYSCONFIG, + &mut dp.IRQSEL, + 50.mhz().into(), + dp.TIM0, + pac::Interrupt::OC0, + ); for _ in 0..10 { led1.set_low().ok(); led2.set_low().ok(); led3.set_low().ok(); - cortex_m::asm::delay(5_000_000); + delay.delay_ms(200_u16); led1.set_high().ok(); led2.set_high().ok(); led3.set_high().ok(); - cortex_m::asm::delay(5_000_000); + delay.delay_ms(200_u16); } loop { led1.toggle().ok(); - cortex_m::asm::delay(5_000_000); + delay.delay_ms(200_u16); led2.toggle().ok(); - cortex_m::asm::delay(5_000_000); + delay.delay_ms(200_u16); led3.toggle().ok(); - cortex_m::asm::delay(5_000_000); + delay.delay_ms(200_u16); } } LibType::Bsp => { @@ -90,22 +97,27 @@ fn main() -> ! { pinsa.pa7.into_push_pull_output(), pinsa.pa6.into_push_pull_output(), ); + let mut delay = set_up_ms_timer( + &mut dp.SYSCONFIG, + &mut dp.IRQSEL, + 50.mhz().into(), + dp.TIM0, + pac::Interrupt::OC0, + ); loop { for _ in 0..10 { // Blink all LEDs quickly for led in leds.iter_mut() { led.toggle(); } - cortex_m::asm::delay(5_000_000); + delay.delay_ms(200_u16); } // Now use a wave pattern loop { - leds[0].toggle(); - cortex_m::asm::delay(5_000_000); - leds[1].toggle(); - cortex_m::asm::delay(5_000_000); - leds[2].toggle(); - cortex_m::asm::delay(5_000_000); + for led in leds.iter_mut() { + led.toggle(); + delay.delay_ms(200_u16); + } } } } diff --git a/examples/max11619-adc.rs b/examples/max11619-adc.rs index 4e97b5b..29acca3 100644 --- a/examples/max11619-adc.rs +++ b/examples/max11619-adc.rs @@ -14,7 +14,7 @@ use va108xx_hal::{ prelude::*, spi::{Spi, SpiBase, SpiConfig, TransferConfig}, timer::{default_ms_irq_handler, set_up_ms_timer, Delay}, - utility::{port_mux, PortSel, Funsel} + utility::{port_mux, Funsel, PortSel}, }; use vorago_reb1::max11619::{ max11619_externally_clocked_no_wakeup, max11619_externally_clocked_with_wakeup, @@ -39,7 +39,7 @@ pub enum ReadMode { #[derive(Debug, PartialEq, Copy, Clone)] pub enum MuxMode { None, - PortB19to17 + PortB19to17, } const EXAMPLE_MODE: ExampleMode = ExampleMode::NotUsingEoc;