blob: 793dcdc2414871501055badbb72a547d0dbb5202 [file] [log] [blame]
Wyatt Hepler3c4e5de2020-03-03 14:37:52 -08001.. default-domain:: cpp
2
3.. highlight:: sh
4
5-----------
6pw_checksum
7-----------
Armando Montanez0054a9b2020-03-13 13:06:24 -07008The ``pw_checksum`` module provides functions for calculating checksums.
Wyatt Hepler3c4e5de2020-03-03 14:37:52 -08009
10pw_checksum/ccitt_crc16.h
11=========================
12
13.. cpp:namespace:: pw::checksum
14
15.. cpp:var:: constexpr uint16_t kCcittCrc16DefaultInitialValue = 0xFFFF
16
17 The default initial value for the CRC16.
18
19.. cpp:function:: uint16_t CcittCrc16(span<const std::byte> data, uint16_t initial_value = kCcittCrc16DefaultInitialValue)
20
21 Calculates the CRC16 of the provided data using polynomial 0x1021, with a
22 default initial value of :cpp:expr:`0xFFFF`.
23
24 To incrementally calculate a CRC16, use the previous value as the initial
25 value.
26
27 .. code-block:: cpp
28
29 uint16_t crc = CcittCrc16(my_data);
30
31 crc = CcittCrc16(more_data, crc);
32
33Compatibility
34=============
35* C
36* C++17
37
38Dependencies
39============
Armando Montanez0054a9b2020-03-13 13:06:24 -070040* ``pw_span``