23#include <zephyr/kernel.h>
31 for (
size_t i = size; i-- > 0;) {
32 printk(
"%02X", bitfield[i]);
37void set_bit(uint8_t *bitfield,
size_t bit_index) {
38 bitfield[bit_index / 8] |= BIT(bit_index % 8);
42 return bitfield[bit_index / 8] & BIT(bit_index % 8);
46 for (
size_t i = 0; i < num_bytes; i++) {
55 return __builtin_popcount(
byte);
69 size_t total_count = 0;
70 for (
size_t i = 0; i < num_bytes; i++) {
void print_bitfield_as_binary(uint8_t *bitfield, size_t size)
void bitwise_and_bitfields(uint8_t *result, const bluesync_timestamps_t *rcv, const bluesync_timestamps_t *local, size_t num_bytes)
Perform a bitwise AND between two bitfields and store the result.
size_t count_set_bits(uint8_t *bitfield, size_t num_bytes)
Count the number of bits set to 1 in a bitfield.
void set_bit(uint8_t *bitfield, size_t bit_index)
Set a specific bit in the bitfield.
bool is_bit_set(uint8_t *bitfield, size_t bit_index)
Check if a specific bit is set in the bitfield.
static uint8_t count_bits_in_byte(uint8_t byte)
static struct local_time local
uint8_t bitfield[NB_BYTES_BITFIELD]