Add GET_BIT() and GET_BITS() macros to bit.h

These macros are useful for decoding bit fields.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
This commit is contained in:
Seppo Ingalsuo 2021-04-16 18:53:08 +03:00 committed by Liam Girdwood
parent 58b4aa472a
commit 8c497439bc
1 changed files with 4 additions and 0 deletions

View File

@ -24,5 +24,9 @@
#define SET_BIT(b, x) (((x) & 1) << (b))
#define SET_BITS(b_hi, b_lo, x) \
(((x) & ((1ULL << ((b_hi) - (b_lo) + 1ULL)) - 1ULL)) << (b_lo))
#define GET_BIT(b, x) \
(((x) & (1ULL << (b))) >> (b))
#define GET_BITS(b_hi, b_lo, x) \
(((x) & MASK(b_hi, b_lo)) >> (b_lo))
#endif /* __SOF_BIT_H__ */