Wyatt Hepler | 3c4e5de | 2020-03-03 14:37:52 -0800 | [diff] [blame] | 1 | .. default-domain:: cpp |
| 2 | |
| 3 | .. highlight:: sh |
| 4 | |
| 5 | ----------- |
| 6 | pw_checksum |
| 7 | ----------- |
Armando Montanez | 0054a9b | 2020-03-13 13:06:24 -0700 | [diff] [blame] | 8 | The ``pw_checksum`` module provides functions for calculating checksums. |
Wyatt Hepler | 3c4e5de | 2020-03-03 14:37:52 -0800 | [diff] [blame] | 9 | |
| 10 | pw_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 | |
| 33 | Compatibility |
| 34 | ============= |
| 35 | * C |
| 36 | * C++17 |
| 37 | |
| 38 | Dependencies |
| 39 | ============ |
Armando Montanez | 0054a9b | 2020-03-13 13:06:24 -0700 | [diff] [blame] | 40 | * ``pw_span`` |