Skip to content

fix examples #436

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions examples/adc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fn main() -> ! {
// practical needs. User specified value is be approximated using supported
// prescaler values 2/4/6/8.
let clocks = rcc.cfgr.adcclk(2.MHz()).freeze(&mut flash.acr);
hprintln!("adc freq: {}", clocks.adcclk()).unwrap();
hprintln!("adc freq: {}", clocks.adcclk());

// Setup ADC
let mut adc1 = adc::Adc::adc1(p.ADC1, clocks);
Expand All @@ -41,12 +41,12 @@ fn main() -> ! {

loop {
let data: u16 = adc1.read(&mut ch0).unwrap();
hprintln!("adc1: {}", data).unwrap();
hprintln!("adc1: {}", data);

#[cfg(any(feature = "stm32f103", feature = "connectivity"))]
{
let data1: u16 = adc2.read(&mut ch1).unwrap();
hprintln!("adc2: {}", data1).unwrap();
hprintln!("adc2: {}", data1);
}
}
}
6 changes: 3 additions & 3 deletions examples/adc_temperature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ fn main() -> ! {
usbpre: rcc::UsbPre::DIV1_5,
adcpre: rcc::AdcPre::DIV2,
}, &mut flash.acr);*/
hprintln!("sysclk freq: {}", clocks.sysclk()).unwrap();
hprintln!("adc freq: {}", clocks.adcclk()).unwrap();
hprintln!("sysclk freq: {}", clocks.sysclk());
hprintln!("adc freq: {}", clocks.adcclk());

// Setup ADC
let mut adc = adc::Adc::adc1(p.ADC1, clocks);
Expand All @@ -44,6 +44,6 @@ fn main() -> ! {
loop {
let temp = adc.read_temp();

hprintln!("temp: {}", temp).unwrap();
hprintln!("temp: {}", temp);
}
}
2 changes: 1 addition & 1 deletion examples/crc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fn main() -> ! {
crc.write(0x12345678);

let val = crc.read();
hprintln!("found={:08x}, expected={:08x}", val, 0xdf8a8a2b_u32).ok();
hprintln!("found={:08x}, expected={:08x}", val, 0xdf8a8a2b_u32);

loop {}
}
2 changes: 1 addition & 1 deletion examples/dynamic_gpio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ fn main() -> ! {
loop {
pin.make_floating_input(&mut gpioc.crh);
block!(timer.wait()).unwrap();
hprintln!("{}", pin.is_high().unwrap()).unwrap();
hprintln!("{}", pin.is_high().unwrap());

pin.make_push_pull_output(&mut gpioc.crh);
pin.set_high().unwrap();
Expand Down
2 changes: 1 addition & 1 deletion examples/hello.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ use cortex_m_rt::entry;

#[entry]
fn main() -> ! {
hprintln!("Hello, world!").unwrap();
hprintln!("Hello, world!");
loop {}
}
9 changes: 7 additions & 2 deletions examples/mfrc522.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@ use cortex_m::iprintln;

use cortex_m_rt::entry;
use embedded_hal::digital::v1_compat::OldOutputPin;
use embedded_hal::spi::{Mode, Phase, Polarity};
use mfrc522::Mfrc522;
use stm32f1xx_hal::{pac, prelude::*, spi::Spi};
pub const MODE: Mode = Mode {
polarity: Polarity::IdleLow,
phase: Phase::CaptureOnFirstTransition,
};

#[entry]
fn main() -> ! {
Expand All @@ -32,7 +37,7 @@ fn main() -> ! {
dp.SPI1,
(sck, miso, mosi),
&mut afio.mapr,
mfrc522::MODE,
MODE,
1.MHz(),
clocks,
);
Expand All @@ -46,7 +51,7 @@ fn main() -> ! {
loop {
if let Ok(atqa) = mfrc522.reqa() {
if let Ok(uid) = mfrc522.select(&atqa) {
iprintln!(_stim, "* {:?}", uid);
iprintln!(_stim, "* {:?}", uid.as_bytes());
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/multi_mode_gpio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ fn main() -> ! {
// Wait for the timer to trigger an update and change the state of the LED
loop {
block!(timer.wait()).unwrap();
hprintln!("{}", pin.is_high()).unwrap();
hprintln!("{}", pin.is_high());
pin.as_push_pull_output(&mut gpioc.crh, |out| {
out.set_high();
block!(timer.wait()).unwrap();
Expand Down
2 changes: 1 addition & 1 deletion examples/panics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use cortex_m_rt::{entry, exception, ExceptionFrame};

#[entry]
fn main() -> ! {
hprintln!("Hello, world!").unwrap();
hprintln!("Hello, world!");
loop {}
}

Expand Down
2 changes: 1 addition & 1 deletion examples/qei.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@ fn main() -> ! {

let elapsed = after.wrapping_sub(before) as i16;

hprintln!("{}", elapsed).unwrap();
hprintln!("{}", elapsed);
}
}
2 changes: 1 addition & 1 deletion examples/rtc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ fn main() -> ! {
let rtc = Rtc::new(p.RTC, &mut backup_domain);

loop {
hprintln!("time: {}", rtc.current_time()).unwrap();
hprintln!("time: {}", rtc.current_time());
}
}