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