Merge pull request #3966 from i509VCB/mspm0-init

Embassy for MSPM0
This commit is contained in:
Ulf Lilleengen
2025-03-21 13:32:14 +00:00
committed by GitHub
53 changed files with 3780 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
[target.'cfg(all(target_arch = "arm", target_os = "none"))']
# replace MSPM0C1104 with your chip as listed in `probe-rs chip list`
runner = "probe-rs run --chip MSPM0C1104 --protocol=swd"
[build]
target = "thumbv6m-none-eabi"
[env]
DEFMT_LOG = "debug"
# defmt's buffer needs to be shrunk since the MSPM0C1104 only has 1KB of ram.
DEFMT_RTT_BUFFER_SIZE = "72"

View File

@@ -0,0 +1,32 @@
[package]
edition = "2021"
name = "embassy-mspm0-c1104-examples"
version = "0.1.0"
license = "MIT OR Apache-2.0"
[dependencies]
embassy-mspm0 = { version = "0.1.0", path = "../../embassy-mspm0", features = ["mspm0c110x", "rt", "time-driver-any"] }
embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["task-arena-size-128", "arch-cortex-m", "executor-thread", "executor-interrupt"] }
embassy-sync = { version = "0.6.2", path = "../../embassy-sync", features = ["defmt"] }
embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt"] }
panic-halt = "0.2.0"
cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] }
cortex-m-rt = { version = "0.7.0"}
defmt = "0.3"
defmt-rtt = "0.4"
panic-probe = { version = "0.3.2", features = ["print-defmt"] }
panic-semihosting = "0.6.0"
# The chip only has 1KB of ram, so we must optimize binaries regardless
[profile.dev]
debug = 0
opt-level = "z"
lto = true
codegen-units = 1
# strip = true
[profile.release]
debug = 0
opt-level = "z"
lto = true
codegen-units = 1

View File

@@ -0,0 +1,27 @@
# Examples for MSPM0C110x family
Run individual examples with
```
cargo run --bin <module-name>
```
for example
```
cargo run --bin blinky
```
## Checklist before running examples
A large number of the examples are written for the [LP-MSPM0C1104](https://www.ti.com/tool/LP-MSPM0C1104) board.
You might need to adjust `.cargo/config.toml`, `Cargo.toml` and possibly update pin numbers or peripherals to match the specific MCU or board you are using.
* [ ] Update .cargo/config.toml with the correct probe-rs command to use your specific MCU. For example for C1104 it should be `probe-rs run --chip MSPM0C1104`. (use `probe-rs chip list` to find your chip)
* [ ] Update Cargo.toml to have the correct `embassy-mspm0` feature. For example for C1104 it should be `mspm0c1104`. Look in the `Cargo.toml` file of the `embassy-mspm0` project to find the correct feature flag for your chip.
* [ ] If your board has a special clock or power configuration, make sure that it is set up appropriately.
* [ ] If your board has different pin mapping, update any pin numbers or peripherals in the given example code to match your schematic
If you are unsure, please drop by the Embassy Matrix chat for support, and let us know:
* Which example you are trying to run
* Which chip and board you are using
Embassy Chat: https://matrix.to/#/#embassy-rs:matrix.org

View File

@@ -0,0 +1,35 @@
//! This build script copies the `memory.x` file from the crate root into
//! a directory where the linker can always find it at build time.
//! For many projects this is optional, as the linker always searches the
//! project root directory -- wherever `Cargo.toml` is. However, if you
//! are using a workspace or have a more complicated build setup, this
//! build script becomes required. Additionally, by requesting that
//! Cargo re-run the build script whenever `memory.x` is changed,
//! updating `memory.x` ensures a rebuild of the application with the
//! new memory settings.
use std::env;
use std::fs::File;
use std::io::Write;
use std::path::PathBuf;
fn main() {
// Put `memory.x` in our output directory and ensure it's
// on the linker search path.
let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
File::create(out.join("memory.x"))
.unwrap()
.write_all(include_bytes!("memory.x"))
.unwrap();
println!("cargo:rustc-link-search={}", out.display());
// By default, Cargo will re-run a build script whenever
// any file in the project changes. By specifying `memory.x`
// here, we ensure the build script is only re-run when
// `memory.x` is changed.
println!("cargo:rerun-if-changed=memory.x");
println!("cargo:rustc-link-arg-bins=--nmagic");
println!("cargo:rustc-link-arg-bins=-Tlink.x");
println!("cargo:rustc-link-arg-bins=-Tdefmt.x");
}

View File

@@ -0,0 +1,5 @@
MEMORY
{
FLASH : ORIGIN = 0x00000000, LENGTH = 16K
RAM : ORIGIN = 0x20000000, LENGTH = 1K
}

View File

@@ -0,0 +1,25 @@
#![no_std]
#![no_main]
use defmt::*;
use embassy_executor::Spawner;
use embassy_mspm0::gpio::{Level, Output};
use embassy_mspm0::Config;
use embassy_time::Timer;
use {defmt_rtt as _, panic_halt as _};
#[embassy_executor::main]
async fn main(_spawner: Spawner) -> ! {
info!("Hello world!");
let p = embassy_mspm0::init(Config::default());
let mut led1 = Output::new(p.PA22, Level::Low);
led1.set_inversion(true);
loop {
Timer::after_millis(400).await;
info!("Toggle");
led1.toggle();
}
}

View File

@@ -0,0 +1,33 @@
#![no_std]
#![no_main]
use defmt::*;
use embassy_executor::Spawner;
use embassy_mspm0::gpio::{Input, Level, Output, Pull};
use embassy_mspm0::Config;
use {defmt_rtt as _, panic_halt as _};
#[embassy_executor::main]
async fn main(_spawner: Spawner) -> ! {
info!("Hello world!");
let p = embassy_mspm0::init(Config::default());
let led1 = p.PA22;
let s2 = p.PA16;
let mut led1 = Output::new(led1, Level::Low);
let mut s2 = Input::new(s2, Pull::Up);
// led1 is active low
led1.set_high();
loop {
s2.wait_for_falling_edge().await;
info!("Switch 2 was pressed");
led1.toggle();
}
}

View File

@@ -0,0 +1,9 @@
[target.'cfg(all(target_arch = "arm", target_os = "none"))']
# replace MSPM0G3507 with your chip as listed in `probe-rs chip list`
runner = "probe-rs run --chip MSPM0G3507 --protocol=swd"
[build]
target = "thumbv6m-none-eabi"
[env]
DEFMT_LOG = "debug"

View File

@@ -0,0 +1,21 @@
[package]
edition = "2021"
name = "embassy-mspm0-g3507-examples"
version = "0.1.0"
license = "MIT OR Apache-2.0"
[dependencies]
embassy-mspm0 = { version = "0.1.0", path = "../../embassy-mspm0", features = ["mspm0g350x", "rt", "time-driver-any"] }
embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["task-arena-size-4096", "arch-cortex-m", "executor-thread", "executor-interrupt"] }
embassy-sync = { version = "0.6.2", path = "../../embassy-sync", features = ["defmt"] }
embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt"] }
panic-halt = "0.2.0"
cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] }
cortex-m-rt = { version = "0.7.0"}
defmt = "0.3"
defmt-rtt = "0.4"
panic-probe = { version = "0.3.2", features = ["print-defmt"] }
panic-semihosting = "0.6.0"
[profile.release]
debug = 2

View File

@@ -0,0 +1,27 @@
# Examples for MSPM0C350x family
Run individual examples with
```
cargo run --bin <module-name>
```
for example
```
cargo run --bin blinky
```
## Checklist before running examples
A large number of the examples are written for the [LP-MSPM0G3507](https://www.ti.com/tool/LP-MSPM0G3507) board.
You might need to adjust `.cargo/config.toml`, `Cargo.toml` and possibly update pin numbers or peripherals to match the specific MCU or board you are using.
* [ ] Update .cargo/config.toml with the correct probe-rs command to use your specific MCU. For example for G3507 it should be `probe-rs run --chip MSPM0G3507`. (use `probe-rs chip list` to find your chip)
* [ ] Update Cargo.toml to have the correct `embassy-mspm0` feature. For example for G3507 it should be `mspm0g3507`. Look in the `Cargo.toml` file of the `embassy-mspm0` project to find the correct feature flag for your chip.
* [ ] If your board has a special clock or power configuration, make sure that it is set up appropriately.
* [ ] If your board has different pin mapping, update any pin numbers or peripherals in the given example code to match your schematic
If you are unsure, please drop by the Embassy Matrix chat for support, and let us know:
* Which example you are trying to run
* Which chip and board you are using
Embassy Chat: https://matrix.to/#/#embassy-rs:matrix.org

View File

@@ -0,0 +1,35 @@
//! This build script copies the `memory.x` file from the crate root into
//! a directory where the linker can always find it at build time.
//! For many projects this is optional, as the linker always searches the
//! project root directory -- wherever `Cargo.toml` is. However, if you
//! are using a workspace or have a more complicated build setup, this
//! build script becomes required. Additionally, by requesting that
//! Cargo re-run the build script whenever `memory.x` is changed,
//! updating `memory.x` ensures a rebuild of the application with the
//! new memory settings.
use std::env;
use std::fs::File;
use std::io::Write;
use std::path::PathBuf;
fn main() {
// Put `memory.x` in our output directory and ensure it's
// on the linker search path.
let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
File::create(out.join("memory.x"))
.unwrap()
.write_all(include_bytes!("memory.x"))
.unwrap();
println!("cargo:rustc-link-search={}", out.display());
// By default, Cargo will re-run a build script whenever
// any file in the project changes. By specifying `memory.x`
// here, we ensure the build script is only re-run when
// `memory.x` is changed.
println!("cargo:rerun-if-changed=memory.x");
println!("cargo:rustc-link-arg-bins=--nmagic");
println!("cargo:rustc-link-arg-bins=-Tlink.x");
println!("cargo:rustc-link-arg-bins=-Tdefmt.x");
}

View File

@@ -0,0 +1,6 @@
MEMORY
{
FLASH : ORIGIN = 0x00000000, LENGTH = 128K
/* Select non-parity range of SRAM due to SRAM_ERR_01 errata in SLAZ758 */
RAM : ORIGIN = 0x20200000, LENGTH = 32K
}

View File

@@ -0,0 +1,25 @@
#![no_std]
#![no_main]
use defmt::*;
use embassy_executor::Spawner;
use embassy_mspm0::gpio::{Level, Output};
use embassy_mspm0::Config;
use embassy_time::Timer;
use {defmt_rtt as _, panic_halt as _};
#[embassy_executor::main]
async fn main(_spawner: Spawner) -> ! {
info!("Hello world!");
let p = embassy_mspm0::init(Config::default());
let mut led1 = Output::new(p.PA0, Level::Low);
led1.set_inversion(true);
loop {
Timer::after_millis(400).await;
info!("Toggle");
led1.toggle();
}
}

View File

@@ -0,0 +1,33 @@
#![no_std]
#![no_main]
use defmt::*;
use embassy_executor::Spawner;
use embassy_mspm0::gpio::{Input, Level, Output, Pull};
use embassy_mspm0::Config;
use {defmt_rtt as _, panic_halt as _};
#[embassy_executor::main]
async fn main(_spawner: Spawner) -> ! {
info!("Hello world!");
let p = embassy_mspm0::init(Config::default());
let led1 = p.PA0;
let s2 = p.PB21;
let mut led1 = Output::new(led1, Level::Low);
let mut s2 = Input::new(s2, Pull::Up);
// led1 is active low
led1.set_high();
loop {
s2.wait_for_falling_edge().await;
info!("Switch 2 was pressed");
led1.toggle();
}
}

View File

@@ -0,0 +1,9 @@
[target.'cfg(all(target_arch = "arm", target_os = "none"))']
# replace MSPM0G3519 with your chip as listed in `probe-rs chip list`
runner = "probe-rs run --restore-unwritten --verify --chip MSPM0G3519 --protocol=swd"
[build]
target = "thumbv6m-none-eabi"
[env]
DEFMT_LOG = "trace"

View File

@@ -0,0 +1,21 @@
[package]
edition = "2021"
name = "embassy-mspm0-g3519-examples"
version = "0.1.0"
license = "MIT OR Apache-2.0"
[dependencies]
embassy-mspm0 = { version = "0.1.0", path = "../../embassy-mspm0", features = ["mspm0g351x", "rt", "time-driver-any"] }
embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["task-arena-size-16384", "arch-cortex-m", "executor-thread", "executor-interrupt"] }
embassy-sync = { version = "0.6.2", path = "../../embassy-sync", features = ["defmt"] }
embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt"] }
panic-halt = "0.2.0"
cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] }
cortex-m-rt = { version = "0.7.0"}
defmt = "0.3"
defmt-rtt = "0.4"
panic-probe = { version = "0.3.2", features = ["print-defmt"] }
panic-semihosting = "0.6.0"
[profile.release]
debug = 2

View File

@@ -0,0 +1,27 @@
# Examples for MSPM0G351x family
Run individual examples with
```
cargo run --bin <module-name>
```
for example
```
cargo run --bin blinky
```
## Checklist before running examples
A large number of the examples are written for the [LP-MSPM0G3519](https://www.ti.com/tool/LP-MSPM0G3519) board.
You might need to adjust `.cargo/config.toml`, `Cargo.toml` and possibly update pin numbers or peripherals to match the specific MCU or board you are using.
* [ ] Update .cargo/config.toml with the correct probe-rs command to use your specific MCU. For example for G3519 it should be `probe-rs run --chip MSPM0G3519`. (use `probe-rs chip list` to find your chip)
* [ ] Update Cargo.toml to have the correct `embassy-mspm0` feature. For example for G3519 it should be `mspm0g3519`. Look in the `Cargo.toml` file of the `embassy-mspm0` project to find the correct feature flag for your chip.
* [ ] If your board has a special clock or power configuration, make sure that it is set up appropriately.
* [ ] If your board has different pin mapping, update any pin numbers or peripherals in the given example code to match your schematic
If you are unsure, please drop by the Embassy Matrix chat for support, and let us know:
* Which example you are trying to run
* Which chip and board you are using
Embassy Chat: https://matrix.to/#/#embassy-rs:matrix.org

View File

@@ -0,0 +1,35 @@
//! This build script copies the `memory.x` file from the crate root into
//! a directory where the linker can always find it at build time.
//! For many projects this is optional, as the linker always searches the
//! project root directory -- wherever `Cargo.toml` is. However, if you
//! are using a workspace or have a more complicated build setup, this
//! build script becomes required. Additionally, by requesting that
//! Cargo re-run the build script whenever `memory.x` is changed,
//! updating `memory.x` ensures a rebuild of the application with the
//! new memory settings.
use std::env;
use std::fs::File;
use std::io::Write;
use std::path::PathBuf;
fn main() {
// Put `memory.x` in our output directory and ensure it's
// on the linker search path.
let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
File::create(out.join("memory.x"))
.unwrap()
.write_all(include_bytes!("memory.x"))
.unwrap();
println!("cargo:rustc-link-search={}", out.display());
// By default, Cargo will re-run a build script whenever
// any file in the project changes. By specifying `memory.x`
// here, we ensure the build script is only re-run when
// `memory.x` is changed.
println!("cargo:rerun-if-changed=memory.x");
println!("cargo:rustc-link-arg-bins=--nmagic");
println!("cargo:rustc-link-arg-bins=-Tlink.x");
println!("cargo:rustc-link-arg-bins=-Tdefmt.x");
}

View File

@@ -0,0 +1,6 @@
MEMORY
{
FLASH : ORIGIN = 0x00000000, LENGTH = 512K
/* Select non-parity range of SRAM due to SRAM_ERR_01 errata in SLAZ758 */
RAM : ORIGIN = 0x20200000, LENGTH = 128K
}

View File

@@ -0,0 +1,25 @@
#![no_std]
#![no_main]
use defmt::*;
use embassy_executor::Spawner;
use embassy_mspm0::gpio::{Level, Output};
use embassy_mspm0::Config;
use embassy_time::Timer;
use {defmt_rtt as _, panic_halt as _};
#[embassy_executor::main]
async fn main(_spawner: Spawner) -> ! {
info!("Hello world!");
let p = embassy_mspm0::init(Config::default());
let mut led1 = Output::new(p.PA0, Level::Low);
led1.set_inversion(true);
loop {
Timer::after_millis(400).await;
info!("Toggle");
led1.toggle();
}
}

View File

@@ -0,0 +1,33 @@
#![no_std]
#![no_main]
use defmt::*;
use embassy_executor::Spawner;
use embassy_mspm0::gpio::{Input, Level, Output, Pull};
use embassy_mspm0::Config;
use {defmt_rtt as _, panic_halt as _};
#[embassy_executor::main]
async fn main(_spawner: Spawner) -> ! {
info!("Hello world!");
let p = embassy_mspm0::init(Config::default());
let led1 = p.PA0;
let s2 = p.PB3;
let mut led1 = Output::new(led1, Level::Low);
let mut s2 = Input::new(s2, Pull::Up);
// led1 is active low
led1.set_high();
loop {
s2.wait_for_falling_edge().await;
info!("Switch 2 was pressed");
led1.toggle();
}
}

View File

@@ -0,0 +1,9 @@
[target.'cfg(all(target_arch = "arm", target_os = "none"))']
# replace MSPM0L1306 with your chip as listed in `probe-rs chip list`
runner = "probe-rs run --chip MSPM0L1306 --protocol=swd"
[build]
target = "thumbv6m-none-eabi"
[env]
DEFMT_LOG = "trace"

View File

@@ -0,0 +1,21 @@
[package]
edition = "2021"
name = "embassy-mspm0-l1306-examples"
version = "0.1.0"
license = "MIT OR Apache-2.0"
[dependencies]
embassy-mspm0 = { version = "0.1.0", path = "../../embassy-mspm0", features = ["mspm0l130x", "rt", "time-driver-any"] }
embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["task-arena-size-1024", "arch-cortex-m", "executor-thread", "executor-interrupt"] }
embassy-sync = { version = "0.6.2", path = "../../embassy-sync", features = ["defmt"] }
embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt"] }
panic-halt = "0.2.0"
cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] }
cortex-m-rt = { version = "0.7.0"}
defmt = "0.3"
defmt-rtt = "0.4"
panic-probe = { version = "0.3.2", features = ["print-defmt"] }
panic-semihosting = "0.6.0"
[profile.release]
debug = 2

View File

@@ -0,0 +1,27 @@
# Examples for MSPM0L130x family
Run individual examples with
```
cargo run --bin <module-name>
```
for example
```
cargo run --bin blinky
```
## Checklist before running examples
A large number of the examples are written for the [LP-MSPM0L1306](https://www.ti.com/tool/LP-MSPM0L1306) board.
You might need to adjust `.cargo/config.toml`, `Cargo.toml` and possibly update pin numbers or peripherals to match the specific MCU or board you are using.
* [ ] Update .cargo/config.toml with the correct probe-rs command to use your specific MCU. For example for L1306 it should be `probe-rs run --chip MSPM0L1306`. (use `probe-rs chip list` to find your chip)
* [ ] Update Cargo.toml to have the correct `embassy-mspm0` feature. For example for L1306 it should be `mspm0l1306`. Look in the `Cargo.toml` file of the `embassy-mspm0` project to find the correct feature flag for your chip.
* [ ] If your board has a special clock or power configuration, make sure that it is set up appropriately.
* [ ] If your board has different pin mapping, update any pin numbers or peripherals in the given example code to match your schematic
If you are unsure, please drop by the Embassy Matrix chat for support, and let us know:
* Which example you are trying to run
* Which chip and board you are using
Embassy Chat: https://matrix.to/#/#embassy-rs:matrix.org

View File

@@ -0,0 +1,35 @@
//! This build script copies the `memory.x` file from the crate root into
//! a directory where the linker can always find it at build time.
//! For many projects this is optional, as the linker always searches the
//! project root directory -- wherever `Cargo.toml` is. However, if you
//! are using a workspace or have a more complicated build setup, this
//! build script becomes required. Additionally, by requesting that
//! Cargo re-run the build script whenever `memory.x` is changed,
//! updating `memory.x` ensures a rebuild of the application with the
//! new memory settings.
use std::env;
use std::fs::File;
use std::io::Write;
use std::path::PathBuf;
fn main() {
// Put `memory.x` in our output directory and ensure it's
// on the linker search path.
let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
File::create(out.join("memory.x"))
.unwrap()
.write_all(include_bytes!("memory.x"))
.unwrap();
println!("cargo:rustc-link-search={}", out.display());
// By default, Cargo will re-run a build script whenever
// any file in the project changes. By specifying `memory.x`
// here, we ensure the build script is only re-run when
// `memory.x` is changed.
println!("cargo:rerun-if-changed=memory.x");
println!("cargo:rustc-link-arg-bins=--nmagic");
println!("cargo:rustc-link-arg-bins=-Tlink.x");
println!("cargo:rustc-link-arg-bins=-Tdefmt.x");
}

View File

@@ -0,0 +1,5 @@
MEMORY
{
FLASH : ORIGIN = 0x00000000, LENGTH = 64K
RAM : ORIGIN = 0x20000000, LENGTH = 4K
}

View File

@@ -0,0 +1,25 @@
#![no_std]
#![no_main]
use defmt::*;
use embassy_executor::Spawner;
use embassy_mspm0::gpio::{Level, Output};
use embassy_mspm0::Config;
use embassy_time::Timer;
use {defmt_rtt as _, panic_halt as _};
#[embassy_executor::main]
async fn main(_spawner: Spawner) -> ! {
info!("Hello world!");
let p = embassy_mspm0::init(Config::default());
let mut led1 = Output::new(p.PA0, Level::Low);
led1.set_inversion(true);
loop {
Timer::after_millis(400).await;
info!("Toggle");
led1.toggle();
}
}

View File

@@ -0,0 +1,33 @@
#![no_std]
#![no_main]
use defmt::*;
use embassy_executor::Spawner;
use embassy_mspm0::gpio::{Input, Level, Output, Pull};
use embassy_mspm0::Config;
use {defmt_rtt as _, panic_halt as _};
#[embassy_executor::main]
async fn main(_spawner: Spawner) -> ! {
info!("Hello world!");
let p = embassy_mspm0::init(Config::default());
let led1 = p.PA0;
let s2 = p.PA14;
let mut led1 = Output::new(led1, Level::Low);
let mut s2 = Input::new(s2, Pull::Up);
// led1 is active low
led1.set_high();
loop {
s2.wait_for_falling_edge().await;
info!("Switch 2 was pressed");
led1.toggle();
}
}

View File

@@ -0,0 +1,9 @@
[target.'cfg(all(target_arch = "arm", target_os = "none"))']
# replace MSPM0L2228 with your chip as listed in `probe-rs chip list`
runner = "probe-rs run --restore-unwritten --verify --chip MSPM0L2228 --protocol=swd"
[build]
target = "thumbv6m-none-eabi"
[env]
DEFMT_LOG = "trace"

View File

@@ -0,0 +1,21 @@
[package]
edition = "2021"
name = "embassy-mspm0-l2228-examples"
version = "0.1.0"
license = "MIT OR Apache-2.0"
[dependencies]
embassy-mspm0 = { version = "0.1.0", path = "../../embassy-mspm0", features = ["mspm0l222x", "rt", "time-driver-any"] }
embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["task-arena-size-1024", "arch-cortex-m", "executor-thread", "executor-interrupt"] }
embassy-sync = { version = "0.6.2", path = "../../embassy-sync", features = ["defmt"] }
embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt"] }
panic-halt = "0.2.0"
cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] }
cortex-m-rt = { version = "0.7.0"}
defmt = "0.3"
defmt-rtt = "0.4"
panic-probe = { version = "0.3.2", features = ["print-defmt"] }
panic-semihosting = "0.6.0"
[profile.release]
debug = 2

View File

@@ -0,0 +1,27 @@
# Examples for MSPM0L222x family
Run individual examples with
```
cargo run --bin <module-name>
```
for example
```
cargo run --bin blinky
```
## Checklist before running examples
A large number of the examples are written for the [LP-MSPM0L2228](https://www.ti.com/tool/LP-MSPM0L2228) board.
You might need to adjust `.cargo/config.toml`, `Cargo.toml` and possibly update pin numbers or peripherals to match the specific MCU or board you are using.
* [ ] Update .cargo/config.toml with the correct probe-rs command to use your specific MCU. For example for L2228 it should be `probe-rs run --chip MSPM0L2228`. (use `probe-rs chip list` to find your chip)
* [ ] Update Cargo.toml to have the correct `embassy-mspm0` feature. For example for L2228 it should be `mspm0l2228`. Look in the `Cargo.toml` file of the `embassy-mspm0` project to find the correct feature flag for your chip.
* [ ] If your board has a special clock or power configuration, make sure that it is set up appropriately.
* [ ] If your board has different pin mapping, update any pin numbers or peripherals in the given example code to match your schematic
If you are unsure, please drop by the Embassy Matrix chat for support, and let us know:
* Which example you are trying to run
* Which chip and board you are using
Embassy Chat: https://matrix.to/#/#embassy-rs:matrix.org

View File

@@ -0,0 +1,35 @@
//! This build script copies the `memory.x` file from the crate root into
//! a directory where the linker can always find it at build time.
//! For many projects this is optional, as the linker always searches the
//! project root directory -- wherever `Cargo.toml` is. However, if you
//! are using a workspace or have a more complicated build setup, this
//! build script becomes required. Additionally, by requesting that
//! Cargo re-run the build script whenever `memory.x` is changed,
//! updating `memory.x` ensures a rebuild of the application with the
//! new memory settings.
use std::env;
use std::fs::File;
use std::io::Write;
use std::path::PathBuf;
fn main() {
// Put `memory.x` in our output directory and ensure it's
// on the linker search path.
let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
File::create(out.join("memory.x"))
.unwrap()
.write_all(include_bytes!("memory.x"))
.unwrap();
println!("cargo:rustc-link-search={}", out.display());
// By default, Cargo will re-run a build script whenever
// any file in the project changes. By specifying `memory.x`
// here, we ensure the build script is only re-run when
// `memory.x` is changed.
println!("cargo:rerun-if-changed=memory.x");
println!("cargo:rustc-link-arg-bins=--nmagic");
println!("cargo:rustc-link-arg-bins=-Tlink.x");
println!("cargo:rustc-link-arg-bins=-Tdefmt.x");
}

View File

@@ -0,0 +1,6 @@
MEMORY
{
FLASH : ORIGIN = 0x00000000, LENGTH = 256K
/* Select non-parity range of SRAM due to SRAM_ERR_01 errata in SLAZ758 */
RAM : ORIGIN = 0x20200000, LENGTH = 32K
}

View File

@@ -0,0 +1,25 @@
#![no_std]
#![no_main]
use defmt::*;
use embassy_executor::Spawner;
use embassy_mspm0::gpio::{Level, Output};
use embassy_mspm0::Config;
use embassy_time::Timer;
use {defmt_rtt as _, panic_halt as _};
#[embassy_executor::main]
async fn main(_spawner: Spawner) -> ! {
info!("Hello world!");
let p = embassy_mspm0::init(Config::default());
let mut led1 = Output::new(p.PA0, Level::Low);
led1.set_inversion(true);
loop {
Timer::after_millis(400).await;
info!("Toggle");
led1.toggle();
}
}

View File

@@ -0,0 +1,33 @@
#![no_std]
#![no_main]
use defmt::*;
use embassy_executor::Spawner;
use embassy_mspm0::gpio::{Input, Level, Output, Pull};
use embassy_mspm0::Config;
use {defmt_rtt as _, panic_halt as _};
#[embassy_executor::main]
async fn main(_spawner: Spawner) -> ! {
info!("Hello world!");
let p = embassy_mspm0::init(Config::default());
let led1 = p.PA0;
let s2 = p.PB8;
let mut led1 = Output::new(led1, Level::Low);
let mut s2 = Input::new(s2, Pull::Up);
// led1 is active low
led1.set_high();
loop {
s2.wait_for_falling_edge().await;
info!("Switch 2 was pressed");
led1.toggle();
}
}