| 1 | pub const GpioRegister = packed struct(u8) { |
| 2 | GPIO0: bool, |
| 3 | GPIO1: bool, |
| 4 | GPIO2: bool, |
| 5 | GPIO3: bool, |
| 6 | reserved: u4 = 0, |
| 7 | }; |
| 8 | |
| 9 | const gpio: *volatile GpioRegister = @ptrFromInt(0x0123); |
| 10 | |
| 11 | pub fn writeToGpio(new_states: GpioRegister) void { |
| 12 | // Example of what not to do: |
| 13 | // BAD! gpio.GPIO0 = true; BAD! |
| 14 | |
| 15 | // Instead, do this: |
| 16 | gpio.* = new_states; |
| 17 | } |
| 18 | |
| 19 | // syntax |