BA
/
BaBoRo1
Erste version der Software für der Prototyp
mbed-os/drivers/MbedCRC.cpp@4:75df35ef4fb6, 2018-03-30 (annotated)
- Committer:
- borlanic
- Date:
- Fri Mar 30 14:07:05 2018 +0000
- Revision:
- 4:75df35ef4fb6
- Parent:
- 0:380207fcb5c1
commentar
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
borlanic | 0:380207fcb5c1 | 1 | /* mbed Microcontroller Library |
borlanic | 0:380207fcb5c1 | 2 | * Copyright (c) 2018 ARM Limited |
borlanic | 0:380207fcb5c1 | 3 | * |
borlanic | 0:380207fcb5c1 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
borlanic | 0:380207fcb5c1 | 5 | * you may not use this file except in compliance with the License. |
borlanic | 0:380207fcb5c1 | 6 | * You may obtain a copy of the License at |
borlanic | 0:380207fcb5c1 | 7 | * |
borlanic | 0:380207fcb5c1 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
borlanic | 0:380207fcb5c1 | 9 | * |
borlanic | 0:380207fcb5c1 | 10 | * Unless required by applicable law or agreed to in writing, software |
borlanic | 0:380207fcb5c1 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
borlanic | 0:380207fcb5c1 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
borlanic | 0:380207fcb5c1 | 13 | * See the License for the specific language governing permissions and |
borlanic | 0:380207fcb5c1 | 14 | * limitations under the License. |
borlanic | 0:380207fcb5c1 | 15 | */ |
borlanic | 0:380207fcb5c1 | 16 | |
borlanic | 0:380207fcb5c1 | 17 | #include <stddef.h> |
borlanic | 0:380207fcb5c1 | 18 | #include "drivers/TableCRC.h" |
borlanic | 0:380207fcb5c1 | 19 | #include "drivers/MbedCRC.h" |
borlanic | 0:380207fcb5c1 | 20 | |
borlanic | 0:380207fcb5c1 | 21 | namespace mbed { |
borlanic | 0:380207fcb5c1 | 22 | /** \addtogroup drivers */ |
borlanic | 0:380207fcb5c1 | 23 | /** @{*/ |
borlanic | 0:380207fcb5c1 | 24 | |
borlanic | 0:380207fcb5c1 | 25 | /* Default values for different types of polynomials |
borlanic | 0:380207fcb5c1 | 26 | */ |
borlanic | 0:380207fcb5c1 | 27 | template <uint32_t polynomial, uint8_t width> |
borlanic | 0:380207fcb5c1 | 28 | MbedCRC<polynomial, width>::MbedCRC(uint32_t initial_xor, uint32_t final_xor, bool reflect_data, bool reflect_remainder): |
borlanic | 0:380207fcb5c1 | 29 | _initial_value(initial_xor), _final_xor(final_xor), _reflect_data(reflect_data), _reflect_remainder(reflect_remainder), _crc_table(NULL) |
borlanic | 0:380207fcb5c1 | 30 | { |
borlanic | 0:380207fcb5c1 | 31 | mbed_crc_ctor(); |
borlanic | 0:380207fcb5c1 | 32 | } |
borlanic | 0:380207fcb5c1 | 33 | |
borlanic | 0:380207fcb5c1 | 34 | template<> |
borlanic | 0:380207fcb5c1 | 35 | MbedCRC<POLY_32BIT_ANSI, 32>::MbedCRC(uint32_t initial_xor, uint32_t final_xor, bool reflect_data, bool reflect_remainder): |
borlanic | 0:380207fcb5c1 | 36 | _initial_value(initial_xor), _final_xor(final_xor), _reflect_data(reflect_data), _reflect_remainder(reflect_remainder), |
borlanic | 0:380207fcb5c1 | 37 | _crc_table((uint32_t *)Table_CRC_32bit_ANSI) |
borlanic | 0:380207fcb5c1 | 38 | { |
borlanic | 0:380207fcb5c1 | 39 | mbed_crc_ctor(); |
borlanic | 0:380207fcb5c1 | 40 | } |
borlanic | 0:380207fcb5c1 | 41 | |
borlanic | 0:380207fcb5c1 | 42 | template<> |
borlanic | 0:380207fcb5c1 | 43 | MbedCRC<POLY_8BIT_CCITT, 8>::MbedCRC(uint32_t initial_xor, uint32_t final_xor, bool reflect_data, bool reflect_remainder): |
borlanic | 0:380207fcb5c1 | 44 | _initial_value(initial_xor), _final_xor(final_xor), _reflect_data(reflect_data), _reflect_remainder(reflect_remainder), |
borlanic | 0:380207fcb5c1 | 45 | _crc_table((uint32_t *)Table_CRC_8bit_CCITT) |
borlanic | 0:380207fcb5c1 | 46 | { |
borlanic | 0:380207fcb5c1 | 47 | mbed_crc_ctor(); |
borlanic | 0:380207fcb5c1 | 48 | } |
borlanic | 0:380207fcb5c1 | 49 | |
borlanic | 0:380207fcb5c1 | 50 | template<> |
borlanic | 0:380207fcb5c1 | 51 | MbedCRC<POLY_7BIT_SD, 7>::MbedCRC(uint32_t initial_xor, uint32_t final_xor, bool reflect_data, bool reflect_remainder): |
borlanic | 0:380207fcb5c1 | 52 | _initial_value(initial_xor), _final_xor(final_xor), _reflect_data(reflect_data), _reflect_remainder(reflect_remainder), |
borlanic | 0:380207fcb5c1 | 53 | _crc_table((uint32_t *)Table_CRC_7Bit_SD) |
borlanic | 0:380207fcb5c1 | 54 | { |
borlanic | 0:380207fcb5c1 | 55 | mbed_crc_ctor(); |
borlanic | 0:380207fcb5c1 | 56 | } |
borlanic | 0:380207fcb5c1 | 57 | |
borlanic | 0:380207fcb5c1 | 58 | template<> |
borlanic | 0:380207fcb5c1 | 59 | MbedCRC<POLY_16BIT_CCITT, 16>::MbedCRC(uint32_t initial_xor, uint32_t final_xor, bool reflect_data, bool reflect_remainder): |
borlanic | 0:380207fcb5c1 | 60 | _initial_value(initial_xor), _final_xor(final_xor), _reflect_data(reflect_data), _reflect_remainder(reflect_remainder), |
borlanic | 0:380207fcb5c1 | 61 | _crc_table((uint32_t *)Table_CRC_16bit_CCITT) |
borlanic | 0:380207fcb5c1 | 62 | { |
borlanic | 0:380207fcb5c1 | 63 | } |
borlanic | 0:380207fcb5c1 | 64 | |
borlanic | 0:380207fcb5c1 | 65 | template<> |
borlanic | 0:380207fcb5c1 | 66 | MbedCRC<POLY_16BIT_IBM, 16>::MbedCRC(uint32_t initial_xor, uint32_t final_xor, bool reflect_data, bool reflect_remainder): |
borlanic | 0:380207fcb5c1 | 67 | _initial_value(initial_xor), _final_xor(final_xor), _reflect_data(reflect_data), _reflect_remainder(reflect_remainder), |
borlanic | 0:380207fcb5c1 | 68 | _crc_table((uint32_t *)Table_CRC_16bit_IBM) |
borlanic | 0:380207fcb5c1 | 69 | { |
borlanic | 0:380207fcb5c1 | 70 | mbed_crc_ctor(); |
borlanic | 0:380207fcb5c1 | 71 | } |
borlanic | 0:380207fcb5c1 | 72 | |
borlanic | 0:380207fcb5c1 | 73 | template<> |
borlanic | 0:380207fcb5c1 | 74 | MbedCRC<POLY_32BIT_ANSI, 32>::MbedCRC(): |
borlanic | 0:380207fcb5c1 | 75 | _initial_value(~(0x0)), _final_xor(~(0x0)), _reflect_data(true), _reflect_remainder(true), |
borlanic | 0:380207fcb5c1 | 76 | _crc_table((uint32_t *)Table_CRC_32bit_ANSI) |
borlanic | 0:380207fcb5c1 | 77 | { |
borlanic | 0:380207fcb5c1 | 78 | mbed_crc_ctor(); |
borlanic | 0:380207fcb5c1 | 79 | } |
borlanic | 0:380207fcb5c1 | 80 | |
borlanic | 0:380207fcb5c1 | 81 | template<> |
borlanic | 0:380207fcb5c1 | 82 | MbedCRC<POLY_16BIT_IBM, 16>::MbedCRC(): |
borlanic | 0:380207fcb5c1 | 83 | _initial_value(0), _final_xor(0), _reflect_data(true), _reflect_remainder(true), |
borlanic | 0:380207fcb5c1 | 84 | _crc_table((uint32_t *)Table_CRC_16bit_IBM) |
borlanic | 0:380207fcb5c1 | 85 | { |
borlanic | 0:380207fcb5c1 | 86 | mbed_crc_ctor(); |
borlanic | 0:380207fcb5c1 | 87 | } |
borlanic | 0:380207fcb5c1 | 88 | |
borlanic | 0:380207fcb5c1 | 89 | template<> |
borlanic | 0:380207fcb5c1 | 90 | MbedCRC<POLY_16BIT_CCITT, 16>::MbedCRC(): |
borlanic | 0:380207fcb5c1 | 91 | _initial_value(~(0x0)), _final_xor(0), _reflect_data(false), _reflect_remainder(false), |
borlanic | 0:380207fcb5c1 | 92 | _crc_table((uint32_t *)Table_CRC_16bit_CCITT) |
borlanic | 0:380207fcb5c1 | 93 | { |
borlanic | 0:380207fcb5c1 | 94 | mbed_crc_ctor(); |
borlanic | 0:380207fcb5c1 | 95 | } |
borlanic | 0:380207fcb5c1 | 96 | |
borlanic | 0:380207fcb5c1 | 97 | template<> |
borlanic | 0:380207fcb5c1 | 98 | MbedCRC<POLY_7BIT_SD, 7>::MbedCRC(): |
borlanic | 0:380207fcb5c1 | 99 | _initial_value(0), _final_xor(0), _reflect_data(false), _reflect_remainder(false), |
borlanic | 0:380207fcb5c1 | 100 | _crc_table((uint32_t *)Table_CRC_7Bit_SD) |
borlanic | 0:380207fcb5c1 | 101 | { |
borlanic | 0:380207fcb5c1 | 102 | mbed_crc_ctor(); |
borlanic | 0:380207fcb5c1 | 103 | } |
borlanic | 0:380207fcb5c1 | 104 | |
borlanic | 0:380207fcb5c1 | 105 | template<> |
borlanic | 0:380207fcb5c1 | 106 | MbedCRC<POLY_8BIT_CCITT, 8>::MbedCRC(): |
borlanic | 0:380207fcb5c1 | 107 | _initial_value(0), _final_xor(0), _reflect_data(false), _reflect_remainder(false), |
borlanic | 0:380207fcb5c1 | 108 | _crc_table((uint32_t *)Table_CRC_8bit_CCITT) |
borlanic | 0:380207fcb5c1 | 109 | { |
borlanic | 0:380207fcb5c1 | 110 | mbed_crc_ctor(); |
borlanic | 0:380207fcb5c1 | 111 | } |
borlanic | 0:380207fcb5c1 | 112 | |
borlanic | 0:380207fcb5c1 | 113 | /** @}*/ |
borlanic | 0:380207fcb5c1 | 114 | } // namespace mbed |
borlanic | 0:380207fcb5c1 | 115 |