From 396dacc0de4c0d3d34eb4f61e70a9d29bfb9727e Mon Sep 17 00:00:00 2001 From: astapleton Date: Fri, 31 May 2024 14:48:56 -0700 Subject: [PATCH] ci: update CI tooling --- .github/workflows/ci.yml | 29 +++++++++----------------- .github/workflows/clippy.yml | 18 ++++++---------- .github/workflows/nightly.yml | 32 ++++++++++------------------- .github/workflows/rustfmt.yml | 18 +++++----------- .github/workflows/version-match.yml | 6 +++--- examples/blinky.rs | 13 ++++++------ examples/utilities/mod.rs | 2 -- examples/utilities/power.rs | 15 -------------- src/lib.rs | 12 ++++++----- 9 files changed, 48 insertions(+), 97 deletions(-) delete mode 100644 examples/utilities/power.rs diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bcc5d31..63cfc57 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,6 +1,6 @@ on: push: - branches: [ staging, trying, master ] + branches: [ master ] pull_request: name: Continuous integration @@ -22,31 +22,22 @@ jobs: FLAGS: rt steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Cache cargo registry and index - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: | ~/.cargo/registry ~/.cargo/git key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml') }} - name: Cache cargo build - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: target key: ${{ runner.os }}-target-${{ matrix.rust }}-${{ hashFiles('**/Cargo.toml') }}-memory-${{ hashFiles('**/*.x') }} - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: ${{ matrix.rust }} - target: thumbv8m.main-none-eabihf - override: true - - uses: actions-rs/cargo@v1 - with: - use-cross: true - command: build - args: --verbose --release --examples --target thumbv8m.main-none-eabihf --features ${{ matrix.mcu }},${{ env.FLAGS }} - - uses: actions-rs/cargo@v1 - with: - command: test - args: --lib --target x86_64-unknown-linux-gnu --features ${{ matrix.mcu }},${{ env.FLAGS }} + - name: Install thumbv8m rust target + run: rustup target add thumbv8m.main-none-eabihf + - name: Build + run: cargo build --verbose --release --examples --target thumbv8m.main-none-eabihf --features ${{ matrix.mcu }},${{ env.FLAGS }} + - name: Test + run: cargo test --lib --target x86_64-unknown-linux-gnu --features ${{ matrix.mcu }},${{ env.FLAGS }} diff --git a/.github/workflows/clippy.yml b/.github/workflows/clippy.yml index b6b2be2..0e88222 100644 --- a/.github/workflows/clippy.yml +++ b/.github/workflows/clippy.yml @@ -1,7 +1,7 @@ on: pull_request: push: - branches: [staging, trying, master] + branches: [master] name: Clippy @@ -9,14 +9,8 @@ jobs: clippy_check: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - components: clippy - toolchain: 1.69.0 - target: thumbv8m.main-none-eabihf - override: true - - uses: actions-rs/clippy-check@v1 - with: - token: ${{ secrets.GITHUB_TOKEN }} - args: --examples --target thumbv8m.main-none-eabihf --features=rt,stm32h503 -- -D warnings + - uses: actions/checkout@v4 + - name: Install thumb8 rust target + run: rustup target add thumbv8m.main-none-eabihf + - name: Cargo clippy + run: cargo clippy --examples --target thumbv8m.main-none-eabihf --features=rt,stm32h503 -- -D warnings diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 7a5c1ab..eac72d9 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -14,9 +14,6 @@ jobs: matrix: mcu: - stm32h503 - - stm32h562 - - stm32h563 - - stm32h573 logging: # Example logging options - log-itm - log-semihost @@ -25,31 +22,24 @@ jobs: FLAGS: rt steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Cache cargo registry and index - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: | ~/.cargo/registry ~/.cargo/git key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml') }} - name: Cache cargo build - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: target key: ${{ runner.os }}-target-nightly-${{ hashFiles('**/Cargo.toml') }}-memory-${{ hashFiles('**/*.x') }} - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: nightly - target: thumbv8m.main-none-eabihf - override: true - - uses: actions-rs/cargo@v1 - with: - use-cross: true - command: build - args: --verbose --release --examples --target thumbv8m.main-none-eabihf --features ${{ matrix.mcu }},${{ env.FLAGS }},${{ matrix.logging }} - - uses: actions-rs/cargo@v1 - with: - command: test - args: --lib --target x86_64-unknown-linux-gnu --features ${{ matrix.mcu }},${{ env.FLAGS }} + - name: Install nightly toolchain + run: rustup toolchain install nightly + - name: Install thumbv8m rust target + run: rustup +nightly target add thumbv8m.main-none-eabihf + - name: Build + run: cargo +nightly build --verbose --release --examples --target thumbv8m.main-none-eabihf --features ${{ matrix.mcu }},${{ env.FLAGS }},${{ matrix.logging }} + - name: Test + run: cargo +nightly test --lib --target x86_64-unknown-linux-gnu --features ${{ matrix.mcu }},${{ env.FLAGS }} diff --git a/.github/workflows/rustfmt.yml b/.github/workflows/rustfmt.yml index 544a598..ba5d20c 100644 --- a/.github/workflows/rustfmt.yml +++ b/.github/workflows/rustfmt.yml @@ -1,23 +1,15 @@ on: push: - branches: [ staging, trying, master ] + branches: [ master ] pull_request: -name: Code formatting check +name: rustfmt jobs: fmt: name: Rustfmt runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - - run: rustup component add rustfmt - - uses: actions-rs/cargo@v1 - with: - command: fmt - args: --all -- --check + - uses: actions/checkout@v4 + - name: Check formatting + run: cargo fmt --all -- --check diff --git a/.github/workflows/version-match.yml b/.github/workflows/version-match.yml index ec06533..b819ea3 100644 --- a/.github/workflows/version-match.yml +++ b/.github/workflows/version-match.yml @@ -1,6 +1,6 @@ on: push: - branches: [ staging, trying, master ] + branches: [ master ] pull_request: name: Verify rustc versions match @@ -10,6 +10,6 @@ jobs: name: Rustc version match runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 - run: node tools/verify-rust-version.js diff --git a/examples/blinky.rs b/examples/blinky.rs index e99f3db..6c846fd 100644 --- a/examples/blinky.rs +++ b/examples/blinky.rs @@ -10,23 +10,22 @@ use stm32h5xx_hal::pac; fn main() -> ! { utilities::logger::init(); - let cp = cortex_m::Peripherals::take().unwrap(); let dp = pac::Peripherals::take().unwrap(); // TODO: Power/clock config is required before blinky can... blink. - dp.GPIOA.moder.write(|w| w.mode5().variant(1)); // output - dp.GPIOA.pupdr.write(|w| w.pupd5().variant(1)); // pull-up + dp.GPIOA.moder().write(|w| w.mode5().output()); // output + dp.GPIOA.pupdr().write(|w| w.pupd5().pull_up()); // pull-up // dp.GPIOA.odr.write(|w| w.od5().set_bit()); loop { - dp.GPIOA.odr.write(|w| w.od5().clear_bit()); - for _ in 0..1_000_0 { + dp.GPIOA.odr().write(|w| w.od5().low()); + for _ in 0..10_000 { cortex_m::asm::nop(); } - dp.GPIOA.odr.write(|w| w.od5().set_bit()); - for _ in 0..1_000_0 { + dp.GPIOA.odr().write(|w| w.od5().high()); + for _ in 0..10_000 { cortex_m::asm::nop(); } } diff --git a/examples/utilities/mod.rs b/examples/utilities/mod.rs index 39e92a3..35e91cb 100644 --- a/examples/utilities/mod.rs +++ b/examples/utilities/mod.rs @@ -1,5 +1,3 @@ //! Utilities for examples pub mod logger; -#[macro_use] -mod power; diff --git a/examples/utilities/power.rs b/examples/utilities/power.rs deleted file mode 100644 index a08d9c5..0000000 --- a/examples/utilities/power.rs +++ /dev/null @@ -1,15 +0,0 @@ -//! Power Configuration for examples - -macro_rules! example_power { - ($pwr:ident) => {{ - cfg_if::cfg_if! { - if #[cfg(all(feature = "smps", feature = "example-smps"))] { - $pwr.smps() - } else if #[cfg(all(feature = "smps", feature = "example-ldo"))] { - $pwr.ldo() - } else { - $pwr - } - } - }}; -} diff --git a/src/lib.rs b/src/lib.rs index e759a33..33247e1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -18,11 +18,13 @@ compile_error!("Cannot not select both rm0492 and rm0481"); #[cfg(feature = "stm32h503")] pub use stm32h5::stm32h503 as stm32; -#[cfg(any( - feature = "stm32h562", - feature = "stm32h563", - feature = "stm32h573", -))] +#[cfg(feature = "stm32h562")] +pub use stm32h5::stm32h562 as stm32; + +#[cfg(feature = "stm32h563")] +pub use stm32h5::stm32h563 as stm32; + +#[cfg(feature = "stm32h573")] pub use stm32h5::stm32h573 as stm32; #[cfg(feature = "device-selected")]