MCPcopy Create free account
hub / github.com/RobTillaart/Arduino / fletcher32

Function fletcher32

libraries/Fletcher/Fletcher.cpp:40–56  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38
39
40uint32_t fletcher32(uint16_t *data, uint16_t length, uint32_t s1, uint32_t s2)
41{
42 uint32_t _s1 = s1;
43 uint32_t _s2 = s2;
44 for (uint16_t i = 0; i < length;)
45 {
46 // if _s2 is halfway it is time to do modulo
47 while ((i < length) && (_s2 < 2147483648ULL)) // MAGIC NR
48 {
49 _s1 += data[i++];
50 _s2 += _s1;
51 }
52 _s1 %= FLETCHER_32;
53 _s2 %= FLETCHER_32;
54 }
55 return (_s2 << 16) | _s1;
56}
57
58
59uint64_t fletcher64(uint32_t *data, uint16_t length, uint64_t s1, uint64_t s2)

Callers 1

unittestFunction · 0.85

Calls

no outgoing calls

Tested by 1

unittestFunction · 0.68