Documentation
Tools for embedded systems
Loading...
Searching...
No Matches
qbitfield.h
1
9#ifndef QBITFIELD_H
10#define QBITFIELD_H
11
12#ifdef __cplusplus
13extern "C" {
14#endif
15
16 #include <stdint.h>
17 #include <stdlib.h>
18
29 typedef struct
30 {
32 uint32_t *field; /*-> used-defined memory block to hold the bitfield storage */
33 size_t size; /*-> Bits capacity*/
34 size_t nSlots; /*-> Number of 32-bit slots for the bitfield storage*/
37
41 #define QBITFIELD_SIZE( NBITS ) ( 4 * ( ( ( (NBITS)-1 ) / 32 ) + 1 ) )
42
52 int qBitField_Setup( qBitField_t * const b,
53 void * const area,
54 const size_t area_size );
55
61 int qBitField_ClearAll( qBitField_t * const b );
62
68 int qBitField_SetAll( qBitField_t * const b );
69
76 int qBitField_SetBit( qBitField_t * const b,
77 const size_t index );
78
85 int qBitField_ClearBit( qBitField_t * const b,
86 const size_t index );
87
94 int qBitField_ToggleBit( qBitField_t * const b,
95 const size_t index );
96
103 uint8_t qBitField_ReadBit( const qBitField_t * const b,
104 const size_t index );
105
113 int qBitField_WriteBit( qBitField_t * const b,
114 const size_t index,
115 uint8_t value );
116
124 uint32_t qBitField_ReadUINTn( const qBitField_t * const b,
125 const size_t index,
126 size_t xBits );
127
136 int qBitField_WriteUINTn( qBitField_t * const b,
137 const size_t index,
138 uint32_t value,
139 size_t xBits );
140
147 float qBitField_ReadFloat( const qBitField_t * const b,
148 const size_t index );
149
157 int qBitField_WriteFloat( qBitField_t * const b,
158 const size_t index,
159 float value );
160
170 void* qBitField_Dump( const qBitField_t * const b,
171 void * const dst,
172 size_t n );
173
176#ifdef __cplusplus
177}
178#endif
179
180#endif
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.
Definition qbitfield.c:293
int qBitField_WriteFloat(qBitField_t *const b, const size_t index, float value)
Writes a 32-bit floating point value to the BitField.
Definition qbitfield.c:276
float qBitField_ReadFloat(const qBitField_t *const b, const size_t index)
Reads a 32-bit floating point value from the BitField.
Definition qbitfield.c:260
int qBitField_ClearBit(qBitField_t *const b, const size_t index)
Clears one bit in a BitField.
Definition qbitfield.c:151
int qBitField_SetBit(qBitField_t *const b, const size_t index)
Sets one bit in a BitField.
Definition qbitfield.c:138
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.
Definition qbitfield.c:230
int qBitField_ClearAll(qBitField_t *const b)
Clear all the bits in the BitField.
Definition qbitfield.c:114
int qBitField_WriteBit(qBitField_t *const b, const size_t index, uint8_t value)
Writes one bit in a bitfield.
Definition qbitfield.c:189
int qBitField_Setup(qBitField_t *const b, void *const area, const size_t area_size)
Setup a initialize a BitField instance.
Definition qbitfield.c:95
uint8_t qBitField_ReadBit(const qBitField_t *const b, const size_t index)
Retrieve the state of a bit in a bitfield.
Definition qbitfield.c:177
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.
Definition qbitfield.c:208
int qBitField_ToggleBit(qBitField_t *const b, const size_t index)
Toggles (i.e. reverses the state of) a bit in a BitField.
Definition qbitfield.c:164
int qBitField_SetAll(qBitField_t *const b)
Set all the bits in the BitField.
Definition qbitfield.c:126
A BitField object.
Definition qbitfield.h:30