PebbleOS
Loading...
Searching...
No Matches
Macros
bits.h File Reference

Macros

#define PBL_BIT(n)   (1U << (n))
 Unsigned 32-bit value with a single bit set.
 
#define PBL_BIT64(n)   (1ULL << (n))
 Unsigned 64-bit value with a single bit set.
 
#define PBL_BIT_MASK(n)   (PBL_BIT(n) - 1U)
 Unsigned 32-bit mask with the n least significant bits set.
 
#define PBL_BIT64_MASK(n)   (PBL_BIT64(n) - 1ULL)
 Unsigned 64-bit mask with the n least significant bits set.
 
#define PBL_GENMASK(h, l)   (((2U << ((h) - (l))) - 1U) << (l))
 Unsigned 32-bit mask with bits l to h set, both included.
 
#define PBL_GENMASK64(h, l)   (((2ULL << ((h) - (l))) - 1ULL) << (l))
 Unsigned 64-bit mask with bits l to h set, both included.
 
#define PBL_LSB_GET(value)   ((value) & -(value))
 Isolate the least significant set bit of a value.
 
#define PBL_FIELD_GET(mask, value)   (((value) & (mask)) / PBL_LSB_GET(mask))
 Extract a field from a register value.
 
#define PBL_FIELD_PREP(mask, value)   (((value) * PBL_LSB_GET(mask)) & (mask))
 Prepare a field value for a register.
 
#define PBL_WRITE_BIT(var, bit, set)
 Set or clear a bit in a variable.