vintagepc / MINI404

Like MK404... with an appendectomy :smile: (Simulates MK3.x, MK4, MINI and XL)
https://vintagepc.github.io/MINI404/
Other
26 stars 8 forks source link

[BUG] HW CRC32 calculation works even without clock enabled #82

Closed milosfec closed 3 years ago

milosfec commented 3 years ago

Describe the bug Real HW requires calling __HAL_RCC_CRC_CLK_ENABLE(); prior to using CRC32 calculation, but on the simulator it works even without enabling the clock.

To Reproduce

static inline uint32_t crc32(const uint32_t *buffer, uint32_t length) {
  CRC->CR = CRC_CR_RESET;
  while (length--) {
    const uint32_t word = *((uint32_t *)buffer++);
    CRC->DR = __RBIT(word);
  }
  return __RBIT(CRC->DR) ^ 0xFFFFFFFF;
}

Expected behavior Mentioned function should return 0xFFFFFFFF unless __HAL_RCC_CRC_CLK_ENABLE(); is called prior to calling the function.