BeRTOS
|
Bitarray module. More...
Go to the source code of this file.
Defines | |
#define | BITARRAY_ALLOC(name, size) uint8_t name[DIV_ROUNDUP((size), 8)] |
Convenience macro to create a memory area for the BitArray. | |
Functions | |
void | bitarray_set (BitArray *bitx, int idx) |
Set one bit into the bit array. | |
void | bitarray_clear (BitArray *bitx, int idx) |
Clear one bit in the bit array. | |
void | bitarray_setRange (BitArray *bitx, int idx, int offset) |
Set a range of bits. | |
void | bitarray_clearRange (BitArray *bitx, int idx, int offset) |
Clear a range of bits. | |
bool | bitarray_test (BitArray *bitx, int idx) |
Test a bit. | |
bool | bitarray_isFull (BitArray *bitx) |
Check if the bitarray is full. | |
bool | bitarray_isRangeFull (BitArray *bitx, int idx, int offset) |
Test if a range of bit is full. | |
bool | bitarray_isRangeEmpty (BitArray *bitx, int idx, int offset) |
Test if a range of bit is empty. | |
void | bitarray_dump (BitArray *bitx) |
Print on debug serial a BitArray. | |
void | bitarray_init (BitArray *bitx, size_t bitarray_len, uint8_t *array, size_t size) |
Init a BitArray. |
Bitarray module.
Definition in file bitarray.h.
#define BITARRAY_ALLOC | ( | name, | |
size | |||
) | uint8_t name[DIV_ROUNDUP((size), 8)] |
Convenience macro to create a memory area for the BitArray.
name | Name of the variable. |
size | Number of bits requested. It will be rounded to the nearest byte |
Definition at line 61 of file bitarray.h.
void bitarray_clear | ( | BitArray * | bitx, |
int | idx | ||
) | [inline] |
Clear one bit in the bit array.
bitx | BitArray context |
idx | The bit to clear |
Definition at line 83 of file bitarray.h.
void bitarray_clearRange | ( | BitArray * | bitx, |
int | idx, | ||
int | offset | ||
) | [inline] |
Clear a range of bits.
The range starts from idx (inclusive) and spans offset bits.
bitx | BitArray context |
idx | Starting bit |
offset | Number of bits to clear |
Definition at line 119 of file bitarray.h.
void bitarray_dump | ( | BitArray * | bitx | ) | [inline] |
Print on debug serial a BitArray.
bitx | BitArray to be printed. |
Definition at line 217 of file bitarray.h.
void bitarray_init | ( | BitArray * | bitx, |
size_t | bitarray_len, | ||
uint8_t * | array, | ||
size_t | size | ||
) | [inline] |
Init a BitArray.
The BitArray uses an external array for storage. You can use the macro BITARRAY_ALLOC to declare an appropriate memory size. Example usage:
BITARRAY_ALLOC(bits_mem, 17); BitArray bits; bitarray_init(&bits, 17, bits_mem, sizeof(bits_mem))
bitx | BitArray context |
bitarray_len | Number of bits in the BitArray |
array | Memory area for the BitArray |
size | Size (in bytes) of the memory area array |
Definition at line 257 of file bitarray.h.
bool bitarray_isFull | ( | BitArray * | bitx | ) | [inline] |
Check if the bitarray is full.
Only bitarray_len bits are tested.
bitx | BitArray to test |
Definition at line 151 of file bitarray.h.
bool bitarray_isRangeEmpty | ( | BitArray * | bitx, |
int | idx, | ||
int | offset | ||
) | [inline] |
Test if a range of bit is empty.
bitx | BitArray context |
idx | Starting bit |
offset | Number of bits to test |
Definition at line 200 of file bitarray.h.
bool bitarray_isRangeFull | ( | BitArray * | bitx, |
int | idx, | ||
int | offset | ||
) | [inline] |
Test if a range of bit is full.
bitx | BitArray context |
idx | Starting bit |
offset | Number of bits to test |
Definition at line 178 of file bitarray.h.
void bitarray_set | ( | BitArray * | bitx, |
int | idx | ||
) | [inline] |
Set one bit into the bit array.
bitx | BitArray context |
idx | The bit to set |
Definition at line 68 of file bitarray.h.
void bitarray_setRange | ( | BitArray * | bitx, |
int | idx, | ||
int | offset | ||
) | [inline] |
Set a range of bits.
The range starts from idx (inclusive) and spans offset bits.
bitx | BitArray context |
idx | Starting bit |
offset | Number of bit to set |
Definition at line 102 of file bitarray.h.
bool bitarray_test | ( | BitArray * | bitx, |
int | idx | ||
) | [inline] |
Test a bit.
bitx | BitArray context |
idx | Bit to test |
Definition at line 134 of file bitarray.h.