nrf5340_app_pac/i2s0_ns/config/
swidth.rs

1#[doc = "Register `SWIDTH` reader"]
2pub struct R(crate::R<SWIDTH_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<SWIDTH_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<SWIDTH_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<SWIDTH_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `SWIDTH` writer"]
17pub struct W(crate::W<SWIDTH_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<SWIDTH_SPEC>;
20    #[inline(always)]
21    fn deref(&self) -> &Self::Target {
22        &self.0
23    }
24}
25impl core::ops::DerefMut for W {
26    #[inline(always)]
27    fn deref_mut(&mut self) -> &mut Self::Target {
28        &mut self.0
29    }
30}
31impl From<crate::W<SWIDTH_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<SWIDTH_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `SWIDTH` reader - Sample and half-frame width"]
38pub type SWIDTH_R = crate::FieldReader<u8, SWIDTH_A>;
39#[doc = "Sample and half-frame width\n\nValue on reset: 1"]
40#[derive(Clone, Copy, Debug, PartialEq)]
41#[repr(u8)]
42pub enum SWIDTH_A {
43    #[doc = "0: 8 bit sample."]
44    _8BIT = 0,
45    #[doc = "1: 16 bit sample."]
46    _16BIT = 1,
47    #[doc = "2: 24 bit sample."]
48    _24BIT = 2,
49    #[doc = "3: 32 bit sample."]
50    _32BIT = 3,
51    #[doc = "4: 8 bit sample in a 16-bit half-frame."]
52    _8BIT_IN16 = 4,
53    #[doc = "5: 8 bit sample in a 32-bit half-frame."]
54    _8BIT_IN32 = 5,
55    #[doc = "6: 16 bit sample in a 32-bit half-frame."]
56    _16BIT_IN32 = 6,
57    #[doc = "7: 24 bit sample in a 32-bit half-frame."]
58    _24BIT_IN32 = 7,
59}
60impl From<SWIDTH_A> for u8 {
61    #[inline(always)]
62    fn from(variant: SWIDTH_A) -> Self {
63        variant as _
64    }
65}
66impl SWIDTH_R {
67    #[doc = "Get enumerated values variant"]
68    #[inline(always)]
69    pub fn variant(&self) -> SWIDTH_A {
70        match self.bits {
71            0 => SWIDTH_A::_8BIT,
72            1 => SWIDTH_A::_16BIT,
73            2 => SWIDTH_A::_24BIT,
74            3 => SWIDTH_A::_32BIT,
75            4 => SWIDTH_A::_8BIT_IN16,
76            5 => SWIDTH_A::_8BIT_IN32,
77            6 => SWIDTH_A::_16BIT_IN32,
78            7 => SWIDTH_A::_24BIT_IN32,
79            _ => unreachable!(),
80        }
81    }
82    #[doc = "Checks if the value of the field is `_8BIT`"]
83    #[inline(always)]
84    pub fn is_8bit(&self) -> bool {
85        *self == SWIDTH_A::_8BIT
86    }
87    #[doc = "Checks if the value of the field is `_16BIT`"]
88    #[inline(always)]
89    pub fn is_16bit(&self) -> bool {
90        *self == SWIDTH_A::_16BIT
91    }
92    #[doc = "Checks if the value of the field is `_24BIT`"]
93    #[inline(always)]
94    pub fn is_24bit(&self) -> bool {
95        *self == SWIDTH_A::_24BIT
96    }
97    #[doc = "Checks if the value of the field is `_32BIT`"]
98    #[inline(always)]
99    pub fn is_32bit(&self) -> bool {
100        *self == SWIDTH_A::_32BIT
101    }
102    #[doc = "Checks if the value of the field is `_8BIT_IN16`"]
103    #[inline(always)]
104    pub fn is_8bit_in16(&self) -> bool {
105        *self == SWIDTH_A::_8BIT_IN16
106    }
107    #[doc = "Checks if the value of the field is `_8BIT_IN32`"]
108    #[inline(always)]
109    pub fn is_8bit_in32(&self) -> bool {
110        *self == SWIDTH_A::_8BIT_IN32
111    }
112    #[doc = "Checks if the value of the field is `_16BIT_IN32`"]
113    #[inline(always)]
114    pub fn is_16bit_in32(&self) -> bool {
115        *self == SWIDTH_A::_16BIT_IN32
116    }
117    #[doc = "Checks if the value of the field is `_24BIT_IN32`"]
118    #[inline(always)]
119    pub fn is_24bit_in32(&self) -> bool {
120        *self == SWIDTH_A::_24BIT_IN32
121    }
122}
123#[doc = "Field `SWIDTH` writer - Sample and half-frame width"]
124pub type SWIDTH_W<'a, const O: u8> =
125    crate::FieldWriterSafe<'a, u32, SWIDTH_SPEC, u8, SWIDTH_A, 3, O>;
126impl<'a, const O: u8> SWIDTH_W<'a, O> {
127    #[doc = "8 bit sample."]
128    #[inline(always)]
129    pub fn _8bit(self) -> &'a mut W {
130        self.variant(SWIDTH_A::_8BIT)
131    }
132    #[doc = "16 bit sample."]
133    #[inline(always)]
134    pub fn _16bit(self) -> &'a mut W {
135        self.variant(SWIDTH_A::_16BIT)
136    }
137    #[doc = "24 bit sample."]
138    #[inline(always)]
139    pub fn _24bit(self) -> &'a mut W {
140        self.variant(SWIDTH_A::_24BIT)
141    }
142    #[doc = "32 bit sample."]
143    #[inline(always)]
144    pub fn _32bit(self) -> &'a mut W {
145        self.variant(SWIDTH_A::_32BIT)
146    }
147    #[doc = "8 bit sample in a 16-bit half-frame."]
148    #[inline(always)]
149    pub fn _8bit_in16(self) -> &'a mut W {
150        self.variant(SWIDTH_A::_8BIT_IN16)
151    }
152    #[doc = "8 bit sample in a 32-bit half-frame."]
153    #[inline(always)]
154    pub fn _8bit_in32(self) -> &'a mut W {
155        self.variant(SWIDTH_A::_8BIT_IN32)
156    }
157    #[doc = "16 bit sample in a 32-bit half-frame."]
158    #[inline(always)]
159    pub fn _16bit_in32(self) -> &'a mut W {
160        self.variant(SWIDTH_A::_16BIT_IN32)
161    }
162    #[doc = "24 bit sample in a 32-bit half-frame."]
163    #[inline(always)]
164    pub fn _24bit_in32(self) -> &'a mut W {
165        self.variant(SWIDTH_A::_24BIT_IN32)
166    }
167}
168impl R {
169    #[doc = "Bits 0:2 - Sample and half-frame width"]
170    #[inline(always)]
171    pub fn swidth(&self) -> SWIDTH_R {
172        SWIDTH_R::new((self.bits & 7) as u8)
173    }
174}
175impl W {
176    #[doc = "Bits 0:2 - Sample and half-frame width"]
177    #[inline(always)]
178    pub fn swidth(&mut self) -> SWIDTH_W<0> {
179        SWIDTH_W::new(self)
180    }
181    #[doc = "Writes raw bits to the register."]
182    #[inline(always)]
183    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
184        self.0.bits(bits);
185        self
186    }
187}
188#[doc = "Sample width\n\nThis register you can [`read`](crate::generic::Reg::read), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [swidth](index.html) module"]
189pub struct SWIDTH_SPEC;
190impl crate::RegisterSpec for SWIDTH_SPEC {
191    type Ux = u32;
192}
193#[doc = "`read()` method returns [swidth::R](R) reader structure"]
194impl crate::Readable for SWIDTH_SPEC {
195    type Reader = R;
196}
197#[doc = "`write(|w| ..)` method takes [swidth::W](W) writer structure"]
198impl crate::Writable for SWIDTH_SPEC {
199    type Writer = W;
200}
201#[doc = "`reset()` method sets SWIDTH to value 0x01"]
202impl crate::Resettable for SWIDTH_SPEC {
203    #[inline(always)]
204    fn reset_value() -> Self::Ux {
205        0x01
206    }
207}