From 517714c98e4b5dc4c7ee844527f5d33fdc342125 Mon Sep 17 00:00:00 2001 From: Irina Chiorean Date: Fri, 25 Jul 2025 18:00:49 +0300 Subject: feat: add RTC time driver --- examples/lpc55s69/Cargo.toml | 4 ++-- examples/lpc55s69/README.md | 12 +++++++++++ examples/lpc55s69/src/bin/blinky_embassy_time.rs | 26 ++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 examples/lpc55s69/README.md create mode 100644 examples/lpc55s69/src/bin/blinky_embassy_time.rs (limited to 'examples') diff --git a/examples/lpc55s69/Cargo.toml b/examples/lpc55s69/Cargo.toml index 5faec13da..f9bd409e2 100644 --- a/examples/lpc55s69/Cargo.toml +++ b/examples/lpc55s69/Cargo.toml @@ -6,10 +6,10 @@ license = "MIT OR Apache-2.0" [dependencies] -embassy-nxp = { version = "0.1.0", path = "../../embassy-nxp", features = ["lpc55", "rt", "defmt"] } +embassy-nxp = { version = "0.1.0", path = "../../embassy-nxp", features = ["lpc55", "rt", "defmt", "time-driver-rtc"] } embassy-executor = { version = "0.8.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt"] } embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = ["defmt"] } -embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt"] } +embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", "tick-hz-32_768"] } panic-halt = "1.0.0" cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] } cortex-m-rt = { version = "0.7.0"} diff --git a/examples/lpc55s69/README.md b/examples/lpc55s69/README.md new file mode 100644 index 000000000..d200f4f99 --- /dev/null +++ b/examples/lpc55s69/README.md @@ -0,0 +1,12 @@ +# LPC55S69 Examples + +## Available examples: +- blinky_nop: Blink the integrated RED LED using nops as delay. Useful for flashing simple and known-good software on board. +- button_executor: Turn on/off an LED by pressing the USER button. Demonstrates how to use the PINT and GPIO drivers. +- blinky_embassy_time: Blink the integrated RED LED using `embassy-time`. Demonstrates how to use the time-driver that uses RTC. + +## Important Notes + +On older version of probe-rs, some examples (such as `blinky_embassy_time`) do not work directly after flashing and the board must be reset after flashing. It is reccomended to update the version of probe-rs to the latest one. + +When developing drivers for this board, probe-rs might not be able to flash the board after entering a fault. Either reset the board to clear the fault, or use NXP's proprietary software `LinkServer`/`LinkFlash` to bring the board back to a known-good state. \ No newline at end of file diff --git a/examples/lpc55s69/src/bin/blinky_embassy_time.rs b/examples/lpc55s69/src/bin/blinky_embassy_time.rs new file mode 100644 index 000000000..adc3d8bd3 --- /dev/null +++ b/examples/lpc55s69/src/bin/blinky_embassy_time.rs @@ -0,0 +1,26 @@ +#![no_std] +#![no_main] + +use defmt::*; +use embassy_executor::Spawner; +use embassy_nxp::gpio::{Level, Output}; +use embassy_time::Timer; +use {defmt_rtt as _, panic_halt as _}; + +#[embassy_executor::main] +async fn main(_spawner: Spawner) { + let p = embassy_nxp::init(Default::default()); + info!("Initialization complete"); + let mut led = Output::new(p.PIO1_6, Level::Low); + + info!("Entering main loop"); + loop { + info!("led off!"); + led.set_high(); + Timer::after_millis(500).await; + + info!("led on!"); + led.set_low(); + Timer::after_millis(500).await; + } +} -- cgit