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