Subversion Repositories idreammicro-avr

Rev

Blame | Last modification | View Log | Download | RSS feed

/**************************************************************************//**
 * \brief Bit manipulation library - API
 * \author Copyright (C) 2011  Julien Le Sech - www.idreammicro.com
 * \version 1.0
 * \date 20110823
 *
 * This file is part of the iDreamMicro library.
 *
 * 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 3 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.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program. If not, see http://www.gnu.org/licenses/
 ******************************************************************************/


/**************************************************************************//**
 * \headerfile bits.h
 ******************************************************************************/


#ifndef H__IDREAMMICRO__USEFUL__BITS__H
#define H__IDREAMMICRO__USEFUL__BITS__H

#ifdef _cplusplus
extern "C"{
#endif

/******************************************************************************
 * Public macro definitions.
 ******************************************************************************/


/**************************************************************************//**
 * \def BIT__SET
 * \brief Set a bit in a byte.
 ******************************************************************************/

#define BIT__SET(variable, bit) (variable |= (1 << bit))

/**************************************************************************//**
 * \def BIT__RST
 * \brief Reset a bit in a byte.
 ******************************************************************************/

#define BIT__RST(variable, bit) (variable &= ~(1 << bit))

/**************************************************************************//**
 * \def BIT__TGL
 * \brief Toggle a bit in a byte.
 ******************************************************************************/

#define BIT__TGL(variable, bit) (variable ^= (1 << bit))

/**************************************************************************//**
 * \def BIT__TST
 * \brief Test a bit in a byte.
 ******************************************************************************/

#define BIT__TST(variable, bit) (variable & (1 << bit))

#ifdef _cplusplus
}
#endif

#endif /* H__IDREAMMICRO__USEFUL__BITS__H */