How we interact with the real world • No special CPU instructions to control peripherals • Harvard architecture maximalism • General-purpose I/O and more advanced peripherals 0x0000 0000 Program Text 0x2000 0000 RAM 0x4000 0000 Peripherals 0x4000 0100 GPIO A 0x4000 0200 GPIO B
GPIOA_ODR &= ~(1 << 5); The Rust way GPIOA.modify(|r,w| w .odr5() .set_bit() ); GPIOA.modify(|r,w| w .odr5() .clear_bit() ); // API generated by svd2rust
led = gpioa.pa5; // Pin<GPIOA, 5, Output<PushPull>> let led = led.into_push_pull_output(); led.set_high(); // Pin<GPIOA, 5, Analog> let led = led.into_analog();