Sound Open Firmware
Loading...
Searching...
No Matches
bit.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-3-Clause
2 *
3 * Copyright(c) 2018 Intel Corporation. All rights reserved.
4 *
5 * Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
6 */
7
8#ifndef __ZEPHYR_RTOS_BIT_H__
9#define __ZEPHYR_RTOS_BIT_H__
10
11#include <zephyr/sys/util.h>
12
13/* TODO: align with Zephyr BIT APIs */
14
15#define MASK(b_hi, b_lo) \
16 (((1ULL << ((b_hi) - (b_lo) + 1ULL)) - 1ULL) << (b_lo))
17#define SET_BIT(b, x) (((x) & 1) << (b))
18#define SET_BITS(b_hi, b_lo, x) \
19 (((x) & ((1ULL << ((b_hi) - (b_lo) + 1ULL)) - 1ULL)) << (b_lo))
20#define GET_BIT(b, x) \
21 (((x) & (1ULL << (b))) >> (b))
22#define GET_BITS(b_hi, b_lo, x) \
23 (((x) & MASK(b_hi, b_lo)) >> (b_lo))
24
25#endif /* __ZEPHYR_RTOS_BIT_H__ */