The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

mbed 2

This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.

Committer:
AnnaBridge
Date:
Wed Feb 20 20:53:29 2019 +0000
Revision:
172:65be27845400
Parent:
171:3a7713b1edbc
mbed library release version 165

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AnnaBridge 146:22da6e220af6 1 /*
AnnaBridge 146:22da6e220af6 2 * Copyright (c) 2013 Nordic Semiconductor ASA
AnnaBridge 146:22da6e220af6 3 * All rights reserved.
AnnaBridge 146:22da6e220af6 4 *
AnnaBridge 146:22da6e220af6 5 * Redistribution and use in source and binary forms, with or without modification,
AnnaBridge 146:22da6e220af6 6 * are permitted provided that the following conditions are met:
AnnaBridge 146:22da6e220af6 7 *
AnnaBridge 146:22da6e220af6 8 * 1. Redistributions of source code must retain the above copyright notice, this list
AnnaBridge 146:22da6e220af6 9 * of conditions and the following disclaimer.
AnnaBridge 146:22da6e220af6 10 *
AnnaBridge 146:22da6e220af6 11 * 2. Redistributions in binary form, except as embedded into a Nordic Semiconductor ASA
AnnaBridge 146:22da6e220af6 12 * integrated circuit in a product or a software update for such product, must reproduce
AnnaBridge 146:22da6e220af6 13 * the above copyright notice, this list of conditions and the following disclaimer in
AnnaBridge 146:22da6e220af6 14 * the documentation and/or other materials provided with the distribution.
AnnaBridge 146:22da6e220af6 15 *
AnnaBridge 146:22da6e220af6 16 * 3. Neither the name of Nordic Semiconductor ASA nor the names of its contributors may be
AnnaBridge 146:22da6e220af6 17 * used to endorse or promote products derived from this software without specific prior
AnnaBridge 146:22da6e220af6 18 * written permission.
AnnaBridge 146:22da6e220af6 19 *
AnnaBridge 146:22da6e220af6 20 * 4. This software, with or without modification, must only be used with a
AnnaBridge 146:22da6e220af6 21 * Nordic Semiconductor ASA integrated circuit.
AnnaBridge 146:22da6e220af6 22 *
AnnaBridge 146:22da6e220af6 23 * 5. Any software provided in binary or object form under this license must not be reverse
AnnaBridge 146:22da6e220af6 24 * engineered, decompiled, modified and/or disassembled.
AnnaBridge 146:22da6e220af6 25 *
AnnaBridge 146:22da6e220af6 26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
AnnaBridge 146:22da6e220af6 27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
AnnaBridge 146:22da6e220af6 28 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
AnnaBridge 146:22da6e220af6 29 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
AnnaBridge 146:22da6e220af6 30 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
AnnaBridge 146:22da6e220af6 31 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
AnnaBridge 146:22da6e220af6 32 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
AnnaBridge 146:22da6e220af6 33 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
AnnaBridge 146:22da6e220af6 34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
AnnaBridge 146:22da6e220af6 35 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
AnnaBridge 146:22da6e220af6 36 *
AnnaBridge 146:22da6e220af6 37 */
AnnaBridge 146:22da6e220af6 38
AnnaBridge 146:22da6e220af6 39
AnnaBridge 146:22da6e220af6 40 /** @cond */
AnnaBridge 146:22da6e220af6 41 /**@file
AnnaBridge 146:22da6e220af6 42 *
AnnaBridge 146:22da6e220af6 43 * @ingroup experimental_api
AnnaBridge 146:22da6e220af6 44 * @defgroup sdk_common SDK Common Header
AnnaBridge 146:22da6e220af6 45 * @breif All common headers needed for SDK examples will be included here so that application
AnnaBridge 146:22da6e220af6 46 * developer does not have to include headers on him/herself.
AnnaBridge 146:22da6e220af6 47 * @{
AnnaBridge 146:22da6e220af6 48 */
AnnaBridge 146:22da6e220af6 49
AnnaBridge 146:22da6e220af6 50 #ifndef SDK_COMMON_H__
AnnaBridge 146:22da6e220af6 51 #define SDK_COMMON_H__
AnnaBridge 146:22da6e220af6 52
AnnaBridge 146:22da6e220af6 53 #include <stdint.h>
AnnaBridge 146:22da6e220af6 54 #include <stdbool.h>
AnnaBridge 146:22da6e220af6 55 #include <string.h>
AnnaBridge 146:22da6e220af6 56 #include "nordic_common.h"
AnnaBridge 146:22da6e220af6 57 #include "compiler_abstraction.h"
AnnaBridge 146:22da6e220af6 58 #include "sdk_os.h"
AnnaBridge 146:22da6e220af6 59 #include "sdk_errors.h"
AnnaBridge 146:22da6e220af6 60 #include "app_util.h"
AnnaBridge 146:22da6e220af6 61
AnnaBridge 146:22da6e220af6 62 /**@brief Macro for verifying that the module is initialized. It will cause the function to return
AnnaBridge 146:22da6e220af6 63 * if not.
AnnaBridge 146:22da6e220af6 64 *
AnnaBridge 146:22da6e220af6 65 * @param[in] param The variable to check if is NULL.
AnnaBridge 146:22da6e220af6 66 */
AnnaBridge 146:22da6e220af6 67 #ifndef DISABLE_PARAM_CHECK
AnnaBridge 146:22da6e220af6 68 #define VERIFY_PARAM_NOT_NULL(param) \
AnnaBridge 146:22da6e220af6 69 do \
AnnaBridge 146:22da6e220af6 70 { \
AnnaBridge 146:22da6e220af6 71 if (param == NULL) \
AnnaBridge 146:22da6e220af6 72 { \
AnnaBridge 146:22da6e220af6 73 return NRF_ERROR_NULL; \
AnnaBridge 146:22da6e220af6 74 } \
AnnaBridge 146:22da6e220af6 75 } while(0)
AnnaBridge 146:22da6e220af6 76 #else
AnnaBridge 146:22da6e220af6 77 #define VERIFY_PARAM_NOT_NULL()
AnnaBridge 146:22da6e220af6 78 #endif /* DISABLE_PARAM_CHECK */
AnnaBridge 146:22da6e220af6 79
AnnaBridge 146:22da6e220af6 80
AnnaBridge 146:22da6e220af6 81 /**@brief Macro for verifying that the module is initialized. It will cause the function to return
AnnaBridge 146:22da6e220af6 82 * if not.
AnnaBridge 146:22da6e220af6 83 *
AnnaBridge 146:22da6e220af6 84 * @param[in] param The variable to check if is NULL.
AnnaBridge 146:22da6e220af6 85 */
AnnaBridge 146:22da6e220af6 86 #ifndef DISABLE_PARAM_CHECK
AnnaBridge 146:22da6e220af6 87 #define VERIFY_PARAM_NOT_NULL_VOID(param) \
AnnaBridge 146:22da6e220af6 88 do \
AnnaBridge 146:22da6e220af6 89 { \
AnnaBridge 146:22da6e220af6 90 if (param == NULL) \
AnnaBridge 146:22da6e220af6 91 { \
AnnaBridge 146:22da6e220af6 92 return; \
AnnaBridge 146:22da6e220af6 93 } \
AnnaBridge 146:22da6e220af6 94 } while(0)
AnnaBridge 146:22da6e220af6 95 #else
AnnaBridge 146:22da6e220af6 96 #define VERIFY_PARAM_NOT_NULL_VOID()
AnnaBridge 146:22da6e220af6 97 #endif /* DISABLE_PARAM_CHECK */
AnnaBridge 146:22da6e220af6 98
AnnaBridge 146:22da6e220af6 99
AnnaBridge 146:22da6e220af6 100 /**@brief Macro for verifying that a function returned NRF_SUCCESS. Will return the err code
AnnaBridge 146:22da6e220af6 101 * if not.
AnnaBridge 146:22da6e220af6 102 *
AnnaBridge 146:22da6e220af6 103 * @param[in] err_code The error code to check.
AnnaBridge 146:22da6e220af6 104 */
AnnaBridge 146:22da6e220af6 105 #ifndef DISABLE_PARAM_CHECK
AnnaBridge 146:22da6e220af6 106 #define VERIFY_SUCCESS(err_code) \
AnnaBridge 146:22da6e220af6 107 do \
AnnaBridge 146:22da6e220af6 108 { \
AnnaBridge 146:22da6e220af6 109 if (err_code != NRF_SUCCESS) \
AnnaBridge 146:22da6e220af6 110 { \
AnnaBridge 146:22da6e220af6 111 return err_code; \
AnnaBridge 146:22da6e220af6 112 } \
AnnaBridge 146:22da6e220af6 113 } while(0)
AnnaBridge 146:22da6e220af6 114 #else
AnnaBridge 146:22da6e220af6 115 #define VERIFY_SUCCESS()
AnnaBridge 146:22da6e220af6 116 #endif /* DISABLE_PARAM_CHECK */
AnnaBridge 146:22da6e220af6 117
AnnaBridge 146:22da6e220af6 118
AnnaBridge 146:22da6e220af6 119 /**@brief Macro for verifying that a function returned NRF_SUCCESS. Will return if not.
AnnaBridge 146:22da6e220af6 120 *
AnnaBridge 146:22da6e220af6 121 * @param[in] err_code The error code to check.
AnnaBridge 146:22da6e220af6 122 */
AnnaBridge 146:22da6e220af6 123 #ifndef DISABLE_PARAM_CHECK
AnnaBridge 146:22da6e220af6 124 #define VERIFY_SUCCESS_VOID(err_code) \
AnnaBridge 146:22da6e220af6 125 do \
AnnaBridge 146:22da6e220af6 126 { \
AnnaBridge 146:22da6e220af6 127 if (err_code != NRF_SUCCESS) \
AnnaBridge 146:22da6e220af6 128 { \
AnnaBridge 146:22da6e220af6 129 return; \
AnnaBridge 146:22da6e220af6 130 } \
AnnaBridge 146:22da6e220af6 131 } while(0)
AnnaBridge 146:22da6e220af6 132 #else
AnnaBridge 146:22da6e220af6 133 #define VERIFY_SUCCESS_VOID()
AnnaBridge 146:22da6e220af6 134 #endif /* DISABLE_PARAM_CHECK */
AnnaBridge 146:22da6e220af6 135
AnnaBridge 146:22da6e220af6 136
AnnaBridge 146:22da6e220af6 137 /**@brief Macro for verifying statement to be true. Will return err_code if not.
AnnaBridge 146:22da6e220af6 138 *
AnnaBridge 146:22da6e220af6 139 * @param[in] statement Statement to test.
AnnaBridge 146:22da6e220af6 140 * @param[in] err_code Error value to return if test was invalid.
AnnaBridge 146:22da6e220af6 141 *
AnnaBridge 146:22da6e220af6 142 * @retval err_code if test fails.
AnnaBridge 146:22da6e220af6 143 */
AnnaBridge 146:22da6e220af6 144 #define VERIFY_TRUE(statement, err_code) \
AnnaBridge 146:22da6e220af6 145 do \
AnnaBridge 146:22da6e220af6 146 { \
AnnaBridge 146:22da6e220af6 147 if (!(statement)) \
AnnaBridge 146:22da6e220af6 148 { \
AnnaBridge 146:22da6e220af6 149 return err_code; \
AnnaBridge 146:22da6e220af6 150 } \
AnnaBridge 146:22da6e220af6 151 } while(0)
AnnaBridge 146:22da6e220af6 152
AnnaBridge 146:22da6e220af6 153
AnnaBridge 146:22da6e220af6 154 /**@brief Macro for verifying statement to be true. Will return if not.
AnnaBridge 146:22da6e220af6 155 *
AnnaBridge 146:22da6e220af6 156 * @param[in] statement Statement to test.
AnnaBridge 146:22da6e220af6 157 */
AnnaBridge 146:22da6e220af6 158 #define VERIFY_TRUE_VOID(statement) \
AnnaBridge 146:22da6e220af6 159 do \
AnnaBridge 146:22da6e220af6 160 { \
AnnaBridge 146:22da6e220af6 161 if (!(statement)) \
AnnaBridge 146:22da6e220af6 162 { \
AnnaBridge 146:22da6e220af6 163 return; \
AnnaBridge 146:22da6e220af6 164 } \
AnnaBridge 146:22da6e220af6 165 } while(0)
AnnaBridge 146:22da6e220af6 166
AnnaBridge 146:22da6e220af6 167
AnnaBridge 146:22da6e220af6 168 /**@brief Macro for verifying statement to be false. Will return err_code if not.
AnnaBridge 146:22da6e220af6 169 *
AnnaBridge 146:22da6e220af6 170 * @param[in] statement Statement to test.
AnnaBridge 146:22da6e220af6 171 * @param[in] err_code Error value to return if test was invalid.
AnnaBridge 146:22da6e220af6 172 *
AnnaBridge 146:22da6e220af6 173 * @retval err_code if test fails.
AnnaBridge 146:22da6e220af6 174 */
AnnaBridge 146:22da6e220af6 175 #define VERIFY_FALSE(statement, err_code) \
AnnaBridge 146:22da6e220af6 176 do \
AnnaBridge 146:22da6e220af6 177 { \
AnnaBridge 146:22da6e220af6 178 if ((statement)) \
AnnaBridge 146:22da6e220af6 179 { \
AnnaBridge 146:22da6e220af6 180 return err_code; \
AnnaBridge 146:22da6e220af6 181 } \
AnnaBridge 146:22da6e220af6 182 } while(0)
AnnaBridge 146:22da6e220af6 183
AnnaBridge 146:22da6e220af6 184
AnnaBridge 146:22da6e220af6 185 /**@brief Macro for verifying statement to be false. Will return if not.
AnnaBridge 146:22da6e220af6 186 *
AnnaBridge 146:22da6e220af6 187 * @param[in] statement Statement to test.
AnnaBridge 146:22da6e220af6 188 */
AnnaBridge 146:22da6e220af6 189 #define VERIFY_FALSE_VOID(statement) \
AnnaBridge 146:22da6e220af6 190 do \
AnnaBridge 146:22da6e220af6 191 { \
AnnaBridge 146:22da6e220af6 192 if ((statement)) \
AnnaBridge 146:22da6e220af6 193 { \
AnnaBridge 146:22da6e220af6 194 return; \
AnnaBridge 146:22da6e220af6 195 } \
AnnaBridge 146:22da6e220af6 196 } while(0)
AnnaBridge 146:22da6e220af6 197
AnnaBridge 146:22da6e220af6 198 /** @} */
AnnaBridge 146:22da6e220af6 199 /** @endcond */
AnnaBridge 146:22da6e220af6 200 #endif // SDK_COMMON_H__
AnnaBridge 146:22da6e220af6 201