forked from stm32-rs/stm32h7xx-hal
-
Notifications
You must be signed in to change notification settings - Fork 1
/
digital_read.rs
41 lines (30 loc) · 959 Bytes
/
digital_read.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#![deny(warnings)]
#![no_main]
#![no_std]
use stm32h7xx_hal::hal::digital::v2::InputPin;
use cortex_m_rt::entry;
use stm32h7xx_hal::{pac, prelude::*};
#[macro_use]
mod utilities;
use log::info;
#[entry]
fn main() -> ! {
utilities::logger::init();
info!("stm32h7xx-hal example - digitalRead");
let _cp = cortex_m::Peripherals::take().unwrap();
let dp = pac::Peripherals::take().unwrap();
info!("Setup PWR... ");
let pwr = dp.PWR.constrain();
let pwrcfg = example_power!(pwr).freeze();
info!("Setup RCC... ");
let rcc = dp.RCC.constrain();
let ccdr = rcc.sys_ck(100.mhz()).freeze(pwrcfg, &dp.SYSCFG);
// Push button configuration
let gpioc = dp.GPIOC.split(ccdr.peripheral.GPIOC);
let button1 = gpioc.pc5.into_pull_up_input();
loop {
let result = button1.is_high().unwrap();
info!("{}", result);
cortex_m::asm::delay(10000000);
}
}