APM:Libraries
Macros
util.h File Reference

Miscellaneous utility macros and procedures. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define BIT(shift)   (1UL << (shift))
 
#define BIT_MASK_SHIFT(mask, shift)   ((mask) << (shift))
 
#define GET_BITS(x, m, n)   ((((uint32)x) << (31 - (n))) >> ((31 - (n)) + (m)))
 
#define IS_POWER_OF_TWO(v)   ((v) && !((v) & ((v) - 1)))
 

Detailed Description

Miscellaneous utility macros and procedures.

Definition in file util.h.

Macro Definition Documentation

◆ BIT

#define BIT (   shift)    (1UL << (shift))

1 << the bit number

Definition at line 40 of file util.h.

Referenced by gpio_read_bit(), gpio_set_mode(), gpio_toggle_bit(), gpio_write_bit(), i2c_lowLevel_deinit(), and i2c_lowLevel_init().

◆ BIT_MASK_SHIFT

#define BIT_MASK_SHIFT (   mask,
  shift 
)    ((mask) << (shift))

Mask shifted left by 'shift'

Definition at line 42 of file util.h.

◆ GET_BITS

#define GET_BITS (   x,
  m,
 
)    ((((uint32)x) << (31 - (n))) >> ((31 - (n)) + (m)))

Bits m to n of x

Definition at line 44 of file util.h.

◆ IS_POWER_OF_TWO

#define IS_POWER_OF_TWO (   v)    ((v) && !((v) & ((v) - 1)))

True if v is a power of two (1, 2, 4, 8, ...)

Definition at line 46 of file util.h.