Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

lib_def.h

Prototypes

Code Block
LanguageC++
CaptionTextCAPTION
languagecpp
          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

C++
Code Block
Language
CaptionTextCAPTION
languagecpp
          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 */