cortex_ar/register/
dracr.rs

1//! Code for managing DRACR (*Data Region Access Control Register*)
2
3use arbitrary_int::u3;
4
5use crate::register::{SysReg, SysRegRead, SysRegWrite};
6
7/// DRACR (*Data Region Access Control Register*)
8#[bitbybit::bitfield(u32, debug, defmt_bitfields(feature = "defmt"))]
9#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
10pub struct Dracr {
11    /// Execute Never
12    #[bits(12..=12, rw)]
13    nx: bool,
14    /// Access Permission bits
15    #[bits(8..=10, rw)]
16    ap: u3,
17    /// TEX bits
18    #[bits(3..=5, rw)]
19    tex: u3,
20    /// S bit
21    #[bits(2..=2, rw)]
22    s: bool,
23    /// C bit
24    #[bits(1..=1, rw)]
25    c: bool,
26    /// B bit
27    #[bits(0..=0, rw)]
28    b: bool,
29}
30
31impl SysReg for Dracr {
32    const CP: u32 = 15;
33    const CRN: u32 = 6;
34    const OP1: u32 = 0;
35    const CRM: u32 = 1;
36    const OP2: u32 = 4;
37}
38impl crate::register::SysRegRead for Dracr {}
39impl Dracr {
40    #[inline]
41    /// Reads DRACR (*Data Region Access Control Register*)
42    ///
43    /// Set RGNR to control which region this reads.
44    pub fn read() -> Dracr {
45        unsafe { Self::new_with_raw_value(<Self as SysRegRead>::read_raw()) }
46    }
47}
48
49impl crate::register::SysRegWrite for Dracr {}
50impl Dracr {
51    #[inline]
52    /// Writes DRACR (*Data Region Access Control Register*)
53    ///
54    /// Set RGNR to control which region this affects.
55    pub fn write(value: Dracr) {
56        unsafe { <Self as SysRegWrite>::write_raw(value.raw_value()) }
57    }
58}