takashi kadono / Mbed OS Nucleo_446

Dependencies:   ssd1331

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers MbedCRC.cpp Source File

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 SingletonPtr<PlatformMutex>  mbed_crc_mutex;
00026 
00027 /* Default values for different types of polynomials
00028 */
00029 template<>
00030 MbedCRC<POLY_32BIT_ANSI, 32>::MbedCRC():
00031     _initial_value(~(0x0)), _final_xor(~(0x0)), _reflect_data(true), _reflect_remainder(true),
00032     _crc_table((uint32_t *)Table_CRC_32bit_ANSI)
00033 {
00034     mbed_crc_ctor();
00035 }
00036 
00037 template<>
00038 MbedCRC<POLY_32BIT_REV_ANSI, 32>::MbedCRC():
00039     _initial_value(~(0x0)), _final_xor(~(0x0)), _reflect_data(false), _reflect_remainder(false),
00040     _crc_table((uint32_t *)Table_CRC_32bit_Rev_ANSI)
00041 {
00042     mbed_crc_ctor();
00043 }
00044 
00045 template<>
00046 MbedCRC<POLY_16BIT_IBM, 16>::MbedCRC():
00047     _initial_value(0), _final_xor(0), _reflect_data(true), _reflect_remainder(true),
00048     _crc_table((uint32_t *)Table_CRC_16bit_IBM)
00049 {
00050     mbed_crc_ctor();
00051 }
00052 
00053 template<>
00054 MbedCRC<POLY_16BIT_CCITT, 16>::MbedCRC():
00055     _initial_value(~(0x0)), _final_xor(0), _reflect_data(false), _reflect_remainder(false),
00056     _crc_table((uint32_t *)Table_CRC_16bit_CCITT)
00057 {
00058     mbed_crc_ctor();
00059 }
00060 
00061 template<>
00062 MbedCRC<POLY_7BIT_SD, 7>::MbedCRC():
00063     _initial_value(0), _final_xor(0), _reflect_data(false), _reflect_remainder(false),
00064     _crc_table((uint32_t *)Table_CRC_7Bit_SD)
00065 {
00066     mbed_crc_ctor();
00067 }
00068 
00069 template<>
00070 MbedCRC<POLY_8BIT_CCITT, 8>::MbedCRC():
00071     _initial_value(0), _final_xor(0), _reflect_data(false), _reflect_remainder(false),
00072     _crc_table((uint32_t *)Table_CRC_8bit_CCITT)
00073 {
00074     mbed_crc_ctor();
00075 }
00076 
00077 /** @}*/
00078 } // namespace mbed
00079