Skip to content

Commit

Permalink
demo: add ch32v208 demo to ci
Browse files Browse the repository at this point in the history
  • Loading branch information
andelf committed May 13, 2024
1 parent 2a43d85 commit 1780cd0
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 0 deletions.
6 changes: 6 additions & 0 deletions examples/ch32v208/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -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"
31 changes: 31 additions & 0 deletions examples/ch32v208/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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.
5 changes: 5 additions & 0 deletions examples/ch32v208/build.rs
Original file line number Diff line number Diff line change
@@ -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");
}
21 changes: 21 additions & 0 deletions examples/ch32v208/src/bin/blinky.rs
Original file line number Diff line number Diff line change
@@ -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);
}
}
}

0 comments on commit 1780cd0

Please sign in to comment.