intel_spi/
mmio.rs

1// SPDX-License-Identifier: MIT
2
3use core::ops::{BitAnd, BitOr, Not};
4use core::ptr;
5
6use super::io::Io;
7
8#[repr(transparent)]
9pub struct Mmio<T> {
10    value: T
11}
12
13impl<T> Io for Mmio<T> where T: Copy + PartialEq + BitAnd<Output = T> + BitOr<Output = T> + Not<Output = T> {
14    type Value = T;
15
16    fn read(&self) -> T {
17        unsafe { ptr::read_volatile(&self.value) }
18    }
19
20    fn write(&mut self, value: T) {
21        unsafe { ptr::write_volatile(&mut self.value, value) };
22    }
23}