Closed dbrgn closed 4 years ago
I'm not really sure if it is worth it to use hardware CRC if one just calculates the CRC of two bytes. I guess setting up the hardware CRC is overhead as well, but I may be wrong. IMHO the hardware CRC is useful if one wants to calculate the CRC over some larger data in the flash.
Let's close this for now, it's probably overkill for those few bytes.
Many STM32 MCUs (including the STM32L071) feature a hardware CRC implementation.
As an optimization, it would be nice if the default CRC software-implementation could be swapped with a custom implementation that may be faster.
This could be done using a trait:
The driver struct would then be parametrized:
The simplest way to pass in the concrete implementation would be if the default factory functions (like
shtc3
) use the default implementation, but theShtCx
struct would allow swapping the implementation:However, I'm not sure if the software implementation can be optimized out by the compiler or not. Probably not. Maybe a builder would be better.
What do you think, @rnestler?