Skip to content

Commit de1b149

Browse files
authored
Merge pull request #143 from stm32-rs/fix-clippy-lints
Fix clippy lints
2 parents 903a68f + a15ecc0 commit de1b149

File tree

4 files changed

+57
-64
lines changed

4 files changed

+57
-64
lines changed

src/adc.rs

Lines changed: 56 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -478,13 +478,11 @@ pub mod config {
478478
/// },
479479
/// };
480480
///
481-
/// fn main() {
482-
/// let mut adc = Adc::adc1(device.ADC1, true, AdcConfig::default());
483-
/// let pa3 = gpioa.pa3.into_analog();
484-
/// let sample = adc.convert(&pa3, SampleTime::Cycles_480);
485-
/// let millivolts = adc.sample_to_millivolts(sample);
486-
/// info!("pa3: {}mV", millivolts);
487-
/// }
481+
/// let mut adc = Adc::adc1(device.ADC1, true, AdcConfig::default());
482+
/// let pa3 = gpioa.pa3.into_analog();
483+
/// let sample = adc.convert(&pa3, SampleTime::Cycles_480);
484+
/// let millivolts = adc.sample_to_millivolts(sample);
485+
/// info!("pa3: {}mV", millivolts);
488486
/// ```
489487
///
490488
/// ## Sequence conversion
@@ -502,27 +500,25 @@ pub mod config {
502500
/// },
503501
/// };
504502
///
505-
/// fn main() {
506-
/// let config = AdcConfig::default()
507-
/// //We'll either need DMA or an interrupt per conversion to convert
508-
/// //multiple values in a sequence
509-
/// .end_of_conversion_interrupt(Eoc::Conversion);
510-
/// //Scan mode is also required to convert a sequence
511-
/// .scan(Scan::Enabled)
512-
/// //And since we're looking for one interrupt per conversion the
513-
/// //clock will need to be fairly slow to avoid overruns breaking
514-
/// //the sequence. If you are running in debug mode and logging in
515-
/// //the interrupt, good luck... try setting pclk2 really low.
516-
/// //(Better yet use DMA)
517-
/// .clock(Clock::Pclk2_div_8);
518-
/// let mut adc = Adc::adc1(device.ADC1, true, config);
519-
/// let pa0 = gpioa.pa0.into_analog();
520-
/// let pa3 = gpioa.pa3.into_analog();
521-
/// adc.configure_channel(&pa0, Sequence::One, SampleTime::Cycles_112);
522-
/// adc.configure_channel(&pa3, Sequence::Two, SampleTime::Cycles_480);
523-
/// adc.configure_channel(&pa0, Sequence::Three, SampleTime::Cycles_112);
524-
/// adc.start_conversion();
525-
/// }
503+
/// let config = AdcConfig::default()
504+
/// //We'll either need DMA or an interrupt per conversion to convert
505+
/// //multiple values in a sequence
506+
/// .end_of_conversion_interrupt(Eoc::Conversion);
507+
/// //Scan mode is also required to convert a sequence
508+
/// .scan(Scan::Enabled)
509+
/// //And since we're looking for one interrupt per conversion the
510+
/// //clock will need to be fairly slow to avoid overruns breaking
511+
/// //the sequence. If you are running in debug mode and logging in
512+
/// //the interrupt, good luck... try setting pclk2 really low.
513+
/// //(Better yet use DMA)
514+
/// .clock(Clock::Pclk2_div_8);
515+
/// let mut adc = Adc::adc1(device.ADC1, true, config);
516+
/// let pa0 = gpioa.pa0.into_analog();
517+
/// let pa3 = gpioa.pa3.into_analog();
518+
/// adc.configure_channel(&pa0, Sequence::One, SampleTime::Cycles_112);
519+
/// adc.configure_channel(&pa3, Sequence::Two, SampleTime::Cycles_480);
520+
/// adc.configure_channel(&pa0, Sequence::Three, SampleTime::Cycles_112);
521+
/// adc.start_conversion();
526522
/// ```
527523
///
528524
/// ## External trigger
@@ -550,47 +546,46 @@ pub mod config {
550546
/// },
551547
/// };
552548
///
553-
/// fn main() {
554-
/// let config = AdcConfig::default()
555-
/// //Set the trigger you want
556-
/// .external_trigger(TriggerMode::RisingEdge, ExternalTrigger::Tim_1_cc_1);
557-
/// let mut adc = Adc::adc1(device.ADC1, true, config);
558-
/// let pa0 = gpioa.pa0.into_analog();
559-
/// adc.configure_channel(&pa0, Sequence::One, SampleTime::Cycles_112);
560-
/// //Make sure it's enabled but don't start the conversion
561-
/// adc.enable();
549+
/// let config = AdcConfig::default()
550+
/// //Set the trigger you want
551+
/// .external_trigger(TriggerMode::RisingEdge, ExternalTrigger::Tim_1_cc_1);
552+
/// let mut adc = Adc::adc1(device.ADC1, true, config);
553+
/// let pa0 = gpioa.pa0.into_analog();
554+
/// adc.configure_channel(&pa0, Sequence::One, SampleTime::Cycles_112);
555+
/// //Make sure it's enabled but don't start the conversion
556+
/// adc.enable();
562557
///
563-
/// //Configure the timer
564-
/// let mut tim = Timer::tim1(device.TIM1, 1.hz(), clocks);
565-
/// unsafe {
566-
/// let tim = &(*TIM1::ptr());
558+
/// //Configure the timer
559+
/// let mut tim = Timer::tim1(device.TIM1, 1.hz(), clocks);
560+
/// unsafe {
561+
/// let tim = &(*TIM1::ptr());
567562
///
568-
/// //This is pwm mode 1, the default mode is "frozen" which won't work
569-
/// let mode = 0b0110;
563+
/// //This is pwm mode 1, the default mode is "frozen" which won't work
564+
/// let mode = 0b0110;
570565
///
571-
/// //Channel 1
572-
/// //Disable the channel before configuring it
573-
/// tim.ccer.modify(|_, w| w.cc1e().clear_bit());
566+
/// //Channel 1
567+
/// //Disable the channel before configuring it
568+
/// tim.ccer.modify(|_, w| w.cc1e().clear_bit());
574569
///
575-
/// tim.ccmr1_output.modify(|_, w| w
576-
/// //Preload enable for channel
577-
/// .oc1pe().set_bit()
570+
/// tim.ccmr1_output.modify(|_, w| w
571+
/// //Preload enable for channel
572+
/// .oc1pe().set_bit()
578573
///
579-
/// //Set mode for channel
580-
/// .oc1m().bits(mode)
581-
/// );
574+
/// //Set mode for channel
575+
/// .oc1m().bits(mode)
576+
/// );
582577
///
583-
/// //Set the duty cycle, 0 won't work in pwm mode but might be ok in
584-
/// //toggle mode or match mode
585-
/// let max_duty = tim.arr.read().arr().bits() as u16;
586-
/// tim.ccr1.modify(|_, w| w.ccr1().bits(max_duty / 2));
578+
/// //Set the duty cycle, 0 won't work in pwm mode but might be ok in
579+
/// //toggle mode or match mode
580+
/// let max_duty = tim.arr.read().arr().bits() as u16;
581+
/// tim.ccr1.modify(|_, w| w.ccr1().bits(max_duty / 2));
587582
///
588-
/// //Enable the channel
589-
/// tim.ccer.modify(|_, w| w.cc1e().set_bit());
583+
/// //Enable the channel
584+
/// tim.ccer.modify(|_, w| w.cc1e().set_bit());
590585
///
591-
/// //Enable the TIM main Output
592-
/// tim.bdtr.modify(|_, w| w.moe().set_bit());
593-
/// }
586+
/// //Enable the TIM main Output
587+
/// tim.bdtr.modify(|_, w| w.moe().set_bit());
588+
/// }
594589
/// ```
595590
#[derive(Clone, Copy)]
596591
pub struct Adc<ADC> {

src/rng.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ impl RngExt for RNG {
5252

5353
// verify the clock configuration is valid
5454
let hclk = clocks.hclk();
55-
let rng_clk = clocks.pll48clk().unwrap_or(0u32.hz());
55+
let rng_clk = clocks.pll48clk().unwrap_or_else(|| 0u32.hz());
5656
assert!(rng_clk.0 >= (hclk.0 / 16));
5757

5858
// enable the RNG peripheral

src/spi.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use core::ptr;
33

44
use embedded_hal::spi;
55
pub use embedded_hal::spi::{Mode, Phase, Polarity};
6-
use nb;
76

87
#[cfg(any(
98
feature = "stm32f401",

src/timer.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use cast::{u16, u32};
44
use cortex_m::peripheral::syst::SystClkSource;
55
use cortex_m::peripheral::SYST;
66
use embedded_hal::timer::{CountDown, Periodic};
7-
use nb;
87
use void::Void;
98

109
use crate::stm32::RCC;

0 commit comments

Comments
 (0)