avr-rust / ruduino

Reusable components for the Arduino Uno.
Apache License 2.0
702 stars 50 forks source link

Shouldn't all IO registers use volatile operations? #21

Closed shepmaster closed 4 years ago

shepmaster commented 4 years ago
    fn toggle_raw(mask: Self::T) {
        unsafe {
            *Self::ADDRESS ^= mask;
        }
    }

As I understand it, without using volatile operations, the compiler can see something like port = on; port = off; port = on and optimize that to just port = on.