Skip to content

Commit 3c928c2

Browse files
authored
upgrade to latest embassy (#2)
* upgrade to latest embassy * try clippy * try again, custom toolchain * wait we need that
1 parent 1c2f08d commit 3c928c2

25 files changed

Lines changed: 171 additions & 159 deletions

.cargo/config.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ runner = 'probe-rs run --chip STM32F405RGTx'
55
target = "thumbv7em-none-eabi"
66

77
[env]
8-
DEFMT_LOG = "trace"
8+
DEFMT_LOG = "info"
99

1010
[unstable]
1111
build-std-features = ["panic_immediate_abort"]

.github/workflows/rust-ci.yml

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,31 @@
11
name: Rust CI
22

33
on:
4-
push:
5-
branches:
6-
- main
7-
- develop
8-
pull_request:
9-
branches:
10-
- main
11-
- develop
4+
push:
5+
branches:
6+
- main
7+
- develop
8+
pull_request:
9+
branches:
10+
- main
11+
- develop
1212

1313
jobs:
14-
build:
15-
runs-on: ubuntu-latest
14+
build:
15+
runs-on: ubuntu-latest
1616

17-
steps:
18-
- name: Setup Rust
19-
uses: actions/checkout@v3
20-
with:
21-
submodules: recursive
22-
- name: Build
23-
run: cargo build --verbose --workspace --all --all-features
24-
# - name: Test
25-
# run: cargo test --verbose
26-
- name: Clippy
27-
run: cargo clippy --all-features --all --workspace
28-
- name: Format
29-
run: cargo fmt --verbose --all --check
17+
steps:
18+
- name: Clone repo
19+
uses: actions/checkout@v6
20+
with:
21+
submodules: recursive
22+
- name: Setup Rust
23+
uses: actions-rust-lang/setup-rust-toolchain@v1
24+
- name: Build
25+
run: cargo build --verbose --workspace --all --all-features
26+
# - name: Test
27+
# run: cargo test --verbose
28+
- name: Clippy
29+
run: cargo clippy --all-features --all --workspace
30+
- name: Format
31+
run: cargo fmt --verbose --all --check

Cargo.toml

Lines changed: 22 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,30 @@
11
[workspace]
22
members = ["msb-fw-rs","crates/*"]
3-
resolver = "2"
3+
resolver = "3"
44

55
[workspace.dependencies]
6-
embassy-stm32 = { version = "0.1.0", features = ["defmt", "stm32f405rg", "unstable-pac", "memory-x", "time", "time-driver-any", "exti"] }
7-
embassy-sync = { version = "0.6.1", features = ["defmt"] }
8-
embassy-executor = { version = "0.7.0", features = ["nightly", "arch-cortex-m", "executor-thread", "executor-interrupt", "defmt"] }
9-
embassy-time = { version = "0.4.0", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] }
10-
embassy-embedded-hal = { version = "0.2.0", features = ["defmt"] }
11-
embassy-futures = { version = "0.1.1", features = ["defmt"] }
12-
13-
defmt = "0.3.10"
14-
defmt-rtt = "0.4.1"
15-
16-
cortex-m = { version = "0.7.7", features = ["inline-asm", "critical-section-single-core"] }
17-
cortex-m-rt = "0.7.5"
18-
embedded-hal = { version = "1.0.0", features = ["defmt-03"] }
19-
embedded-hal-bus = { version = "0.2", features = ["async", "defmt-03"] }
20-
embedded-io = { version = "0.6.1", features = ["defmt-03"] }
21-
embedded-io-async = { version = "0.6.1", features = ["defmt-03"] }
22-
panic-probe = { version = "0.3.2", features = ["print-defmt", "defmt-error"] }
23-
heapless = { version = "0.8.0", default-features = false }
24-
static_cell = "2.1.0"
6+
embassy-stm32 = { version = "0.6.0", features = ["defmt", "stm32f405rg", "unstable-pac", "memory-x", "time", "time-driver-any", "exti"] }
7+
embassy-sync = { version = "0.8.0", features = ["defmt"] }
8+
embassy-executor = { version = "0.10.0", features = ["executor-thread", "executor-interrupt", "defmt", "embassy-time-driver", "platform-cortex-m"] }
9+
embassy-time = { version = "0.5.1", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] }
10+
embassy-embedded-hal = { version = "0.6.0", features = ["defmt", "time"] }
11+
embassy-futures = { version = "0.1.2", features = ["defmt"] }
12+
13+
defmt = "1"
14+
defmt-rtt = "1"
15+
16+
cortex-m = { version = "0.7", features = ["inline-asm", "critical-section-single-core"] }
17+
cortex-m-rt = "0.7"
18+
embedded-hal = { version = "1", features = ["defmt-03"] }
19+
embedded-hal-bus = { version = "0.3", features = ["async", "defmt-03"] }
20+
embedded-io = { version = "0.7", features = ["defmt"] }
21+
embedded-io-async = { version = "0.7", features = ["defmt"] }
22+
panic-probe = { version = "1", features = ["print-defmt", "defmt-error"] }
23+
heapless = { version = "0.9", default-features = false }
24+
static_cell = "2.1"
2525
#chrono = { version = "^0.4", default-features = false}
26-
embedded-hal-async = {version = "1.0.0", features = ["defmt-03"] }
27-
bitfield = "^0.17.0"
28-
29-
30-
[patch.crates-io]
31-
embassy-stm32 = {git = "https://github.com/embassy-rs/embassy", rev = "b127ca9844a7e4e9079800be81d173e2725066c6"}
32-
embassy-sync = {git = "https://github.com/embassy-rs/embassy", rev = "b127ca9844a7e4e9079800be81d173e2725066c6"}
33-
embassy-executor = {git = "https://github.com/embassy-rs/embassy", rev = "b127ca9844a7e4e9079800be81d173e2725066c6"}
34-
embassy-time = {git = "https://github.com/embassy-rs/embassy", rev = "b127ca9844a7e4e9079800be81d173e2725066c6"}
35-
embassy-embedded-hal = {git = "https://github.com/embassy-rs/embassy", rev = "b127ca9844a7e4e9079800be81d173e2725066c6"}
36-
embassy-futures = {git = "https://github.com/embassy-rs/embassy", rev = "b127ca9844a7e4e9079800be81d173e2725066c6"}
37-
38-
26+
embedded-hal-async = {version = "1", features = ["defmt-03"] }
27+
bitfield = "0.19"
3928

4029
[profile.release]
4130
opt-level = "s"

README.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ To lint and check stuff, run `cargo clippy`.
2121
### On car stuff
2222

2323
To run a RTT terminal dedicated:
24-
`cargo embed --release --config rtt`
24+
`cargo embed --release rtt`
2525

2626
To run a GDB terminal dedicated:
27-
`cargo embed --release --config gdb`
27+
`cargo embed --release gdb`
2828

2929
To flash and leave code:
30-
`cargo embed --release --config `
30+
`cargo embed --release`
3131

3232

3333

@@ -56,3 +56,14 @@ This structure has multiple benefits, including:
5656
- Shared `target` folder meaning a shared build cache for quicker and space-saving builds
5757
- Other quirks, such as vscode `settings.json` and `config.toml`, are shared between projects
5858

59+
60+
### Versioning
61+
62+
Updating versions is as follows
63+
64+
1. Update the rust-toolchain to the version found in embassy repo
65+
2. Update all embassy versions to the versions found in the embassy repo, use x.y.z, in main Cargo.toml
66+
3. Update all features, especially ones that say the version in them (ex. "defmt-03")
67+
3. Update major package versions of other projects, use x.y, in main Cargo.toml
68+
4. Update package versions of other projects, in individual Cargo.toml
69+
4. Fix any build issues

crates/lsm6dso-ner/Cargo.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
[package]
22
name = "lsm6dso-ner"
33
version = "0.1.0"
4-
edition = "2021"
4+
edition = "2024"
55

66
[dependencies]
77
arrayref = "0.3.8"
88
embedded-hal-async.workspace = true
9-
10-

crates/pca9539-ner/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
[package]
22
name = "pca9539-ner"
33
version = "0.1.0"
4-
edition = "2021"
4+
edition = "2024"
55

66
[dependencies]
77
embedded-hal-async.workspace = true
8-
embedded-hal.workspace = true
8+
embedded-hal.workspace = true

crates/sht3x-ner/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "sht3x-ner"
33
version = "0.1.0"
4-
edition = "2021"
4+
edition = "2024"
55

66
[dependencies]
77
defmt.workspace = true

crates/vl6180x-ner/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
[package]
22
name = "vl6180x-ner"
33
version = "0.1.0"
4-
edition = "2021"
4+
edition = "2024"
55

66
[dependencies]
77
embedded-hal-async.workspace = true
88
embedded-hal.workspace = true
99
int-enum = {version = "1.1.2", default-features = false}
10-
#int-enum-impl = "0.5.0"
10+
#int-enum-impl = "0.5.0"

crates/vl6180x-ner/src/config.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ impl Config {
139139
pub fn set_range_inter_measurement_period(&mut self, time_ms: u16) -> Result<(), Error<()>> {
140140
let min_eq_val = ((self.range_max_convergence_time + 5) as f32 / 0.9) as u16;
141141
let min = if 10 < min_eq_val { min_eq_val } else { 10 };
142-
if time_ms % 10 != 0 || time_ms < min || time_ms > 2550 {
142+
if !time_ms.is_multiple_of(10) || time_ms < min || time_ms > 2550 {
143143
return Err(Error::InvalidConfigurationValue(time_ms));
144144
}
145145
self.range_inter_measurement_period = time_ms;
@@ -257,7 +257,7 @@ impl Config {
257257
pub fn set_ambient_inter_measurement_period(&mut self, time_ms: u16) -> Result<(), Error<()>> {
258258
let min_eq_val = ((self.ambient_integration_period as f32 * 1.1) / 0.9) as u16;
259259
let min = if 10 < min_eq_val { min_eq_val } else { 10 };
260-
if time_ms % 10 != 0 || time_ms < min || time_ms > 2560 {
260+
if !time_ms.is_multiple_of(10) || time_ms < min || time_ms > 2560 {
261261
return Err(Error::InvalidConfigurationValue(time_ms));
262262
}
263263
self.ambient_inter_measurement_period = time_ms;

crates/vl6180x-ner/src/device_status.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,10 @@ where
9595

9696
async fn wait_device_booted(&mut self) -> Result<(), E> {
9797
loop {
98-
if let Ok(result) = self.read_named_register(SYSTEM__FRESH_OUT_OF_RESET).await {
99-
if result == 0x01 {
100-
break;
101-
}
98+
if let Ok(result) = self.read_named_register(SYSTEM__FRESH_OUT_OF_RESET).await
99+
&& result == 0x01
100+
{
101+
break;
102102
}
103103
}
104104
Ok(())

0 commit comments

Comments
 (0)