Skip to content

Commit

Permalink
chore: update targets for example and deps
Browse files Browse the repository at this point in the history
  • Loading branch information
Codetector1374 committed Nov 3, 2024
1 parent 144a644 commit 9ee0488
Show file tree
Hide file tree
Showing 16 changed files with 111 additions and 83 deletions.
1 change: 0 additions & 1 deletion .github/workflows/build-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ jobs:
rustup component add rust-src
rustup update
rustup target add riscv32imc-unknown-none-elf
rustup target add riscv32imfc-unknown-none-elf
rustup target add riscv32i-unknown-none-elf
- name: Fetch Deps
# if this is a pull request
Expand Down
13 changes: 8 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,17 @@ jobs:
- chip: ch32v208wbu6
target: riscv32imc-unknown-none-elf
- chip: ch32v303vct6
target: riscv32imfc-unknown-none-elf
# use rv32imc because ri32imfc does not exist, hal should not use FP anyways
target: riscv32imc-unknown-none-elf
- chip: ch32v305fbp6
target: riscv32imfc-unknown-none-elf
# use rv32imc because ri32imfc does not exist
target: riscv32imc-unknown-none-elf
- chip: ch32v307vct6
target: riscv32imfc-unknown-none-elf
# use rv32imc because ri32imfc does not exist
target: riscv32imc-unknown-none-elf
- chip: ch32x035f7p6
target: riscv32imfc-unknown-none-elf
# use rv32imc because ri32imfc does not exist
target: riscv32imc-unknown-none-elf
- chip: ch641
target: riscv32i-unknown-none-elf
runs-on: ubuntu-latest
Expand All @@ -58,7 +62,6 @@ jobs:
rustup component add rust-src
rustup update
rustup target add riscv32imc-unknown-none-elf
rustup target add riscv32imfc-unknown-none-elf
rustup target add riscv32i-unknown-none-elf
- name: Fetch Deps
# if this is a pull request
Expand Down
12 changes: 7 additions & 5 deletions examples/ch32l103/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,17 @@ embassy-executor = { version = "0.6.0", features = [
] }
embassy-time = { version = "0.3.2" }

qingke-rt = { version = "0.4.0" }
qingke = "0.4.0"
# qingke-rt = { version = "0.4.0", path = "../../../qingke/qingke-rt" }
# qingke = { version = "0.4.0", path = "../../../qingke" }
# This is okay because we should automatically use whatever ch32-hal uses
qingke = "*"
qingke-rt = "*"

panic-halt = "0.2.0"
panic-halt = "1.0"
embedded-hal = "1.0.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.

[profile.dev]
opt-level = 1 # At least some opt so binary is not insane
11 changes: 5 additions & 6 deletions examples/ch32v003/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,18 @@ ch32-hal = { path = "../../", features = [
] }
embassy-executor = { version = "0.6.0", features = [
"integrated-timers",
"arch-riscv32",
"arch-spin",
"executor-thread",
"task-arena-size-128", # or better use nightly, but fails on recent Rust versions
] }
embassy-time = { version = "0.3.0" }

qingke-rt = { version = "0.4.0", features = ["highcode"] }
qingke = "0.4.0"
# qingke-rt = { version = "0.4.0", path = "../../../qingke/qingke-rt" }
# qingke = { version = "0.4.0", path = "../../../qingke" }
# This is okay because we should automatically use whatever ch32-hal uses
qingke = "*"
qingke-rt = { version = "*", features = ["highcode"] }


panic-halt = "0.2.0"
panic-halt = "1.0"

embedded-hal = "1.0.0"

Expand Down
11 changes: 5 additions & 6 deletions examples/ch32v103/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,20 @@ ch32-hal = { path = "../../", features = [
] }
embassy-executor = { version = "0.6.0", features = [
"integrated-timers",
"arch-riscv32",
"arch-spin",
"executor-thread",
] }
embassy-time = { version = "0.3.2" }

qingke-rt = "0.4.0"
qingke = "0.4.0"
# qingke-rt = { version = "0.4.0", path = "../../../qingke/qingke-rt" }
# qingke = { version = "0.4.0", path = "../../../qingke" }
# This is okay because we should automatically use whatever ch32-hal uses
qingke-rt = "*"
qingke = "*"

# Not working for now
# defmt = "0.3"
# defmt-rtt = "0.4"

panic-halt = "0.2.0"
panic-halt = "1.0"

display-interface-spi = "0.5.0"
mipidsi = "0.7.1"
Expand Down
15 changes: 6 additions & 9 deletions examples/ch32v203/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,22 @@ ch32-hal = { path = "../../", features = [
"rt",
"time-driver-tim2",
], default-features = false }
#ch32-metapac = { features = [
# "memory-x",
# "rt",
#], path = "../../../ch32-data/build/ch32-metapac" }

embassy-executor = { version = "0.6.0", features = [
"integrated-timers",
"arch-riscv32",
"executor-thread",
] }

embassy-time = { version = "0.3.2" }
embassy-usb = { version = "0.3.0" }
embassy-futures = { version = "0.1.0" }

qingke-rt = "0.4.0"
qingke = "0.4.0"
#qingke-rt = { version = "0.4.0", path = "../../../qingke/qingke-rt" }
# qingke = { version = "0.4.0", path = "../../../qingke" }
# This is okay because we should automatically use whatever ch32-hal uses
qingke-rt = "*"
qingke = "*"

panic-halt = "0.2.0"
panic-halt = "1.0"

display-interface-spi = "0.5.0"
embedded-hal = "1.0.0"
Expand Down
9 changes: 4 additions & 5 deletions examples/ch32v208/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@ embassy-executor = { version = "0.6.0", features = [
] }
embassy-time = { version = "0.3.2" }

qingke-rt = "0.4.0"
qingke = "0.4.0"
# qingke-rt = { version = "0.4.0", path = "../../../qingke/qingke-rt" }
# qingke = { version = "0.4.0", path = "../../../qingke" }
# This is okay because we should automatically use whatever ch32-hal uses
qingke-rt = "*"
qingke = "*"

panic-halt = "0.2.0"
panic-halt = "1.0"

[profile.release]
strip = false # symbols are not flashed to the microcontroller, so don't strip them.
Expand Down
5 changes: 4 additions & 1 deletion examples/ch32v305/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
[build]
target = "riscv32imfc-unknown-none-elf"
target = "riscv32imfc-unknown-none-elf.json"

[unstable]
build-std = ["core"]

[target.riscv32imfc-unknown-none-elf]
# runner = "wlink flash --enable-sdi-print --watch-serial"
Expand Down
20 changes: 10 additions & 10 deletions examples/ch32v305/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,28 @@ embassy-executor = { version = "0.6.0", features = [
] }
embassy-time = { version = "0.3.2" }

qingke-rt = "0.4.0"
qingke = "0.4.0"
# qingke-rt = { version = "0.4.0", path = "../../../qingke/qingke-rt" }
# qingke = { version = "0.4.0", path = "../../../qingke" }
qingke-rt = "*"
qingke = "*"

# Not working for now
# defmt = "0.3"
# defmt-rtt = "0.4"
panic-halt = "1.0"

panic-halt = "0.2.0"
portable-atomic = { version = "1", default-features = false, features = [
"critical-section",
] }

display-interface-spi = "0.5.0"
mipidsi = "0.7.1"
embedded-graphics = "0.8.1"
embedded-hal-bus = "0.1.0"
embedded-hal = "1.0.0"
micromath = "2.1.0"
nb = "1.1.0"
heapless = "0.8.0"
heapless = { version = "0.8.0", features = ["portable-atomic"] }


[profile.release]
strip = false # symbols are not flashed to the microcontroller, so don't strip them.
lto = true
opt-level = "z" # Optimize for size.

[profile.dev]
opt-level = 2 # At least some opt so binary size is not insane
19 changes: 19 additions & 0 deletions examples/ch32v305/riscv32imfc-unknown-none-elf.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"arch": "riscv32",
"atomic-cas": false,
"cpu": "generic-rv32",
"crt-objects-fallback": "false",
"data-layout": "e-m:e-p:32:32-i64:64-n32-S128",
"eh-frame-header": false,
"emit-debug-gdb-scripts": false,
"features": "+m,+f,+c,+forced-atomics",
"is-builtin": false,
"linker": "rust-lld",
"linker-flavor": "gnu-lld",
"llvm-abiname": "ilp32f",
"llvm-target": "riscv32",
"max-atomic-width": 32,
"panic-strategy": "abort",
"relocation-model": "static",
"target-pointer-width": "32"
}
5 changes: 4 additions & 1 deletion examples/ch32v307/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
[build]
target = "riscv32imfc-unknown-none-elf"
target = "riscv32imfc-unknown-none-elf.json"

[unstable]
build-std = ["core"]

[target.riscv32imfc-unknown-none-elf]
runner = "wlink flash --enable-sdi-print --watch-serial"
Expand Down
13 changes: 4 additions & 9 deletions examples/ch32v307/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,14 @@ embassy-time = "0.3.2"
embassy-usb = "0.3.0"
nb = "1.1.0"

qingke = "0.4.0"
qingke-rt = "0.4.0"
# This is okay because we should automatically use whatever ch32-hal uses
qingke = "*"
qingke-rt = "*"

# Not working for now
# defmt = "0.3"
# defmt-rtt = "0.4"

panic-halt = "0.2.0"
panic-halt = "1.0"

display-interface-spi = "0.5.0"
mipidsi = "0.7.1"
embedded-graphics = "0.8.1"
embedded-hal-bus = "0.2.0"
# for ssd1306
ssd1306 = "0.9"

Expand Down
19 changes: 19 additions & 0 deletions examples/ch32v307/riscv32imfc-unknown-none-elf.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"arch": "riscv32",
"atomic-cas": false,
"cpu": "generic-rv32",
"crt-objects-fallback": "false",
"data-layout": "e-m:e-p:32:32-i64:64-n32-S128",
"eh-frame-header": false,
"emit-debug-gdb-scripts": false,
"features": "+m,+f,+c,+forced-atomics",
"is-builtin": false,
"linker": "rust-lld",
"linker-flavor": "gnu-lld",
"llvm-abiname": "ilp32f",
"llvm-target": "riscv32",
"max-atomic-width": 32,
"panic-strategy": "abort",
"relocation-model": "static",
"target-pointer-width": "32"
}
9 changes: 3 additions & 6 deletions examples/ch32x035/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,14 @@ embassy-executor = { version = "0.6.0", features = [
] }
embassy-time = { version = "0.3.2" }

qingke-rt = "0.4.0"
qingke = "0.4.0"
# qingke-rt = { version = "0.4.0", path = "../../../qingke/qingke-rt" }
# qingke = { version = "0.4.0", path = "../../../qingke" }
qingke-rt = "*"
qingke = "*"

panic-halt = "0.2.0"
panic-halt = "1.0"

display-interface-spi = "0.5.0"
mipidsi = "0.7.1"
embedded-graphics = "0.8.1"
embedded-hal-bus = "0.2.0"
embedded-hal = "1.0.0"
heapless = "0.8.0"

Expand Down
13 changes: 4 additions & 9 deletions examples/ch641/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,12 @@ embassy-executor = { version = "0.6.0", features = [
"task-arena-size-128", # or better use nightly, but fails on recent Rust versions
] }
embassy-time = { version = "0.3.2" }

qingke-rt = "0.4.0"
qingke = "0.4.0"
# qingke-rt = { version = "0.4.0", path = "../../../qingke/qingke-rt" }
# qingke = { version = "0.4.0", path = "../../../qingke" }


panic-halt = "0.2.0"

embedded-hal = "1.0.0"

qingke-rt = "*"
qingke = "*"

panic-halt = "1.0"

[profile.release]
strip = false # symbols are not flashed to the microcontroller, so don't strip them.
Expand Down
19 changes: 9 additions & 10 deletions src/embassy/time_driver_systick.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//! SysTick-based time driver.

use core::arch::asm;
use core::cell::Cell;
use core::sync::atomic::{AtomicU32, AtomicU8, Ordering};
use core::{mem, ptr};
Expand All @@ -9,11 +8,9 @@ use critical_section::{CriticalSection, Mutex};
use embassy_time_driver::{AlarmHandle, Driver};
use pac::systick::vals;
use qingke::interrupt::Priority;
#[cfg(feature = "highcode")]
use qingke_rt::highcode;
use qingke_rt::interrupt;

use crate::{pac, println};
use crate::pac;

pub const ALARM_COUNT: usize = 1;

Expand Down Expand Up @@ -130,20 +127,21 @@ impl Driver for SystickDriver {
let period = self.period.load(Ordering::Relaxed) as u64;
rb.cnt().read() / period
}

unsafe fn allocate_alarm(&self) -> Option<AlarmHandle> {
let id = self.alarm_count.fetch_update(Ordering::AcqRel, Ordering::Acquire, |x| {
let id = critical_section::with(|_| {
let x = self.alarm_count.load(Ordering::Acquire);
if x < ALARM_COUNT as u8 {
Some(x + 1)
self.alarm_count.store(x + 1, Ordering::Release);
Some(x)
} else {
None
}
});

match id {
Ok(id) => Some(AlarmHandle::new(id)),
Err(_) => None,
}
id.map(|id| AlarmHandle::new(id))
}

fn set_alarm_callback(&self, alarm: AlarmHandle, callback: fn(*mut ()), ctx: *mut ()) {
critical_section::with(|cs| {
let alarm = self.get_alarm(cs, alarm);
Expand All @@ -152,6 +150,7 @@ impl Driver for SystickDriver {
alarm.ctx.set(ctx);
})
}

fn set_alarm(&self, alarm: AlarmHandle, timestamp: u64) -> bool {
critical_section::with(|cs| {
let rb = &crate::pac::SYSTICK;
Expand Down

0 comments on commit 9ee0488

Please sign in to comment.