crc.rs 502 B

123456789101112131415161718192021222324252627
  1. //! CRC calculation
  2. #![deny(unsafe_code)]
  3. #![no_main]
  4. #![no_std]
  5. use panic_halt as _;
  6. use cortex_m_rt::entry;
  7. use cortex_m_semihosting::hprintln;
  8. use stm32f1xx_hal::{pac, prelude::*};
  9. #[entry]
  10. fn main() -> ! {
  11. let p = pac::Peripherals::take().unwrap();
  12. let mut rcc = p.RCC.constrain();
  13. let mut crc = p.CRC.new(&mut rcc.ahb);
  14. crc.reset();
  15. crc.write(0x12345678);
  16. let val = crc.read();
  17. hprintln!("found={:08x}, expected={:08x}", val, 0xdf8a8a2bu32).ok();
  18. loop {}
  19. }