diff options
| author | 1-rafael-1 <[email protected]> | 2025-09-15 20:07:18 +0200 |
|---|---|---|
| committer | 1-rafael-1 <[email protected]> | 2025-09-15 20:07:18 +0200 |
| commit | 6bb3d2c0720fa082f27d3cdb70f516058497ec87 (patch) | |
| tree | 5a1e255cff999b00800f203b91a759c720c973e5 /examples/lpc55s69 | |
| parent | eb685574601d98c44faed9a3534d056199b46e20 (diff) | |
| parent | 92a6fd2946f2cbb15359290f68aa360953da2ff7 (diff) | |
Merge branch 'main' into rp2040-rtc-alarm
Diffstat (limited to 'examples/lpc55s69')
| -rw-r--r-- | examples/lpc55s69/Cargo.toml | 22 | ||||
| -rw-r--r-- | examples/lpc55s69/README.md | 12 | ||||
| -rw-r--r-- | examples/lpc55s69/src/bin/blinky_embassy_time.rs | 26 | ||||
| -rw-r--r-- | examples/lpc55s69/src/bin/usart_blocking.rs | 40 |
4 files changed, 92 insertions, 8 deletions
diff --git a/examples/lpc55s69/Cargo.toml b/examples/lpc55s69/Cargo.toml index f5a6e6995..579748595 100644 --- a/examples/lpc55s69/Cargo.toml +++ b/examples/lpc55s69/Cargo.toml | |||
| @@ -4,19 +4,25 @@ name = "embassy-nxp-lpc55s69-examples" | |||
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
| 6 | 6 | ||
| 7 | publish = false | ||
| 7 | 8 | ||
| 8 | [dependencies] | 9 | [dependencies] |
| 9 | embassy-nxp = { version = "0.1.0", path = "../../embassy-nxp", features = ["rt"] } | 10 | embassy-nxp = { version = "0.1.0", path = "../../embassy-nxp", features = ["lpc55-core0", "rt", "defmt", "time-driver-rtc"] } |
| 10 | embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt"] } | 11 | embassy-executor = { version = "0.9.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt"] } |
| 11 | embassy-sync = { version = "0.6.2", path = "../../embassy-sync", features = ["defmt"] } | 12 | embassy-sync = { version = "0.7.2", path = "../../embassy-sync", features = ["defmt"] } |
| 12 | embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt"] } | 13 | embassy-time = { version = "0.5.0", path = "../../embassy-time", features = ["defmt", "tick-hz-32_768"] } |
| 13 | panic-halt = "0.2.0" | 14 | panic-halt = "1.0.0" |
| 14 | cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] } | 15 | cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] } |
| 15 | cortex-m-rt = { version = "0.7.0"} | 16 | cortex-m-rt = { version = "0.7.0"} |
| 16 | defmt = "0.3" | 17 | defmt = "1.0.1" |
| 17 | defmt-rtt = "0.4" | 18 | defmt-rtt = "1.0.0" |
| 18 | panic-probe = { version = "0.3.2", features = ["print-defmt"] } | 19 | panic-probe = { version = "1.0.0", features = ["print-defmt"] } |
| 19 | panic-semihosting = "0.6.0" | 20 | panic-semihosting = "0.6.0" |
| 20 | 21 | ||
| 21 | [profile.release] | 22 | [profile.release] |
| 22 | debug = 2 | 23 | debug = 2 |
| 24 | |||
| 25 | [package.metadata.embassy] | ||
| 26 | build = [ | ||
| 27 | { target = "thumbv8m.main-none-eabihf", artifact-dir = "out/examples/lpc55s69" } | ||
| 28 | ] | ||
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 @@ | |||
| 1 | # LPC55S69 Examples | ||
| 2 | |||
| 3 | ## Available examples: | ||
| 4 | - blinky_nop: Blink the integrated RED LED using nops as delay. Useful for flashing simple and known-good software on board. | ||
| 5 | - button_executor: Turn on/off an LED by pressing the USER button. Demonstrates how to use the PINT and GPIO drivers. | ||
| 6 | - blinky_embassy_time: Blink the integrated RED LED using `embassy-time`. Demonstrates how to use the time-driver that uses RTC. | ||
| 7 | |||
| 8 | ## Important Notes | ||
| 9 | |||
| 10 | 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. | ||
| 11 | |||
| 12 | 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 @@ | |||
| 1 | #![no_std] | ||
| 2 | #![no_main] | ||
| 3 | |||
| 4 | use defmt::*; | ||
| 5 | use embassy_executor::Spawner; | ||
| 6 | use embassy_nxp::gpio::{Level, Output}; | ||
| 7 | use embassy_time::Timer; | ||
| 8 | use {defmt_rtt as _, panic_halt as _}; | ||
| 9 | |||
| 10 | #[embassy_executor::main] | ||
| 11 | async fn main(_spawner: Spawner) { | ||
| 12 | let p = embassy_nxp::init(Default::default()); | ||
| 13 | info!("Initialization complete"); | ||
| 14 | let mut led = Output::new(p.PIO1_6, Level::Low); | ||
| 15 | |||
| 16 | info!("Entering main loop"); | ||
| 17 | loop { | ||
| 18 | info!("led off!"); | ||
| 19 | led.set_high(); | ||
| 20 | Timer::after_millis(500).await; | ||
| 21 | |||
| 22 | info!("led on!"); | ||
| 23 | led.set_low(); | ||
| 24 | Timer::after_millis(500).await; | ||
| 25 | } | ||
| 26 | } | ||
diff --git a/examples/lpc55s69/src/bin/usart_blocking.rs b/examples/lpc55s69/src/bin/usart_blocking.rs new file mode 100644 index 000000000..a38ec0c5b --- /dev/null +++ b/examples/lpc55s69/src/bin/usart_blocking.rs | |||
| @@ -0,0 +1,40 @@ | |||
| 1 | #![no_std] | ||
| 2 | #![no_main] | ||
| 3 | |||
| 4 | use core::str::from_utf8_mut; | ||
| 5 | |||
| 6 | use defmt::*; | ||
| 7 | use embassy_executor::Spawner; | ||
| 8 | use embassy_nxp::usart::{Config, Usart}; | ||
| 9 | use embassy_time::Timer; | ||
| 10 | use {defmt_rtt as _, panic_halt as _}; | ||
| 11 | |||
| 12 | #[embassy_executor::main] | ||
| 13 | async fn main(_spawner: Spawner) { | ||
| 14 | let p = embassy_nxp::init(Default::default()); | ||
| 15 | let mut usart = Usart::new_blocking(p.USART2, p.PIO0_27, p.PIO1_24, Config::default()); | ||
| 16 | let tx_buf = b"Hello, Ferris!"; | ||
| 17 | let mut rx_buf = [0u8; 14]; | ||
| 18 | |||
| 19 | loop { | ||
| 20 | info!("Write a message"); | ||
| 21 | usart.blocking_write(tx_buf).unwrap(); | ||
| 22 | usart.blocking_flush().unwrap(); | ||
| 23 | |||
| 24 | Timer::after_millis(500).await; | ||
| 25 | |||
| 26 | info!("Read a message"); | ||
| 27 | usart.blocking_read(&mut rx_buf).unwrap(); | ||
| 28 | |||
| 29 | match from_utf8_mut(&mut rx_buf) { | ||
| 30 | Ok(str) => { | ||
| 31 | info!("The message is: {}", str); | ||
| 32 | } | ||
| 33 | Err(_) => { | ||
| 34 | error!("Error in converting to UTF8"); | ||
| 35 | } | ||
| 36 | } | ||
| 37 | |||
| 38 | Timer::after_millis(500).await; | ||
| 39 | } | ||
| 40 | } | ||
