aboutsummaryrefslogtreecommitdiff
path: root/embassy-mcxa
diff options
context:
space:
mode:
authorFelipe Balbi <[email protected]>2025-12-08 09:38:57 -0800
committerFelipe Balbi <[email protected]>2025-12-08 09:44:23 -0800
commitd9193fb77730110d37e17271b1836273594b5706 (patch)
tree9fb2d885b27684d0b2dcdf201a459f7022bbc3ac /embassy-mcxa
parentcc34871ebef2513f69ce52f8f8f717473e701ec2 (diff)
Fix more review comments
Diffstat (limited to 'embassy-mcxa')
-rw-r--r--embassy-mcxa/src/crc.rs68
1 files changed, 34 insertions, 34 deletions
diff --git a/embassy-mcxa/src/crc.rs b/embassy-mcxa/src/crc.rs
index 8f3b6b5de..753a59122 100644
--- a/embassy-mcxa/src/crc.rs
+++ b/embassy-mcxa/src/crc.rs
@@ -25,8 +25,7 @@ impl<'d, M: Mode> Crc<'d, M> {
25 } 25 }
26 } 26 }
27 27
28 // Configure the underlying peripheral. `f` is expected to set the 28 // Configure the underlying peripheral according to the reference manual.
29 // operating mode to either 16- or 32-bits.
30 fn configure(config: Config, width: Tcrc) { 29 fn configure(config: Config, width: Tcrc) {
31 Self::regs().ctrl().modify(|_, w| { 30 Self::regs().ctrl().modify(|_, w| {
32 w.fxor() 31 w.fxor()
@@ -350,39 +349,40 @@ macro_rules! impl_word {
350 }; 349 };
351} 350}
352 351
353impl_word!( 352impl_word!(u8, 8, write_u8, read_u8);
354 u8, 353impl_word!(u16, 16, write_u16, read_u16);
355 8, 354impl_word!(u32, 32, write_u32, read_u32);
356 |regs: &'static crate::pac::crc0::RegisterBlock, word| { 355
357 regs.data8().write(|w| unsafe { w.bits(word) }); 356fn write_u8(regs: &'static crate::pac::crc0::RegisterBlock, word: u8) {
358 }, 357 regs.data8().write(|w| unsafe { w.bits(word) });
359 |regs: &'static crate::pac::crc0::RegisterBlock| { regs.data8().read().bits() } 358}
360); 359
361impl_word!( 360fn read_u8(regs: &'static crate::pac::crc0::RegisterBlock) -> u8 {
362 u16, 361 regs.data8().read().bits()
363 16, 362}
364 |regs: &'static crate::pac::crc0::RegisterBlock, word| { 363
365 regs.data16().write(|w| unsafe { w.bits(word) }); 364fn write_u16(regs: &'static crate::pac::crc0::RegisterBlock, word: u16) {
366 }, 365 regs.data16().write(|w| unsafe { w.bits(word) });
367 |regs: &'static crate::pac::crc0::RegisterBlock| { 366}
368 let ctrl = regs.ctrl().read(); 367
369 368fn read_u16(regs: &'static crate::pac::crc0::RegisterBlock) -> u16 {
370 // if transposition is enabled, result sits in the upper 16 bits 369 let ctrl = regs.ctrl().read();
371 if ctrl.totr().is_byts_trnps() || ctrl.totr().is_byts_bts_trnps() { 370
372 (regs.data32().read().bits() >> 16) as u16 371 // if transposition is enabled, result sits in the upper 16 bits
373 } else { 372 if ctrl.totr().is_byts_trnps() || ctrl.totr().is_byts_bts_trnps() {
374 regs.data16().read().bits() 373 (regs.data32().read().bits() >> 16) as u16
375 } 374 } else {
375 regs.data16().read().bits()
376 } 376 }
377); 377}
378impl_word!( 378
379 u32, 379fn write_u32(regs: &'static crate::pac::crc0::RegisterBlock, word: u32) {
380 32, 380 regs.data32().write(|w| unsafe { w.bits(word) });
381 |regs: &'static crate::pac::crc0::RegisterBlock, word| { 381}
382 regs.data32().write(|w| unsafe { w.bits(word) }); 382
383 }, 383fn read_u32(regs: &'static crate::pac::crc0::RegisterBlock) -> u32 {
384 |regs: &'static crate::pac::crc0::RegisterBlock| { regs.data32().read().bits() } 384 regs.data32().read().bits()
385); 385}
386 386
387/// CRC configuration. 387/// CRC configuration.
388#[derive(Copy, Clone, Debug)] 388#[derive(Copy, Clone, Debug)]