STM32G0 MCAL 0.0.1
Tiny MCAL for educational purpose.
Loading...
Searching...
No Matches
Bfx_8bits.h File Reference

This file contains the complete Bitfield functions for fixed point for 8 bit registers. More...

#include "Std_Types.h"

Go to the source code of this file.

Functions

static void Bfx_SetBit_u8u8 (uint8 *Data, uint8 BitPn)
 Set a single bit in Data pointer
 
static void Bfx_ClrBit_u8u8 (uint8 *Data, uint8 BitPn)
 Clears a single bit in Data pointer
 
static boolean Bfx_GetBit_u8u8_u8 (uint8 Data, uint8 BitPn)
 Obtain one bit especified
 
static void Bfx_SetBits_u8u8u8u8 (uint8 *Data, uint8 BitStartPn, uint8 BitLn, uint8 Status)
 Modifies consecutive bits acording to status
 
static uint8 Bfx_GetBits_u8u8u8_u8 (uint8 Data, uint8 BitStartPn, uint8 BitLn)
 Obtains consecutive bits from an unsigned integer
 
static void Bfx_SetBitMask_u8u8 (uint8 *Data, uint8 Mask)
 Using a mask to set bits
 
static void Bfx_ClrBitMask_u8u8 (uint8 *Data, uint8 Mask)
 Using a mask to clear bits
 
static boolean Bfx_TstBitMask_u8u8_u8 (uint8 Data, uint8 Mask)
 Compare a mask with a seccion of an unsigned integer
 
static boolean Bfx_TstBitLnMask_u8u8_u8 (uint8 Data, uint8 Mask)
 Compare any bit of a mask with a seccion of an unsigned integer
 
static boolean Bfx_TstParityEven_u8_u8 (uint8 Data)
 Determines if an unsigned integer has even parity
 
static void Bfx_ToggleBits_u8 (uint8 *Data)
 Changes the value of every bit of an unsigned integer
 
static void Bfx_ToggleBitMask_u8u8 (uint8 *Data, uint8 Mask)
 Using a mask to toggle bits
 
static void Bfx_ShiftBitRt_u8u8 (uint8 *Data, uint8 ShiftCnt)
 Shifts a unsigned integer to the right acourding to ShiftCnt
 
static void Bfx_ShiftBitLt_u8u8 (uint8 *Data, uint8 ShiftCnt)
 Shifts a unsigned integer to the left acourding to ShiftCnt
 
static void Bfx_RotBitRt_u8u8 (uint8 *Data, uint8 ShiftCnt)
 Rotates a unsigned integer to the right acourding to ShiftCnt
 
static void Bfx_RotBitLt_u8u8 (uint8 *Data, uint8 ShiftCnt)
 Rotates a unsigned integer to the left acourding to ShiftCnt
 
static void Bfx_CopyBit_u8u8u8u8 (uint8 *DestinationData, uint8 DestinationPosition, uint8 SourceData, uint8 SourcePosition)
 Copies a bit from an integer to another
 
static void Bfx_PutBits_u8u8u8u8 (uint8 *Data, uint8 BitStartPn, uint8 BitLn, uint8 Pattern)
 Takes a pattern and puts it in an unsigned integer
 
static void Bfx_PutBitsMask_u8u8u8 (uint8 *Data, uint8 Pattern, uint8 Mask)
 Takes a pattern and a mask and puts it in an unsigned integer
 
static void Bfx_PutBit_u8u8u8 (uint8 *Data, uint8 BitPn, boolean Status)
 Sets the bit of an unsigned integer according to Status
 
static uint8 Bfx_CountLeadingOnes_u8 (uint8 Data)
 Counts consecutive ones
 
static uint8 Bfx_CountLeadingSigns_s8 (sint8 Data)
 Count consecutive bits which have the same value as the MSB
 
static uint8 Bfx_CountLeadingZeros_u8 (uint8 Data)
 Counts consecutive zeros
 
static sint8 Bfx_ShiftBitSat_s8s8_s8 (sint8 ShiftCnt, sint8 Data)
 Arithmetic shift with saturation
 
static uint8 Bfx_ShiftBitSat_u8s8_u8 (sint8 ShiftCnt, uint8 Data)
 Arithmetic shift with saturation
 

Detailed Description

This file contains the complete Bitfield functions for fixed point for 8 bit registers.

Bfx routines specification specifies the functionality, API and the configuration of the AUTOSAR library for BIT functionality dedicated to fixed-point arithmetic routines. All bit functions are re-entrant and can handle several simultaneous requests from the application.

Function Documentation

◆ Bfx_ClrBit_u8u8()

static void Bfx_ClrBit_u8u8 ( uint8 * Data,
uint8 BitPn )
inlinestatic

Clears a single bit in Data pointer

This function shall clear the logical status of the input data to ’0’ at the requested bit position.

Parameters
DataUnsigned integer to modify
BitPnNumber of bit to modify
Requirement
SWS_Bfx_00010, SWS_Bfx_00011, SWS_Bfx_00015

◆ Bfx_ClrBitMask_u8u8()

static void Bfx_ClrBitMask_u8u8 ( uint8 * Data,
uint8 Mask )
inlinestatic

Using a mask to clear bits

This function shall clear the logical status to ’0’ for the input data for all the bit positions as per the mask.

Parameters
DataUnsigned integer to modify
MaskMask that indicates the bits to clear
Requirement
SWS_Bfx_00039, SWS_Bfx_00040, SWS_Bfx_00045

◆ Bfx_CopyBit_u8u8u8u8()

static void Bfx_CopyBit_u8u8u8u8 ( uint8 * DestinationData,
uint8 DestinationPosition,
uint8 SourceData,
uint8 SourcePosition )
inlinestatic

Copies a bit from an integer to another

This function shall copy a bit from source data from bit position to destination data at bit position.

Parameters
DestinationDataUnsigned integer receptor
DestinationPositionDestination bit
SourceDataUnsigned integer source
SourcePositionSource bit
Requirement
SWS_Bfx_00101, SWS_Bfx_00108

◆ Bfx_CountLeadingOnes_u8()

static uint8 Bfx_CountLeadingOnes_u8 ( uint8 Data)
inlinestatic

Counts consecutive ones

Count the number of consecutive ones in Data starting with the most significant bit and return the result.

Parameters
DataUnsigned integer to check
Return values
Counter
Requirement
SWS_Bfx_91003, SWS_Bfx_00137

◆ Bfx_CountLeadingSigns_s8()

static uint8 Bfx_CountLeadingSigns_s8 ( sint8 Data)
inlinestatic

Count consecutive bits which have the same value as the MSB

Count the number of consecutive bits which have the same value as most significant bit in Data, starting with bit at position msb minus one. Put the result in Data. It is the number of leading sign bits minus one, giving the number of redundant sign bits in Data.

Parameters
DataSigned integer to check
Return values
Data
Requirement
SWS_Bfx_91004, SWS_Bfx_00139

◆ Bfx_CountLeadingZeros_u8()

static uint8 Bfx_CountLeadingZeros_u8 ( uint8 Data)
inlinestatic

Counts consecutive zeros

Count the number of consecutive zeros in Data starting with the most significant bit and return the result.

Parameters
DataUnsigned integer to check
Return values
Counter
Requirement
SWS_Bfx_91005, SWS_Bfx_00141

◆ Bfx_GetBit_u8u8_u8()

static boolean Bfx_GetBit_u8u8_u8 ( uint8 Data,
uint8 BitPn )
inlinestatic

Obtain one bit especified

This function shall return the logical status of the input data for the requested bit position.

Parameters
DataUnsigned integer containing the bit
BitPnNumber of bit to obtain
Return values
Result
Requirement
SWS_Bfx_00016, SWS_Bfx_00017, SWS_Bfx_00020

◆ Bfx_GetBits_u8u8u8_u8()

static uint8 Bfx_GetBits_u8u8u8_u8 ( uint8 Data,
uint8 BitStartPn,
uint8 BitLn )
inlinestatic

Obtains consecutive bits from an unsigned integer

This function shall return the Bits of the input data starting from ’BitStartPn’ for the length of ’BitLn’.

Parameters
DataUnsigned integer with the bits
BitStartPnBit that indicates the start of the bits to obtain
BitLnNumber of bits to obtain
Return values
Result
Requirement
SWS_Bfx_00028, SWS_Bfx_00029, SWS_Bfx_00034

◆ Bfx_PutBit_u8u8u8()

static void Bfx_PutBit_u8u8u8 ( uint8 * Data,
uint8 BitPn,
boolean Status )
inlinestatic

Sets the bit of an unsigned integer according to Status

This function shall update the bit specified by BitPn of input data as ’1’ or ’0’ as per ’Status’ value.

Parameters
DataUnsigned integer to modify
BitPnPin to modify
Statusboolean value to set
Requirement
SWS_Bfx_00130, SWS_Bfx_00132

◆ Bfx_PutBits_u8u8u8u8()

static void Bfx_PutBits_u8u8u8u8 ( uint8 * Data,
uint8 BitStartPn,
uint8 BitLn,
uint8 Pattern )
inlinestatic

Takes a pattern and puts it in an unsigned integer

This function shall put bits as mentioned in Pattern to the input Data from the specified bit position.

Parameters
DataUnsigned integer to modify
BitStartPnLSB to start
BitLnLenght of the chain of bits
PatternPattern to partially copy
Requirement
SWS_Bfx_00110, SWS_Bfx_00112

◆ Bfx_PutBitsMask_u8u8u8()

static void Bfx_PutBitsMask_u8u8u8 ( uint8 * Data,
uint8 Pattern,
uint8 Mask )
inlinestatic

Takes a pattern and a mask and puts it in an unsigned integer

This function shall put all bits defined in Pattern and for which the corresponding Mask bit is set to 1 in the input Data.

Parameters
DataUnsigned integer to modify
PatternPattern to partially copy
MaskMask that indicates the bits to copy
Requirement
SWS_Bfx_00120, SWS_Bfx_00124

◆ Bfx_RotBitLt_u8u8()

static void Bfx_RotBitLt_u8u8 ( uint8 * Data,
uint8 ShiftCnt )
inlinestatic

Rotates a unsigned integer to the left acourding to ShiftCnt

This function shall rotate data to the right by ShiftCnt. The least significant bit is rotated to the most significant bit location for every single bit shift cycle.

Parameters
DataUnsigned integer to modify
ShiftCntNumber of shifts to perform
Requirement
SWS_Bfx_00095, SWS_Bfx_00098

◆ Bfx_RotBitRt_u8u8()

static void Bfx_RotBitRt_u8u8 ( uint8 * Data,
uint8 ShiftCnt )
inlinestatic

Rotates a unsigned integer to the right acourding to ShiftCnt

This function shall rotate data to the right by ShiftCnt. The least significant bit is rotated to the most significant bit location for every single bit shift cycle.

Parameters
DataUnsigned integer to modify
ShiftCntNumber of shifts to perform
Requirement
SWS_Bfx_00086, SWS_Bfx_00090

◆ Bfx_SetBit_u8u8()

static void Bfx_SetBit_u8u8 ( uint8 * Data,
uint8 BitPn )
inlinestatic

Set a single bit in Data pointer

This function shall set the logical status of input data as ’1’ at the requested bit position.

Parameters
DataUnsigned integer to modify
BitPnNumber of bit to modify
Requirement
SWS_Bfx_00001, SWS_Bfx_00002, SWS_Bfx_00008

◆ Bfx_SetBitMask_u8u8()

static void Bfx_SetBitMask_u8u8 ( uint8 * Data,
uint8 Mask )
inlinestatic

Using a mask to set bits

This function shall set the data to logical status ’1’ as per the corresponding Mask bits when set to value 1 and remaining bits will retain their original values.

Parameters
DataUnsigned integer to modify
MaskMask that indicates the bits to set
Requirement
SWS_Bfx_00035, SWS_Bfx_00036, SWS_Bfx_00038

◆ Bfx_SetBits_u8u8u8u8()

static void Bfx_SetBits_u8u8u8u8 ( uint8 * Data,
uint8 BitStartPn,
uint8 BitLn,
uint8 Status )
inlinestatic

Modifies consecutive bits acording to status

This function shall set the input data as ’1’ or ’0’ as per ’Status’ value starting from ’BitStartPn’ for the length ’BitLn’.

Parameters
DataUnsigned integer to modify
BitStartPnBit that indicates the start of the bits to modify
BitLnNumber of bits to modify
StatusValue that the bits will take
Requirement
SWS_Bfx_00021, SWS_Bfx_00022, SWS_Bfx_00025

◆ Bfx_ShiftBitLt_u8u8()

static void Bfx_ShiftBitLt_u8u8 ( uint8 * Data,
uint8 ShiftCnt )
inlinestatic

Shifts a unsigned integer to the left acourding to ShiftCnt

This function shall shift data to the left by ShiftCnt. The least significant bit (right-most bit) is replaced by a ’0’ bit and the most significant bit (left-most bit) is discarded for every single bit shift cycle.

Parameters
DataUnsigned integer to modify
ShiftCntNumber of shifts to perform
Requirement
SWS_Bfx_00076, SWS_Bfx_00080

◆ Bfx_ShiftBitRt_u8u8()

static void Bfx_ShiftBitRt_u8u8 ( uint8 * Data,
uint8 ShiftCnt )
inlinestatic

Shifts a unsigned integer to the right acourding to ShiftCnt

This function shall shift data to the right by ShiftCnt. The most significant bit (left-most bit) is replaced by a ’0’ bit and the least significant bit (right-most bit) is discarded for every single bit shift cycle.

Parameters
DataUnsigned integer to modify
ShiftCntNumber of shifts to perform
Requirement
SWS_Bfx_00070, SWS_Bfx_00075

◆ Bfx_ShiftBitSat_s8s8_s8()

static sint8 Bfx_ShiftBitSat_s8s8_s8 ( sint8 ShiftCnt,
sint8 Data )
inlinestatic

Arithmetic shift with saturation

If the shift count is greater than or equal to zero, then shift the value in Data by the amount specified by shift count to left.

For signed data an arithmetic shift is performed. The vacated bits are filled with zeros and the result is saturated if its sign bit differs from the sign bits that are shifted out.

If the shift count is less than zero, right-shift the value in Data by the absolute value of the shift count. The vacated bits are filled with the sign-bit (the most significant bit) and bits shifted out are discarded.

Parameters
ShiftCntShift count
DataSigned integer to check
Return values
Data
Requirement
SWS_Bfx_91002, SWS_Bfx_00134, SWS_Bfx_00135

◆ Bfx_ShiftBitSat_u8s8_u8()

static uint8 Bfx_ShiftBitSat_u8s8_u8 ( sint8 ShiftCnt,
uint8 Data )
inlinestatic

Arithmetic shift with saturation

If the shift count is greater than or equal to zero, then shift the value in Data by the amount specified by shift count to left.

For unsigned data a logical shift is performed. In this case the result is saturated, if the leading one bit is shifted out.

If the shift count is less than zero, right-shift the value in Data by the absolute value of the shift count. The vacated bits are filled with the sign-bit (the most significant bit) and bits shifted out are discarded.

Parameters
ShiftCntShift count
DataUnsigned integer to check
Return values
Data
Requirement
SWS_Bfx_91002, SWS_Bfx_00134, SWS_Bfx_00135

◆ Bfx_ToggleBitMask_u8u8()

static void Bfx_ToggleBitMask_u8u8 ( uint8 * Data,
uint8 Mask )
inlinestatic

Using a mask to toggle bits

This function toggles the bits of data when the corresponding bit of the mask is enabled and set to 1.

Parameters
DataUnsigned integer to modify
MaskMask that indicates the bits to toggle
Requirement
SWS_Bfx_00066, SWS_Bfx_00069

◆ Bfx_ToggleBits_u8()

static void Bfx_ToggleBits_u8 ( uint8 * Data)
inlinestatic

Changes the value of every bit of an unsigned integer

This function toggles all the bits of data (1’s Complement Data).

Parameters
DataUnsigned integer to modify
Requirement
SWS_Bfx_00061, SWS_Bfx_00065

◆ Bfx_TstBitLnMask_u8u8_u8()

static boolean Bfx_TstBitLnMask_u8u8_u8 ( uint8 Data,
uint8 Mask )
inlinestatic

Compare any bit of a mask with a seccion of an unsigned integer

This function makes a test on the input data and if at least one bit is set as per the mask, then the function shall return TRUE, otherwise it shall return FALSE.

Parameters
DataUnsigned integer to compare
MaskMask used to compare
Return values
Result
Requirement
SWS_Bfx_00051, SWS_Bfx_00055

◆ Bfx_TstBitMask_u8u8_u8()

static boolean Bfx_TstBitMask_u8u8_u8 ( uint8 Data,
uint8 Mask )
inlinestatic

Compare a mask with a seccion of an unsigned integer

This function shall return TRUE, if all bits defined in Mask value are set in the input Data value. In all other cases this function shall return FALSE.

Parameters
DataUnsigned integer to compare
MaskMask used to compare
Return values
Result
Requirement
SWS_Bfx_00046, SWS_Bfx_00047, SWS_Bfx_00050

◆ Bfx_TstParityEven_u8_u8()

static boolean Bfx_TstParityEven_u8_u8 ( uint8 Data)
inlinestatic

Determines if an unsigned integer has even parity

This function tests the number of bits set to 1. If this number is even, it shall return TRUE, otherwise it returns FALSE.

Parameters
DataUnsigned integer to compare
Return values
Result
Requirement
SWS_Bfx_00056, SWS_Bfx_00060