Skip to content

Commit 195aef5

Browse files
Merge pull request #266 from hannes-hochreiner/master
Enabling and disabling the TWIM instance
2 parents be8e7e0 + dbe7fa8 commit 195aef5

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

nrf-hal-common/src/twim.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,21 @@ where
8686
Twim(twim)
8787
}
8888

89+
/// Disable the instance.
90+
///
91+
/// Disabling the instance will switch off the peripheral leading to a
92+
/// considerably lower energy use. However, while the instance is disabled
93+
/// it is not possible to use it for communication. The configuration of
94+
/// the instance will be retained.
95+
pub fn disable(&mut self) {
96+
self.0.enable.write(|w| w.enable().disabled());
97+
}
98+
99+
/// Re-enable the instance after it was previously disabled.
100+
pub fn enable(&mut self) {
101+
self.0.enable.write(|w| w.enable().enabled());
102+
}
103+
89104
/// Set TX buffer, checking that it is in RAM and has suitable length.
90105
unsafe fn set_tx_buffer(&mut self, buffer: &[u8]) -> Result<(), Error> {
91106
slice_in_ram_or(buffer, Error::DMABufferNotInDataMemory)?;

0 commit comments

Comments
 (0)