aboutsummaryrefslogtreecommitdiff
path: root/examples/nrf54lm20/src
diff options
context:
space:
mode:
authorHaobo Gu <[email protected]>2025-12-08 17:21:27 +0800
committerHaobo Gu <[email protected]>2025-12-08 17:23:47 +0800
commit8cf8b2406d4be014d466a9318303a65c5c7ff076 (patch)
treefcabea0e4f5800c0bb49a9961951480ec75af2d1 /examples/nrf54lm20/src
parentb9e467bdfe44e51a8b633040d9fe9cd43c581d36 (diff)
feat: add nRF54LM20A support
Signed-off-by: Haobo Gu <[email protected]>
Diffstat (limited to 'examples/nrf54lm20/src')
-rw-r--r--examples/nrf54lm20/src/bin/blinky.rs23
-rw-r--r--examples/nrf54lm20/src/bin/gpio.rs23
-rw-r--r--examples/nrf54lm20/src/bin/gpiote_channel.rs49
-rw-r--r--examples/nrf54lm20/src/bin/gpiote_port.rs33
-rw-r--r--examples/nrf54lm20/src/bin/timer.rs30
5 files changed, 158 insertions, 0 deletions
diff --git a/examples/nrf54lm20/src/bin/blinky.rs b/examples/nrf54lm20/src/bin/blinky.rs
new file mode 100644
index 000000000..962e9f5a6
--- /dev/null
+++ b/examples/nrf54lm20/src/bin/blinky.rs
@@ -0,0 +1,23 @@
1#![no_std]
2#![no_main]
3
4use defmt::info;
5use embassy_executor::Spawner;
6use embassy_nrf::gpio::{Level, Output, OutputDrive};
7use embassy_time::Timer;
8use {defmt_rtt as _, panic_probe as _};
9
10#[embassy_executor::main]
11async fn main(_spawner: Spawner) {
12 let p = embassy_nrf::init(Default::default());
13 let mut led = Output::new(p.P1_22, Level::Low, OutputDrive::HighDrive);
14
15 loop {
16 info!("high!");
17 led.set_high();
18 Timer::after_millis(300).await;
19 info!("low!");
20 led.set_low();
21 Timer::after_millis(300).await;
22 }
23}
diff --git a/examples/nrf54lm20/src/bin/gpio.rs b/examples/nrf54lm20/src/bin/gpio.rs
new file mode 100644
index 000000000..4b6b4630d
--- /dev/null
+++ b/examples/nrf54lm20/src/bin/gpio.rs
@@ -0,0 +1,23 @@
1#![no_std]
2#![no_main]
3
4use defmt::info;
5use embassy_executor::Spawner;
6use embassy_nrf::gpio::{Input, Pull};
7use embassy_time::Timer;
8use {defmt_rtt as _, panic_probe as _};
9
10#[embassy_executor::main]
11async fn main(_spawner: Spawner) {
12 let p = embassy_nrf::init(Default::default());
13 let btn = Input::new(p.P1_26, Pull::Up);
14
15 loop {
16 if btn.is_high() {
17 info!("high");
18 } else {
19 info!("low");
20 }
21 Timer::after_millis(100).await;
22 }
23}
diff --git a/examples/nrf54lm20/src/bin/gpiote_channel.rs b/examples/nrf54lm20/src/bin/gpiote_channel.rs
new file mode 100644
index 000000000..0f30f06c7
--- /dev/null
+++ b/examples/nrf54lm20/src/bin/gpiote_channel.rs
@@ -0,0 +1,49 @@
1#![no_std]
2#![no_main]
3
4use defmt::info;
5use embassy_executor::Spawner;
6use embassy_nrf::gpio::Pull;
7use embassy_nrf::gpiote::{InputChannel, InputChannelPolarity};
8use {defmt_rtt as _, panic_probe as _};
9
10#[embassy_executor::main]
11async fn main(_spawner: Spawner) {
12 let p = embassy_nrf::init(Default::default());
13 info!("Starting!");
14
15 let mut ch1 = InputChannel::new(p.GPIOTE20_CH0, p.P1_26, Pull::Up, InputChannelPolarity::HiToLo);
16 let mut ch2 = InputChannel::new(p.GPIOTE20_CH1, p.P1_09, Pull::Up, InputChannelPolarity::LoToHi);
17 let mut ch3 = InputChannel::new(p.GPIOTE20_CH2, p.P1_08, Pull::Up, InputChannelPolarity::Toggle);
18 let mut ch4 = InputChannel::new(p.GPIOTE30_CH0, p.P0_05, Pull::Up, InputChannelPolarity::Toggle);
19
20 let button1 = async {
21 loop {
22 ch1.wait().await;
23 info!("Button 1 pressed")
24 }
25 };
26
27 let button2 = async {
28 loop {
29 ch2.wait().await;
30 info!("Button 2 released")
31 }
32 };
33
34 let button3 = async {
35 loop {
36 ch3.wait().await;
37 info!("Button 3 toggled")
38 }
39 };
40
41 let button4 = async {
42 loop {
43 ch4.wait().await;
44 info!("Button 4 toggled")
45 }
46 };
47
48 embassy_futures::join::join4(button1, button2, button3, button4).await;
49}
diff --git a/examples/nrf54lm20/src/bin/gpiote_port.rs b/examples/nrf54lm20/src/bin/gpiote_port.rs
new file mode 100644
index 000000000..6dbd63d92
--- /dev/null
+++ b/examples/nrf54lm20/src/bin/gpiote_port.rs
@@ -0,0 +1,33 @@
1#![no_std]
2#![no_main]
3
4use defmt::{info, unwrap};
5use embassy_executor::Spawner;
6use embassy_nrf::gpio::{Input, Pull};
7use {defmt_rtt as _, panic_probe as _};
8
9#[embassy_executor::task(pool_size = 4)]
10async fn button_task(n: usize, mut pin: Input<'static>) {
11 loop {
12 pin.wait_for_low().await;
13 info!("Button {:?} pressed!", n);
14 pin.wait_for_high().await;
15 info!("Button {:?} released!", n);
16 }
17}
18
19#[embassy_executor::main]
20async fn main(spawner: Spawner) {
21 let p = embassy_nrf::init(Default::default());
22 info!("Starting!");
23
24 let btn1 = Input::new(p.P1_26, Pull::Up);
25 let btn2 = Input::new(p.P1_09, Pull::Up);
26 let btn3 = Input::new(p.P1_08, Pull::Up);
27 let btn4 = Input::new(p.P0_05, Pull::Up);
28
29 spawner.spawn(unwrap!(button_task(1, btn1)));
30 spawner.spawn(unwrap!(button_task(2, btn2)));
31 spawner.spawn(unwrap!(button_task(3, btn3)));
32 spawner.spawn(unwrap!(button_task(4, btn4)));
33}
diff --git a/examples/nrf54lm20/src/bin/timer.rs b/examples/nrf54lm20/src/bin/timer.rs
new file mode 100644
index 000000000..68acc91c1
--- /dev/null
+++ b/examples/nrf54lm20/src/bin/timer.rs
@@ -0,0 +1,30 @@
1#![no_std]
2#![no_main]
3
4use defmt::{info, unwrap};
5use embassy_executor::Spawner;
6use embassy_time::Timer;
7use {defmt_rtt as _, panic_probe as _};
8
9#[embassy_executor::task]
10async fn run1() {
11 loop {
12 info!("BIG INFREQUENT TICK");
13 Timer::after_secs(10).await;
14 }
15}
16
17#[embassy_executor::task]
18async fn run2() {
19 loop {
20 info!("tick");
21 Timer::after_secs(1).await;
22 }
23}
24
25#[embassy_executor::main]
26async fn main(spawner: Spawner) {
27 let _p = embassy_nrf::init(Default::default());
28 spawner.spawn(unwrap!(run1()));
29 spawner.spawn(unwrap!(run2()));
30}