Expose read so the value can be obtained without a write.

This commit is contained in:
Joshua Salzedo 2021-09-26 17:28:58 -07:00
parent c892289b2c
commit 7899d73359
No known key found for this signature in database
GPG Key ID: C3D0EB484493B731

View File

@ -1,4 +1,4 @@
use crate::pac::{CRC as PAC_CRC}; use crate::pac::CRC as PAC_CRC;
use crate::peripherals::CRC; use crate::peripherals::CRC;
use crate::rcc::sealed::RccPeripheral; use crate::rcc::sealed::RccPeripheral;
@ -31,17 +31,18 @@ impl Crc {
// write a single byte to the device, and return the result // write a single byte to the device, and return the result
unsafe { unsafe {
PAC_CRC.dr().write_value(word); PAC_CRC.dr().write_value(word);
PAC_CRC.dr().read()
} }
self.read()
} }
/// Feed a slice of words to the peripheral and return the result. /// Feed a slice of words to the peripheral and return the result.
pub fn feed_words(&mut self, words: &[u32]) -> u32 { pub fn feed_words(&mut self, words: &[u32]) -> u32 {
for word in words { for word in words {
unsafe { unsafe { PAC_CRC.dr().write_value(*word) }
PAC_CRC.dr().write_value(*word)
}
} }
self.read()
}
pub fn read(&self) -> u32 {
unsafe { PAC_CRC.dr().read() } unsafe { PAC_CRC.dr().read() }
} }