add new hardware peripheral

This commit is contained in:
2026-05-25 18:41:46 +02:00
parent 8028dfd5fc
commit be5dd9632c
10 changed files with 91 additions and 18 deletions

View File

@@ -17,18 +17,25 @@ fn main() -> ! {
let mut rcc = dp.RCC.constrain();
let mut gpioa = dp.GPIOA.split(&mut rcc);
let mut gpiob = dp.GPIOB.split(&mut rcc);
let mut gpioc = dp.GPIOC.split(&mut rcc);
let button = gpioa.pa0.into_pull_down_input(&mut gpioa.crl);
// Assumes the center switch line goes high when pressed.
let button = gpioa.pa8.into_pull_down_input(&mut gpioa.crh);
let mut vcc = gpioa.pa10.into_push_pull_output(&mut gpioa.crh);
let mut gnd = gpiob.pb12.into_push_pull_output(&mut gpiob.crh);
let mut led = gpioc.pc13.into_push_pull_output(&mut gpioc.crh);
let mut delay = cp.SYST.delay(&rcc.clocks);
gnd.set_low();
vcc.set_high();
let mut was_pressed = button.is_high();
led.set_high();
info!("button-input: PA0 button to 3V3 with internal pull-down");
info!("button-input: PA8 center button, PA10 high, PB12 low");
loop {
let pressed = button.is_high();
let pressed = !button.is_high();
if pressed != was_pressed {
was_pressed = pressed;