26 while (first != last) {
29 checksum ^= (*first++ * UINT32_C(2654435769)) >> 1;
38 memset(buffer, 0, (
static_cast<size_t>(length_words) + 1) *
sizeof(
uint32_t));
39 memcpy(buffer, data,
len);
50 memcpy(data, buffer,
len);
size_t rtc_pref_bytes_to_words(size_t bytes)
Round a byte count up to whole 32-bit words.
bool rtc_pref_decode(const uint32_t *buffer, uint32_t type, uint8_t length_words, uint8_t *data, size_t len)
Verify the checksum of a record held in buffer (length_words data words + 1 checksum word) and,...
void rtc_pref_encode(uint32_t *buffer, uint32_t type, uint8_t length_words, const uint8_t *data, size_t len)
Encode len data bytes into buffer (length_words data words + 1 trailing checksum word).
uint32_t rtc_pref_calculate_checksum(It first, It last, uint32_t type)
Compute the integrity checksum over [first, last), seeded with type.