From 1780cd07a4a507ca0149d19c5c9699b1da7b609c Mon Sep 17 00:00:00 2001 From: Andelf Date: Mon, 13 May 2024 22:38:53 +0800 Subject: [PATCH] demo: add ch32v208 demo to ci --- examples/ch32v208/.cargo/config.toml | 6 ++++++ examples/ch32v208/Cargo.toml | 31 ++++++++++++++++++++++++++++ examples/ch32v208/build.rs | 5 +++++ examples/ch32v208/src/bin/blinky.rs | 21 +++++++++++++++++++ 4 files changed, 63 insertions(+) create mode 100644 examples/ch32v208/.cargo/config.toml create mode 100644 examples/ch32v208/Cargo.toml create mode 100644 examples/ch32v208/build.rs create mode 100644 examples/ch32v208/src/bin/blinky.rs diff --git a/examples/ch32v208/.cargo/config.toml b/examples/ch32v208/.cargo/config.toml new file mode 100644 index 0000000..d12976a --- /dev/null +++ b/examples/ch32v208/.cargo/config.toml @@ -0,0 +1,6 @@ +[build] +target = "riscv32imac-unknown-none-elf" + +[target."riscv32imac-unknown-none-elf"] +runner = "wlink -v flash --enable-sdi-print --watch-serial" +# runner = "wlink -v flash" diff --git a/examples/ch32v208/Cargo.toml b/examples/ch32v208/Cargo.toml new file mode 100644 index 0000000..c8d072f --- /dev/null +++ b/examples/ch32v208/Cargo.toml @@ -0,0 +1,31 @@ +[package] +name = "ch32v208-examples" +version = "0.1.0" +edition = "2021" + +[dependencies] +ch32-hal = { path = "../../", features = [ + "ch32v208wbu6", + "defmt", + "embassy", + "rt", +], default-features = false } +embassy-executor = { version = "0.5.0", features = [ + "nightly", + "integrated-timers", + "arch-riscv32", + "executor-thread", +] } +embassy-time = { version = "0.3.0" } + +qingke-rt = { version = "0.2.0" } +qingke = { version = "0.2.0" } +# qingke-rt = { version = "0.2.0", path = "../../../qingke/qingke-rt" } +# qingke = { version = "0.2.0", path = "../../../qingke" } + +panic-halt = "0.2.0" + +[profile.release] +strip = false # symbols are not flashed to the microcontroller, so don't strip them. +lto = true +opt-level = "z" # Optimize for size. diff --git a/examples/ch32v208/build.rs b/examples/ch32v208/build.rs new file mode 100644 index 0000000..298d6bb --- /dev/null +++ b/examples/ch32v208/build.rs @@ -0,0 +1,5 @@ +fn main() { + // println!("cargo:rustc-link-arg-bins=--nmagic"); + println!("cargo:rustc-link-arg-bins=-Tlink.x"); + // println!("cargo:rustc-link-arg-bins=-Tdefmt.x"); +} diff --git a/examples/ch32v208/src/bin/blinky.rs b/examples/ch32v208/src/bin/blinky.rs new file mode 100644 index 0000000..338e93a --- /dev/null +++ b/examples/ch32v208/src/bin/blinky.rs @@ -0,0 +1,21 @@ +#![no_std] +#![no_main] +#![feature(type_alias_impl_trait)] + +use hal::gpio::{Level, Output}; +use qingke::riscv; +use {ch32_hal as hal, panic_halt as _}; + +#[qingke_rt::entry] +fn main() -> ! { + let p = hal::init(Default::default()); + + let mut led = Output::new(p.PB8, Level::Low, Default::default()); + loop { + led.toggle(); + + unsafe { + riscv::asm::delay(1000000); + } + } +}