test
Fork of nrf51-sdk by
Embed:
(wiki syntax)
Show/hide line numbers
nordic_common.h
Go to the documentation of this file.
00001 /* 00002 * Copyright (c) Nordic Semiconductor ASA 00003 * All rights reserved. 00004 * 00005 * Redistribution and use in source and binary forms, with or without modification, 00006 * are permitted provided that the following conditions are met: 00007 * 00008 * 1. Redistributions of source code must retain the above copyright notice, this 00009 * list of conditions and the following disclaimer. 00010 * 00011 * 2. Redistributions in binary form must reproduce the above copyright notice, this 00012 * list of conditions and the following disclaimer in the documentation and/or 00013 * other materials provided with the distribution. 00014 * 00015 * 3. Neither the name of Nordic Semiconductor ASA nor the names of other 00016 * contributors to this software may be used to endorse or promote products 00017 * derived from this software without specific prior written permission. 00018 * 00019 * 00020 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 00021 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 00022 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00023 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 00024 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00025 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00026 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 00027 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00028 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00029 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00030 * 00031 */ 00032 00033 /** @file 00034 * @brief Common defines and macros for firmware developed by Nordic Semiconductor. 00035 */ 00036 00037 #ifndef NORDIC_COMMON_H__ 00038 #define NORDIC_COMMON_H__ 00039 00040 /** The upper 8 bits of a 32 bit value */ 00041 //lint -emacro(572,MSB) // Suppress warning 572 "Excessive shift value" 00042 #define MSB(a) (((a) & 0xFF000000) >> 24) 00043 /** The lower 8 bits (of a 32 bit value) */ 00044 #define LSB(a) ((a) & 0x000000FF) 00045 00046 /** The upper 8 bits of a 16 bit value */ 00047 //lint -emacro(572,MSB_16) // Suppress warning 572 "Excessive shift value" 00048 #define MSB_16(a) (((a) & 0xFF00) >> 8) 00049 /** The lower 8 bits (of a 16 bit value) */ 00050 #define LSB_16(a) ((a) & 0x00FF) 00051 00052 /** Leaves the minimum of the two 32-bit arguments */ 00053 /*lint -emacro(506, MIN) */ /* Suppress "Constant value Boolean */ 00054 #define MIN(a, b) ((a) < (b) ? (a) : (b)) 00055 /** Leaves the maximum of the two 32-bit arguments */ 00056 /*lint -emacro(506, MAX) */ /* Suppress "Constant value Boolean */ 00057 #define MAX(a, b) ((a) < (b) ? (b) : (a)) 00058 00059 /** Concatenates two parameters. Useful as a second level of indirection, 00060 * when a parameter can be macro itself. */ 00061 #define CONCAT_2(p1, p2) p1##p2 00062 /** Concatenates three parameters. Useful as a second level of indirection, 00063 * when a parameter can be macro itself. */ 00064 #define CONCAT_3(p1, p2, p3) p1##p2##p3 00065 00066 /**@brief Set a bit in the uint32 word. 00067 * 00068 * @param[in] W Word whose bit is being set. 00069 * @param[in] B Bit number in the word to be set. 00070 */ 00071 #define SET_BIT(W,B) ((W) |= (uint32_t)(1U << (B))) 00072 00073 00074 /**@brief Clears a bit in the uint32 word. 00075 * 00076 * @param[in] W Word whose bit is to be cleared. 00077 * @param[in] B Bit number in the word to be cleared. 00078 */ 00079 #define CLR_BIT(W, B) ((W) &= (~((uint32_t)1 << (B)))) 00080 00081 00082 /**@brief Checks if a bit is set. 00083 * 00084 * @param[in] W Word whose bit is to be checked. 00085 * @param[in] B Bit number in the word to be checked. 00086 * 00087 * @retval 1 if bit is set. 00088 * @retval 0 if bit is not set. 00089 */ 00090 #define IS_SET(W,B) (((W) >> (B)) & 1) 00091 00092 #define BIT_0 0x01 /**< The value of bit 0 */ 00093 #define BIT_1 0x02 /**< The value of bit 1 */ 00094 #define BIT_2 0x04 /**< The value of bit 2 */ 00095 #define BIT_3 0x08 /**< The value of bit 3 */ 00096 #define BIT_4 0x10 /**< The value of bit 4 */ 00097 #define BIT_5 0x20 /**< The value of bit 5 */ 00098 #define BIT_6 0x40 /**< The value of bit 6 */ 00099 #define BIT_7 0x80 /**< The value of bit 7 */ 00100 #define BIT_8 0x0100 /**< The value of bit 8 */ 00101 #define BIT_9 0x0200 /**< The value of bit 9 */ 00102 #define BIT_10 0x0400 /**< The value of bit 10 */ 00103 #define BIT_11 0x0800 /**< The value of bit 11 */ 00104 #define BIT_12 0x1000 /**< The value of bit 12 */ 00105 #define BIT_13 0x2000 /**< The value of bit 13 */ 00106 #define BIT_14 0x4000 /**< The value of bit 14 */ 00107 #define BIT_15 0x8000 /**< The value of bit 15 */ 00108 #define BIT_16 0x00010000 /**< The value of bit 16 */ 00109 #define BIT_17 0x00020000 /**< The value of bit 17 */ 00110 #define BIT_18 0x00040000 /**< The value of bit 18 */ 00111 #define BIT_19 0x00080000 /**< The value of bit 19 */ 00112 #define BIT_20 0x00100000 /**< The value of bit 20 */ 00113 #define BIT_21 0x00200000 /**< The value of bit 21 */ 00114 #define BIT_22 0x00400000 /**< The value of bit 22 */ 00115 #define BIT_23 0x00800000 /**< The value of bit 23 */ 00116 #define BIT_24 0x01000000 /**< The value of bit 24 */ 00117 #define BIT_25 0x02000000 /**< The value of bit 25 */ 00118 #define BIT_26 0x04000000 /**< The value of bit 26 */ 00119 #define BIT_27 0x08000000 /**< The value of bit 27 */ 00120 #define BIT_28 0x10000000 /**< The value of bit 28 */ 00121 #define BIT_29 0x20000000 /**< The value of bit 29 */ 00122 #define BIT_30 0x40000000 /**< The value of bit 30 */ 00123 #define BIT_31 0x80000000 /**< The value of bit 31 */ 00124 00125 #define UNUSED_VARIABLE(X) ((void)(X)) 00126 #define UNUSED_PARAMETER(X) UNUSED_VARIABLE(X) 00127 00128 #endif // NORDIC_COMMON_H__
Generated on Tue Jul 12 2022 15:51:26 by 1.7.2