nrf52840_pac/pdm/
mode.rs
1#[doc = "Register `MODE` reader"]
2pub struct R(crate::R<MODE_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<MODE_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<MODE_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<MODE_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `MODE` writer"]
17pub struct W(crate::W<MODE_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::W<MODE_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<MODE_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::W<MODE_SPEC>) -> Self {
34 W(writer)
35 }
36}
37#[doc = "Field `OPERATION` reader - Mono or stereo operation"]
38pub type OPERATION_R = crate::BitReader<OPERATION_A>;
39#[doc = "Mono or stereo operation\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq)]
41pub enum OPERATION_A {
42 #[doc = "0: Sample and store one pair (Left + Right) of 16bit samples per RAM word R=\\[31:16\\]; L=\\[15:0\\]"]
43 STEREO = 0,
44 #[doc = "1: Sample and store two successive Left samples (16 bit each) per RAM word L1=\\[31:16\\]; L0=\\[15:0\\]"]
45 MONO = 1,
46}
47impl From<OPERATION_A> for bool {
48 #[inline(always)]
49 fn from(variant: OPERATION_A) -> Self {
50 variant as u8 != 0
51 }
52}
53impl OPERATION_R {
54 #[doc = "Get enumerated values variant"]
55 #[inline(always)]
56 pub fn variant(&self) -> OPERATION_A {
57 match self.bits {
58 false => OPERATION_A::STEREO,
59 true => OPERATION_A::MONO,
60 }
61 }
62 #[doc = "Checks if the value of the field is `STEREO`"]
63 #[inline(always)]
64 pub fn is_stereo(&self) -> bool {
65 *self == OPERATION_A::STEREO
66 }
67 #[doc = "Checks if the value of the field is `MONO`"]
68 #[inline(always)]
69 pub fn is_mono(&self) -> bool {
70 *self == OPERATION_A::MONO
71 }
72}
73#[doc = "Field `OPERATION` writer - Mono or stereo operation"]
74pub type OPERATION_W<'a, const O: u8> = crate::BitWriter<'a, u32, MODE_SPEC, OPERATION_A, O>;
75impl<'a, const O: u8> OPERATION_W<'a, O> {
76 #[doc = "Sample and store one pair (Left + Right) of 16bit samples per RAM word R=\\[31:16\\]; L=\\[15:0\\]"]
77 #[inline(always)]
78 pub fn stereo(self) -> &'a mut W {
79 self.variant(OPERATION_A::STEREO)
80 }
81 #[doc = "Sample and store two successive Left samples (16 bit each) per RAM word L1=\\[31:16\\]; L0=\\[15:0\\]"]
82 #[inline(always)]
83 pub fn mono(self) -> &'a mut W {
84 self.variant(OPERATION_A::MONO)
85 }
86}
87#[doc = "Field `EDGE` reader - Defines on which PDM_CLK edge Left (or mono) is sampled"]
88pub type EDGE_R = crate::BitReader<EDGE_A>;
89#[doc = "Defines on which PDM_CLK edge Left (or mono) is sampled\n\nValue on reset: 0"]
90#[derive(Clone, Copy, Debug, PartialEq)]
91pub enum EDGE_A {
92 #[doc = "0: Left (or mono) is sampled on falling edge of PDM_CLK"]
93 LEFT_FALLING = 0,
94 #[doc = "1: Left (or mono) is sampled on rising edge of PDM_CLK"]
95 LEFT_RISING = 1,
96}
97impl From<EDGE_A> for bool {
98 #[inline(always)]
99 fn from(variant: EDGE_A) -> Self {
100 variant as u8 != 0
101 }
102}
103impl EDGE_R {
104 #[doc = "Get enumerated values variant"]
105 #[inline(always)]
106 pub fn variant(&self) -> EDGE_A {
107 match self.bits {
108 false => EDGE_A::LEFT_FALLING,
109 true => EDGE_A::LEFT_RISING,
110 }
111 }
112 #[doc = "Checks if the value of the field is `LEFT_FALLING`"]
113 #[inline(always)]
114 pub fn is_left_falling(&self) -> bool {
115 *self == EDGE_A::LEFT_FALLING
116 }
117 #[doc = "Checks if the value of the field is `LEFT_RISING`"]
118 #[inline(always)]
119 pub fn is_left_rising(&self) -> bool {
120 *self == EDGE_A::LEFT_RISING
121 }
122}
123#[doc = "Field `EDGE` writer - Defines on which PDM_CLK edge Left (or mono) is sampled"]
124pub type EDGE_W<'a, const O: u8> = crate::BitWriter<'a, u32, MODE_SPEC, EDGE_A, O>;
125impl<'a, const O: u8> EDGE_W<'a, O> {
126 #[doc = "Left (or mono) is sampled on falling edge of PDM_CLK"]
127 #[inline(always)]
128 pub fn left_falling(self) -> &'a mut W {
129 self.variant(EDGE_A::LEFT_FALLING)
130 }
131 #[doc = "Left (or mono) is sampled on rising edge of PDM_CLK"]
132 #[inline(always)]
133 pub fn left_rising(self) -> &'a mut W {
134 self.variant(EDGE_A::LEFT_RISING)
135 }
136}
137impl R {
138 #[doc = "Bit 0 - Mono or stereo operation"]
139 #[inline(always)]
140 pub fn operation(&self) -> OPERATION_R {
141 OPERATION_R::new((self.bits & 1) != 0)
142 }
143 #[doc = "Bit 1 - Defines on which PDM_CLK edge Left (or mono) is sampled"]
144 #[inline(always)]
145 pub fn edge(&self) -> EDGE_R {
146 EDGE_R::new(((self.bits >> 1) & 1) != 0)
147 }
148}
149impl W {
150 #[doc = "Bit 0 - Mono or stereo operation"]
151 #[inline(always)]
152 pub fn operation(&mut self) -> OPERATION_W<0> {
153 OPERATION_W::new(self)
154 }
155 #[doc = "Bit 1 - Defines on which PDM_CLK edge Left (or mono) is sampled"]
156 #[inline(always)]
157 pub fn edge(&mut self) -> EDGE_W<1> {
158 EDGE_W::new(self)
159 }
160 #[doc = "Writes raw bits to the register."]
161 #[inline(always)]
162 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
163 self.0.bits(bits);
164 self
165 }
166}
167#[doc = "Defines the routing of the connected PDM microphones' signals\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 [mode](index.html) module"]
168pub struct MODE_SPEC;
169impl crate::RegisterSpec for MODE_SPEC {
170 type Ux = u32;
171}
172#[doc = "`read()` method returns [mode::R](R) reader structure"]
173impl crate::Readable for MODE_SPEC {
174 type Reader = R;
175}
176#[doc = "`write(|w| ..)` method takes [mode::W](W) writer structure"]
177impl crate::Writable for MODE_SPEC {
178 type Writer = W;
179}
180#[doc = "`reset()` method sets MODE to value 0"]
181impl crate::Resettable for MODE_SPEC {
182 #[inline(always)]
183 fn reset_value() -> Self::Ux {
184 0
185 }
186}