Skip to content

Commit

Permalink
Merge #389
Browse files Browse the repository at this point in the history
389: fix deprecation & clippy warnings r=therealprof a=burrbull



Co-authored-by: Andrey Zgarbul <zgarbul.andrey@gmail.com>
  • Loading branch information
bors[bot] and burrbull authored Jan 9, 2022
2 parents ecd81e0 + 45f04e3 commit fa6eb8a
Show file tree
Hide file tree
Showing 28 changed files with 49 additions and 31 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions examples/adc-dma-circ.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! ADC interface circular DMA RX transfer test
#![allow(clippy::empty_loop)]
#![no_main]
#![no_std]

Expand Down
1 change: 1 addition & 0 deletions examples/adc-dma-rx.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! ADC interface DMA RX transfer test
#![allow(clippy::empty_loop)]
#![no_main]
#![no_std]

Expand Down
8 changes: 5 additions & 3 deletions examples/blinky_rtcalarm_irq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand All @@ -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<Output<PushPull>>;
type LedPin = gpioc::PC13<Output<PushPull>>;

// Make LED pin globally available
static G_LED: Mutex<RefCell<Option<LEDPIN>>> = Mutex::new(RefCell::new(None));
static G_LED: Mutex<RefCell<Option<LedPin>>> = Mutex::new(RefCell::new(None));
// Make RTC globally available
static G_RTC: Mutex<RefCell<Option<Rtc>>> = Mutex::new(RefCell::new(None));
// Make EXTI registers globally available
Expand All @@ -50,7 +52,7 @@ fn main() -> ! {
#[cfg(not(feature = "stm32f101"))]
#[interrupt]
fn RTCALARM() {
static mut LED: Option<LEDPIN> = None;
static mut LED: Option<LedPin> = None;
static mut RTC: Option<Rtc> = None;
static mut EXTI: Option<EXTI> = None;

Expand Down
6 changes: 3 additions & 3 deletions examples/blinky_timer_irq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Output<PushPull>>;
type LedPin = gpioc::PC13<Output<PushPull>>;

// Make LED pin globally available
static G_LED: Mutex<RefCell<Option<LEDPIN>>> = Mutex::new(RefCell::new(None));
static G_LED: Mutex<RefCell<Option<LedPin>>> = Mutex::new(RefCell::new(None));

// Make timer interrupt registers globally available
static G_TIM: Mutex<RefCell<Option<CountDownTimer<TIM2>>>> = Mutex::new(RefCell::new(None));
Expand All @@ -44,7 +44,7 @@ static G_TIM: Mutex<RefCell<Option<CountDownTimer<TIM2>>>> = Mutex::new(RefCell:
// This specific interrupt will "trip" when the timer TIM2 times out
#[interrupt]
fn TIM2() {
static mut LED: Option<LEDPIN> = None;
static mut LED: Option<LedPin> = None;
static mut TIM: Option<CountDownTimer<TIM2>> = None;

let led = LED.get_or_insert_with(|| {
Expand Down
1 change: 1 addition & 0 deletions examples/crc.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! CRC calculation
#![deny(unsafe_code)]
#![allow(clippy::empty_loop)]
#![no_main]
#![no_std]

Expand Down
1 change: 1 addition & 0 deletions examples/exti.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down
1 change: 1 addition & 0 deletions examples/hello.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! Prints "Hello, world" on the OpenOCD console
#![allow(clippy::empty_loop)]
#![deny(unsafe_code)]
#![no_main]
#![no_std]
Expand Down
1 change: 1 addition & 0 deletions examples/itm.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![deny(unsafe_code)]
#![allow(clippy::empty_loop)]
#![no_main]
#![no_std]

Expand Down
1 change: 1 addition & 0 deletions examples/led.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
1 change: 1 addition & 0 deletions examples/panics.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! Prints "Hello, world" on the OpenOCD console
#![allow(clippy::empty_loop)]
#![no_main]
#![no_std]

Expand Down
1 change: 1 addition & 0 deletions examples/pwm.rs
Original file line number Diff line number Diff line change
@@ -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]

Expand Down
1 change: 1 addition & 0 deletions examples/pwm_custom.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Testing PWM output for custom pin combinations
#![deny(unsafe_code)]
#![allow(clippy::empty_loop)]
#![no_main]
#![no_std]

Expand Down
1 change: 1 addition & 0 deletions examples/serial-dma-circ.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Serial interface circular DMA RX transfer test
#![deny(unsafe_code)]
#![allow(clippy::empty_loop)]
#![no_std]
#![no_main]

Expand Down
1 change: 1 addition & 0 deletions examples/serial-dma-peek.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! Serial interface DMA RX transfer test
#![allow(clippy::empty_loop)]
#![deny(unsafe_code)]
#![no_main]
#![no_std]
Expand Down
1 change: 1 addition & 0 deletions examples/serial-dma-rx.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Serial interface DMA RX transfer test
#![deny(unsafe_code)]
#![allow(clippy::empty_loop)]
#![no_main]
#![no_std]

Expand Down
1 change: 1 addition & 0 deletions examples/serial-dma-tx.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Serial interface DMA TX transfer test
#![deny(unsafe_code)]
#![allow(clippy::empty_loop)]
#![no_main]
#![no_std]

Expand Down
1 change: 1 addition & 0 deletions examples/serial-fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down
1 change: 1 addition & 0 deletions examples/serial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
1 change: 1 addition & 0 deletions examples/serial_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down
1 change: 1 addition & 0 deletions examples/serial_reconfigure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
6 changes: 3 additions & 3 deletions examples/spi-dma.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
1 change: 1 addition & 0 deletions examples/spi.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![deny(unsafe_code)]
#![allow(clippy::empty_loop)]
#![no_std]
#![no_main]

Expand Down
6 changes: 3 additions & 3 deletions src/i2c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ impl<PINS> I2c<I2C1, PINS> {
PINS: Pins<I2C1>,
{
mapr.modify_mapr(|_, w| w.i2c1_remap().bit(PINS::REMAP));
I2c::<I2C1, _>::_i2c(i2c, pins, mode, clocks)
I2c::<I2C1, _>::configure(i2c, pins, mode, clocks)
}
}

Expand All @@ -147,7 +147,7 @@ impl<PINS> I2c<I2C2, PINS> {
where
PINS: Pins<I2C2>,
{
I2c::<I2C2, _>::_i2c(i2c, pins, mode, clocks)
I2c::<I2C2, _>::configure(i2c, pins, mode, clocks)
}
}

Expand All @@ -156,7 +156,7 @@ where
I2C: Instance,
{
/// Configures the I2C peripheral to work in master mode
fn _i2c<M: Into<Mode>>(i2c: I2C, pins: PINS, mode: M, clocks: Clocks) -> Self {
fn configure<M: Into<Mode>>(i2c: I2C, pins: PINS, mode: M, clocks: Clocks) -> Self {
let mode = mode.into();
let rcc = unsafe { &(*RCC::ptr()) };
I2C::enable(rcc);
Expand Down
15 changes: 6 additions & 9 deletions src/i2c/blocking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl<PINS> BlockingI2c<I2C1, PINS> {
PINS: Pins<I2C1>,
{
mapr.modify_mapr(|_, w| w.i2c1_remap().bit(PINS::REMAP));
BlockingI2c::<I2C1, _>::_i2c(
BlockingI2c::<I2C1, _>::configure(
i2c,
pins,
mode,
Expand Down Expand Up @@ -64,7 +64,7 @@ impl<PINS> BlockingI2c<I2C2, PINS> {
where
PINS: Pins<I2C2>,
{
BlockingI2c::<I2C2, _>::_i2c(
BlockingI2c::<I2C2, _>::configure(
i2c,
pins,
mode,
Expand Down Expand Up @@ -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)
}};
}

Expand All @@ -166,7 +163,7 @@ where
I2C: Instance,
{
#[allow(clippy::too_many_arguments)]
fn _i2c<M: Into<Mode>>(
fn configure<M: Into<Mode>>(
i2c: I2C,
pins: PINS,
mode: M,
Expand All @@ -176,7 +173,7 @@ where
addr_timeout_us: u32,
data_timeout_us: u32,
) -> Self {
I2c::<I2C, _>::_i2c(i2c, pins, mode, clocks).blocking(
I2c::<I2C, _>::configure(i2c, pins, mode, clocks).blocking(
start_timeout_us,
start_retries,
addr_timeout_us,
Expand Down
4 changes: 2 additions & 2 deletions src/rtc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ impl Rtc<RtcClkLse> {
}

impl Rtc<RtcClkLsi> {
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,
Expand Down Expand Up @@ -136,7 +136,7 @@ impl Rtc<RtcClkLsi> {
}

impl Rtc<RtcClkHseDiv128> {
pub fn rtc<F>(regs: RTC, bkp: &mut BackupDomain, hse: F) -> Self
pub fn new_hse<F>(regs: RTC, bkp: &mut BackupDomain, hse: F) -> Self
where
F: Into<Hertz>,
{
Expand Down
10 changes: 5 additions & 5 deletions src/spi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ impl<REMAP, PINS> Spi<SPI1, REMAP, PINS, u8> {
PINS: Pins<REMAP>,
{
mapr.modify_mapr(|_, w| w.spi1_remap().bit(REMAP::REMAP));
Spi::<SPI1, _, _, u8>::_spi(spi, pins, mode, freq.into(), clocks)
Spi::<SPI1, _, _, u8>::configure(spi, pins, mode, freq.into(), clocks)
}
}

Expand All @@ -191,7 +191,7 @@ impl<REMAP, PINS> Spi<SPI2, REMAP, PINS, u8> {
REMAP: Remap<Periph = SPI2>,
PINS: Pins<REMAP>,
{
Spi::<SPI2, _, _, u8>::_spi(spi, pins, mode, freq.into(), clocks)
Spi::<SPI2, _, _, u8>::configure(spi, pins, mode, freq.into(), clocks)
}
}

Expand All @@ -211,7 +211,7 @@ impl<REMAP, PINS> Spi<SPI3, REMAP, PINS, u8> {
REMAP: Remap<Periph = SPI3>,
PINS: Pins<REMAP>,
{
Spi::<SPI3, _, _, u8>::_spi(spi, pins, mode, freq.into(), clocks)
Spi::<SPI3, _, _, u8>::configure(spi, pins, mode, freq.into(), clocks)
}

/**
Expand All @@ -236,7 +236,7 @@ impl<REMAP, PINS> Spi<SPI3, REMAP, PINS, u8> {
PINS: Pins<REMAP>,
{
mapr.modify_mapr(|_, w| w.spi3_remap().bit(REMAP::REMAP));
Spi::<SPI3, _, _, u8>::_spi(spi, pins, mode, freq.into(), clocks)
Spi::<SPI3, _, _, u8>::configure(spi, pins, mode, freq.into(), clocks)
}
}

Expand Down Expand Up @@ -333,7 +333,7 @@ impl<SPI, REMAP, PINS> Spi<SPI, REMAP, PINS, u8>
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);
Expand Down
4 changes: 2 additions & 2 deletions src/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
}
}
}
Expand All @@ -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)
}
}

0 comments on commit fa6eb8a

Please sign in to comment.