From 76102d28a42738b1bbb61adca6af3ce86c47296b Mon Sep 17 00:00:00 2001 From: kirbylife Date: Sat, 10 Dec 2022 00:45:48 -0600 Subject: [PATCH] now use the read_volatile and xor op to flip the bit value --- src/main.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index 8ea7370..d58ee28 100644 --- a/src/main.rs +++ b/src/main.rs @@ -15,9 +15,9 @@ pub extern "C" fn main() -> ! { unsafe { write_volatile(DDRB, 0b11111111) }; loop { - unsafe { write_volatile(PORTB, 0b00000000) }; - sleep(1); - unsafe { write_volatile(PORTB, 0b00100000) }; + let mut portb_value = unsafe { read_volatile(PORTB) }; + portb_value = portb_value ^ (1 << 5); + unsafe { write_volatile(PORTB, portb_value) }; sleep(1); } }