Skip to content

Commit 2af2322

Browse files
Demindirotoku-sa-n
andauthored
Add set_0_* to rw1c! macro (#148)
* Add set_0_* to rw1c! macro This is necessary to avoid clearing certains bits, such as Port Enable/Disable. Supersedes #146 * Update CHANGELOG Co-authored-by: Hiroki Tokunaga <[email protected]>
1 parent 79bf39b commit 2af2322

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## Unreleased - ReleaseDate
44
### Added
5+
- `set_0_*` for all RW1C bits, which sets the bit to 0. This prevents the bit from being cleared on write.
56
- `Default` implementations for registers without RsvdP bits, which allows avoiding a redundant read.
67

78
## 0.9.0 - 2022-08-23

src/macros.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,15 @@ macro_rules! rw1c_bit {
121121
self.0[$offset].set_bit($bit,true);
122122
self
123123
}
124+
125+
#[doc = "Set the "]
126+
#[doc = $name]
127+
#[doc = " bit to 0, preventing the bit from being cleared on write."]
128+
pub fn [<set_0_ $method>](&mut self) -> &mut Self {
129+
use bit_field::BitField;
130+
self.0[$offset].set_bit($bit,false);
131+
self
132+
}
124133
}
125134
};
126135
($bit:literal,$method:ident,$name:literal) => {
@@ -134,6 +143,15 @@ macro_rules! rw1c_bit {
134143
self.0.set_bit($bit,true);
135144
self
136145
}
146+
147+
#[doc = "Set the "]
148+
#[doc = $name]
149+
#[doc = " bit to 0, preventing the bit from being cleared on write."]
150+
pub fn [<set_0_ $method>](&mut self) -> &mut Self {
151+
use bit_field::BitField;
152+
self.0.set_bit($bit,false);
153+
self
154+
}
137155
}
138156
};
139157
}

0 commit comments

Comments
 (0)