From 47f6113b97679bc7a40ac78526bf770ee3e16a65 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sat, 27 Mar 2021 09:28:19 +0000 Subject: [PATCH] Intermediate commit - Passing all tests --- include/etl/crc8_ccitt.h | 4 +- include/etl/crc8_rohc.h | 4 +- include/etl/private/crc_implementation.h | 100 ++++++++--------------- include/etl/private/crc_parameters.h | 35 +++++++- 4 files changed, 70 insertions(+), 73 deletions(-) diff --git a/include/etl/crc8_ccitt.h b/include/etl/crc8_ccitt.h index 4ebe9277..80c7ec8e 100644 --- a/include/etl/crc8_ccitt.h +++ b/include/etl/crc8_ccitt.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef ETL_CRC8_CCITT_EXP_INCLUDED -#define ETL_CRC8_CCITT_EXP_INCLUDED +#ifndef ETL_CRC8_CCITT_INCLUDED +#define ETL_CRC8_CCITT_INCLUDED #include "platform.h" #include "private/crc_implementation.h" diff --git a/include/etl/crc8_rohc.h b/include/etl/crc8_rohc.h index de15247c..79588eba 100644 --- a/include/etl/crc8_rohc.h +++ b/include/etl/crc8_rohc.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef ETL_CRC8_ROHC_EXP_INCLUDED -#define ETL_CRC8_ROHC_EXP_INCLUDED +#ifndef ETL_CRC8_ROHC_INCLUDED +#define ETL_CRC8_ROHC_INCLUDED #include "platform.h" #include "private/crc_implementation.h" diff --git a/include/etl/private/crc_implementation.h b/include/etl/private/crc_implementation.h index 8cdd1722..491a199c 100644 --- a/include/etl/private/crc_implementation.h +++ b/include/etl/private/crc_implementation.h @@ -1,5 +1,35 @@ +///\file -#pragma once +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2021 jwellbelove + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files(the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and / or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions : + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +******************************************************************************/ + +#ifndef ETL_CRC_IMPLEMENTATION_INCLUDED +#define ETL_CRC_IMPLEMENTATION_INCLUDED #include "../platform.h" #include "../frame_check_sequence.h" @@ -109,60 +139,6 @@ namespace etl crc_entry::value>::value; }; - ////************************************************************************* - //// Accumulator_Bits > Chunk_Bits and not reflected - //template - //typename etl::enable_if<(Accumulator_Bits > Chunk_Bits) && !Reflect, TAccumulator>::type - // crc_update_chunk(TAccumulator crc, uint8_t value, const TAccumulator table[]) - //{ - // size_t index = (crc >> (Accumulator_Bits - Chunk_Bits)) ^ value; - - // crc <<= Chunk_Bits; - // crc ^= table[index]; - - // return crc; - //} - - ////************************************************************************* - //// Accumulator_Bits > Chunk_Bits and reflected - //template - //typename etl::enable_if<(Accumulator_Bits > Chunk_Bits) && Reflect, TAccumulator>::type - // crc_update_chunk(TAccumulator crc, uint8_t value, const TAccumulator table[]) - //{ - // size_t index = size_t((crc & Chunk_Mask) ^ value); - - // crc >>= Chunk_Bits; - // crc ^= table[index]; - - // return crc; - //} - - ////************************************************************************* - //// Accumulator_Bits == Chunk_Bits and not reflected - //template - //typename etl::enable_if<(Accumulator_Bits == Chunk_Bits) && !Reflect, TAccumulator>::type - // crc_update_chunk(TAccumulator crc, uint8_t value, const TAccumulator table[]) - //{ - // size_t index = size_t((crc >> (Accumulator_Bits - Chunk_Bits)) ^ value); - - // crc = table[index]; - - // return crc; - //} - - ////************************************************************************* - //// Accumulator_Bits == Chunk_Bits and reflected - //template - //typename etl::enable_if<(Accumulator_Bits == Chunk_Bits) && Reflect, TAccumulator>::type - // crc_update_chunk(TAccumulator crc, uint8_t value, const TAccumulator table[]) - //{ - // size_t index = size_t((crc & Chunk_Mask) ^ value); - - // crc = table[index]; - - // return crc; - //} - //***************************************************************************** // CRC Policies. //***************************************************************************** @@ -191,12 +167,6 @@ namespace etl //************************************************************************* static accumulator_type update_chunk(accumulator_type crc, uint8_t value, const accumulator_type table[]) { - //// Extract the most significant nibble of the crc and xor with the value nibble. - //size_t index = size_t((crc >> (etl::integral_limits::bits - Chunk_Bits)) ^ value); - - //crc <<= Chunk_Bits; - //crc ^= table[index]; - value &= Chunk_Mask; if ETL_IF_CONSTEXPR(TCrcParameters::Reflect) @@ -536,12 +506,6 @@ namespace etl //************************************************************************* static accumulator_type update_chunk(accumulator_type crc, uint8_t value, const accumulator_type table[]) { - //// Extract the most significant nibble of the crc and xor with the value nibble. - //size_t index = size_t((crc >> (etl::integral_limits::bits - Chunk_Bits)) ^ value); - - //crc <<= Chunk_Bits; - //crc ^= table[index]; - value &= Chunk_Mask; if ETL_IF_CONSTEXPR(TCrcParameters::Reflect) @@ -754,3 +718,5 @@ namespace etl } }; } + +#endif diff --git a/include/etl/private/crc_parameters.h b/include/etl/private/crc_parameters.h index f1c4796c..b90ba3de 100644 --- a/include/etl/private/crc_parameters.h +++ b/include/etl/private/crc_parameters.h @@ -1,4 +1,35 @@ -#pragma once +///\file + +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2021 jwellbelove + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files(the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and / or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions : + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +******************************************************************************/ + +#ifndef ETL_CRC_PARAMETERS_INCLUDED +#define ETL_CRC_PARAMETERS_INCLUDED #include "../platform.h" #include "../integral_limits.h" @@ -71,4 +102,4 @@ namespace etl } } - +#endif