diff options
| author | Dario Nieuwenhuis <[email protected]> | 2021-07-05 03:24:36 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-07-05 03:24:36 +0200 |
| commit | ed83b93b6dd34cf09d1f772ec32ebd036e8798a7 (patch) | |
| tree | 76ec36764d49225112056f8e3ef38d40ad5f7cde | |
| parent | fd38e789572c044e7d26d26379fa00f2adefdb03 (diff) | |
| parent | ecc151d4e28394ed2dcec466e86ea1880095f9aa (diff) | |
Merge pull request #276 from embassy-rs/deny-warnings
Deny warnings in CI
| -rw-r--r-- | .github/workflows/rust.yml | 9 | ||||
| -rw-r--r-- | embassy-nrf/src/gpiote.rs | 10 | ||||
| -rw-r--r-- | embassy-stm32/src/adc/v3.rs | 22 | ||||
| -rw-r--r-- | examples/stm32l4/src/bin/adc.rs | 9 |
4 files changed, 26 insertions, 24 deletions
diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index f4105230d..fc836dfce 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml | |||
| @@ -102,8 +102,15 @@ jobs: | |||
| 102 | with: | 102 | with: |
| 103 | path: target | 103 | path: target |
| 104 | key: ${{ runner.os }}-${{ matrix.target }} | 104 | key: ${{ runner.os }}-${{ matrix.target }} |
| 105 | |||
| 106 | # We have to append the "-D warnings" flag to .cargo/config rather than | ||
| 107 | # using the RUSTFLAGS environment variable because if we set RUSTFLAGS | ||
| 108 | # cargo will ignore the rustflags config in .cargo/config. | ||
| 105 | - name: Check | 109 | - name: Check |
| 106 | run: cd ${{ matrix.package }} && cargo check --features=${{ matrix.features }} --target=${{ matrix.target }} | 110 | run: | |
| 111 | mkdir -p .cargo | ||
| 112 | echo -e '[target."cfg(all())"]\nrustflags = ["-D", "warnings"]' >> .cargo/config | ||
| 113 | cd ${{ matrix.package }} && RUSTFLAGS=-Dwarnings cargo check --features=${{ matrix.features }} --target=${{ matrix.target }} | ||
| 107 | 114 | ||
| 108 | fmt: | 115 | fmt: |
| 109 | runs-on: ubuntu-latest | 116 | runs-on: ubuntu-latest |
diff --git a/embassy-nrf/src/gpiote.rs b/embassy-nrf/src/gpiote.rs index 2ef26e36a..54d3dd012 100644 --- a/embassy-nrf/src/gpiote.rs +++ b/embassy-nrf/src/gpiote.rs | |||
| @@ -10,7 +10,7 @@ use embedded_hal::digital::v2::{InputPin, StatefulOutputPin}; | |||
| 10 | use futures::future::poll_fn; | 10 | use futures::future::poll_fn; |
| 11 | 11 | ||
| 12 | use crate::gpio::sealed::Pin as _; | 12 | use crate::gpio::sealed::Pin as _; |
| 13 | use crate::gpio::{AnyPin, Input, Output, Pin as GpioPin, Port}; | 13 | use crate::gpio::{AnyPin, Input, Output, Pin as GpioPin}; |
| 14 | use crate::pac; | 14 | use crate::pac; |
| 15 | use crate::ppi::{Event, Task}; | 15 | use crate::ppi::{Event, Task}; |
| 16 | use crate::{interrupt, peripherals}; | 16 | use crate::{interrupt, peripherals}; |
| @@ -140,8 +140,8 @@ impl<'d, C: Channel, T: GpioPin> InputChannel<'d, C, T> { | |||
| 140 | }; | 140 | }; |
| 141 | #[cfg(any(feature = "nrf52833", feature = "nrf52840"))] | 141 | #[cfg(any(feature = "nrf52833", feature = "nrf52840"))] |
| 142 | w.port().bit(match pin.pin.port() { | 142 | w.port().bit(match pin.pin.port() { |
| 143 | Port::Port0 => false, | 143 | crate::gpio::Port::Port0 => false, |
| 144 | Port::Port1 => true, | 144 | crate::gpio::Port::Port1 => true, |
| 145 | }); | 145 | }); |
| 146 | unsafe { w.psel().bits(pin.pin.pin()) } | 146 | unsafe { w.psel().bits(pin.pin.pin()) } |
| 147 | }); | 147 | }); |
| @@ -223,8 +223,8 @@ impl<'d, C: Channel, T: GpioPin> OutputChannel<'d, C, T> { | |||
| 223 | }; | 223 | }; |
| 224 | #[cfg(any(feature = "nrf52833", feature = "nrf52840"))] | 224 | #[cfg(any(feature = "nrf52833", feature = "nrf52840"))] |
| 225 | w.port().bit(match pin.pin.port() { | 225 | w.port().bit(match pin.pin.port() { |
| 226 | Port::Port0 => false, | 226 | crate::gpio::Port::Port0 => false, |
| 227 | Port::Port1 => true, | 227 | crate::gpio::Port::Port1 => true, |
| 228 | }); | 228 | }); |
| 229 | unsafe { w.psel().bits(pin.pin.pin()) } | 229 | unsafe { w.psel().bits(pin.pin.pin()) } |
| 230 | }); | 230 | }); |
diff --git a/embassy-stm32/src/adc/v3.rs b/embassy-stm32/src/adc/v3.rs index 36af6ec49..7480c4a36 100644 --- a/embassy-stm32/src/adc/v3.rs +++ b/embassy-stm32/src/adc/v3.rs | |||
| @@ -1,6 +1,5 @@ | |||
| 1 | use crate::adc::{AdcPin, Instance}; | 1 | use crate::adc::{AdcPin, Instance}; |
| 2 | use core::marker::PhantomData; | 2 | use core::marker::PhantomData; |
| 3 | use cortex_m::delay::Delay; | ||
| 4 | use embassy::util::Unborrow; | 3 | use embassy::util::Unborrow; |
| 5 | use embassy_extras::unborrow; | 4 | use embassy_extras::unborrow; |
| 6 | use embedded_hal::blocking::delay::DelayUs; | 5 | use embedded_hal::blocking::delay::DelayUs; |
| @@ -123,7 +122,7 @@ pub struct Adc<'d, T: Instance> { | |||
| 123 | } | 122 | } |
| 124 | 123 | ||
| 125 | impl<'d, T: Instance> Adc<'d, T> { | 124 | impl<'d, T: Instance> Adc<'d, T> { |
| 126 | pub fn new(_peri: impl Unborrow<Target = T> + 'd, mut delay: Delay) -> (Self, Delay) { | 125 | pub fn new(_peri: impl Unborrow<Target = T> + 'd, delay: &mut impl DelayUs<u32>) -> Self { |
| 127 | unborrow!(_peri); | 126 | unborrow!(_peri); |
| 128 | unsafe { | 127 | unsafe { |
| 129 | T::regs().cr().modify(|reg| { | 128 | T::regs().cr().modify(|reg| { |
| @@ -142,18 +141,15 @@ impl<'d, T: Instance> Adc<'d, T> { | |||
| 142 | 141 | ||
| 143 | delay.delay_us(1); | 142 | delay.delay_us(1); |
| 144 | 143 | ||
| 145 | ( | 144 | Self { |
| 146 | Self { | 145 | sample_time: Default::default(), |
| 147 | sample_time: Default::default(), | 146 | resolution: Resolution::default(), |
| 148 | resolution: Resolution::default(), | 147 | calibrated_vdda: VDDA_CALIB_MV, |
| 149 | calibrated_vdda: VDDA_CALIB_MV, | 148 | phantom: PhantomData, |
| 150 | phantom: PhantomData, | 149 | } |
| 151 | }, | ||
| 152 | delay, | ||
| 153 | ) | ||
| 154 | } | 150 | } |
| 155 | 151 | ||
| 156 | pub fn enable_vref(&self, mut delay: Delay) -> (Vref, Delay) { | 152 | pub fn enable_vref(&self, delay: &mut impl DelayUs<u32>) -> Vref { |
| 157 | unsafe { | 153 | unsafe { |
| 158 | T::common_regs().ccr().modify(|reg| { | 154 | T::common_regs().ccr().modify(|reg| { |
| 159 | reg.set_vrefen(true); | 155 | reg.set_vrefen(true); |
| @@ -166,7 +162,7 @@ impl<'d, T: Instance> Adc<'d, T> { | |||
| 166 | //cortex_m::asm::delay(20_000_000); | 162 | //cortex_m::asm::delay(20_000_000); |
| 167 | delay.delay_us(15); | 163 | delay.delay_us(15); |
| 168 | 164 | ||
| 169 | (Vref {}, delay) | 165 | Vref {} |
| 170 | } | 166 | } |
| 171 | 167 | ||
| 172 | pub fn enable_temperature(&self) -> Temperature { | 168 | pub fn enable_temperature(&self) -> Temperature { |
diff --git a/examples/stm32l4/src/bin/adc.rs b/examples/stm32l4/src/bin/adc.rs index a909e1bb2..a3c44d3c1 100644 --- a/examples/stm32l4/src/bin/adc.rs +++ b/examples/stm32l4/src/bin/adc.rs | |||
| @@ -16,8 +16,8 @@ use cortex_m_rt::entry; | |||
| 16 | use cortex_m::delay::Delay; | 16 | use cortex_m::delay::Delay; |
| 17 | use embassy_stm32::adc::{Adc, Resolution}; | 17 | use embassy_stm32::adc::{Adc, Resolution}; |
| 18 | use stm32l4::stm32l4x5 as pac; | 18 | use stm32l4::stm32l4x5 as pac; |
| 19 | use stm32l4xx_hal::rcc::PllSource; | ||
| 20 | use stm32l4xx_hal::prelude::*; | 19 | use stm32l4xx_hal::prelude::*; |
| 20 | use stm32l4xx_hal::rcc::PllSource; | ||
| 21 | 21 | ||
| 22 | #[entry] | 22 | #[entry] |
| 23 | fn main() -> ! { | 23 | fn main() -> ! { |
| @@ -29,12 +29,11 @@ fn main() -> ! { | |||
| 29 | let mut rcc = pp.RCC.constrain(); | 29 | let mut rcc = pp.RCC.constrain(); |
| 30 | let mut pwr = pp.PWR.constrain(&mut rcc.apb1r1); | 30 | let mut pwr = pp.PWR.constrain(&mut rcc.apb1r1); |
| 31 | 31 | ||
| 32 | let delay = Delay::new(cp.SYST, 80_000_000); | 32 | let mut delay = Delay::new(cp.SYST, 80_000_000); |
| 33 | 33 | ||
| 34 | // TRY the other clock configuration | 34 | // TRY the other clock configuration |
| 35 | // let clocks = rcc.cfgr.freeze(&mut flash.acr); | 35 | // let clocks = rcc.cfgr.freeze(&mut flash.acr); |
| 36 | rcc | 36 | rcc.cfgr |
| 37 | .cfgr | ||
| 38 | .sysclk(80.mhz()) | 37 | .sysclk(80.mhz()) |
| 39 | .pclk1(80.mhz()) | 38 | .pclk1(80.mhz()) |
| 40 | .pclk2(80.mhz()) | 39 | .pclk2(80.mhz()) |
| @@ -69,7 +68,7 @@ fn main() -> ! { | |||
| 69 | 68 | ||
| 70 | let p = embassy_stm32::init(Default::default()); | 69 | let p = embassy_stm32::init(Default::default()); |
| 71 | 70 | ||
| 72 | let (mut adc, _) = Adc::new(p.ADC1, delay); | 71 | let mut adc = Adc::new(p.ADC1, &mut delay); |
| 73 | //adc.enable_vref(); | 72 | //adc.enable_vref(); |
| 74 | adc.set_resolution(Resolution::EightBit); | 73 | adc.set_resolution(Resolution::EightBit); |
| 75 | let mut channel = p.PC0; | 74 | let mut channel = p.PC0; |
