nrf52840_pac/pwm0/
loop_.rs

1#[doc = "Register `LOOP` reader"]
2pub struct R(crate::R<LOOP_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<LOOP_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<LOOP_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<LOOP_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `LOOP` writer"]
17pub struct W(crate::W<LOOP_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<LOOP_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<LOOP_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<LOOP_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `CNT` reader - Number of playbacks of pattern cycles"]
38pub type CNT_R = crate::FieldReader<u16, CNT_A>;
39#[doc = "Number of playbacks of pattern cycles\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq)]
41#[repr(u16)]
42pub enum CNT_A {
43    #[doc = "0: Looping disabled (stop at the end of the sequence)"]
44    DISABLED = 0,
45}
46impl From<CNT_A> for u16 {
47    #[inline(always)]
48    fn from(variant: CNT_A) -> Self {
49        variant as _
50    }
51}
52impl CNT_R {
53    #[doc = "Get enumerated values variant"]
54    #[inline(always)]
55    pub fn variant(&self) -> Option<CNT_A> {
56        match self.bits {
57            0 => Some(CNT_A::DISABLED),
58            _ => None,
59        }
60    }
61    #[doc = "Checks if the value of the field is `DISABLED`"]
62    #[inline(always)]
63    pub fn is_disabled(&self) -> bool {
64        *self == CNT_A::DISABLED
65    }
66}
67#[doc = "Field `CNT` writer - Number of playbacks of pattern cycles"]
68pub type CNT_W<'a, const O: u8> = crate::FieldWriter<'a, u32, LOOP_SPEC, u16, CNT_A, 16, O>;
69impl<'a, const O: u8> CNT_W<'a, O> {
70    #[doc = "Looping disabled (stop at the end of the sequence)"]
71    #[inline(always)]
72    pub fn disabled(self) -> &'a mut W {
73        self.variant(CNT_A::DISABLED)
74    }
75}
76impl R {
77    #[doc = "Bits 0:15 - Number of playbacks of pattern cycles"]
78    #[inline(always)]
79    pub fn cnt(&self) -> CNT_R {
80        CNT_R::new((self.bits & 0xffff) as u16)
81    }
82}
83impl W {
84    #[doc = "Bits 0:15 - Number of playbacks of pattern cycles"]
85    #[inline(always)]
86    pub fn cnt(&mut self) -> CNT_W<0> {
87        CNT_W::new(self)
88    }
89    #[doc = "Writes raw bits to the register."]
90    #[inline(always)]
91    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
92        self.0.bits(bits);
93        self
94    }
95}
96#[doc = "Number of playbacks of a loop\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 [loop_](index.html) module"]
97pub struct LOOP_SPEC;
98impl crate::RegisterSpec for LOOP_SPEC {
99    type Ux = u32;
100}
101#[doc = "`read()` method returns [loop_::R](R) reader structure"]
102impl crate::Readable for LOOP_SPEC {
103    type Reader = R;
104}
105#[doc = "`write(|w| ..)` method takes [loop_::W](W) writer structure"]
106impl crate::Writable for LOOP_SPEC {
107    type Writer = W;
108}
109#[doc = "`reset()` method sets LOOP to value 0"]
110impl crate::Resettable for LOOP_SPEC {
111    #[inline(always)]
112    fn reset_value() -> Self::Ux {
113        0
114    }
115}