Fix variable names in crc_v2/v3.

removed `reclaim` in crc_v1.
used write instead of modify.
renamed `init` to `reset` in crc_v1.
This commit is contained in:
Joshua Salzedo 2021-09-27 10:46:09 -07:00
parent 43ad28b9f9
commit e36d4f460a
No known key found for this signature in database
GPG Key ID: C3D0EB484493B731
2 changed files with 15 additions and 21 deletions

View File

@ -22,12 +22,12 @@ impl Crc {
let mut instance = Self { let mut instance = Self {
_peripheral: peripheral, _peripheral: peripheral,
}; };
instance.init(); instance.reset();
instance instance
} }
/// Resets the CRC unit to default value (0xFFFF_FFFF) /// Resets the CRC unit to default value (0xFFFF_FFFF)
pub fn init(&mut self) { pub fn reset(&mut self) {
unsafe { PAC_CRC.cr().write(|w| w.set_reset(true)) }; unsafe { PAC_CRC.cr().write(|w| w.set_reset(true)) };
} }
@ -51,10 +51,4 @@ impl Crc {
unsafe { PAC_CRC.dr().read() } unsafe { PAC_CRC.dr().read() }
} }
/// Reclaims the CRC peripheral.
pub fn release(self) -> CRC {
CRC::disable();
self._peripheral
}
} }

View File

@ -99,7 +99,7 @@ impl Crc {
// configure CR components // configure CR components
// (reverse I/O, polysize, poly) // (reverse I/O, polysize, poly)
PAC_CRC.cr().modify(|w| { PAC_CRC.cr().write(|w| {
// configure reverse output // configure reverse output
w.set_rev_out(match self._config.reverse_out { w.set_rev_out(match self._config.reverse_out {
true => vals::RevOut::REVERSED, true => vals::RevOut::REVERSED,
@ -144,33 +144,33 @@ impl Crc {
unsafe { PAC_CRC.dr().read() } unsafe { PAC_CRC.dr().read() }
} }
/// Feeds a halfword into the CRC peripheral. Returns the computed checksum. /// Feeds a halfword into the CRC peripheral. Returns the computed checksum.
pub fn feed_halfword(&mut self, byte: u16) -> u32 { pub fn feed_halfword(&mut self, halfword: u16) -> u32 {
unsafe { unsafe {
PAC_CRC.dr16().write_value(byte as u32); PAC_CRC.dr16().write_value(halfword as u32);
PAC_CRC.dr().read() PAC_CRC.dr().read()
} }
} }
/// Feeds an slice of halfwords into the CRC peripheral. Returns the computed checksum. /// Feeds an slice of halfwords into the CRC peripheral. Returns the computed checksum.
pub fn feed_halfwords(&mut self, bytes: &[u16]) -> u32 { pub fn feed_halfwords(&mut self, halfwords: &[u16]) -> u32 {
for byte in bytes { for halfword in halfwords {
unsafe { unsafe {
PAC_CRC.dr16().write_value(*byte as u32); PAC_CRC.dr16().write_value(*halfword as u32);
} }
} }
unsafe { PAC_CRC.dr().read() } unsafe { PAC_CRC.dr().read() }
} }
/// Feeds a halfword into the CRC peripheral. Returns the computed checksum. /// Feeds a words into the CRC peripheral. Returns the computed checksum.
pub fn feed_word(&mut self, byte: u32) -> u32 { pub fn feed_word(&mut self, word: u32) -> u32 {
unsafe { unsafe {
PAC_CRC.dr().write_value(byte as u32); PAC_CRC.dr().write_value(word as u32);
PAC_CRC.dr().read() PAC_CRC.dr().read()
} }
} }
/// Feeds an slice of halfwords into the CRC peripheral. Returns the computed checksum. /// Feeds an slice of words into the CRC peripheral. Returns the computed checksum.
pub fn feed_words(&mut self, bytes: &[u32]) -> u32 { pub fn feed_words(&mut self, words: &[u32]) -> u32 {
for byte in bytes { for word in words {
unsafe { unsafe {
PAC_CRC.dr().write_value(*byte as u32); PAC_CRC.dr().write_value(*word as u32);
} }
} }
unsafe { PAC_CRC.dr().read() } unsafe { PAC_CRC.dr().read() }