bl808_pac/i2c/
bus_busy.rs1#[doc = "Register `bus_busy` reader"]
2pub struct R(crate::R<BUS_BUSY_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<BUS_BUSY_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<BUS_BUSY_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<BUS_BUSY_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `bus_busy` writer"]
17pub struct W(crate::W<BUS_BUSY_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::W<BUS_BUSY_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<BUS_BUSY_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::W<BUS_BUSY_SPEC>) -> Self {
34 W(writer)
35 }
36}
37#[doc = "Field `busy` reader - Indicator to I2C bus busy signal"]
38pub type BUSY_R = crate::BitReader<BUSY_A>;
39#[doc = "Indicator to I2C bus busy signal\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41pub enum BUSY_A {
42 #[doc = "1: Bus is busy"]
43 BUSY = 1,
44 #[doc = "0: Bus is not busy"]
45 IDLE = 0,
46}
47impl From<BUSY_A> for bool {
48 #[inline(always)]
49 fn from(variant: BUSY_A) -> Self {
50 variant as u8 != 0
51 }
52}
53impl BUSY_R {
54 #[doc = "Get enumerated values variant"]
55 #[inline(always)]
56 pub fn variant(&self) -> BUSY_A {
57 match self.bits {
58 true => BUSY_A::BUSY,
59 false => BUSY_A::IDLE,
60 }
61 }
62 #[doc = "Checks if the value of the field is `BUSY`"]
63 #[inline(always)]
64 pub fn is_busy(&self) -> bool {
65 *self == BUSY_A::BUSY
66 }
67 #[doc = "Checks if the value of the field is `IDLE`"]
68 #[inline(always)]
69 pub fn is_idle(&self) -> bool {
70 *self == BUSY_A::IDLE
71 }
72}
73#[doc = "Force clear I2C bus busy state\n\n Not for normal use; only use when I2C bus hangs\n\nValue on reset: 0"]
74#[derive(Clone, Copy, Debug, PartialEq, Eq)]
75pub enum FORCE_CLEAR_AW {
76 #[doc = "1: Write 1 to force clear busy flag"]
77 CLEAR = 1,
78}
79impl From<FORCE_CLEAR_AW> for bool {
80 #[inline(always)]
81 fn from(variant: FORCE_CLEAR_AW) -> Self {
82 variant as u8 != 0
83 }
84}
85#[doc = "Field `force_clear` writer - Force clear I2C bus busy state\n\n Not for normal use; only use when I2C bus hangs"]
86pub type FORCE_CLEAR_W<'a, const O: u8> =
87 crate::BitWriter<'a, u32, BUS_BUSY_SPEC, FORCE_CLEAR_AW, O>;
88impl<'a, const O: u8> FORCE_CLEAR_W<'a, O> {
89 #[doc = "Write 1 to force clear busy flag"]
90 #[inline(always)]
91 pub fn clear(self) -> &'a mut W {
92 self.variant(FORCE_CLEAR_AW::CLEAR)
93 }
94}
95impl R {
96 #[doc = "Bit 0 - Indicator to I2C bus busy signal"]
97 #[inline(always)]
98 pub fn busy(&self) -> BUSY_R {
99 BUSY_R::new((self.bits & 1) != 0)
100 }
101}
102impl W {
103 #[doc = "Bit 1 - Force clear I2C bus busy state\n\n Not for normal use; only use when I2C bus hangs"]
104 #[inline(always)]
105 pub fn force_clear(&mut self) -> FORCE_CLEAR_W<1> {
106 FORCE_CLEAR_W::new(self)
107 }
108 #[doc = "Writes raw bits to the register."]
109 #[inline(always)]
110 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
111 self.0.bits(bits);
112 self
113 }
114}
115#[doc = "Bus busy state indicator\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 [bus_busy](index.html) module"]
116pub struct BUS_BUSY_SPEC;
117impl crate::RegisterSpec for BUS_BUSY_SPEC {
118 type Ux = u32;
119}
120#[doc = "`read()` method returns [bus_busy::R](R) reader structure"]
121impl crate::Readable for BUS_BUSY_SPEC {
122 type Reader = R;
123}
124#[doc = "`write(|w| ..)` method takes [bus_busy::W](W) writer structure"]
125impl crate::Writable for BUS_BUSY_SPEC {
126 type Writer = W;
127}
128#[doc = "`reset()` method sets bus_busy to value 0"]
129impl crate::Resettable for BUS_BUSY_SPEC {
130 #[inline(always)]
131 fn reset_value() -> Self::Ux {
132 0
133 }
134}