Loading...
Searching...
No Matches
crc1.h
Go to the documentation of this file.
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
https://www.etlcpp.com
Copyright(c) 2023 John Wellbelove
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_CRC1_INCLUDED
#define ETL_CRC1_INCLUDED
#include "platform.h"
#include "binary.h"
#include "frame_check_sequence.h"
namespace etl
{
//***************************************************************************
//***************************************************************************
struct crc1_policy
{
typedef uint8_t value_type;
enum
{
odd_parity = 1,
even_parity = 0
};
//*********************************
ETL_CONSTEXPR14 value_type initial() const
{
return even_parity;
}
//*********************************
ETL_CONSTEXPR14 uint8_t add(int parity, uint8_t value) const
{
return parity ^ etl::parity(value);
}
//*********************************
ETL_CONSTEXPR14 uint8_t final(uint8_t parity) const
{
return parity;
}
};
class crc1 : public etl::frame_check_sequence<crc1_policy>
{
public:
enum
{
odd_parity = crc1_policy::odd_parity,
even_parity = crc1_policy::even_parity
};
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 crc1()
{
this->reset();
}
//*************************************************************************
//*************************************************************************
template <typename TIterator>
ETL_CONSTEXPR14 crc1(TIterator begin, const TIterator end)
{
this->reset();
this->add(begin, end);
}
};
} // namespace etl
#endif
binary.h
etl::crc1::crc1
ETL_CONSTEXPR14 crc1()
Default constructor.
Definition crc1.h:86
etl::crc1::crc1
ETL_CONSTEXPR14 crc1(TIterator begin, const TIterator end)
Definition crc1.h:97
frame_check_sequence.h
etl::parity
ETL_CONSTEXPR14 etl::enable_if< etl::is_integral< T >::value &&etl::is_unsigned< T >::value &&(etl::integral_limits< T >::bits==16U), uint_least8_t >::type parity(T value)
Definition binary.h:1020
etl::frame_check_sequence< crc1_policy >::add
ETL_CONSTEXPR14 void add(TIterator begin, const TIterator end)
Definition frame_check_sequence.h:145
etl::frame_check_sequence< crc1_policy >::reset
ETL_CONSTEXPR14 void reset()
Definition frame_check_sequence.h:134
etl::frame_check_sequence
Definition frame_check_sequence.h:98
etl
Definition absolute.h:40
etl::end
TContainer::iterator end(TContainer &container)
Definition iterator.h:1166
etl::begin
TContainer::iterator begin(TContainer &container)
Definition iterator.h:1136
platform.h
etl::crc1_policy
Definition crc1.h:45