mirror of
https://github.com/embassy-rs/embassy.git
synced 2024-11-26 16:52:33 +00:00
Merge all of the crc_v2 configurations into a single modify call
This commit is contained in:
parent
8fac444c4e
commit
f9ff5336d4
@ -55,59 +55,55 @@ impl Crc {
|
||||
CRC::reset();
|
||||
let mut instance = Self {
|
||||
_peripheral: peripheral,
|
||||
_config: config
|
||||
_config: config,
|
||||
};
|
||||
unimplemented!();
|
||||
// instance.init();
|
||||
// instance
|
||||
}
|
||||
|
||||
// Configure device settings
|
||||
fn configure_revout(&mut self) {
|
||||
unsafe {
|
||||
PAC_CRC.cr().modify(|w| {w.set_rev_out(
|
||||
match self._config.reverse_out {
|
||||
true => {vals::RevOut::REVERSED}
|
||||
false => {vals::RevOut::NORMAL}
|
||||
}
|
||||
)})
|
||||
}
|
||||
}
|
||||
|
||||
fn configure_revin(&mut self) {
|
||||
unsafe {
|
||||
PAC_CRC.cr().modify(|w| {w.set_rev_in(
|
||||
match self._config.reverse_in {
|
||||
CrcInputReverseConfig::None => {vals::RevIn::NORMAL}
|
||||
CrcInputReverseConfig::Byte => {vals::RevIn::BYTE}
|
||||
CrcInputReverseConfig::Halfword => {vals::RevIn::HALFWORD}
|
||||
CrcInputReverseConfig::Word => {vals::RevIn::WORD}
|
||||
}
|
||||
)})
|
||||
}
|
||||
}
|
||||
|
||||
fn configure_polysize(&mut self) {
|
||||
unsafe {
|
||||
PAC_CRC.cr().modify(|w| {w.set_polysize(
|
||||
match self._config.poly_size {
|
||||
PolySize::Width7 => {vals::Polysize::POLYSIZE7}
|
||||
PolySize::Width8 => {vals::Polysize::POLYSIZE8}
|
||||
PolySize::Width16 => {vals::Polysize::POLYSIZE16}
|
||||
PolySize::Width32 => {vals::Polysize::POLYSIZE32}
|
||||
}
|
||||
)})
|
||||
}
|
||||
}
|
||||
|
||||
pub fn reset(&mut self) {
|
||||
unsafe { PAC_CRC.cr().modify(|w| w.set_reset(true)); }
|
||||
}
|
||||
|
||||
fn set_crc_init(&mut self, value: u32) {
|
||||
unsafe {
|
||||
PAC_CRC.init().write_value(value)
|
||||
}
|
||||
}
|
||||
|
||||
fn reconfigure(&mut self) {
|
||||
unsafe {
|
||||
// Init CRC value
|
||||
PAC_CRC.init().write_value(self._config.crc_init_value);
|
||||
|
||||
PAC_CRC.cr().modify(|w| {
|
||||
// configure reverse output
|
||||
w.set_rev_out(
|
||||
match self._config.reverse_out {
|
||||
true => { vals::RevOut::REVERSED }
|
||||
false => { vals::RevOut::NORMAL }
|
||||
}
|
||||
);
|
||||
// configure reverse input
|
||||
w.set_rev_in(
|
||||
match self._config.reverse_in {
|
||||
CrcInputReverseConfig::None => { vals::RevIn::NORMAL }
|
||||
CrcInputReverseConfig::Byte => { vals::RevIn::BYTE }
|
||||
CrcInputReverseConfig::Halfword => { vals::RevIn::HALFWORD }
|
||||
CrcInputReverseConfig::Word => { vals::RevIn::WORD }
|
||||
}
|
||||
);
|
||||
// configure the polynomial.
|
||||
w.set_polysize(
|
||||
match self._config.poly_size {
|
||||
PolySize::Width7 => { vals::Polysize::POLYSIZE7 }
|
||||
PolySize::Width8 => { vals::Polysize::POLYSIZE8 }
|
||||
PolySize::Width16 => { vals::Polysize::POLYSIZE16 }
|
||||
PolySize::Width32 => { vals::Polysize::POLYSIZE32 }
|
||||
}
|
||||
)
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
self.reset();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user