-
Notifications
You must be signed in to change notification settings - Fork 69
/
Copy pathgpio_erased.rs
56 lines (49 loc) · 1.44 KB
/
gpio_erased.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// TOOD Implement:
// https://github.com/dfrankland/proton-c/commit/0289f1cfa15000d6b1b2a8175420c16ffdff7451
#![no_main]
#![no_std]
use panic_semihosting as _;
use cortex_m::asm;
use cortex_m_rt::entry;
use cortex_m_semihosting::hprintln;
use hal::gpio::{self, Input};
use hal::pac;
use hal::prelude::*;
use stm32f3xx_hal as hal;
#[entry]
fn main() -> ! {
let dp = pac::Peripherals::take().unwrap();
let mut rcc = dp.RCC.constrain();
let mut gpiob = dp.GPIOB.split(&mut rcc.ahb);
let mut gpioc = dp.GPIOC.split(&mut rcc.ahb);
let mut gpiod = dp.GPIOD.split(&mut rcc.ahb);
let mut pin_array: [gpio::PXx<Input>; 4] = [
gpiob
.pb11
.into_floating_input(&mut gpiob.moder, &mut gpiob.pupdr)
.downgrade()
.downgrade(),
gpioc
.pc4
.into_floating_input(&mut gpioc.moder, &mut gpioc.pupdr)
.downgrade()
.downgrade(),
gpiod
.pd3
.into_floating_input(&mut gpiod.moder, &mut gpiod.pupdr)
.downgrade()
.downgrade(),
gpiod
.pd2
.into_floating_input(&mut gpiod.moder, &mut gpiod.pupdr)
.downgrade()
.downgrade(),
];
hprintln!("Start scanning pin array");
loop {
for pin in pin_array.iter_mut() {
hprintln!("Value is {}", pin.is_high().unwrap());
asm::delay(1_000_000);
}
}
}