nrf5340_net_pac/twim0_ns/
frequency.rs1#[doc = "Register `FREQUENCY` reader"]
2pub struct R(crate::R<FREQUENCY_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<FREQUENCY_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<FREQUENCY_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<FREQUENCY_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `FREQUENCY` writer"]
17pub struct W(crate::W<FREQUENCY_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::W<FREQUENCY_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<FREQUENCY_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::W<FREQUENCY_SPEC>) -> Self {
34 W(writer)
35 }
36}
37#[doc = "Field `FREQUENCY` reader - TWI master clock frequency"]
38pub type FREQUENCY_R = crate::FieldReader<u32, FREQUENCY_A>;
39#[doc = "TWI master clock frequency\n\nValue on reset: 67108864"]
40#[derive(Clone, Copy, Debug, PartialEq)]
41#[repr(u32)]
42pub enum FREQUENCY_A {
43 #[doc = "26738688: 100 kbps"]
44 K100 = 26738688,
45 #[doc = "67108864: 250 kbps"]
46 K250 = 67108864,
47 #[doc = "104857600: 400 kbps"]
48 K400 = 104857600,
49 #[doc = "267386880: 1000 kbps"]
50 K1000 = 267386880,
51}
52impl From<FREQUENCY_A> for u32 {
53 #[inline(always)]
54 fn from(variant: FREQUENCY_A) -> Self {
55 variant as _
56 }
57}
58impl FREQUENCY_R {
59 #[doc = "Get enumerated values variant"]
60 #[inline(always)]
61 pub fn variant(&self) -> Option<FREQUENCY_A> {
62 match self.bits {
63 26738688 => Some(FREQUENCY_A::K100),
64 67108864 => Some(FREQUENCY_A::K250),
65 104857600 => Some(FREQUENCY_A::K400),
66 267386880 => Some(FREQUENCY_A::K1000),
67 _ => None,
68 }
69 }
70 #[doc = "Checks if the value of the field is `K100`"]
71 #[inline(always)]
72 pub fn is_k100(&self) -> bool {
73 *self == FREQUENCY_A::K100
74 }
75 #[doc = "Checks if the value of the field is `K250`"]
76 #[inline(always)]
77 pub fn is_k250(&self) -> bool {
78 *self == FREQUENCY_A::K250
79 }
80 #[doc = "Checks if the value of the field is `K400`"]
81 #[inline(always)]
82 pub fn is_k400(&self) -> bool {
83 *self == FREQUENCY_A::K400
84 }
85 #[doc = "Checks if the value of the field is `K1000`"]
86 #[inline(always)]
87 pub fn is_k1000(&self) -> bool {
88 *self == FREQUENCY_A::K1000
89 }
90}
91#[doc = "Field `FREQUENCY` writer - TWI master clock frequency"]
92pub type FREQUENCY_W<'a, const O: u8> =
93 crate::FieldWriter<'a, u32, FREQUENCY_SPEC, u32, FREQUENCY_A, 32, O>;
94impl<'a, const O: u8> FREQUENCY_W<'a, O> {
95 #[doc = "100 kbps"]
96 #[inline(always)]
97 pub fn k100(self) -> &'a mut W {
98 self.variant(FREQUENCY_A::K100)
99 }
100 #[doc = "250 kbps"]
101 #[inline(always)]
102 pub fn k250(self) -> &'a mut W {
103 self.variant(FREQUENCY_A::K250)
104 }
105 #[doc = "400 kbps"]
106 #[inline(always)]
107 pub fn k400(self) -> &'a mut W {
108 self.variant(FREQUENCY_A::K400)
109 }
110 #[doc = "1000 kbps"]
111 #[inline(always)]
112 pub fn k1000(self) -> &'a mut W {
113 self.variant(FREQUENCY_A::K1000)
114 }
115}
116impl R {
117 #[doc = "Bits 0:31 - TWI master clock frequency"]
118 #[inline(always)]
119 pub fn frequency(&self) -> FREQUENCY_R {
120 FREQUENCY_R::new(self.bits)
121 }
122}
123impl W {
124 #[doc = "Bits 0:31 - TWI master clock frequency"]
125 #[inline(always)]
126 pub fn frequency(&mut self) -> FREQUENCY_W<0> {
127 FREQUENCY_W::new(self)
128 }
129 #[doc = "Writes raw bits to the register."]
130 #[inline(always)]
131 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
132 self.0.bits(bits);
133 self
134 }
135}
136#[doc = "TWI frequency. Accuracy depends on the HFCLK source selected.\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 [frequency](index.html) module"]
137pub struct FREQUENCY_SPEC;
138impl crate::RegisterSpec for FREQUENCY_SPEC {
139 type Ux = u32;
140}
141#[doc = "`read()` method returns [frequency::R](R) reader structure"]
142impl crate::Readable for FREQUENCY_SPEC {
143 type Reader = R;
144}
145#[doc = "`write(|w| ..)` method takes [frequency::W](W) writer structure"]
146impl crate::Writable for FREQUENCY_SPEC {
147 type Writer = W;
148}
149#[doc = "`reset()` method sets FREQUENCY to value 0x0400_0000"]
150impl crate::Resettable for FREQUENCY_SPEC {
151 #[inline(always)]
152 fn reset_value() -> Self::Ux {
153 0x0400_0000
154 }
155}