From 9ea766f0b8d2d9da0de8a445cfd27f7ea86693a4 Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Tue, 8 Feb 2022 12:04:29 +0100 Subject: [PATCH 1/3] Adding mainboard LED toggle on fan NACK --- src/hardware/chassis_fans.rs | 23 ++++++++++++++++++----- src/hardware/mod.rs | 5 +++++ src/hardware/setup.rs | 14 +++++++++++++- 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/src/hardware/chassis_fans.rs b/src/hardware/chassis_fans.rs index 3b716d54..504231e5 100644 --- a/src/hardware/chassis_fans.rs +++ b/src/hardware/chassis_fans.rs @@ -4,7 +4,8 @@ //! Copyright (C) 2020 QUARTIQ GmbH - All Rights Reserved //! Unauthorized usage, editing, or copying is strictly prohibited. //! Proprietary and confidential. -use super::{I2cError, I2cProxy}; +use super::{I2cError, I2cProxy, MainboardLeds}; +use embedded_hal::digital::v2::OutputPin; use max6639::Max6639; /// The default fan speed on power-up. @@ -14,6 +15,7 @@ pub const DEFAULT_FAN_SPEED: f32 = 0.2; pub struct ChassisFans { fans: [Max6639; 3], duty_cycle: f32, + leds: MainboardLeds, } impl ChassisFans { @@ -25,10 +27,11 @@ impl ChassisFans { /// /// # Returns /// A new fan controller. - pub fn new(fans: [Max6639; 3]) -> Self { + pub fn new(fans: [Max6639; 3], leds: MainboardLeds) -> Self { ChassisFans { fans, duty_cycle: DEFAULT_FAN_SPEED, + leds, } } @@ -58,14 +61,24 @@ impl ChassisFans { // Bound the duty cycle to a normalized range. let duty_cycle = duty_cycle.clamp(0.0, 1.0); + let leds = &mut self.leds; + // Keep retrying until the configuration succeeds or the maximum number of retry // attempts is exhausted. - let retry_set = |fan: &mut Max6639, subfan, duty_cycle| { + let mut retry_set = |fan: &mut Max6639, subfan, duty_cycle| { for _ in 0..2 { match fan.set_duty_cycle(subfan, duty_cycle) { - Err(max6639::Error::Interface(I2cError::NACK)) => {} + Err(max6639::Error::Interface(I2cError::NACK)) => { + leds.0.set_high().unwrap(); + leds.1.set_high().unwrap(); + leds.2.set_high().unwrap(); + } Err(e) => Err(e).unwrap(), - Ok(_) => break, + Ok(_) => { + leds.0.set_low().unwrap(); + leds.1.set_low().unwrap(); + leds.2.set_low().unwrap(); + } } } }; diff --git a/src/hardware/mod.rs b/src/hardware/mod.rs index ae3437bb..488572dd 100644 --- a/src/hardware/mod.rs +++ b/src/hardware/mod.rs @@ -50,6 +50,11 @@ pub type Spi = hal::spi::Spi< ), >; +pub type Led1 = hal::gpio::gpioc::PC8>; +pub type Led2 = hal::gpio::gpioc::PC9>; +pub type Led3 = hal::gpio::gpioc::PC10>; +pub type MainboardLeds = (Led1, Led2, Led3); + #[cfg(feature = "phy_enc424j600")] pub type NetworkStack = smoltcp_nal::NetworkStack< 'static, diff --git a/src/hardware/setup.rs b/src/hardware/setup.rs index 848f6bdd..414c2220 100644 --- a/src/hardware/setup.rs +++ b/src/hardware/setup.rs @@ -332,6 +332,18 @@ pub fn setup( }; let mut fans = { + let main_board_leds = { + let mut led1 = gpioc.pc8.into_push_pull_output(); + let mut led2 = gpioc.pc9.into_push_pull_output(); + let mut led3 = gpioc.pc10.into_push_pull_output(); + + led1.set_low().unwrap(); + led2.set_low().unwrap(); + led3.set_low().unwrap(); + + (led1, led2, led3) + }; + let fan1 = max6639::Max6639::new(i2c_bus_manager.acquire_i2c(), max6639::AddressPin::Pulldown) .unwrap(); @@ -341,7 +353,7 @@ pub fn setup( max6639::Max6639::new(i2c_bus_manager.acquire_i2c(), max6639::AddressPin::Pullup) .unwrap(); - ChassisFans::new([fan1, fan2, fan3]) + ChassisFans::new([fan1, fan2, fan3], main_board_leds) }; assert!(fans.self_test(&mut delay)); From d3a629fa2963ec1aae615b5999b14bdf17d82729 Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Tue, 8 Feb 2022 14:02:56 +0100 Subject: [PATCH 2/3] Refactoring CI to upload artifact --- .github/workflows/ci.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5dfbb849..a41a403f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -83,9 +83,7 @@ jobs: - name: Upload Artifacts uses: actions/upload-artifact@v2 - if: ${{ matrix.toolchain == 'stable' - && (github.ref == 'refs/heads/master' - || github.ref == 'refs/heads/develop') }} + if: ${{ matrix.toolchain == 'stable' }} with: name: Firmware Images (features=${{ matrix.features }}) path: | From 6ef01bff68df51f27e2144799c32b4cc989079e4 Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Wed, 16 Feb 2022 11:44:58 +0100 Subject: [PATCH 3/3] Reverting GHA change, updating version in TOML --- .github/workflows/ci.yml | 4 +++- Cargo.toml | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a41a403f..5dfbb849 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -83,7 +83,9 @@ jobs: - name: Upload Artifacts uses: actions/upload-artifact@v2 - if: ${{ matrix.toolchain == 'stable' }} + if: ${{ matrix.toolchain == 'stable' + && (github.ref == 'refs/heads/master' + || github.ref == 'refs/heads/develop') }} with: name: Firmware Images (features=${{ matrix.features }}) path: | diff --git a/Cargo.toml b/Cargo.toml index 5e5b1fe7..d9e4e02e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ authors = ["Ryan Summers "] edition = "2018" readme = "README.md" name = "booster" -version = "0.3.0-rc.1" +version = "0.3.0-rc.3" build = "build.rs" resolver = "2"