ra6m4/adc120/
adbufptr.rs

1#[doc = "Register `ADBUFPTR` reader"]
2pub struct R(crate::R<ADBUFPTR_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<ADBUFPTR_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<ADBUFPTR_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<ADBUFPTR_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `ADBUFPTR` writer"]
17pub struct W(crate::W<ADBUFPTR_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<ADBUFPTR_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<ADBUFPTR_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<ADBUFPTR_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `BUFPTR` reader - Data Buffer Pointer"]
38pub type BUFPTR_R = crate::FieldReader<u8, u8>;
39#[doc = "Field `BUFPTR` writer - Data Buffer Pointer"]
40pub type BUFPTR_W<'a, const O: u8> = crate::FieldWriter<'a, u8, ADBUFPTR_SPEC, u8, u8, 4, O>;
41#[doc = "Field `PTROVF` reader - Pointer Overflow Flag"]
42pub type PTROVF_R = crate::BitReader<PTROVF_A>;
43#[doc = "Pointer Overflow Flag\n\nValue on reset: 0"]
44#[derive(Clone, Copy, Debug, PartialEq, Eq)]
45pub enum PTROVF_A {
46    #[doc = "0: The data buffer pointer has not overflowed."]
47    _0 = 0,
48    #[doc = "1: The data buffer pointer has overflowed."]
49    _1 = 1,
50}
51impl From<PTROVF_A> for bool {
52    #[inline(always)]
53    fn from(variant: PTROVF_A) -> Self {
54        variant as u8 != 0
55    }
56}
57impl PTROVF_R {
58    #[doc = "Get enumerated values variant"]
59    #[inline(always)]
60    pub fn variant(&self) -> PTROVF_A {
61        match self.bits {
62            false => PTROVF_A::_0,
63            true => PTROVF_A::_1,
64        }
65    }
66    #[doc = "Checks if the value of the field is `_0`"]
67    #[inline(always)]
68    pub fn is_0(&self) -> bool {
69        *self == PTROVF_A::_0
70    }
71    #[doc = "Checks if the value of the field is `_1`"]
72    #[inline(always)]
73    pub fn is_1(&self) -> bool {
74        *self == PTROVF_A::_1
75    }
76}
77#[doc = "Field `PTROVF` writer - Pointer Overflow Flag"]
78pub type PTROVF_W<'a, const O: u8> = crate::BitWriter<'a, u8, ADBUFPTR_SPEC, PTROVF_A, O>;
79impl<'a, const O: u8> PTROVF_W<'a, O> {
80    #[doc = "The data buffer pointer has not overflowed."]
81    #[inline(always)]
82    pub fn _0(self) -> &'a mut W {
83        self.variant(PTROVF_A::_0)
84    }
85    #[doc = "The data buffer pointer has overflowed."]
86    #[inline(always)]
87    pub fn _1(self) -> &'a mut W {
88        self.variant(PTROVF_A::_1)
89    }
90}
91impl R {
92    #[doc = "Bits 0:3 - Data Buffer Pointer"]
93    #[inline(always)]
94    pub fn bufptr(&self) -> BUFPTR_R {
95        BUFPTR_R::new(self.bits & 0x0f)
96    }
97    #[doc = "Bit 4 - Pointer Overflow Flag"]
98    #[inline(always)]
99    pub fn ptrovf(&self) -> PTROVF_R {
100        PTROVF_R::new(((self.bits >> 4) & 1) != 0)
101    }
102}
103impl W {
104    #[doc = "Bits 0:3 - Data Buffer Pointer"]
105    #[inline(always)]
106    #[must_use]
107    pub fn bufptr(&mut self) -> BUFPTR_W<0> {
108        BUFPTR_W::new(self)
109    }
110    #[doc = "Bit 4 - Pointer Overflow Flag"]
111    #[inline(always)]
112    #[must_use]
113    pub fn ptrovf(&mut self) -> PTROVF_W<4> {
114        PTROVF_W::new(self)
115    }
116    #[doc = "Writes raw bits to the register."]
117    #[inline(always)]
118    pub unsafe fn bits(&mut self, bits: u8) -> &mut Self {
119        self.0.bits(bits);
120        self
121    }
122}
123#[doc = "A/D Data Buffer Pointer Register\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 [adbufptr](index.html) module"]
124pub struct ADBUFPTR_SPEC;
125impl crate::RegisterSpec for ADBUFPTR_SPEC {
126    type Ux = u8;
127}
128#[doc = "`read()` method returns [adbufptr::R](R) reader structure"]
129impl crate::Readable for ADBUFPTR_SPEC {
130    type Reader = R;
131}
132#[doc = "`write(|w| ..)` method takes [adbufptr::W](W) writer structure"]
133impl crate::Writable for ADBUFPTR_SPEC {
134    type Writer = W;
135    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
136    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
137}
138#[doc = "`reset()` method sets ADBUFPTR to value 0"]
139impl crate::Resettable for ADBUFPTR_SPEC {
140    const RESET_VALUE: Self::Ux = 0;
141}