...
lib_def.h
Prototypes
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
DEF_BIT_MASK(bit_mask, bit_shift);
DEF_BIT_MASK_08(bit_mask, bit_shift);
DEF_BIT_MASK_16(bit_mask, bit_shift);
DEF_BIT_MASK_32(bit_mask, bit_shift);
DEF_BIT_MASK_64(bit_mask, bit_shift);
|
Arguments
bit_mask
Bit mask to shift.
...
bit_shift
values that overflow the target CPU and/or compiler environment (e.g. negative or greater-than-CPU-data-size values) may generate compiler warnings and/or errors.
Example Usage
Code Block | Language | C++|||
---|---|---|---|---|
| ||||
CPU_INT16U mask;
CPU_INT16U mask_hi;
CPU_INT32U mask_32;
mask = 0x0065u;
mask_hi = DEF_BIT_MASK(mask, 8u);
mask_32 = DEF_BIT_MASK_16(mask, 10u); /* 16-bit shift macro overflows; sets mask_32 = 0x00009400 */
mask_32 = DEF_BIT_MASK_16(mask, 20u); /* 16-bit shift macro overflows; sets mask_32 = 0 */
mask_32 = DEF_BIT_MASK_32(mask, 20u); /* 32-bit shift macro correctly sets mask_32 = 0x06500000 */
|