Documentation
Tools for embedded systems
Loading...
Searching...
No Matches
qBitField

API for the Bit-Field manipulation library. More...

Data Structures

struct  qBitField_t
 A BitField object. More...
 

Macros

#define QBITFIELD_SIZE(NBITS)
 Use to determine the uint8_t array-size for a BitField.
 

Functions

int qBitField_Setup (qBitField_t *const b, void *const area, const size_t area_size)
 Setup a initialize a BitField instance.
 
int qBitField_ClearAll (qBitField_t *const b)
 Clear all the bits in the BitField.
 
int qBitField_SetAll (qBitField_t *const b)
 Set all the bits in the BitField.
 
int qBitField_SetBit (qBitField_t *const b, const size_t index)
 Sets one bit in a BitField.
 
int qBitField_ClearBit (qBitField_t *const b, const size_t index)
 Clears one bit in a BitField.
 
int qBitField_ToggleBit (qBitField_t *const b, const size_t index)
 Toggles (i.e. reverses the state of) a bit in a BitField.
 
uint8_t qBitField_ReadBit (const qBitField_t *const b, const size_t index)
 Retrieve the state of a bit in a bitfield.
 
int qBitField_WriteBit (qBitField_t *const b, const size_t index, uint8_t value)
 Writes one bit in a bitfield.
 
uint32_t qBitField_ReadUINTn (const qBitField_t *const b, const size_t index, size_t xBits)
 Reads an unsigned 32-bit value from the BitField.
 
int qBitField_WriteUINTn (qBitField_t *const b, const size_t index, uint32_t value, size_t xBits)
 Writes an unsigned n-bit value from the BitField.
 
float qBitField_ReadFloat (const qBitField_t *const b, const size_t index)
 Reads a 32-bit floating point value from the BitField.
 
int qBitField_WriteFloat (qBitField_t *const b, const size_t index, float value)
 Writes a 32-bit floating point value to the BitField.
 
void * qBitField_Dump (const qBitField_t *const b, void *const dst, size_t n)
 Copies n bytes from the bit-field instance to a designed memory area.
 

Detailed Description

API for the Bit-Field manipulation library.

For a brief description of this module, please read Bit-Field manipulation library

Function Documentation

◆ qBitField_ClearAll()

int qBitField_ClearAll ( qBitField_t *const b)

Clear all the bits in the BitField.

Parameters
[in]bA pointer to the BitField instance
Returns
1 on success, otherwise return 0.

◆ qBitField_ClearBit()

int qBitField_ClearBit ( qBitField_t *const b,
const size_t index )

Clears one bit in a BitField.

Parameters
[in]bA pointer to the BitField instance
[in]indexThe bit-index.
Returns
1 on success, otherwise return 0.

◆ qBitField_Dump()

void * qBitField_Dump ( const qBitField_t *const b,
void *const dst,
size_t n )

Copies n bytes from the bit-field instance to a designed memory area.

Parameters
[in]bA pointer to the BitField instance
[in]dstPointer to the destination array where the content is to be copied.
[in]nNumber of bytes to copy.
Returns
Destination is returned on success, otherwise NULL.

◆ qBitField_ReadBit()

uint8_t qBitField_ReadBit ( const qBitField_t *const b,
const size_t index )

Retrieve the state of a bit in a bitfield.

Parameters
[in]bA pointer to the BitField instance
[in]indexThe bit-index.
Returns
The value of the bit at index.

◆ qBitField_ReadFloat()

float qBitField_ReadFloat ( const qBitField_t *const b,
const size_t index )

Reads a 32-bit floating point value from the BitField.

Parameters
[in]bA pointer to the BitField instance
[in]indexThe bit-index taken as offset.
Returns
The floating point value from the BitField at the desired index

◆ qBitField_ReadUINTn()

uint32_t qBitField_ReadUINTn ( const qBitField_t *const b,
const size_t index,
size_t xBits )

Reads an unsigned 32-bit value from the BitField.

Parameters
[in]bA pointer to the BitField instance
[in]indexThe bit-index taken as offset.
[in]xBitsThe number of bits to read. ( max allowed : 32 bits )
Returns
The value from the bitfield from the desired index

◆ qBitField_SetAll()

int qBitField_SetAll ( qBitField_t *const b)

Set all the bits in the BitField.

Parameters
[in]bA pointer to the BitField instance
Returns
1 on success, otherwise return 0.

◆ qBitField_SetBit()

int qBitField_SetBit ( qBitField_t *const b,
const size_t index )

Sets one bit in a BitField.

Parameters
[in]bA pointer to the BitField instance
[in]indexThe bit-index.
Returns
1 on success, otherwise return 0.

◆ qBitField_Setup()

int qBitField_Setup ( qBitField_t *const b,
void *const area,
const size_t area_size )

Setup a initialize a BitField instance.

Parameters
[in]bA pointer to the BitField instance
[in]areaA pointer to the memory block to hold the BitField. Should be an uint8_t array of size QBITFIELD_SIZE(n), where n, is the number of bits inside the BitField.
[in]area_sizeThe number of bytes in area.
Returns
1 on success, otherwise return 0.

◆ qBitField_ToggleBit()

int qBitField_ToggleBit ( qBitField_t *const b,
const size_t index )

Toggles (i.e. reverses the state of) a bit in a BitField.

Parameters
[in]bA pointer to the BitField instance
[in]indexThe bit-index.
Returns
1 on success, otherwise return 0.

◆ qBitField_WriteBit()

int qBitField_WriteBit ( qBitField_t *const b,
const size_t index,
uint8_t value )

Writes one bit in a bitfield.

Parameters
[in]bA pointer to the BitField instance
[in]indexThe bit-index.
[in]valueThe boolean value to write.
Returns
1 on success, otherwise return 0.

◆ qBitField_WriteFloat()

int qBitField_WriteFloat ( qBitField_t *const b,
const size_t index,
float value )

Writes a 32-bit floating point value to the BitField.

Parameters
[in]bA pointer to the BitField instance
[in]indexThe bit-index taken as offset.
[in]valueThe floating point value to write.
Returns
1 on success, otherwise return 0.

◆ qBitField_WriteUINTn()

int qBitField_WriteUINTn ( qBitField_t *const b,
const size_t index,
uint32_t value,
size_t xBits )

Writes an unsigned n-bit value from the BitField.

Parameters
[in]bA pointer to the BitField instance
[in]indexThe bit-index taken as offset.
[in]valueThe value to write.
[in]xBitsThe number of bits to read. ( max allowed : 32 bits )
Returns
1 on success, otherwise return 0.