use crate::register::{SysReg, SysRegRead, SysRegWrite};
#[derive(Clone, Copy, PartialEq, Eq)]
#[repr(transparent)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct Vbar(pub *mut u32);
impl SysReg for Vbar {
const CP: u32 = 15;
const CRN: u32 = 12;
const OP1: u32 = 0;
const CRM: u32 = 0;
const OP2: u32 = 0;
}
impl SysRegRead for Vbar {}
impl SysRegWrite for Vbar {}
impl Vbar {
#[inline]
pub fn read() -> Vbar {
unsafe { Self(<Self as SysRegRead>::read_raw() as *mut u32) }
}
#[inline]
pub unsafe fn write(value: Self) {
unsafe {
<Self as SysRegWrite>::write_raw(value.0 as u32);
}
}
}
impl core::fmt::Debug for Vbar {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "VBAR {{ {:010p} }}", self.0)
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Vbar {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "VBAR {{ 0x{=usize:08x} }}", self.0 as usize)
}
}