COSA
An Object-Oriented Platform for Arduino Programming
Bits.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define bit_mask(b)   (1 << (b))
 
#define bit_mask_get(p, m)   ((p) & (m))
 
#define bit_mask_set(p, m)   ((p) |= (m))
 
#define bit_mask_clear(p, m)   ((p) &= ~(m))
 
#define bit_mask_toggle(p, m)   ((p) ^= (m))
 
#define bit_mask_write(c, p, m)   (c ? bit_mask_set(p,m) : bit_mask_clear(p,m))
 
#define bit_get(p, b)   ((p) & bit_mask(b))
 
#define bit_set(p, b)   ((p) |= bit_mask(b))
 
#define bit_clear(p, b)   ((p) &= ~bit_mask(b))
 
#define bit_toggle(p, b)   ((p) ^= bit_mask(b))
 
#define bit_write(c, p, b)   (c ? bit_set(p,b) : bit_clear(p,b))
 
#define bit_field_set(p, m, v)   ((p) = ((p) & ~(m)) | ((v) & (m)))
 

Detailed Description

Version
1.0

License

Copyright (C) 2012-2015, Mikael Patel

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

Description

Bit mask, set and field access macro set.

This file is part of the Arduino Che Cosa project.

Definition in file Bits.h.

Macro Definition Documentation

#define bit_clear (   p,
 
)    ((p) &= ~bit_mask(b))

Definition at line 36 of file Bits.h.

#define bit_field_set (   p,
  m,
 
)    ((p) = ((p) & ~(m)) | ((v) & (m)))

Definition at line 40 of file Bits.h.

#define bit_get (   p,
 
)    ((p) & bit_mask(b))

Definition at line 34 of file Bits.h.

#define bit_mask (   b)    (1 << (b))

Definition at line 27 of file Bits.h.

#define bit_mask_clear (   p,
 
)    ((p) &= ~(m))

Definition at line 30 of file Bits.h.

#define bit_mask_get (   p,
 
)    ((p) & (m))

Definition at line 28 of file Bits.h.

#define bit_mask_set (   p,
 
)    ((p) |= (m))

Definition at line 29 of file Bits.h.

#define bit_mask_toggle (   p,
 
)    ((p) ^= (m))

Definition at line 31 of file Bits.h.

#define bit_mask_write (   c,
  p,
 
)    (c ? bit_mask_set(p,m) : bit_mask_clear(p,m))

Definition at line 32 of file Bits.h.

#define bit_set (   p,
 
)    ((p) |= bit_mask(b))

Definition at line 35 of file Bits.h.

#define bit_toggle (   p,
 
)    ((p) ^= bit_mask(b))

Definition at line 37 of file Bits.h.

#define bit_write (   c,
  p,
 
)    (c ? bit_set(p,b) : bit_clear(p,b))

Definition at line 38 of file Bits.h.