rfLPC
A low level library for using NXP's LPC17xx SoC. Config is given for MBED prototyping board
tools.h
Go to the documentation of this file.
1 /* This file is part of rflpc. Copyright 2010-2011 Michael Hauspie
2  *
3  * rflpc is free software: you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation, either version 3 of the License, or
6  * (at your option) any later version.
7  *
8  * rflpc is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with rflpc. If not, see <http://www.gnu.org/licenses/>.
15  */
16 /*
17  Author: Michael Hauspie <michael.hauspie@univ-lille1.fr>
18  Created:
19  Time-stamp: <2014-05-28 23:10:09 (mickey)>
20 
21  This file contains some macro tools used in rflpc
22 
23 */
27 #ifndef __RFLPC_TOOLS_H__
28 #define __RFLPC_TOOLS_H__
29 
31 #define TOKEN_PASTE2(x, y) x ## y
32 
34 #define TOKEN_PASTE(x, y) TOKEN_PASTE2(x, y)
35 
36 
38 #define RFLPC_SET_BIT(val, bit) (val) |= (1UL << (bit))
39 
40 #define RFLPC_CLR_BIT(val, bit) (val) &= ~(1UL << (bit))
41 
45 #define RFLPC_SET_BITS_VAL(val, bit_pos, bit_val, bit_count) do { \
46  uint32_t mask = ((1 << (bit_count)) - 1) << (bit_pos); \
47  /* Clear bits */ \
48  (val) &= ~mask; \
49  (val) |= ((bit_val) << (bit_pos)) & mask; \
50 } while(0)
51 
55 #define rflpc_idle asm volatile ("wfi")
56 
57 #endif