diff options
| author | Felipe Balbi <[email protected]> | 2025-12-08 09:38:57 -0800 |
|---|---|---|
| committer | Felipe Balbi <[email protected]> | 2025-12-08 09:44:23 -0800 |
| commit | d9193fb77730110d37e17271b1836273594b5706 (patch) | |
| tree | 9fb2d885b27684d0b2dcdf201a459f7022bbc3ac | |
| parent | cc34871ebef2513f69ce52f8f8f717473e701ec2 (diff) | |
Fix more review comments
| -rw-r--r-- | embassy-mcxa/src/crc.rs | 68 |
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 | ||
| 353 | impl_word!( | 352 | impl_word!(u8, 8, write_u8, read_u8); |
| 354 | u8, | 353 | impl_word!(u16, 16, write_u16, read_u16); |
| 355 | 8, | 354 | impl_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) }); | 356 | fn 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 | |
| 361 | impl_word!( | 360 | fn 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) }); | 364 | fn 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 | 368 | fn 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 | } |
| 378 | impl_word!( | 378 | |
| 379 | u32, | 379 | fn 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 | }, | 383 | fn 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)] |
