Skip to content

Commit 7a0bfe6

Browse files
authored
Merge pull request #31 from richardanaya/spinlock-read-write
Make spinlock registers read-write Fixes #18
2 parents d4d8840 + 77305e9 commit 7a0bfe6

34 files changed

+1131
-64
lines changed

src/sio/spinlock0.rs

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,35 @@ impl From<crate::R<SPINLOCK0_SPEC>> for R {
1313
R(reader)
1414
}
1515
}
16+
#[doc = "Register `SPINLOCK0` writer"]
17+
pub struct W(crate::W<SPINLOCK0_SPEC>);
18+
impl core::ops::Deref for W {
19+
type Target = crate::W<SPINLOCK0_SPEC>;
20+
#[inline(always)]
21+
fn deref(&self) -> &Self::Target {
22+
&self.0
23+
}
24+
}
25+
impl core::ops::DerefMut for W {
26+
#[inline(always)]
27+
fn deref_mut(&mut self) -> &mut Self::Target {
28+
&mut self.0
29+
}
30+
}
31+
impl From<crate::W<SPINLOCK0_SPEC>> for W {
32+
#[inline(always)]
33+
fn from(writer: crate::W<SPINLOCK0_SPEC>) -> Self {
34+
W(writer)
35+
}
36+
}
37+
impl W {
38+
#[doc = "Writes raw bits to the register."]
39+
#[inline(always)]
40+
pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
41+
self.0.bits(bits);
42+
self
43+
}
44+
}
1645
#[doc = "Reading from a spinlock address will:
1746
- Return 0 if lock is already locked
1847
- Otherwise return nonzero, and simultaneously claim the lock
@@ -21,7 +50,7 @@ impl From<crate::R<SPINLOCK0_SPEC>> for R {
2150
If core 0 and core 1 attempt to claim the same lock simultaneously, core 0 wins.
2251
The value returned on success is 0x1 << lock number.
2352
24-
This register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).
53+
This 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).
2554
2655
For information about available fields see [spinlock0](index.html) module"]
2756
pub struct SPINLOCK0_SPEC;
@@ -32,6 +61,10 @@ impl crate::RegisterSpec for SPINLOCK0_SPEC {
3261
impl crate::Readable for SPINLOCK0_SPEC {
3362
type Reader = R;
3463
}
64+
#[doc = "`write(|w| ..)` method takes [spinlock0::W](W) writer structure"]
65+
impl crate::Writable for SPINLOCK0_SPEC {
66+
type Writer = W;
67+
}
3568
#[doc = "`reset()` method sets SPINLOCK0 to value 0"]
3669
impl crate::Resettable for SPINLOCK0_SPEC {
3770
#[inline(always)]

src/sio/spinlock1.rs

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,35 @@ impl From<crate::R<SPINLOCK1_SPEC>> for R {
1313
R(reader)
1414
}
1515
}
16+
#[doc = "Register `SPINLOCK1` writer"]
17+
pub struct W(crate::W<SPINLOCK1_SPEC>);
18+
impl core::ops::Deref for W {
19+
type Target = crate::W<SPINLOCK1_SPEC>;
20+
#[inline(always)]
21+
fn deref(&self) -> &Self::Target {
22+
&self.0
23+
}
24+
}
25+
impl core::ops::DerefMut for W {
26+
#[inline(always)]
27+
fn deref_mut(&mut self) -> &mut Self::Target {
28+
&mut self.0
29+
}
30+
}
31+
impl From<crate::W<SPINLOCK1_SPEC>> for W {
32+
#[inline(always)]
33+
fn from(writer: crate::W<SPINLOCK1_SPEC>) -> Self {
34+
W(writer)
35+
}
36+
}
37+
impl W {
38+
#[doc = "Writes raw bits to the register."]
39+
#[inline(always)]
40+
pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
41+
self.0.bits(bits);
42+
self
43+
}
44+
}
1645
#[doc = "Reading from a spinlock address will:
1746
- Return 0 if lock is already locked
1847
- Otherwise return nonzero, and simultaneously claim the lock
@@ -21,7 +50,7 @@ impl From<crate::R<SPINLOCK1_SPEC>> for R {
2150
If core 0 and core 1 attempt to claim the same lock simultaneously, core 0 wins.
2251
The value returned on success is 0x1 << lock number.
2352
24-
This register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).
53+
This 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).
2554
2655
For information about available fields see [spinlock1](index.html) module"]
2756
pub struct SPINLOCK1_SPEC;
@@ -32,6 +61,10 @@ impl crate::RegisterSpec for SPINLOCK1_SPEC {
3261
impl crate::Readable for SPINLOCK1_SPEC {
3362
type Reader = R;
3463
}
64+
#[doc = "`write(|w| ..)` method takes [spinlock1::W](W) writer structure"]
65+
impl crate::Writable for SPINLOCK1_SPEC {
66+
type Writer = W;
67+
}
3568
#[doc = "`reset()` method sets SPINLOCK1 to value 0"]
3669
impl crate::Resettable for SPINLOCK1_SPEC {
3770
#[inline(always)]

src/sio/spinlock10.rs

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,35 @@ impl From<crate::R<SPINLOCK10_SPEC>> for R {
1313
R(reader)
1414
}
1515
}
16+
#[doc = "Register `SPINLOCK10` writer"]
17+
pub struct W(crate::W<SPINLOCK10_SPEC>);
18+
impl core::ops::Deref for W {
19+
type Target = crate::W<SPINLOCK10_SPEC>;
20+
#[inline(always)]
21+
fn deref(&self) -> &Self::Target {
22+
&self.0
23+
}
24+
}
25+
impl core::ops::DerefMut for W {
26+
#[inline(always)]
27+
fn deref_mut(&mut self) -> &mut Self::Target {
28+
&mut self.0
29+
}
30+
}
31+
impl From<crate::W<SPINLOCK10_SPEC>> for W {
32+
#[inline(always)]
33+
fn from(writer: crate::W<SPINLOCK10_SPEC>) -> Self {
34+
W(writer)
35+
}
36+
}
37+
impl W {
38+
#[doc = "Writes raw bits to the register."]
39+
#[inline(always)]
40+
pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
41+
self.0.bits(bits);
42+
self
43+
}
44+
}
1645
#[doc = "Reading from a spinlock address will:
1746
- Return 0 if lock is already locked
1847
- Otherwise return nonzero, and simultaneously claim the lock
@@ -21,7 +50,7 @@ impl From<crate::R<SPINLOCK10_SPEC>> for R {
2150
If core 0 and core 1 attempt to claim the same lock simultaneously, core 0 wins.
2251
The value returned on success is 0x1 << lock number.
2352
24-
This register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).
53+
This 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).
2554
2655
For information about available fields see [spinlock10](index.html) module"]
2756
pub struct SPINLOCK10_SPEC;
@@ -32,6 +61,10 @@ impl crate::RegisterSpec for SPINLOCK10_SPEC {
3261
impl crate::Readable for SPINLOCK10_SPEC {
3362
type Reader = R;
3463
}
64+
#[doc = "`write(|w| ..)` method takes [spinlock10::W](W) writer structure"]
65+
impl crate::Writable for SPINLOCK10_SPEC {
66+
type Writer = W;
67+
}
3568
#[doc = "`reset()` method sets SPINLOCK10 to value 0"]
3669
impl crate::Resettable for SPINLOCK10_SPEC {
3770
#[inline(always)]

src/sio/spinlock11.rs

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,35 @@ impl From<crate::R<SPINLOCK11_SPEC>> for R {
1313
R(reader)
1414
}
1515
}
16+
#[doc = "Register `SPINLOCK11` writer"]
17+
pub struct W(crate::W<SPINLOCK11_SPEC>);
18+
impl core::ops::Deref for W {
19+
type Target = crate::W<SPINLOCK11_SPEC>;
20+
#[inline(always)]
21+
fn deref(&self) -> &Self::Target {
22+
&self.0
23+
}
24+
}
25+
impl core::ops::DerefMut for W {
26+
#[inline(always)]
27+
fn deref_mut(&mut self) -> &mut Self::Target {
28+
&mut self.0
29+
}
30+
}
31+
impl From<crate::W<SPINLOCK11_SPEC>> for W {
32+
#[inline(always)]
33+
fn from(writer: crate::W<SPINLOCK11_SPEC>) -> Self {
34+
W(writer)
35+
}
36+
}
37+
impl W {
38+
#[doc = "Writes raw bits to the register."]
39+
#[inline(always)]
40+
pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
41+
self.0.bits(bits);
42+
self
43+
}
44+
}
1645
#[doc = "Reading from a spinlock address will:
1746
- Return 0 if lock is already locked
1847
- Otherwise return nonzero, and simultaneously claim the lock
@@ -21,7 +50,7 @@ impl From<crate::R<SPINLOCK11_SPEC>> for R {
2150
If core 0 and core 1 attempt to claim the same lock simultaneously, core 0 wins.
2251
The value returned on success is 0x1 << lock number.
2352
24-
This register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).
53+
This 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).
2554
2655
For information about available fields see [spinlock11](index.html) module"]
2756
pub struct SPINLOCK11_SPEC;
@@ -32,6 +61,10 @@ impl crate::RegisterSpec for SPINLOCK11_SPEC {
3261
impl crate::Readable for SPINLOCK11_SPEC {
3362
type Reader = R;
3463
}
64+
#[doc = "`write(|w| ..)` method takes [spinlock11::W](W) writer structure"]
65+
impl crate::Writable for SPINLOCK11_SPEC {
66+
type Writer = W;
67+
}
3568
#[doc = "`reset()` method sets SPINLOCK11 to value 0"]
3669
impl crate::Resettable for SPINLOCK11_SPEC {
3770
#[inline(always)]

src/sio/spinlock12.rs

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,35 @@ impl From<crate::R<SPINLOCK12_SPEC>> for R {
1313
R(reader)
1414
}
1515
}
16+
#[doc = "Register `SPINLOCK12` writer"]
17+
pub struct W(crate::W<SPINLOCK12_SPEC>);
18+
impl core::ops::Deref for W {
19+
type Target = crate::W<SPINLOCK12_SPEC>;
20+
#[inline(always)]
21+
fn deref(&self) -> &Self::Target {
22+
&self.0
23+
}
24+
}
25+
impl core::ops::DerefMut for W {
26+
#[inline(always)]
27+
fn deref_mut(&mut self) -> &mut Self::Target {
28+
&mut self.0
29+
}
30+
}
31+
impl From<crate::W<SPINLOCK12_SPEC>> for W {
32+
#[inline(always)]
33+
fn from(writer: crate::W<SPINLOCK12_SPEC>) -> Self {
34+
W(writer)
35+
}
36+
}
37+
impl W {
38+
#[doc = "Writes raw bits to the register."]
39+
#[inline(always)]
40+
pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
41+
self.0.bits(bits);
42+
self
43+
}
44+
}
1645
#[doc = "Reading from a spinlock address will:
1746
- Return 0 if lock is already locked
1847
- Otherwise return nonzero, and simultaneously claim the lock
@@ -21,7 +50,7 @@ impl From<crate::R<SPINLOCK12_SPEC>> for R {
2150
If core 0 and core 1 attempt to claim the same lock simultaneously, core 0 wins.
2251
The value returned on success is 0x1 << lock number.
2352
24-
This register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).
53+
This 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).
2554
2655
For information about available fields see [spinlock12](index.html) module"]
2756
pub struct SPINLOCK12_SPEC;
@@ -32,6 +61,10 @@ impl crate::RegisterSpec for SPINLOCK12_SPEC {
3261
impl crate::Readable for SPINLOCK12_SPEC {
3362
type Reader = R;
3463
}
64+
#[doc = "`write(|w| ..)` method takes [spinlock12::W](W) writer structure"]
65+
impl crate::Writable for SPINLOCK12_SPEC {
66+
type Writer = W;
67+
}
3568
#[doc = "`reset()` method sets SPINLOCK12 to value 0"]
3669
impl crate::Resettable for SPINLOCK12_SPEC {
3770
#[inline(always)]

src/sio/spinlock13.rs

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,35 @@ impl From<crate::R<SPINLOCK13_SPEC>> for R {
1313
R(reader)
1414
}
1515
}
16+
#[doc = "Register `SPINLOCK13` writer"]
17+
pub struct W(crate::W<SPINLOCK13_SPEC>);
18+
impl core::ops::Deref for W {
19+
type Target = crate::W<SPINLOCK13_SPEC>;
20+
#[inline(always)]
21+
fn deref(&self) -> &Self::Target {
22+
&self.0
23+
}
24+
}
25+
impl core::ops::DerefMut for W {
26+
#[inline(always)]
27+
fn deref_mut(&mut self) -> &mut Self::Target {
28+
&mut self.0
29+
}
30+
}
31+
impl From<crate::W<SPINLOCK13_SPEC>> for W {
32+
#[inline(always)]
33+
fn from(writer: crate::W<SPINLOCK13_SPEC>) -> Self {
34+
W(writer)
35+
}
36+
}
37+
impl W {
38+
#[doc = "Writes raw bits to the register."]
39+
#[inline(always)]
40+
pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
41+
self.0.bits(bits);
42+
self
43+
}
44+
}
1645
#[doc = "Reading from a spinlock address will:
1746
- Return 0 if lock is already locked
1847
- Otherwise return nonzero, and simultaneously claim the lock
@@ -21,7 +50,7 @@ impl From<crate::R<SPINLOCK13_SPEC>> for R {
2150
If core 0 and core 1 attempt to claim the same lock simultaneously, core 0 wins.
2251
The value returned on success is 0x1 << lock number.
2352
24-
This register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).
53+
This 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).
2554
2655
For information about available fields see [spinlock13](index.html) module"]
2756
pub struct SPINLOCK13_SPEC;
@@ -32,6 +61,10 @@ impl crate::RegisterSpec for SPINLOCK13_SPEC {
3261
impl crate::Readable for SPINLOCK13_SPEC {
3362
type Reader = R;
3463
}
64+
#[doc = "`write(|w| ..)` method takes [spinlock13::W](W) writer structure"]
65+
impl crate::Writable for SPINLOCK13_SPEC {
66+
type Writer = W;
67+
}
3568
#[doc = "`reset()` method sets SPINLOCK13 to value 0"]
3669
impl crate::Resettable for SPINLOCK13_SPEC {
3770
#[inline(always)]

src/sio/spinlock14.rs

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,35 @@ impl From<crate::R<SPINLOCK14_SPEC>> for R {
1313
R(reader)
1414
}
1515
}
16+
#[doc = "Register `SPINLOCK14` writer"]
17+
pub struct W(crate::W<SPINLOCK14_SPEC>);
18+
impl core::ops::Deref for W {
19+
type Target = crate::W<SPINLOCK14_SPEC>;
20+
#[inline(always)]
21+
fn deref(&self) -> &Self::Target {
22+
&self.0
23+
}
24+
}
25+
impl core::ops::DerefMut for W {
26+
#[inline(always)]
27+
fn deref_mut(&mut self) -> &mut Self::Target {
28+
&mut self.0
29+
}
30+
}
31+
impl From<crate::W<SPINLOCK14_SPEC>> for W {
32+
#[inline(always)]
33+
fn from(writer: crate::W<SPINLOCK14_SPEC>) -> Self {
34+
W(writer)
35+
}
36+
}
37+
impl W {
38+
#[doc = "Writes raw bits to the register."]
39+
#[inline(always)]
40+
pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
41+
self.0.bits(bits);
42+
self
43+
}
44+
}
1645
#[doc = "Reading from a spinlock address will:
1746
- Return 0 if lock is already locked
1847
- Otherwise return nonzero, and simultaneously claim the lock
@@ -21,7 +50,7 @@ impl From<crate::R<SPINLOCK14_SPEC>> for R {
2150
If core 0 and core 1 attempt to claim the same lock simultaneously, core 0 wins.
2251
The value returned on success is 0x1 << lock number.
2352
24-
This register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).
53+
This 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).
2554
2655
For information about available fields see [spinlock14](index.html) module"]
2756
pub struct SPINLOCK14_SPEC;
@@ -32,6 +61,10 @@ impl crate::RegisterSpec for SPINLOCK14_SPEC {
3261
impl crate::Readable for SPINLOCK14_SPEC {
3362
type Reader = R;
3463
}
64+
#[doc = "`write(|w| ..)` method takes [spinlock14::W](W) writer structure"]
65+
impl crate::Writable for SPINLOCK14_SPEC {
66+
type Writer = W;
67+
}
3568
#[doc = "`reset()` method sets SPINLOCK14 to value 0"]
3669
impl crate::Resettable for SPINLOCK14_SPEC {
3770
#[inline(always)]

0 commit comments

Comments
 (0)