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