Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2 | jlesech | 1 | /**************************************************************************//** |
2 | * \brief Bit manipulation library - API |
||
3 | * \author Copyright (C) 2011 Julien Le Sech - www.idreammicro.com |
||
4 | * \version 1.0 |
||
5 | * \date 20110823 |
||
6 | * |
||
7 | * This file is part of the iDreamMicro library. |
||
8 | * |
||
9 | * This library is free software: you can redistribute it and/or modify it under |
||
10 | * the terms of the GNU Lesser General Public License as published by the Free |
||
11 | * Software Foundation, either version 3 of the License, or (at your option) any |
||
12 | * later version. |
||
13 | * |
||
14 | * This library is distributed in the hope that it will be useful, but WITHOUT |
||
15 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
||
16 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
||
17 | * details. |
||
18 | * |
||
19 | * You should have received a copy of the GNU Lesser General Public License |
||
20 | * along with this program. If not, see http://www.gnu.org/licenses/ |
||
21 | ******************************************************************************/ |
||
22 | |||
23 | /**************************************************************************//** |
||
24 | * \headerfile bits.h |
||
25 | ******************************************************************************/ |
||
26 | |||
27 | #ifndef H__IDREAMMICRO__USEFUL__BITS__H |
||
28 | #define H__IDREAMMICRO__USEFUL__BITS__H |
||
29 | |||
30 | #ifdef _cplusplus |
||
31 | extern "C"{ |
||
32 | #endif |
||
33 | |||
34 | /****************************************************************************** |
||
35 | * Public macro definitions. |
||
36 | ******************************************************************************/ |
||
37 | |||
38 | /**************************************************************************//** |
||
39 | * \def BIT__SET |
||
40 | * \brief Set a bit in a byte. |
||
41 | ******************************************************************************/ |
||
42 | #define BIT__SET(variable, bit) (variable |= (1 << bit)) |
||
43 | |||
44 | /**************************************************************************//** |
||
45 | * \def BIT__RST |
||
46 | * \brief Reset a bit in a byte. |
||
47 | ******************************************************************************/ |
||
48 | #define BIT__RST(variable, bit) (variable &= ~(1 << bit)) |
||
49 | |||
50 | /**************************************************************************//** |
||
51 | * \def BIT__TGL |
||
52 | * \brief Toggle a bit in a byte. |
||
53 | ******************************************************************************/ |
||
54 | #define BIT__TGL(variable, bit) (variable ^= (1 << bit)) |
||
55 | |||
56 | /**************************************************************************//** |
||
57 | * \def BIT__TST |
||
58 | * \brief Test a bit in a byte. |
||
59 | ******************************************************************************/ |
||
60 | #define BIT__TST(variable, bit) (variable & (1 << bit)) |
||
61 | |||
62 | #ifdef _cplusplus |
||
63 | } |
||
64 | #endif |
||
65 | |||
66 | #endif /* H__IDREAMMICRO__USEFUL__BITS__H */ |
||
67 |