aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/lpc55s69/.cargo/config.toml8
-rw-r--r--examples/lpc55s69/Cargo.toml22
-rw-r--r--examples/lpc55s69/build.rs35
-rw-r--r--examples/lpc55s69/memory.x28
-rw-r--r--examples/lpc55s69/src/bin/blinky_nop.rs33
-rw-r--r--examples/lpc55s69/src/bin/button_executor.rs25
6 files changed, 151 insertions, 0 deletions
diff --git a/examples/lpc55s69/.cargo/config.toml b/examples/lpc55s69/.cargo/config.toml
new file mode 100644
index 000000000..9556de72f
--- /dev/null
+++ b/examples/lpc55s69/.cargo/config.toml
@@ -0,0 +1,8 @@
1[target.'cfg(all(target_arch = "arm", target_os = "none"))']
2runner = "probe-rs run --chip LPC55S69JBD100"
3
4[build]
5target = "thumbv8m.main-none-eabihf"
6
7[env]
8DEFMT_LOG = "debug"
diff --git a/examples/lpc55s69/Cargo.toml b/examples/lpc55s69/Cargo.toml
new file mode 100644
index 000000000..14ec2d47e
--- /dev/null
+++ b/examples/lpc55s69/Cargo.toml
@@ -0,0 +1,22 @@
1[package]
2edition = "2021"
3name = "embassy-nxp-lpc55s69-examples"
4version = "0.1.0"
5license = "MIT OR Apache-2.0"
6
7
8[dependencies]
9embassy-nxp = { version = "0.1.0", path = "../../embassy-nxp", features = ["rt"] }
10embassy-executor = { version = "0.6.0", path = "../../embassy-executor", features = ["task-arena-size-32768", "arch-cortex-m", "executor-thread", "executor-interrupt"] }
11embassy-sync = { version = "0.6.0", path = "../../embassy-sync", features = ["defmt"] }
12embassy-time = { version = "0.3.0", path = "../../embassy-time", features = ["defmt"] }
13panic-halt = "0.2.0"
14cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] }
15cortex-m-rt = {version = "0.7.0"}
16defmt = "0.3"
17defmt-rtt = "0.4"
18panic-probe = { version = "0.3.2", features = ["print-defmt"] }
19panic-semihosting = "0.6.0"
20
21[profile.release]
22debug = 2
diff --git a/examples/lpc55s69/build.rs b/examples/lpc55s69/build.rs
new file mode 100644
index 000000000..30691aa97
--- /dev/null
+++ b/examples/lpc55s69/build.rs
@@ -0,0 +1,35 @@
1//! This build script copies the `memory.x` file from the crate root into
2//! a directory where the linker can always find it at build time.
3//! For many projects this is optional, as the linker always searches the
4//! project root directory -- wherever `Cargo.toml` is. However, if you
5//! are using a workspace or have a more complicated build setup, this
6//! build script becomes required. Additionally, by requesting that
7//! Cargo re-run the build script whenever `memory.x` is changed,
8//! updating `memory.x` ensures a rebuild of the application with the
9//! new memory settings.
10
11use std::env;
12use std::fs::File;
13use std::io::Write;
14use std::path::PathBuf;
15
16fn main() {
17 // Put `memory.x` in our output directory and ensure it's
18 // on the linker search path.
19 let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
20 File::create(out.join("memory.x"))
21 .unwrap()
22 .write_all(include_bytes!("memory.x"))
23 .unwrap();
24 println!("cargo:rustc-link-search={}", out.display());
25
26 // By default, Cargo will re-run a build script whenever
27 // any file in the project changes. By specifying `memory.x`
28 // here, we ensure the build script is only re-run when
29 // `memory.x` is changed.
30 println!("cargo:rerun-if-changed=memory.x");
31
32 println!("cargo:rustc-link-arg-bins=--nmagic");
33 println!("cargo:rustc-link-arg-bins=-Tlink.x");
34 println!("cargo:rustc-link-arg-bins=-Tdefmt.x");
35}
diff --git a/examples/lpc55s69/memory.x b/examples/lpc55s69/memory.x
new file mode 100644
index 000000000..1483b2fad
--- /dev/null
+++ b/examples/lpc55s69/memory.x
@@ -0,0 +1,28 @@
1/* File originally from lpc55-hal repo: https://github.com/lpc55/lpc55-hal/blob/main/memory.x */
2MEMORY
3{
4 FLASH : ORIGIN = 0x00000000, LENGTH = 512K
5
6 /* for use with standard link.x */
7 RAM : ORIGIN = 0x20000000, LENGTH = 256K
8
9 /* would be used with proper link.x */
10 /* needs changes to r0 (initialization code) */
11 /* SRAM0 : ORIGIN = 0x20000000, LENGTH = 64K */
12 /* SRAM1 : ORIGIN = 0x20010000, LENGTH = 64K */
13 /* SRAM2 : ORIGIN = 0x20020000, LENGTH = 64K */
14 /* SRAM3 : ORIGIN = 0x20030000, LENGTH = 64K */
15
16 /* CASPER SRAM regions */
17 /* SRAMX0: ORIGIN = 0x1400_0000, LENGTH = 4K /1* to 0x1400_0FFF *1/ */
18 /* SRAMX1: ORIGIN = 0x1400_4000, LENGTH = 4K /1* to 0x1400_4FFF *1/ */
19
20 /* USB1 SRAM regin */
21 /* USB1_SRAM : ORIGIN = 0x40100000, LENGTH = 16K */
22
23 /* To define our own USB RAM section in one regular */
24 /* RAM, probably easiest to shorten length of RAM */
25 /* above, and use this freed RAM section */
26
27}
28
diff --git a/examples/lpc55s69/src/bin/blinky_nop.rs b/examples/lpc55s69/src/bin/blinky_nop.rs
new file mode 100644
index 000000000..58e2d9808
--- /dev/null
+++ b/examples/lpc55s69/src/bin/blinky_nop.rs
@@ -0,0 +1,33 @@
1//! This example has been made with the LPCXpresso55S69 board in mind, which has a built-in LED on PIO1_6.
2
3#![no_std]
4#![no_main]
5
6use cortex_m::asm::nop;
7use defmt::*;
8use embassy_executor::Spawner;
9use embassy_nxp::gpio::{Level, Output};
10use {defmt_rtt as _, panic_halt as _};
11
12#[embassy_executor::main]
13async fn main(_spawner: Spawner) {
14 let p = embassy_nxp::init(Default::default());
15
16 let mut led = Output::new(p.PIO1_6, Level::Low);
17
18 loop {
19 info!("led off!");
20 led.set_high();
21
22 for _ in 0..200_000 {
23 nop();
24 }
25
26 info!("led on!");
27 led.set_low();
28
29 for _ in 0..200_000 {
30 nop();
31 }
32 }
33}
diff --git a/examples/lpc55s69/src/bin/button_executor.rs b/examples/lpc55s69/src/bin/button_executor.rs
new file mode 100644
index 000000000..836b1c9eb
--- /dev/null
+++ b/examples/lpc55s69/src/bin/button_executor.rs
@@ -0,0 +1,25 @@
1//! This example has been made with the LPCXpresso55S69 board in mind, which has a built-in LED on
2//! PIO1_6 and a button (labeled "user") on PIO1_9.
3
4#![no_std]
5#![no_main]
6
7use defmt::*;
8use embassy_executor::Spawner;
9use embassy_nxp::gpio::{Input, Level, Output, Pull};
10use {defmt_rtt as _, panic_halt as _};
11
12#[embassy_executor::main]
13async fn main(_spawner: Spawner) -> ! {
14 let p = embassy_nxp::init(Default::default());
15
16 let mut led = Output::new(p.PIO1_6, Level::Low);
17 let mut button = Input::new(p.PIO1_9, Pull::Up);
18
19 info!("Entered main loop");
20 loop {
21 button.wait_for_rising_edge().await;
22 info!("Button pressed");
23 led.toggle();
24 }
25}