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.
Fork of mbed-dev by
MbedCRC.cpp
00001 /* mbed Microcontroller Library 00002 * Copyright (c) 2018 ARM Limited 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 #include <stddef.h> 00018 #include "drivers/TableCRC.h" 00019 #include "drivers/MbedCRC.h" 00020 00021 namespace mbed { 00022 /** \addtogroup drivers */ 00023 /** @{*/ 00024 00025 /* Default values for different types of polynomials 00026 */ 00027 template<> 00028 MbedCRC<POLY_32BIT_ANSI, 32>::MbedCRC(uint32_t initial_xor, uint32_t final_xor, bool reflect_data, bool reflect_remainder): 00029 _initial_value(initial_xor), _final_xor(final_xor), _reflect_data(reflect_data), _reflect_remainder(reflect_remainder), 00030 _crc_table((uint32_t *)Table_CRC_32bit_ANSI) 00031 { 00032 mbed_crc_ctor(); 00033 } 00034 00035 template<> 00036 MbedCRC<POLY_8BIT_CCITT, 8>::MbedCRC(uint32_t initial_xor, uint32_t final_xor, bool reflect_data, bool reflect_remainder): 00037 _initial_value(initial_xor), _final_xor(final_xor), _reflect_data(reflect_data), _reflect_remainder(reflect_remainder), 00038 _crc_table((uint32_t *)Table_CRC_8bit_CCITT) 00039 { 00040 mbed_crc_ctor(); 00041 } 00042 00043 template<> 00044 MbedCRC<POLY_7BIT_SD, 7>::MbedCRC(uint32_t initial_xor, uint32_t final_xor, bool reflect_data, bool reflect_remainder): 00045 _initial_value(initial_xor), _final_xor(final_xor), _reflect_data(reflect_data), _reflect_remainder(reflect_remainder), 00046 _crc_table((uint32_t *)Table_CRC_7Bit_SD) 00047 { 00048 mbed_crc_ctor(); 00049 } 00050 00051 template<> 00052 MbedCRC<POLY_16BIT_CCITT, 16>::MbedCRC(uint32_t initial_xor, uint32_t final_xor, bool reflect_data, bool reflect_remainder): 00053 _initial_value(initial_xor), _final_xor(final_xor), _reflect_data(reflect_data), _reflect_remainder(reflect_remainder), 00054 _crc_table((uint32_t *)Table_CRC_16bit_CCITT) 00055 { 00056 mbed_crc_ctor(); 00057 } 00058 00059 template<> 00060 MbedCRC<POLY_16BIT_IBM, 16>::MbedCRC(uint32_t initial_xor, uint32_t final_xor, bool reflect_data, bool reflect_remainder): 00061 _initial_value(initial_xor), _final_xor(final_xor), _reflect_data(reflect_data), _reflect_remainder(reflect_remainder), 00062 _crc_table((uint32_t *)Table_CRC_16bit_IBM) 00063 { 00064 mbed_crc_ctor(); 00065 } 00066 00067 template<> 00068 MbedCRC<POLY_32BIT_ANSI, 32>::MbedCRC(): 00069 _initial_value(~(0x0)), _final_xor(~(0x0)), _reflect_data(true), _reflect_remainder(true), 00070 _crc_table((uint32_t *)Table_CRC_32bit_ANSI) 00071 { 00072 mbed_crc_ctor(); 00073 } 00074 00075 template<> 00076 MbedCRC<POLY_16BIT_IBM, 16>::MbedCRC(): 00077 _initial_value(0), _final_xor(0), _reflect_data(true), _reflect_remainder(true), 00078 _crc_table((uint32_t *)Table_CRC_16bit_IBM) 00079 { 00080 mbed_crc_ctor(); 00081 } 00082 00083 template<> 00084 MbedCRC<POLY_16BIT_CCITT, 16>::MbedCRC(): 00085 _initial_value(~(0x0)), _final_xor(0), _reflect_data(false), _reflect_remainder(false), 00086 _crc_table((uint32_t *)Table_CRC_16bit_CCITT) 00087 { 00088 mbed_crc_ctor(); 00089 } 00090 00091 template<> 00092 MbedCRC<POLY_7BIT_SD, 7>::MbedCRC(): 00093 _initial_value(0), _final_xor(0), _reflect_data(false), _reflect_remainder(false), 00094 _crc_table((uint32_t *)Table_CRC_7Bit_SD) 00095 { 00096 mbed_crc_ctor(); 00097 } 00098 00099 template<> 00100 MbedCRC<POLY_8BIT_CCITT, 8>::MbedCRC(): 00101 _initial_value(0), _final_xor(0), _reflect_data(false), _reflect_remainder(false), 00102 _crc_table((uint32_t *)Table_CRC_8bit_CCITT) 00103 { 00104 mbed_crc_ctor(); 00105 } 00106 00107 /** @}*/ 00108 } // namespace mbed 00109
Generated on Tue Jul 12 2022 12:59:33 by
1.7.2
