DEF_BIT_MASK_xx()

Shifts a bit mask.

Files

lib_def.h

Prototypes

          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

Number of bit positions to left-shift the bit mask.

Returned Value

bit_mask left-shifted by bit_shift number of bits.

Required Configuration

None.

Notes / Warnings

bit_mask should be an unsigned integer. bit_shift should be a non-negative integer.

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

          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 */