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.
Dependents: STM32_F103-C8T6basecanblink_led
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 } 00057 00058 template<> 00059 MbedCRC<POLY_16BIT_IBM, 16>::MbedCRC(uint32_t initial_xor, uint32_t final_xor, bool reflect_data, bool reflect_remainder): 00060 _initial_value(initial_xor), _final_xor(final_xor), _reflect_data(reflect_data), _reflect_remainder(reflect_remainder), 00061 _crc_table((uint32_t *)Table_CRC_16bit_IBM) 00062 { 00063 mbed_crc_ctor(); 00064 } 00065 00066 template<> 00067 MbedCRC<POLY_32BIT_ANSI, 32>::MbedCRC(): 00068 _initial_value(~(0x0)), _final_xor(~(0x0)), _reflect_data(true), _reflect_remainder(true), 00069 _crc_table((uint32_t *)Table_CRC_32bit_ANSI) 00070 { 00071 mbed_crc_ctor(); 00072 } 00073 00074 template<> 00075 MbedCRC<POLY_16BIT_IBM, 16>::MbedCRC(): 00076 _initial_value(0), _final_xor(0), _reflect_data(true), _reflect_remainder(true), 00077 _crc_table((uint32_t *)Table_CRC_16bit_IBM) 00078 { 00079 mbed_crc_ctor(); 00080 } 00081 00082 template<> 00083 MbedCRC<POLY_16BIT_CCITT, 16>::MbedCRC(): 00084 _initial_value(~(0x0)), _final_xor(0), _reflect_data(false), _reflect_remainder(false), 00085 _crc_table((uint32_t *)Table_CRC_16bit_CCITT) 00086 { 00087 mbed_crc_ctor(); 00088 } 00089 00090 template<> 00091 MbedCRC<POLY_7BIT_SD, 7>::MbedCRC(): 00092 _initial_value(0), _final_xor(0), _reflect_data(false), _reflect_remainder(false), 00093 _crc_table((uint32_t *)Table_CRC_7Bit_SD) 00094 { 00095 mbed_crc_ctor(); 00096 } 00097 00098 template<> 00099 MbedCRC<POLY_8BIT_CCITT, 8>::MbedCRC(): 00100 _initial_value(0), _final_xor(0), _reflect_data(false), _reflect_remainder(false), 00101 _crc_table((uint32_t *)Table_CRC_8bit_CCITT) 00102 { 00103 mbed_crc_ctor(); 00104 } 00105 00106 /** @}*/ 00107 } // namespace mbed 00108
Generated on Tue Jul 12 2022 17:23:56 by
 1.7.2 
    