From 45f04e3b749102a425dfc15fb7fe22abba34b67b Mon Sep 17 00:00:00 2001 From: Andrey Zgarbul Date: Sun, 9 Jan 2022 10:02:28 +0300 Subject: [PATCH] git fix deprecation & clippy warnings --- Cargo.toml | 2 +- examples/adc-dma-circ.rs | 1 + examples/adc-dma-rx.rs | 1 + examples/blinky_rtcalarm_irq.rs | 8 +++++--- examples/blinky_timer_irq.rs | 6 +++--- examples/crc.rs | 1 + examples/exti.rs | 1 + examples/hello.rs | 1 + examples/itm.rs | 1 + examples/led.rs | 1 + examples/panics.rs | 1 + examples/pwm.rs | 1 + examples/pwm_custom.rs | 1 + examples/serial-dma-circ.rs | 1 + examples/serial-dma-peek.rs | 1 + examples/serial-dma-rx.rs | 1 + examples/serial-dma-tx.rs | 1 + examples/serial-fmt.rs | 1 + examples/serial.rs | 1 + examples/serial_config.rs | 1 + examples/serial_reconfigure.rs | 1 + examples/spi-dma.rs | 6 +++--- examples/spi.rs | 1 + src/i2c.rs | 6 +++--- src/i2c/blocking.rs | 15 ++++++--------- src/rtc.rs | 4 ++-- src/spi.rs | 10 +++++----- src/time.rs | 4 ++-- 28 files changed, 49 insertions(+), 31 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 7fed656a..33f9b4e5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,7 @@ features = ["stm32f103", "rt"] default-target = "x86_64-unknown-linux-gnu" [dependencies] -cortex-m = "0.7" +cortex-m = "0.7.4" cortex-m-rt = "0.7" nb = "1" stm32f1 = "0.14.0" diff --git a/examples/adc-dma-circ.rs b/examples/adc-dma-circ.rs index da0378fd..88684eec 100644 --- a/examples/adc-dma-circ.rs +++ b/examples/adc-dma-circ.rs @@ -1,5 +1,6 @@ //! ADC interface circular DMA RX transfer test +#![allow(clippy::empty_loop)] #![no_main] #![no_std] diff --git a/examples/adc-dma-rx.rs b/examples/adc-dma-rx.rs index c9f679a6..31d1589e 100644 --- a/examples/adc-dma-rx.rs +++ b/examples/adc-dma-rx.rs @@ -1,5 +1,6 @@ //! ADC interface DMA RX transfer test +#![allow(clippy::empty_loop)] #![no_main] #![no_std] diff --git a/examples/blinky_rtcalarm_irq.rs b/examples/blinky_rtcalarm_irq.rs index a5c984b0..4aab935c 100644 --- a/examples/blinky_rtcalarm_irq.rs +++ b/examples/blinky_rtcalarm_irq.rs @@ -7,6 +7,8 @@ //! GPIOs PC13 to PC15 in output mode is restricted: the speed has to be limited to 2MHz with //! a maximum load of 30pF and these IOs must not be used as a current source (e.g. to drive a LED)" +#![allow(clippy::empty_loop)] +#![allow(unused)] #![no_std] #![no_main] @@ -26,10 +28,10 @@ use cortex_m::{asm::wfi, interrupt::Mutex}; use cortex_m_rt::entry; // A type definition for the GPIO pin to be used for our LED -type LEDPIN = gpioc::PC13>; +type LedPin = gpioc::PC13>; // Make LED pin globally available -static G_LED: Mutex>> = Mutex::new(RefCell::new(None)); +static G_LED: Mutex>> = Mutex::new(RefCell::new(None)); // Make RTC globally available static G_RTC: Mutex>> = Mutex::new(RefCell::new(None)); // Make EXTI registers globally available @@ -50,7 +52,7 @@ fn main() -> ! { #[cfg(not(feature = "stm32f101"))] #[interrupt] fn RTCALARM() { - static mut LED: Option = None; + static mut LED: Option = None; static mut RTC: Option = None; static mut EXTI: Option = None; diff --git a/examples/blinky_timer_irq.rs b/examples/blinky_timer_irq.rs index 17b2b3fc..b67aa75e 100644 --- a/examples/blinky_timer_irq.rs +++ b/examples/blinky_timer_irq.rs @@ -32,10 +32,10 @@ use cortex_m_rt::entry; //use cortex_m_semihosting::hprintln; // A type definition for the GPIO pin to be used for our LED -type LEDPIN = gpioc::PC13>; +type LedPin = gpioc::PC13>; // Make LED pin globally available -static G_LED: Mutex>> = Mutex::new(RefCell::new(None)); +static G_LED: Mutex>> = Mutex::new(RefCell::new(None)); // Make timer interrupt registers globally available static G_TIM: Mutex>>> = Mutex::new(RefCell::new(None)); @@ -44,7 +44,7 @@ static G_TIM: Mutex>>> = Mutex::new(RefCell: // This specific interrupt will "trip" when the timer TIM2 times out #[interrupt] fn TIM2() { - static mut LED: Option = None; + static mut LED: Option = None; static mut TIM: Option> = None; let led = LED.get_or_insert_with(|| { diff --git a/examples/crc.rs b/examples/crc.rs index 4038dd77..88ca61ff 100644 --- a/examples/crc.rs +++ b/examples/crc.rs @@ -1,6 +1,7 @@ //! CRC calculation #![deny(unsafe_code)] +#![allow(clippy::empty_loop)] #![no_main] #![no_std] diff --git a/examples/exti.rs b/examples/exti.rs index a9489395..92e5bc8e 100644 --- a/examples/exti.rs +++ b/examples/exti.rs @@ -3,6 +3,7 @@ //! Listens for interrupts on the pa7 pin. On any rising or falling edge, toggles //! the pc13 pin (which is connected to the LED on the blue pill board, hence the `led` name). +#![allow(clippy::empty_loop)] #![no_main] #![no_std] diff --git a/examples/hello.rs b/examples/hello.rs index 4418456d..724a728e 100644 --- a/examples/hello.rs +++ b/examples/hello.rs @@ -1,5 +1,6 @@ //! Prints "Hello, world" on the OpenOCD console +#![allow(clippy::empty_loop)] #![deny(unsafe_code)] #![no_main] #![no_std] diff --git a/examples/itm.rs b/examples/itm.rs index a097ae8a..876b68a6 100644 --- a/examples/itm.rs +++ b/examples/itm.rs @@ -1,4 +1,5 @@ #![deny(unsafe_code)] +#![allow(clippy::empty_loop)] #![no_main] #![no_std] diff --git a/examples/led.rs b/examples/led.rs index 69cd1e15..d5424197 100644 --- a/examples/led.rs +++ b/examples/led.rs @@ -9,6 +9,7 @@ //! section 5.1.2 of the reference manual for an explanation. //! This is not an issue on the blue pill. +#![allow(clippy::empty_loop)] #![deny(unsafe_code)] #![no_main] #![no_std] diff --git a/examples/panics.rs b/examples/panics.rs index 716a89ad..8d202169 100644 --- a/examples/panics.rs +++ b/examples/panics.rs @@ -1,5 +1,6 @@ //! Prints "Hello, world" on the OpenOCD console +#![allow(clippy::empty_loop)] #![no_main] #![no_std] diff --git a/examples/pwm.rs b/examples/pwm.rs index 7f569fc6..b907bd29 100644 --- a/examples/pwm.rs +++ b/examples/pwm.rs @@ -1,6 +1,7 @@ //! Testing PWM output for pre-defined pin combination: all pins for default mapping #![deny(unsafe_code)] +#![allow(clippy::empty_loop)] #![no_main] #![no_std] diff --git a/examples/pwm_custom.rs b/examples/pwm_custom.rs index 9befa710..45fd8f29 100644 --- a/examples/pwm_custom.rs +++ b/examples/pwm_custom.rs @@ -1,6 +1,7 @@ //! Testing PWM output for custom pin combinations #![deny(unsafe_code)] +#![allow(clippy::empty_loop)] #![no_main] #![no_std] diff --git a/examples/serial-dma-circ.rs b/examples/serial-dma-circ.rs index 63bef0fd..6ce4433e 100644 --- a/examples/serial-dma-circ.rs +++ b/examples/serial-dma-circ.rs @@ -1,6 +1,7 @@ //! Serial interface circular DMA RX transfer test #![deny(unsafe_code)] +#![allow(clippy::empty_loop)] #![no_std] #![no_main] diff --git a/examples/serial-dma-peek.rs b/examples/serial-dma-peek.rs index 20b566ca..321fab51 100644 --- a/examples/serial-dma-peek.rs +++ b/examples/serial-dma-peek.rs @@ -1,5 +1,6 @@ //! Serial interface DMA RX transfer test +#![allow(clippy::empty_loop)] #![deny(unsafe_code)] #![no_main] #![no_std] diff --git a/examples/serial-dma-rx.rs b/examples/serial-dma-rx.rs index 225fcb79..3cb36483 100644 --- a/examples/serial-dma-rx.rs +++ b/examples/serial-dma-rx.rs @@ -1,6 +1,7 @@ //! Serial interface DMA RX transfer test #![deny(unsafe_code)] +#![allow(clippy::empty_loop)] #![no_main] #![no_std] diff --git a/examples/serial-dma-tx.rs b/examples/serial-dma-tx.rs index dc9c7b56..b88809b5 100644 --- a/examples/serial-dma-tx.rs +++ b/examples/serial-dma-tx.rs @@ -1,6 +1,7 @@ //! Serial interface DMA TX transfer test #![deny(unsafe_code)] +#![allow(clippy::empty_loop)] #![no_main] #![no_std] diff --git a/examples/serial-fmt.rs b/examples/serial-fmt.rs index 266719d3..a06a4c77 100644 --- a/examples/serial-fmt.rs +++ b/examples/serial-fmt.rs @@ -4,6 +4,7 @@ //! so you can see the message in a serial console (e.g. Arduino console). #![deny(unsafe_code)] +#![allow(clippy::empty_loop)] #![no_main] #![no_std] diff --git a/examples/serial.rs b/examples/serial.rs index c1b2ef49..66ee8cc5 100644 --- a/examples/serial.rs +++ b/examples/serial.rs @@ -2,6 +2,7 @@ //! //! You have to short the TX and RX pins to make this program work +#![allow(clippy::empty_loop)] #![deny(unsafe_code)] #![no_main] #![no_std] diff --git a/examples/serial_config.rs b/examples/serial_config.rs index a28b37f6..0c209d24 100644 --- a/examples/serial_config.rs +++ b/examples/serial_config.rs @@ -3,6 +3,7 @@ //! You have to short the TX and RX pins to make this program work #![deny(unsafe_code)] +#![allow(clippy::empty_loop)] #![no_main] #![no_std] diff --git a/examples/serial_reconfigure.rs b/examples/serial_reconfigure.rs index f4551189..298da789 100644 --- a/examples/serial_reconfigure.rs +++ b/examples/serial_reconfigure.rs @@ -2,6 +2,7 @@ //! //! You have to short the TX and RX pins to make this program work +#![allow(clippy::empty_loop)] #![deny(unsafe_code)] #![no_main] #![no_std] diff --git a/examples/spi-dma.rs b/examples/spi-dma.rs index 50e7f0c0..1a803fb7 100644 --- a/examples/spi-dma.rs +++ b/examples/spi-dma.rs @@ -1,9 +1,9 @@ +//! Transmits data over an SPI port using DMA + +#![allow(clippy::empty_loop)] #![no_std] #![no_main] -/** - Transmits data over an SPI port using DMA -*/ use panic_halt as _; use cortex_m_rt::entry; diff --git a/examples/spi.rs b/examples/spi.rs index b57d1d43..030ba008 100644 --- a/examples/spi.rs +++ b/examples/spi.rs @@ -1,4 +1,5 @@ #![deny(unsafe_code)] +#![allow(clippy::empty_loop)] #![no_std] #![no_main] diff --git a/src/i2c.rs b/src/i2c.rs index 94d45cb6..3cc12cf2 100644 --- a/src/i2c.rs +++ b/src/i2c.rs @@ -137,7 +137,7 @@ impl I2c { PINS: Pins, { mapr.modify_mapr(|_, w| w.i2c1_remap().bit(PINS::REMAP)); - I2c::::_i2c(i2c, pins, mode, clocks) + I2c::::configure(i2c, pins, mode, clocks) } } @@ -147,7 +147,7 @@ impl I2c { where PINS: Pins, { - I2c::::_i2c(i2c, pins, mode, clocks) + I2c::::configure(i2c, pins, mode, clocks) } } @@ -156,7 +156,7 @@ where I2C: Instance, { /// Configures the I2C peripheral to work in master mode - fn _i2c>(i2c: I2C, pins: PINS, mode: M, clocks: Clocks) -> Self { + fn configure>(i2c: I2C, pins: PINS, mode: M, clocks: Clocks) -> Self { let mode = mode.into(); let rcc = unsafe { &(*RCC::ptr()) }; I2C::enable(rcc); diff --git a/src/i2c/blocking.rs b/src/i2c/blocking.rs index 929e1945..3752fd1e 100644 --- a/src/i2c/blocking.rs +++ b/src/i2c/blocking.rs @@ -35,7 +35,7 @@ impl BlockingI2c { PINS: Pins, { mapr.modify_mapr(|_, w| w.i2c1_remap().bit(PINS::REMAP)); - BlockingI2c::::_i2c( + BlockingI2c::::configure( i2c, pins, mode, @@ -64,7 +64,7 @@ impl BlockingI2c { where PINS: Pins, { - BlockingI2c::::_i2c( + BlockingI2c::::configure( i2c, pins, mode, @@ -152,12 +152,9 @@ macro_rules! busy_wait { macro_rules! busy_wait_cycles { ($nb_expr:expr, $cycles:expr) => {{ - let started = DWT::get_cycle_count(); + let started = DWT::cycle_count(); let cycles = $cycles; - busy_wait!( - $nb_expr, - DWT::get_cycle_count().wrapping_sub(started) >= cycles - ) + busy_wait!($nb_expr, DWT::cycle_count().wrapping_sub(started) >= cycles) }}; } @@ -166,7 +163,7 @@ where I2C: Instance, { #[allow(clippy::too_many_arguments)] - fn _i2c>( + fn configure>( i2c: I2C, pins: PINS, mode: M, @@ -176,7 +173,7 @@ where addr_timeout_us: u32, data_timeout_us: u32, ) -> Self { - I2c::::_i2c(i2c, pins, mode, clocks).blocking( + I2c::::configure(i2c, pins, mode, clocks).blocking( start_timeout_us, start_retries, addr_timeout_us, diff --git a/src/rtc.rs b/src/rtc.rs index 7b259371..6f0d25ef 100644 --- a/src/rtc.rs +++ b/src/rtc.rs @@ -93,7 +93,7 @@ impl Rtc { } impl Rtc { - pub fn rtc(regs: RTC, bkp: &mut BackupDomain) -> Self { + pub fn new_lsi(regs: RTC, bkp: &mut BackupDomain) -> Self { let mut result = Rtc { regs, _clock_source: PhantomData, @@ -136,7 +136,7 @@ impl Rtc { } impl Rtc { - pub fn rtc(regs: RTC, bkp: &mut BackupDomain, hse: F) -> Self + pub fn new_hse(regs: RTC, bkp: &mut BackupDomain, hse: F) -> Self where F: Into, { diff --git a/src/spi.rs b/src/spi.rs index ab79e35d..1f9a5916 100644 --- a/src/spi.rs +++ b/src/spi.rs @@ -173,7 +173,7 @@ impl Spi { PINS: Pins, { mapr.modify_mapr(|_, w| w.spi1_remap().bit(REMAP::REMAP)); - Spi::::_spi(spi, pins, mode, freq.into(), clocks) + Spi::::configure(spi, pins, mode, freq.into(), clocks) } } @@ -191,7 +191,7 @@ impl Spi { REMAP: Remap, PINS: Pins, { - Spi::::_spi(spi, pins, mode, freq.into(), clocks) + Spi::::configure(spi, pins, mode, freq.into(), clocks) } } @@ -211,7 +211,7 @@ impl Spi { REMAP: Remap, PINS: Pins, { - Spi::::_spi(spi, pins, mode, freq.into(), clocks) + Spi::::configure(spi, pins, mode, freq.into(), clocks) } /** @@ -236,7 +236,7 @@ impl Spi { PINS: Pins, { mapr.modify_mapr(|_, w| w.spi3_remap().bit(REMAP::REMAP)); - Spi::::_spi(spi, pins, mode, freq.into(), clocks) + Spi::::configure(spi, pins, mode, freq.into(), clocks) } } @@ -333,7 +333,7 @@ impl Spi where SPI: Instance, { - fn _spi(spi: SPI, pins: PINS, mode: Mode, freq: Hertz, clocks: Clocks) -> Self { + fn configure(spi: SPI, pins: PINS, mode: Mode, freq: Hertz, clocks: Clocks) -> Self { // enable or reset SPI let rcc = unsafe { &(*RCC::ptr()) }; SPI::enable(rcc); diff --git a/src/time.rs b/src/time.rs index 35a26252..35ff32b8 100644 --- a/src/time.rs +++ b/src/time.rs @@ -259,7 +259,7 @@ impl MonoTimer { /// Returns an `Instant` corresponding to "now" pub fn now(self) -> Instant { Instant { - now: DWT::get_cycle_count(), + now: DWT::cycle_count(), } } } @@ -273,6 +273,6 @@ pub struct Instant { impl Instant { /// Ticks elapsed since the `Instant` was created pub fn elapsed(self) -> u32 { - DWT::get_cycle_count().wrapping_sub(self.now) + DWT::cycle_count().wrapping_sub(self.now) } }