aarch32_cpu/register/armv8r/
cntp_ctl.rs1use crate::register::{SysReg, SysRegRead, SysRegWrite};
4
5#[bitbybit::bitfield(u32, defmt_bitfields(feature = "defmt"))]
7#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
8pub struct CntpCtl {
9 #[bits(2..=2, r)]
11 istatus: bool,
12 #[bits(1..=1, rw)]
17 imask: bool,
18 #[bits(0..=0, rw)]
20 enable: bool,
21}
22
23impl core::fmt::Debug for CntpCtl {
24 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
25 f.debug_struct("CntpCtl")
26 .field("istatus", &self.istatus())
27 .field("imask", &self.imask())
28 .field("enable", &self.enable())
29 .finish()
30 }
31}
32
33impl SysReg for CntpCtl {
34 const CP: u32 = 15;
35 const CRN: u32 = 14;
36 const OP1: u32 = 0;
37 const CRM: u32 = 2;
38 const OP2: u32 = 1;
39}
40
41impl SysRegRead for CntpCtl {}
42
43impl CntpCtl {
44 #[inline]
45 pub fn read() -> CntpCtl {
47 unsafe { Self::new_with_raw_value(<Self as SysRegRead>::read_raw()) }
48 }
49}
50
51impl SysRegWrite for CntpCtl {}
52
53impl CntpCtl {
54 #[inline]
55 pub fn write(value: Self) {
57 unsafe {
58 <Self as SysRegWrite>::write_raw(value.raw_value());
59 }
60 }
61
62 #[inline]
63 pub fn modify<F>(f: F)
65 where
66 F: FnOnce(&mut Self),
67 {
68 let mut value = Self::read();
69 f(&mut value);
70 Self::write(value);
71 }
72}