Created
August 29, 2022 16:08
-
-
Save Dirbaio/860a566fe38c84a3823b602312e1f086 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![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