Speeduino
Loading...
Searching...
No Matches
Macros
bit_manip.h File Reference

Bit twiddling macros. More...

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

Go to the source code of this file.

Macros

#define BIT_SET(var, pos)   ((var) |= (1U<<(pos)))
 Set bit b (0-7) in byte a.
 
#define BIT_CLEAR(var, pos)   ((var) &= ~(1U<<(pos)))
 Clear bit b (0-7) in byte a.
 
#define BIT_CHECK(var, pos)   !!((var) & (1U<<(pos)))
 Is bit pos (0-7) in byte var set?
 
#define BIT_TOGGLE(var, pos)   ((var)^= 1UL << (pos))
 Toggle the value of bit pos (0-7) in byte var.
 
#define BIT_WRITE(var, pos, bitvalue)   ((bitvalue) ? BIT_SET((var), (pos)) : BIT_CLEAR((var), (pos)))
 Set the value ([0,1], [true, false]) of bit pos (0-7) in byte var.
 

Detailed Description

Bit twiddling macros.

Macro Definition Documentation

◆ BIT_CHECK

#define BIT_CHECK (   var,
  pos 
)    !!((var) & (1U<<(pos)))

Is bit pos (0-7) in byte var set?

◆ BIT_CLEAR

#define BIT_CLEAR (   var,
  pos 
)    ((var) &= ~(1U<<(pos)))

Clear bit b (0-7) in byte a.

◆ BIT_SET

#define BIT_SET (   var,
  pos 
)    ((var) |= (1U<<(pos)))

Set bit b (0-7) in byte a.

◆ BIT_TOGGLE

#define BIT_TOGGLE (   var,
  pos 
)    ((var)^= 1UL << (pos))

Toggle the value of bit pos (0-7) in byte var.

◆ BIT_WRITE

#define BIT_WRITE (   var,
  pos,
  bitvalue 
)    ((bitvalue) ? BIT_SET((var), (pos)) : BIT_CLEAR((var), (pos)))

Set the value ([0,1], [true, false]) of bit pos (0-7) in byte var.