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

Method add

libraries/Fletcher/Fletcher16.cpp:28–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26
27
28void Fletcher16::add(uint8_t value)
29{
30 _count++;
31#if defined(ARDUINO_ARCH_AVR)
32 uint8_t t = 0xFF - value;
33 if (t >= _s1) _s1 += value;
34 else _s1 = _s1 + value + 1;
35
36 t = 0xFF - _s1;
37 if (t >= _s2) _s2 += _s1;
38 else _s2 = _s2 + _s1 + 1;
39
40#elif defined(ARDUINO_ARCH_SAMD) || defined(ESP32) || defined(ESP8266)
41 _s1 += value;
42 _s1 = (_s1 & FLETCHER_16) + (_s1 >> 8);
43 _s2 += _s1;
44 _s2 = (_s2 & FLETCHER_16) + (_s2 >> 8);
45
46#else
47// REFERENCE
48 _s1 += value;
49 if (_s1 >= FLETCHER_16) _s1 -= FLETCHER_16;
50 _s2 += _s1;
51 if (_s2 >= FLETCHER_16) _s2 -= FLETCHER_16;
52#endif
53}
54
55
56void Fletcher16::add(const uint8_t * array, uint16_t length)

Callers 4

unittestFunction · 0.45
fletcher16_nextFunction · 0.45
fletcher32_nextFunction · 0.45
fletcher64_nextFunction · 0.45

Calls

no outgoing calls

Tested by 1

unittestFunction · 0.36