4#include "include/types.hpp"
26 template <
typename T,
typename W>
29 dst = dst |
static_cast<T
>( xBits );
36 template <
typename T,
typename W>
39 dst = dst & ~static_cast<T>( xBits );
49 dst = dst | (
static_cast<T
>( 1U ) <<
static_cast<T
>( xBit ) );
59 dst = dst & ~(
static_cast<T
>( 1U ) <<
static_cast<T
>( xBit ) );
71 return (
static_cast<T
>( 0U ) != ( dst & (
static_cast<T
>( 1U ) <<
static_cast<T
>( xBit ) ) ) );
82 dst = dst ^ (
static_cast<T
>( 1U ) <<
static_cast<T
>( xBit ) );
92 inline void singleWrite( T &dst,
const size_t xBit,
const bool value )
103 template <
typename T,
typename W>
106 return ( 0U != ( reg & xBits) );
112 template <
typename DT,
typename ST>
113 inline DT aligned_cast( ST& src )
117 (void)memcpy( &dst, &src,
sizeof(ST) );
124 template <
typename T>
125 constexpr size_t arraySize(
const T& )
noexcept
143 template <
typename T,
size_t n>
144 constexpr size_t arraySize(
const T (&arr)[n] )
noexcept
156 template <
typename T>
157 inline T
clip( T x,
const T Min,
const T Max )
159 return ( x < Min ) ? Min : ( ( x > Max ) ? Max : x );
167 template <
typename T>
170 return ( x > Max ) ? Max : x ;
178 template <
typename T>
181 return ( x < Min ) ? Min : x ;
192 template <
typename T>
195 return ( x >= Low ) && ( x <= High );
204 return static_cast<uint8_t
>( x >> 4U );
213 return static_cast<uint8_t
>( x & 0x0FU );
223 return static_cast<uint8_t
>( ( h << 4U ) | ( 0x0FU & l ) );
232 return static_cast<uint16_t
>( x >> 8U );
241 return static_cast<uint16_t
>( x & 0x00FFU );
251 return static_cast<uint16_t
>( ( h << 8U ) | ( 0x00FFU & l ) );
260 return static_cast<uint32_t
>( x >> 16U );
269 return static_cast<uint32_t
>( x & 0xFFFFU );
279 return static_cast<uint32_t
>( ( h << 16U ) | ( 0xFFFFU & l ) );
T clipUpper(T x, const T Max)
Ensures that x is bellow the limits set by Max.
Definition helper.hpp:168
uint8_t byteMergeNibbles(uint8_t h, uint8_t l)
Merges two nibbles to form one byte.
Definition helper.hpp:221
T clipLower(T x, const T Min)
Ensures that x is above the value set by Min.
Definition helper.hpp:179
bool singleRead(T dst, const size_t xBit)
Uses the bitwise AND operator to read the value of a single bit from dst.
Definition helper.hpp:69
void singleClear(T &dst, const size_t xBit)
Uses the bitwise AND operator to clear a single bit into dst.
Definition helper.hpp:57
uint32_t dWordWordLow(uint32_t x)
Read the low-word from x.
Definition helper.hpp:267
uint16_t wordByteLow(uint16_t x)
Read the low-byte from x.
Definition helper.hpp:239
void multipleClear(T &dst, W xBits)
Uses the bitwise AND operator to clear bits into dst.
Definition helper.hpp:37
uint32_t dWordWordHigh(uint32_t x)
Read the high-word from x.
Definition helper.hpp:258
uint8_t byteNibbleHigh(uint8_t x)
Read the high-nibble from x.
Definition helper.hpp:202
void singleToggle(T &dst, const size_t xBit)
Uses the bitwise XOR operator to toggle the value of a single bit from dst.
Definition helper.hpp:80
uint16_t wordMergeBytes(uint16_t h, uint16_t l)
Merges two bytes to form one Word.
Definition helper.hpp:249
constexpr size_t arraySize(const T(&arr)[n]) noexcept
Calculates the size of an array. This function takes a reference to an array and calculates its size....
Definition helper.hpp:144
void multipleSet(T &dst, W xBits)
Uses the bitwise OR operator to set bits into dst.
Definition helper.hpp:27
T isBetween(T x, const T Low, const T High)
Check if the value of x is within the limits defined by Low and High.
Definition helper.hpp:193
bool multipleGet(T reg, W xBits)
Read multiple bits by applying the mask given by xBits to the dst variable.
Definition helper.hpp:104
uint16_t wordByteHigh(uint16_t x)
Read the high-byte from x.
Definition helper.hpp:230
T clip(T x, const T Min, const T Max)
Ensures that x is between the limits set by Min and Max.
Definition helper.hpp:157
uint8_t byteNibbleLow(uint8_t x)
Read the low-nibble from x.
Definition helper.hpp:211
void singleSet(T &dst, const size_t xBit)
Uses the bitwise OR operator to set a single bit into dst.
Definition helper.hpp:47
void singleWrite(T &dst, const size_t xBit, const bool value)
Write the boolean value in a single bit of the dst variable.
Definition helper.hpp:92
uint32_t dwordMergeWords(uint32_t h, uint32_t l)
Merges two words to form one DWord.
Definition helper.hpp:277
OS/Kernel interfaces.
Definition bytebuffer.hpp:7