d1_pac/spinlock/
spinlock_lock.rs1#[doc = "Register `spinlock_lock%s` reader"]
2pub type R = crate::R<SPINLOCK_LOCK_SPEC>;
3#[doc = "Register `spinlock_lock%s` writer"]
4pub type W = crate::W<SPINLOCK_LOCK_SPEC>;
5#[doc = "Field `taken` reader - Lock State"]
6pub type TAKEN_R = crate::BitReader<TAKEN_A>;
7#[doc = "Lock State\n\nValue on reset: 0"]
8#[derive(Clone, Copy, Debug, PartialEq, Eq)]
9pub enum TAKEN_A {
10 #[doc = "0: Read 0x0: The lock was previously Not Taken (free). The requester is granted the lock.\n\nWrite 0x0: Set the lock to Not Taken (free)."]
11 FREE = 0,
12 #[doc = "1: Read 0x1: The lock was previously Taken. The requester is not granted the lock and must retry.\n\nWrite 0x1: No update to the lock value."]
13 TAKEN = 1,
14}
15impl From<TAKEN_A> for bool {
16 #[inline(always)]
17 fn from(variant: TAKEN_A) -> Self {
18 variant as u8 != 0
19 }
20}
21impl TAKEN_R {
22 #[doc = "Get enumerated values variant"]
23 #[inline(always)]
24 pub const fn variant(&self) -> TAKEN_A {
25 match self.bits {
26 false => TAKEN_A::FREE,
27 true => TAKEN_A::TAKEN,
28 }
29 }
30 #[doc = "Read 0x0: The lock was previously Not Taken (free). The requester is granted the lock.\n\nWrite 0x0: Set the lock to Not Taken (free)."]
31 #[inline(always)]
32 pub fn is_free(&self) -> bool {
33 *self == TAKEN_A::FREE
34 }
35 #[doc = "Read 0x1: The lock was previously Taken. The requester is not granted the lock and must retry.\n\nWrite 0x1: No update to the lock value."]
36 #[inline(always)]
37 pub fn is_taken(&self) -> bool {
38 *self == TAKEN_A::TAKEN
39 }
40}
41#[doc = "Field `taken` writer - Lock State"]
42pub type TAKEN_W<'a, REG> = crate::BitWriter<'a, REG, TAKEN_A>;
43impl<'a, REG> TAKEN_W<'a, REG>
44where
45 REG: crate::Writable + crate::RegisterSpec,
46{
47 #[doc = "Read 0x0: The lock was previously Not Taken (free). The requester is granted the lock.\n\nWrite 0x0: Set the lock to Not Taken (free)."]
48 #[inline(always)]
49 pub fn free(self) -> &'a mut crate::W<REG> {
50 self.variant(TAKEN_A::FREE)
51 }
52 #[doc = "Read 0x1: The lock was previously Taken. The requester is not granted the lock and must retry.\n\nWrite 0x1: No update to the lock value."]
53 #[inline(always)]
54 pub fn taken(self) -> &'a mut crate::W<REG> {
55 self.variant(TAKEN_A::TAKEN)
56 }
57}
58impl R {
59 #[doc = "Bit 0 - Lock State"]
60 #[inline(always)]
61 pub fn taken(&self) -> TAKEN_R {
62 TAKEN_R::new((self.bits & 1) != 0)
63 }
64}
65impl W {
66 #[doc = "Bit 0 - Lock State"]
67 #[inline(always)]
68 #[must_use]
69 pub fn taken(&mut self) -> TAKEN_W<SPINLOCK_LOCK_SPEC> {
70 TAKEN_W::new(self, 0)
71 }
72 #[doc = r" Writes raw bits to the register."]
73 #[doc = r""]
74 #[doc = r" # Safety"]
75 #[doc = r""]
76 #[doc = r" Passing incorrect value can cause undefined behaviour. See reference manual"]
77 #[inline(always)]
78 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
79 self.bits = bits;
80 self
81 }
82}
83#[doc = "Spinlock Register\n\nYou can [`read`](crate::generic::Reg::read) this register and get [`spinlock_lock::R`](R). You can [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero) this register using [`spinlock_lock::W`](W). You can also [`modify`](crate::generic::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
84pub struct SPINLOCK_LOCK_SPEC;
85impl crate::RegisterSpec for SPINLOCK_LOCK_SPEC {
86 type Ux = u32;
87}
88#[doc = "`read()` method returns [`spinlock_lock::R`](R) reader structure"]
89impl crate::Readable for SPINLOCK_LOCK_SPEC {}
90#[doc = "`write(|w| ..)` method takes [`spinlock_lock::W`](W) writer structure"]
91impl crate::Writable for SPINLOCK_LOCK_SPEC {
92 const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
93 const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
94}
95#[doc = "`reset()` method sets spinlock_lock%s to value 0"]
96impl crate::Resettable for SPINLOCK_LOCK_SPEC {
97 const RESET_VALUE: Self::Ux = 0;
98}