30 #ifndef SYSTEM_LIBRARIES_BITS_OC_BITS_H_ 31 #define SYSTEM_LIBRARIES_BITS_OC_BITS_H_ 47 #define oC_Bits_Mask_U8( FROM , TO ) ((((((uint8_t)1)<<(TO)) - 1 ) | (((uint8_t)1)<<(TO))) ^ ((((uint8_t)1)<<(FROM)) - 1)) 60 #define oC_Bits_Mask_U16( FROM , TO ) ((((((uint16_t)1)<<(TO)) - 1 ) | (((uint16_t)1)<<(TO))) ^ ((((uint16_t)1)<<(FROM)) - 1)) 73 #define oC_Bits_Mask_U32( FROM , TO ) ((((((uint32_t)1)<<(TO)) - 1 ) | (((uint32_t)1)<<(TO))) ^ ((((uint32_t)1)<<(FROM)) - 1)) 86 #define oC_Bits_Mask_U64( FROM , TO ) ((((((uint64_t)1)<<(TO)) - 1 ) | (((uint64_t)1)<<(TO))) ^ ((((uint64_t)1)<<(FROM)) - 1)) 106 #define oC_Bits_ValueWithMask(VALUE,FROM,MASK) ( ((VALUE) << (FROM)) & (MASK) ) 122 *outVariable |= Mask;
139 *outVariable |= Mask;
156 *outVariable |= Mask;
173 *outVariable |= Mask;
190 *outVariable &= ( ~Mask );
207 *outVariable &= ( ~Mask );
224 *outVariable &= ( ~Mask );
241 *outVariable &= ( ~Mask );
262 static inline uint8_t
oC_Bits_SetValueU8( uint8_t * outVariable , uint8_t Value , uint8_t StartBitNr , uint8_t EndBitNr)
264 *outVariable = ( *outVariable & ( ~
oC_Bits_Mask_U8 ( StartBitNr , EndBitNr ))) | ((Value<<StartBitNr) &
oC_Bits_Mask_U8 ( StartBitNr , EndBitNr ));
285 static inline uint16_t
oC_Bits_SetValueU16( uint16_t * outVariable , uint16_t Value , uint8_t StartBitNr , uint8_t EndBitNr)
308 static inline uint32_t
oC_Bits_SetValueU32( uint32_t * outVariable , uint32_t Value , uint8_t StartBitNr , uint8_t EndBitNr)
331 static inline uint64_t
oC_Bits_SetValueU64( uint64_t * outVariable , uint64_t Value , uint8_t StartBitNr , uint8_t EndBitNr)
355 return (
oC_Bits_Mask_U8 ( StartBitNr , EndBitNr ) & Variable)>>StartBitNr;
433 *outLow = (uint32_t)Variable;
434 *outHigh = (uint32_t)(Variable>>32);
449 *outLow = (uint16_t)Variable;
450 *outHigh = (uint16_t)(Variable>>16);
465 *outLow = (uint8_t)Variable;
466 *outHigh = (uint8_t)(Variable>>8);
482 return (((uint16_t)HighPart)<<8)|((uint16_t)LowPart);
498 return (((uint32_t)HighPart)<<16)|((uint32_t)LowPart);
514 return (((uint64_t)HighPart)<<32)|((uint64_t)LowPart);
531 for (i = 0; i < 8; i++)
533 if ((BitMask & 0x01) == 0x01)
540 BitMask = (BitMask >> 1);
560 for (i = 0; i < 16; i++)
562 if ((BitMask & 0x0001) == 0x0001)
569 BitMask = (BitMask >> 1);
589 for (i = 0; i < 32; i++)
591 if ((BitMask & 0x00000001) == 0x00000001)
598 BitMask = (BitMask >> 1);
618 for (i = 0; i < 64; i++)
620 if ((BitMask & 0x0000000000000001) == 0x0000000000000001)
627 BitMask = (BitMask >> 1);
647 return (BitMask & (1<<BitIndex)) == (1<<BitIndex);
664 return (BitMask & ((uint16_t)1<<BitIndex)) == ((uint16_t)1<<BitIndex);
681 return (BitMask & ((uint32_t)1<<BitIndex)) == ((uint32_t)1<<BitIndex);
698 return (BitMask & ((uint64_t)1<<BitIndex)) == ((uint64_t)1<<BitIndex);
713 *outVariable |= (uint8_t)1<<BitIndex;
729 *outVariable |= (uint16_t)1<<BitIndex;
745 *outVariable |= (uint32_t)1<<BitIndex;
761 *outVariable |= (uint64_t)1<<BitIndex;
780 *outVariable &= ~((uint8_t)1<<BitIndex );
798 *outVariable &= ~((uint16_t)1<<BitIndex );
816 *outVariable &= ~((uint32_t)1<<BitIndex );
834 *outVariable &= ~((uint64_t)1<<BitIndex );
852 return (BitMask & BitsToCheck) == BitsToCheck;
869 return (BitMask & BitsToCheck) == BitsToCheck;
886 return (BitMask & BitsToCheck) == BitsToCheck;
903 return (BitMask & BitsToCheck) == BitsToCheck;
920 return ((~BitMask) & BitsToCheck) == BitsToCheck;
937 return ((~BitMask) & BitsToCheck) == BitsToCheck;
954 return ((~BitMask) & BitsToCheck) == BitsToCheck;
971 return ((~BitMask) & BitsToCheck) == BitsToCheck;
988 return (BitMask & BitsToCheck);
1005 return (BitMask & BitsToCheck);
1022 return (BitMask & BitsToCheck);
1039 return (BitMask & BitsToCheck);
1056 return ((~BitMask) & BitsToCheck);
1073 return ((~BitMask) & BitsToCheck);
1090 return ((~BitMask) & BitsToCheck);
1107 return ((~BitMask) & BitsToCheck);
static uint64_t oC_Bits_SetBitU64(uint64_t *outVariable, uint8_t BitIndex)
sets bit in the variable
#define oC_Bits_Mask_U8(FROM, TO)
static bool oC_Bits_AreBitsSetU32(uint32_t BitMask, uint32_t BitsToCheck)
checks if all bits in field are set
static bool oC_Bits_AreBitsSetU16(uint16_t BitMask, uint16_t BitsToCheck)
checks if all bits in field are set
static bool oC_Bits_AreBitsClearU8(uint8_t BitMask, uint8_t BitsToCheck)
checks if all bits in field are clear
static uint16_t oC_Bits_SetBitsU16(uint16_t *outVariable, uint16_t Mask)
static bool oC_Bits_AreBitsClearU64(uint64_t BitMask, uint64_t BitsToCheck)
checks if all bits in field are clear
static bool oC_Bits_AreBitsClearU16(uint16_t BitMask, uint16_t BitsToCheck)
checks if all bits in field are clear
#define oC_Bits_Mask_U32(FROM, TO)
static int8_t oC_Bits_GetBitNumberU16(uint16_t BitMask)
static bool oC_Bits_IsAtLeastOneBitClearU32(uint32_t BitMask, uint32_t BitsToCheck)
checks if at least one of bits in field is set
#define oC_Bits_Mask_U64(FROM, TO)
static uint32_t oC_Bits_SetValueU32(uint32_t *outVariable, uint32_t Value, uint8_t StartBitNr, uint8_t EndBitNr)
static bool oC_Bits_IsAtLeastOneBitClearU8(uint8_t BitMask, uint8_t BitsToCheck)
checks if at least one of bits in field is set
static uint32_t oC_Bits_GetValueU32(uint32_t Variable, uint8_t StartBitNr, uint8_t EndBitNr)
static uint32_t oC_Bits_JoinU16ToU32(uint16_t LowPart, uint16_t HighPart)
static uint8_t oC_Bits_SetBitsU8(uint8_t *outVariable, uint8_t Mask)
static bool oC_Bits_AreBitsSetU8(uint8_t BitMask, uint8_t BitsToCheck)
checks if all bits in field are set
static uint64_t oC_Bits_GetValueU64(uint64_t Variable, uint8_t StartBitNr, uint8_t EndBitNr)
static bool oC_Bits_IsBitSetU64(uint64_t BitMask, uint8_t BitIndex)
checks if bit is set
static uint16_t oC_Bits_SetValueU16(uint16_t *outVariable, uint16_t Value, uint8_t StartBitNr, uint8_t EndBitNr)
static uint64_t oC_Bits_ClearBitsU64(uint64_t *outVariable, uint64_t Mask)
static uint8_t oC_Bits_ClearBitU8(uint8_t *outVariable, uint8_t BitIndex)
clear selected bit
static void oC_Bits_SplitU16ToU8(uint16_t Variable, uint8_t *outLow, uint8_t *outHigh)
#define oC_Bits_Mask_U16(FROM, TO)
static bool oC_Bits_IsBitSetU8(uint8_t BitMask, uint8_t BitIndex)
checks if bit is set
static bool oC_Bits_IsAtLeastOneBitClearU64(uint64_t BitMask, uint64_t BitsToCheck)
checks if at least one of bits in field is set
static bool oC_Bits_IsAtLeastOneBitSetU32(uint32_t BitMask, uint32_t BitsToCheck)
checks if at least one of bits in field is set
static void oC_Bits_SplitU64ToU32(uint64_t Variable, uint32_t *outLow, uint32_t *outHigh)
static uint32_t oC_Bits_SetBitsU32(uint32_t *outVariable, uint32_t Mask)
static int8_t oC_Bits_GetBitNumberU8(uint8_t BitMask)
static uint64_t oC_Bits_SetBitsU64(uint64_t *outVariable, uint64_t Mask)
static uint16_t oC_Bits_SetBitU16(uint16_t *outVariable, uint8_t BitIndex)
sets bit in the variable
static bool oC_Bits_IsAtLeastOneBitSetU8(uint8_t BitMask, uint8_t BitsToCheck)
checks if at least one of bits in field is set
static void oC_Bits_SplitU32ToU16(uint32_t Variable, uint16_t *outLow, uint16_t *outHigh)
static bool oC_Bits_IsAtLeastOneBitClearU16(uint16_t BitMask, uint16_t BitsToCheck)
checks if at least one of bits in field is set
static int8_t oC_Bits_GetBitNumberU32(uint32_t BitMask)
static uint64_t oC_Bits_SetValueU64(uint64_t *outVariable, uint64_t Value, uint8_t StartBitNr, uint8_t EndBitNr)
static uint16_t oC_Bits_ClearBitU16(uint16_t *outVariable, uint8_t BitIndex)
clear selected bit
static uint16_t oC_Bits_JoinU8ToU16(uint8_t LowPart, uint8_t HighPart)
static bool oC_Bits_AreBitsClearU32(uint32_t BitMask, uint32_t BitsToCheck)
checks if all bits in field are clear
static uint64_t oC_Bits_JoinU32ToU64(uint32_t LowPart, uint32_t HighPart)
static bool oC_Bits_IsBitSetU16(uint16_t BitMask, uint8_t BitIndex)
checks if bit is set
static uint16_t oC_Bits_GetValueU16(uint16_t Variable, uint8_t StartBitNr, uint8_t EndBitNr)
static bool oC_Bits_IsAtLeastOneBitSetU16(uint16_t BitMask, uint16_t BitsToCheck)
checks if at least one of bits in field is set
static uint32_t oC_Bits_ClearBitsU32(uint32_t *outVariable, uint32_t Mask)
static bool oC_Bits_IsAtLeastOneBitSetU64(uint64_t BitMask, uint64_t BitsToCheck)
checks if at least one of bits in field is set
static int8_t oC_Bits_GetBitNumberU64(uint64_t BitMask)
static bool oC_Bits_IsBitSetU32(uint32_t BitMask, uint8_t BitIndex)
checks if bit is set
static uint8_t oC_Bits_GetValueU8(uint8_t Variable, uint8_t StartBitNr, uint8_t EndBitNr)
static uint16_t oC_Bits_ClearBitsU16(uint16_t *outVariable, uint16_t Mask)
static uint32_t oC_Bits_SetBitU32(uint32_t *outVariable, uint8_t BitIndex)
sets bit in the variable
static uint8_t oC_Bits_SetValueU8(uint8_t *outVariable, uint8_t Value, uint8_t StartBitNr, uint8_t EndBitNr)
static uint64_t oC_Bits_ClearBitU64(uint64_t *outVariable, uint8_t BitIndex)
clear selected bit
static uint8_t oC_Bits_SetBitU8(uint8_t *outVariable, uint8_t BitIndex)
sets bit in the variable
static uint8_t oC_Bits_ClearBitsU8(uint8_t *outVariable, uint8_t Mask)
static bool oC_Bits_AreBitsSetU64(uint64_t BitMask, uint64_t BitsToCheck)
checks if all bits in field are set
static uint32_t oC_Bits_ClearBitU32(uint32_t *outVariable, uint8_t BitIndex)
clear selected bit