Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
mbed-os/drivers/MbedCRC.cpp@0:2f0e1e23c242, 2018-04-13 (annotated)
- Committer:
- glebiuskv
- Date:
- Fri Apr 13 08:53:46 2018 +0000
- Revision:
- 0:2f0e1e23c242
initial
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| glebiuskv | 0:2f0e1e23c242 | 1 | /* mbed Microcontroller Library |
| glebiuskv | 0:2f0e1e23c242 | 2 | * Copyright (c) 2018 ARM Limited |
| glebiuskv | 0:2f0e1e23c242 | 3 | * |
| glebiuskv | 0:2f0e1e23c242 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| glebiuskv | 0:2f0e1e23c242 | 5 | * you may not use this file except in compliance with the License. |
| glebiuskv | 0:2f0e1e23c242 | 6 | * You may obtain a copy of the License at |
| glebiuskv | 0:2f0e1e23c242 | 7 | * |
| glebiuskv | 0:2f0e1e23c242 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| glebiuskv | 0:2f0e1e23c242 | 9 | * |
| glebiuskv | 0:2f0e1e23c242 | 10 | * Unless required by applicable law or agreed to in writing, software |
| glebiuskv | 0:2f0e1e23c242 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| glebiuskv | 0:2f0e1e23c242 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| glebiuskv | 0:2f0e1e23c242 | 13 | * See the License for the specific language governing permissions and |
| glebiuskv | 0:2f0e1e23c242 | 14 | * limitations under the License. |
| glebiuskv | 0:2f0e1e23c242 | 15 | */ |
| glebiuskv | 0:2f0e1e23c242 | 16 | |
| glebiuskv | 0:2f0e1e23c242 | 17 | #include <stddef.h> |
| glebiuskv | 0:2f0e1e23c242 | 18 | #include "drivers/TableCRC.h" |
| glebiuskv | 0:2f0e1e23c242 | 19 | #include "drivers/MbedCRC.h" |
| glebiuskv | 0:2f0e1e23c242 | 20 | |
| glebiuskv | 0:2f0e1e23c242 | 21 | namespace mbed { |
| glebiuskv | 0:2f0e1e23c242 | 22 | /** \addtogroup drivers */ |
| glebiuskv | 0:2f0e1e23c242 | 23 | /** @{*/ |
| glebiuskv | 0:2f0e1e23c242 | 24 | |
| glebiuskv | 0:2f0e1e23c242 | 25 | /* Default values for different types of polynomials |
| glebiuskv | 0:2f0e1e23c242 | 26 | */ |
| glebiuskv | 0:2f0e1e23c242 | 27 | template<> |
| glebiuskv | 0:2f0e1e23c242 | 28 | MbedCRC<POLY_32BIT_ANSI, 32>::MbedCRC(uint32_t initial_xor, uint32_t final_xor, bool reflect_data, bool reflect_remainder): |
| glebiuskv | 0:2f0e1e23c242 | 29 | _initial_value(initial_xor), _final_xor(final_xor), _reflect_data(reflect_data), _reflect_remainder(reflect_remainder), |
| glebiuskv | 0:2f0e1e23c242 | 30 | _crc_table((uint32_t *)Table_CRC_32bit_ANSI) |
| glebiuskv | 0:2f0e1e23c242 | 31 | { |
| glebiuskv | 0:2f0e1e23c242 | 32 | mbed_crc_ctor(); |
| glebiuskv | 0:2f0e1e23c242 | 33 | } |
| glebiuskv | 0:2f0e1e23c242 | 34 | |
| glebiuskv | 0:2f0e1e23c242 | 35 | template<> |
| glebiuskv | 0:2f0e1e23c242 | 36 | MbedCRC<POLY_8BIT_CCITT, 8>::MbedCRC(uint32_t initial_xor, uint32_t final_xor, bool reflect_data, bool reflect_remainder): |
| glebiuskv | 0:2f0e1e23c242 | 37 | _initial_value(initial_xor), _final_xor(final_xor), _reflect_data(reflect_data), _reflect_remainder(reflect_remainder), |
| glebiuskv | 0:2f0e1e23c242 | 38 | _crc_table((uint32_t *)Table_CRC_8bit_CCITT) |
| glebiuskv | 0:2f0e1e23c242 | 39 | { |
| glebiuskv | 0:2f0e1e23c242 | 40 | mbed_crc_ctor(); |
| glebiuskv | 0:2f0e1e23c242 | 41 | } |
| glebiuskv | 0:2f0e1e23c242 | 42 | |
| glebiuskv | 0:2f0e1e23c242 | 43 | template<> |
| glebiuskv | 0:2f0e1e23c242 | 44 | MbedCRC<POLY_7BIT_SD, 7>::MbedCRC(uint32_t initial_xor, uint32_t final_xor, bool reflect_data, bool reflect_remainder): |
| glebiuskv | 0:2f0e1e23c242 | 45 | _initial_value(initial_xor), _final_xor(final_xor), _reflect_data(reflect_data), _reflect_remainder(reflect_remainder), |
| glebiuskv | 0:2f0e1e23c242 | 46 | _crc_table((uint32_t *)Table_CRC_7Bit_SD) |
| glebiuskv | 0:2f0e1e23c242 | 47 | { |
| glebiuskv | 0:2f0e1e23c242 | 48 | mbed_crc_ctor(); |
| glebiuskv | 0:2f0e1e23c242 | 49 | } |
| glebiuskv | 0:2f0e1e23c242 | 50 | |
| glebiuskv | 0:2f0e1e23c242 | 51 | template<> |
| glebiuskv | 0:2f0e1e23c242 | 52 | MbedCRC<POLY_16BIT_CCITT, 16>::MbedCRC(uint32_t initial_xor, uint32_t final_xor, bool reflect_data, bool reflect_remainder): |
| glebiuskv | 0:2f0e1e23c242 | 53 | _initial_value(initial_xor), _final_xor(final_xor), _reflect_data(reflect_data), _reflect_remainder(reflect_remainder), |
| glebiuskv | 0:2f0e1e23c242 | 54 | _crc_table((uint32_t *)Table_CRC_16bit_CCITT) |
| glebiuskv | 0:2f0e1e23c242 | 55 | { |
| glebiuskv | 0:2f0e1e23c242 | 56 | } |
| glebiuskv | 0:2f0e1e23c242 | 57 | |
| glebiuskv | 0:2f0e1e23c242 | 58 | template<> |
| glebiuskv | 0:2f0e1e23c242 | 59 | MbedCRC<POLY_16BIT_IBM, 16>::MbedCRC(uint32_t initial_xor, uint32_t final_xor, bool reflect_data, bool reflect_remainder): |
| glebiuskv | 0:2f0e1e23c242 | 60 | _initial_value(initial_xor), _final_xor(final_xor), _reflect_data(reflect_data), _reflect_remainder(reflect_remainder), |
| glebiuskv | 0:2f0e1e23c242 | 61 | _crc_table((uint32_t *)Table_CRC_16bit_IBM) |
| glebiuskv | 0:2f0e1e23c242 | 62 | { |
| glebiuskv | 0:2f0e1e23c242 | 63 | mbed_crc_ctor(); |
| glebiuskv | 0:2f0e1e23c242 | 64 | } |
| glebiuskv | 0:2f0e1e23c242 | 65 | |
| glebiuskv | 0:2f0e1e23c242 | 66 | template<> |
| glebiuskv | 0:2f0e1e23c242 | 67 | MbedCRC<POLY_32BIT_ANSI, 32>::MbedCRC(): |
| glebiuskv | 0:2f0e1e23c242 | 68 | _initial_value(~(0x0)), _final_xor(~(0x0)), _reflect_data(true), _reflect_remainder(true), |
| glebiuskv | 0:2f0e1e23c242 | 69 | _crc_table((uint32_t *)Table_CRC_32bit_ANSI) |
| glebiuskv | 0:2f0e1e23c242 | 70 | { |
| glebiuskv | 0:2f0e1e23c242 | 71 | mbed_crc_ctor(); |
| glebiuskv | 0:2f0e1e23c242 | 72 | } |
| glebiuskv | 0:2f0e1e23c242 | 73 | |
| glebiuskv | 0:2f0e1e23c242 | 74 | template<> |
| glebiuskv | 0:2f0e1e23c242 | 75 | MbedCRC<POLY_16BIT_IBM, 16>::MbedCRC(): |
| glebiuskv | 0:2f0e1e23c242 | 76 | _initial_value(0), _final_xor(0), _reflect_data(true), _reflect_remainder(true), |
| glebiuskv | 0:2f0e1e23c242 | 77 | _crc_table((uint32_t *)Table_CRC_16bit_IBM) |
| glebiuskv | 0:2f0e1e23c242 | 78 | { |
| glebiuskv | 0:2f0e1e23c242 | 79 | mbed_crc_ctor(); |
| glebiuskv | 0:2f0e1e23c242 | 80 | } |
| glebiuskv | 0:2f0e1e23c242 | 81 | |
| glebiuskv | 0:2f0e1e23c242 | 82 | template<> |
| glebiuskv | 0:2f0e1e23c242 | 83 | MbedCRC<POLY_16BIT_CCITT, 16>::MbedCRC(): |
| glebiuskv | 0:2f0e1e23c242 | 84 | _initial_value(~(0x0)), _final_xor(0), _reflect_data(false), _reflect_remainder(false), |
| glebiuskv | 0:2f0e1e23c242 | 85 | _crc_table((uint32_t *)Table_CRC_16bit_CCITT) |
| glebiuskv | 0:2f0e1e23c242 | 86 | { |
| glebiuskv | 0:2f0e1e23c242 | 87 | mbed_crc_ctor(); |
| glebiuskv | 0:2f0e1e23c242 | 88 | } |
| glebiuskv | 0:2f0e1e23c242 | 89 | |
| glebiuskv | 0:2f0e1e23c242 | 90 | template<> |
| glebiuskv | 0:2f0e1e23c242 | 91 | MbedCRC<POLY_7BIT_SD, 7>::MbedCRC(): |
| glebiuskv | 0:2f0e1e23c242 | 92 | _initial_value(0), _final_xor(0), _reflect_data(false), _reflect_remainder(false), |
| glebiuskv | 0:2f0e1e23c242 | 93 | _crc_table((uint32_t *)Table_CRC_7Bit_SD) |
| glebiuskv | 0:2f0e1e23c242 | 94 | { |
| glebiuskv | 0:2f0e1e23c242 | 95 | mbed_crc_ctor(); |
| glebiuskv | 0:2f0e1e23c242 | 96 | } |
| glebiuskv | 0:2f0e1e23c242 | 97 | |
| glebiuskv | 0:2f0e1e23c242 | 98 | template<> |
| glebiuskv | 0:2f0e1e23c242 | 99 | MbedCRC<POLY_8BIT_CCITT, 8>::MbedCRC(): |
| glebiuskv | 0:2f0e1e23c242 | 100 | _initial_value(0), _final_xor(0), _reflect_data(false), _reflect_remainder(false), |
| glebiuskv | 0:2f0e1e23c242 | 101 | _crc_table((uint32_t *)Table_CRC_8bit_CCITT) |
| glebiuskv | 0:2f0e1e23c242 | 102 | { |
| glebiuskv | 0:2f0e1e23c242 | 103 | mbed_crc_ctor(); |
| glebiuskv | 0:2f0e1e23c242 | 104 | } |
| glebiuskv | 0:2f0e1e23c242 | 105 | |
| glebiuskv | 0:2f0e1e23c242 | 106 | /** @}*/ |
| glebiuskv | 0:2f0e1e23c242 | 107 | } // namespace mbed |
| glebiuskv | 0:2f0e1e23c242 | 108 |