1.. _module-pw_checksum: 2 3----------- 4pw_checksum 5----------- 6The ``pw_checksum`` module provides functions for calculating checksums. 7 8pw_checksum/crc16_ccitt.h 9========================= 10 11.. cpp:namespace:: pw::checksum 12 13.. cpp:var:: constexpr uint16_t kCcittCrc16DefaultInitialValue = 0xFFFF 14 15 The default initial value for the CRC16. 16 17.. cpp:function:: uint16_t CcittCrc16(span<const std::byte> data, uint16_t initial_value = kCcittCrc16DefaultInitialValue) 18 19 Calculates the CRC16 of the provided data using polynomial 0x1021, with a 20 default initial value of :cpp:expr:`0xFFFF`. 21 22 To incrementally calculate a CRC16, use the previous value as the initial 23 value. 24 25 .. code-block:: cpp 26 27 uint16_t crc = CcittCrc16(my_data); 28 29 crc = CcittCrc16(more_data, crc); 30 31pw_checksum/crc32.h 32=================== 33 34.. cpp:var:: constexpr uint32_t kCrc32InitialValue = 0xFFFFFFFF 35 36 The initial value for the CRC32. 37 38.. cpp:function:: uint32_t Crc32(span<const std::byte> data) 39 40 Calculates the initial / one-time CRC32 of the provided data using polynomial 41 0x4C11DB7, with an initial value of :cpp:expr:`0xFFFFFFFF`. 42 43 .. code-block:: cpp 44 45 uint32_t crc = Crc32(my_data); 46 47.. cpp:function:: uint32_t Crc32(span<const std::byte> data, uint32_t previous_result) 48 49 Incrementally append calculation of a CRC32, need to pass in the previous 50 result. 51 52 .. code-block:: cpp 53 54 uint32_t crc = Crc32(my_data); 55 crc = Crc32(more_data, crc); 56 57Compatibility 58============= 59* C 60* C++17 61 62Dependencies 63============ 64* ``pw_span`` 65