Skip to content

Instantly share code, notes, and snippets.

@Dirbaio
Created August 29, 2022 16:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Dirbaio/860a566fe38c84a3823b602312e1f086 to your computer and use it in GitHub Desktop.
Save Dirbaio/860a566fe38c84a3823b602312e1f086 to your computer and use it in GitHub Desktop.
#![no_std]
#![no_main]
use panic_halt as _;
use stm32ral::{gpio, read_reg, write_reg};
#[cortex_m_rt::entry]
fn main() -> ! {
//critical_section::with(|_| {
cortex_m::interrupt::free(|_| {
unsafe {
if(read_reg!(gpio, GPIOA, IDR) == 1) {
write_reg!(gpio, GPIOA, ODR, 1);
} else {
write_reg!(gpio, GPIOA, ODR, 2);
}
}
});
loop {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment