mbed library sources. Supersedes mbed-src.

Dependents:   Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more

Committer:
AnnaBridge
Date:
Mon Oct 02 15:33:19 2017 +0100
Revision:
174:b96e65c34a4d
Parent:
165:e614a9f1c9e2
This updates the lib to the mbed lib v 152

Who changed what in which revision?

UserRevisionLine numberNew contents of line
<> 162:e13f6fdb2ac4 1 /*
<> 162:e13f6fdb2ac4 2 * Copyright (c) 2016 Nordic Semiconductor ASA
<> 162:e13f6fdb2ac4 3 * All rights reserved.
<> 162:e13f6fdb2ac4 4 *
<> 162:e13f6fdb2ac4 5 * Redistribution and use in source and binary forms, with or without modification,
<> 162:e13f6fdb2ac4 6 * are permitted provided that the following conditions are met:
<> 162:e13f6fdb2ac4 7 *
<> 162:e13f6fdb2ac4 8 * 1. Redistributions of source code must retain the above copyright notice, this list
<> 162:e13f6fdb2ac4 9 * of conditions and the following disclaimer.
<> 162:e13f6fdb2ac4 10 *
<> 162:e13f6fdb2ac4 11 * 2. Redistributions in binary form, except as embedded into a Nordic Semiconductor ASA
<> 162:e13f6fdb2ac4 12 * integrated circuit in a product or a software update for such product, must reproduce
<> 162:e13f6fdb2ac4 13 * the above copyright notice, this list of conditions and the following disclaimer in
<> 162:e13f6fdb2ac4 14 * the documentation and/or other materials provided with the distribution.
<> 162:e13f6fdb2ac4 15 *
<> 162:e13f6fdb2ac4 16 * 3. Neither the name of Nordic Semiconductor ASA nor the names of its contributors may be
<> 162:e13f6fdb2ac4 17 * used to endorse or promote products derived from this software without specific prior
<> 162:e13f6fdb2ac4 18 * written permission.
<> 162:e13f6fdb2ac4 19 *
<> 162:e13f6fdb2ac4 20 * 4. This software, with or without modification, must only be used with a
<> 162:e13f6fdb2ac4 21 * Nordic Semiconductor ASA integrated circuit.
<> 162:e13f6fdb2ac4 22 *
<> 162:e13f6fdb2ac4 23 * 5. Any software provided in binary or object form under this license must not be reverse
<> 162:e13f6fdb2ac4 24 * engineered, decompiled, modified and/or disassembled.
<> 162:e13f6fdb2ac4 25 *
<> 162:e13f6fdb2ac4 26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
<> 162:e13f6fdb2ac4 27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
<> 162:e13f6fdb2ac4 28 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
<> 162:e13f6fdb2ac4 29 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
<> 162:e13f6fdb2ac4 30 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
<> 162:e13f6fdb2ac4 31 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
<> 162:e13f6fdb2ac4 32 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
<> 162:e13f6fdb2ac4 33 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
<> 162:e13f6fdb2ac4 34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
<> 162:e13f6fdb2ac4 35 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<> 162:e13f6fdb2ac4 36 *
<> 162:e13f6fdb2ac4 37 */
<> 162:e13f6fdb2ac4 38
<> 162:e13f6fdb2ac4 39 #ifndef SECTION_VARS_H__
<> 162:e13f6fdb2ac4 40 #define SECTION_VARS_H__
<> 162:e13f6fdb2ac4 41
<> 162:e13f6fdb2ac4 42 #ifdef __cplusplus
<> 162:e13f6fdb2ac4 43 extern "C" {
<> 162:e13f6fdb2ac4 44 #endif
<> 162:e13f6fdb2ac4 45
<> 162:e13f6fdb2ac4 46
<> 162:e13f6fdb2ac4 47 /**
<> 162:e13f6fdb2ac4 48 * @defgroup section_vars Section variables
<> 162:e13f6fdb2ac4 49 * @ingroup app_common
<> 162:e13f6fdb2ac4 50 * @{
<> 162:e13f6fdb2ac4 51 *
<> 162:e13f6fdb2ac4 52 * @brief Section variables.
<> 162:e13f6fdb2ac4 53 */
<> 162:e13f6fdb2ac4 54
<> 162:e13f6fdb2ac4 55
<> 162:e13f6fdb2ac4 56 #if defined(__ICCARM__)
<> 162:e13f6fdb2ac4 57 // Enable IAR language extensions
<> 162:e13f6fdb2ac4 58 #pragma language=extended
<> 162:e13f6fdb2ac4 59 #endif
<> 162:e13f6fdb2ac4 60
<> 162:e13f6fdb2ac4 61
<> 162:e13f6fdb2ac4 62 // Macro to delay macro expansion.
<> 162:e13f6fdb2ac4 63 #define NRF_PRAGMA(x) _Pragma(#x)
<> 162:e13f6fdb2ac4 64
<> 162:e13f6fdb2ac4 65
<> 162:e13f6fdb2ac4 66 //lint -save -e27 Illegal character (0x24)
<> 162:e13f6fdb2ac4 67
<> 162:e13f6fdb2ac4 68
<> 162:e13f6fdb2ac4 69 /**@brief Macro to obtain the symbol marking the beginning of a given section.
<> 162:e13f6fdb2ac4 70 *
<> 162:e13f6fdb2ac4 71 * @details The symbol that this macro resolves to is used to obtain a section start address.
<> 162:e13f6fdb2ac4 72 *
<> 162:e13f6fdb2ac4 73 * @param[in] section_name Name of the section.
<> 162:e13f6fdb2ac4 74 */
AnnaBridge 174:b96e65c34a4d 75 #if defined(__CC_ARM) || (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050))
<> 162:e13f6fdb2ac4 76
<> 162:e13f6fdb2ac4 77 #define NRF_SECTION_VARS_START_SYMBOL(section_name) section_name ## $$Base
<> 162:e13f6fdb2ac4 78
<> 162:e13f6fdb2ac4 79 #elif defined(__GNUC__)
<> 162:e13f6fdb2ac4 80
<> 162:e13f6fdb2ac4 81 #define NRF_SECTION_VARS_START_SYMBOL(section_name) __start_ ## section_name
<> 162:e13f6fdb2ac4 82
<> 162:e13f6fdb2ac4 83 #elif defined(__ICCARM__)
<> 162:e13f6fdb2ac4 84
<> 162:e13f6fdb2ac4 85 #define NRF_SECTION_VARS_START_SYMBOL(section_name) __section_begin(#section_name)
<> 162:e13f6fdb2ac4 86
<> 162:e13f6fdb2ac4 87 #endif
<> 162:e13f6fdb2ac4 88
<> 162:e13f6fdb2ac4 89
<> 162:e13f6fdb2ac4 90 /**@brief Macro to obtain the symbol marking the end of a given section.
<> 162:e13f6fdb2ac4 91 *
<> 162:e13f6fdb2ac4 92 * @details The symbol that this macro resolves to is used to obtain a section stop address.
<> 162:e13f6fdb2ac4 93 *
<> 162:e13f6fdb2ac4 94 * @param[in] section_name Name of the section.
<> 162:e13f6fdb2ac4 95 */
AnnaBridge 174:b96e65c34a4d 96 #if defined(__CC_ARM) || (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050))
<> 162:e13f6fdb2ac4 97
<> 162:e13f6fdb2ac4 98 #define NRF_SECTION_VARS_END_SYMBOL(section_name) section_name ## $$Limit
<> 162:e13f6fdb2ac4 99
<> 162:e13f6fdb2ac4 100 #elif defined(__GNUC__)
<> 162:e13f6fdb2ac4 101
<> 162:e13f6fdb2ac4 102 #define NRF_SECTION_VARS_END_SYMBOL(section_name) __stop_ ## section_name
<> 162:e13f6fdb2ac4 103
<> 162:e13f6fdb2ac4 104 #elif defined(__ICCARM__)
<> 162:e13f6fdb2ac4 105
<> 162:e13f6fdb2ac4 106 #define NRF_SECTION_VARS_END_SYMBOL(section_name) __section_end(#section_name)
<> 162:e13f6fdb2ac4 107
<> 162:e13f6fdb2ac4 108 #endif
<> 162:e13f6fdb2ac4 109
<> 162:e13f6fdb2ac4 110
<> 162:e13f6fdb2ac4 111 //lint -restore
<> 162:e13f6fdb2ac4 112
<> 162:e13f6fdb2ac4 113
<> 162:e13f6fdb2ac4 114 /**@brief Macro for retrieving the length of a given section, in bytes.
<> 162:e13f6fdb2ac4 115 *
<> 162:e13f6fdb2ac4 116 * @param[in] section_name Name of the section.
<> 162:e13f6fdb2ac4 117 */
AnnaBridge 174:b96e65c34a4d 118 #if defined(__CC_ARM) || (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050))
<> 162:e13f6fdb2ac4 119
<> 162:e13f6fdb2ac4 120 #define NRF_SECTION_VARS_LENGTH(section_name) \
<> 162:e13f6fdb2ac4 121 ((uint32_t)&NRF_SECTION_VARS_END_SYMBOL(section_name) - (uint32_t)&NRF_SECTION_VARS_START_SYMBOL(section_name))
<> 162:e13f6fdb2ac4 122
<> 162:e13f6fdb2ac4 123 #elif defined(__GNUC__)
<> 162:e13f6fdb2ac4 124
<> 162:e13f6fdb2ac4 125 #define NRF_SECTION_VARS_LENGTH(section_name) \
<> 162:e13f6fdb2ac4 126 ((uint32_t)&NRF_SECTION_VARS_END_SYMBOL(section_name) - (uint32_t)&NRF_SECTION_VARS_START_SYMBOL(section_name))
<> 162:e13f6fdb2ac4 127
<> 162:e13f6fdb2ac4 128 #elif defined(__ICCARM__)
<> 162:e13f6fdb2ac4 129
<> 162:e13f6fdb2ac4 130 #define NRF_SECTION_VARS_LENGTH(section_name) \
<> 162:e13f6fdb2ac4 131 ((uint32_t)NRF_SECTION_VARS_END_SYMBOL(section_name) - (uint32_t)NRF_SECTION_VARS_START_SYMBOL(section_name))
<> 162:e13f6fdb2ac4 132
<> 162:e13f6fdb2ac4 133 #endif
<> 162:e13f6fdb2ac4 134
<> 162:e13f6fdb2ac4 135
<> 162:e13f6fdb2ac4 136 /**@brief Macro to obtain the address of the beginning of a section.
<> 162:e13f6fdb2ac4 137 *
<> 162:e13f6fdb2ac4 138 * param[in] section_name Name of the section.
<> 162:e13f6fdb2ac4 139 */
AnnaBridge 174:b96e65c34a4d 140 #if defined(__CC_ARM) || (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050))
<> 162:e13f6fdb2ac4 141
<> 162:e13f6fdb2ac4 142 #define NRF_SECTION_VARS_START_ADDR(section_name) (uint32_t)&NRF_SECTION_VARS_START_SYMBOL(section_name)
<> 162:e13f6fdb2ac4 143
<> 162:e13f6fdb2ac4 144 #elif defined(__GNUC__)
<> 162:e13f6fdb2ac4 145
<> 162:e13f6fdb2ac4 146 #define NRF_SECTION_VARS_START_ADDR(section_name) (uint32_t)&NRF_SECTION_VARS_START_SYMBOL(section_name)
<> 162:e13f6fdb2ac4 147
<> 162:e13f6fdb2ac4 148 #elif defined(__ICCARM__)
<> 162:e13f6fdb2ac4 149
<> 162:e13f6fdb2ac4 150 #define NRF_SECTION_VARS_START_ADDR(section_name) (uint32_t)iar_ ## section_name ## _start
<> 162:e13f6fdb2ac4 151
<> 162:e13f6fdb2ac4 152 #endif
<> 162:e13f6fdb2ac4 153
<> 162:e13f6fdb2ac4 154
<> 162:e13f6fdb2ac4 155 /**@brief Macro to obtain the address of end of a section.
<> 162:e13f6fdb2ac4 156 *
<> 162:e13f6fdb2ac4 157 * @param[in] section_name Name of the section.
<> 162:e13f6fdb2ac4 158 */
AnnaBridge 174:b96e65c34a4d 159 #if defined(__CC_ARM) || (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050))
<> 162:e13f6fdb2ac4 160
<> 162:e13f6fdb2ac4 161 #define NRF_SECTION_VARS_END_ADDR(section_name) (uint32_t)&NRF_SECTION_VARS_END_SYMBOL(section_name)
<> 162:e13f6fdb2ac4 162
<> 162:e13f6fdb2ac4 163 #elif defined(__GNUC__)
<> 162:e13f6fdb2ac4 164
<> 162:e13f6fdb2ac4 165 #define NRF_SECTION_VARS_END_ADDR(section_name) (uint32_t)&NRF_SECTION_VARS_END_SYMBOL(section_name)
<> 162:e13f6fdb2ac4 166
<> 162:e13f6fdb2ac4 167 #elif defined(__ICCARM__)
<> 162:e13f6fdb2ac4 168
<> 162:e13f6fdb2ac4 169 #define NRF_SECTION_VARS_END_ADDR(section_name) (uint32_t)iar_ ## section_name ## _end
<> 162:e13f6fdb2ac4 170
<> 162:e13f6fdb2ac4 171 #endif
<> 162:e13f6fdb2ac4 172
<> 162:e13f6fdb2ac4 173
<> 162:e13f6fdb2ac4 174 //lint -save -e19 -esym(526, fs_dataBase) -esym(526, fs_dataLimit) -esym(526, dfu_transBase) -esym(526, dfu_transLimit)
<> 162:e13f6fdb2ac4 175
<> 162:e13f6fdb2ac4 176 /**@brief Macro to create a section to register variables in.
<> 162:e13f6fdb2ac4 177 *
<> 162:e13f6fdb2ac4 178 * @param[in] data_type The data type of the variables to be registered in the section.
<> 162:e13f6fdb2ac4 179 * @param[in] section_name Name of the section.
<> 162:e13f6fdb2ac4 180 *
<> 162:e13f6fdb2ac4 181 * @warning The data type must be word aligned to prevent padding.
<> 162:e13f6fdb2ac4 182 */
AnnaBridge 174:b96e65c34a4d 183 #if defined(__CC_ARM) || (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050))
<> 162:e13f6fdb2ac4 184
<> 162:e13f6fdb2ac4 185 #define NRF_SECTION_VARS_CREATE_SECTION(section_name, data_type) \
<> 162:e13f6fdb2ac4 186 extern data_type * NRF_SECTION_VARS_START_SYMBOL(section_name); \
<> 162:e13f6fdb2ac4 187 extern void * NRF_SECTION_VARS_END_SYMBOL(section_name)
<> 162:e13f6fdb2ac4 188
<> 162:e13f6fdb2ac4 189 #elif defined(__GNUC__)
<> 162:e13f6fdb2ac4 190
<> 162:e13f6fdb2ac4 191 #define NRF_SECTION_VARS_CREATE_SECTION(section_name, data_type) \
<> 162:e13f6fdb2ac4 192 extern data_type * NRF_SECTION_VARS_START_SYMBOL(section_name); \
<> 162:e13f6fdb2ac4 193 extern void * NRF_SECTION_VARS_END_SYMBOL(section_name)
<> 162:e13f6fdb2ac4 194
<> 162:e13f6fdb2ac4 195 #elif defined(__ICCARM__)
<> 162:e13f6fdb2ac4 196
<> 162:e13f6fdb2ac4 197 // No symbol registration required for IAR.
<> 162:e13f6fdb2ac4 198 #define NRF_SECTION_VARS_CREATE_SECTION(section_name, data_type) \
<> 162:e13f6fdb2ac4 199 NRF_PRAGMA(section = #section_name); \
<> 162:e13f6fdb2ac4 200 extern void * iar_ ## section_name ## _start = __section_begin(#section_name); \
<> 162:e13f6fdb2ac4 201 extern void * iar_ ## section_name ## _end = __section_end(#section_name)
<> 162:e13f6fdb2ac4 202
<> 162:e13f6fdb2ac4 203 #endif
<> 162:e13f6fdb2ac4 204
<> 162:e13f6fdb2ac4 205 //lint -restore
<> 162:e13f6fdb2ac4 206
<> 162:e13f6fdb2ac4 207
<> 162:e13f6fdb2ac4 208 /**@brief Macro to declare a variable and register it in a section.
<> 162:e13f6fdb2ac4 209 *
<> 162:e13f6fdb2ac4 210 * @details Declares a variable and registers it in a named section. This macro ensures that the
<> 162:e13f6fdb2ac4 211 * variable is not stripped away when using optimizations.
<> 162:e13f6fdb2ac4 212 *
<> 162:e13f6fdb2ac4 213 * @note The order with which variables are placed in a section is dependant on the order with
<> 162:e13f6fdb2ac4 214 * which the linker encouters the variables during linking.
<> 162:e13f6fdb2ac4 215 *
<> 162:e13f6fdb2ac4 216 * @param[in] section_name Name of the section.
<> 162:e13f6fdb2ac4 217 * @param[in] section_var The variable to register in the given section.
<> 162:e13f6fdb2ac4 218 */
AnnaBridge 174:b96e65c34a4d 219 #if defined(__CC_ARM) || (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050))
<> 162:e13f6fdb2ac4 220
<> 162:e13f6fdb2ac4 221 #define NRF_SECTION_VARS_REGISTER_VAR(section_name, section_var) \
<> 162:e13f6fdb2ac4 222 static section_var __attribute__ ((section(#section_name))) __attribute__((used))
<> 162:e13f6fdb2ac4 223
<> 162:e13f6fdb2ac4 224 #elif defined(__GNUC__)
<> 162:e13f6fdb2ac4 225
<> 162:e13f6fdb2ac4 226 #define NRF_SECTION_VARS_REGISTER_VAR(section_name, section_var) \
<> 162:e13f6fdb2ac4 227 static section_var __attribute__ ((section("."#section_name))) __attribute__((used))
<> 162:e13f6fdb2ac4 228
<> 162:e13f6fdb2ac4 229 #elif defined(__ICCARM__)
<> 162:e13f6fdb2ac4 230
<> 162:e13f6fdb2ac4 231 #define NRF_SECTION_VARS_REGISTER_VAR(section_name, section_var) \
<> 162:e13f6fdb2ac4 232 __root section_var @ #section_name
<> 162:e13f6fdb2ac4 233
<> 162:e13f6fdb2ac4 234 #endif
<> 162:e13f6fdb2ac4 235
<> 162:e13f6fdb2ac4 236
<> 162:e13f6fdb2ac4 237 /**@brief Macro to retrieve a variable from a section.
<> 162:e13f6fdb2ac4 238 *
<> 162:e13f6fdb2ac4 239 * @warning The stored symbol can only be resolved using this macro if the
<> 162:e13f6fdb2ac4 240 * type of the data is word aligned. The operation of acquiring
<> 162:e13f6fdb2ac4 241 * the stored symbol relies on sizeof of the stored type, no
<> 162:e13f6fdb2ac4 242 * padding can exist in the named section in between individual
<> 162:e13f6fdb2ac4 243 * stored items or this macro will fail.
<> 162:e13f6fdb2ac4 244 *
<> 162:e13f6fdb2ac4 245 * @param[in] i Index of the variable in section.
<> 162:e13f6fdb2ac4 246 * @param[in] data_type Data type of the variable.
<> 162:e13f6fdb2ac4 247 * @param[in] section_name Name of the section.
<> 162:e13f6fdb2ac4 248 */
AnnaBridge 174:b96e65c34a4d 249 #if defined(__CC_ARM) || (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050))
<> 162:e13f6fdb2ac4 250
<> 162:e13f6fdb2ac4 251 #define NRF_SECTION_VARS_GET(i, data_type, section_name) \
<> 162:e13f6fdb2ac4 252 (data_type*)(NRF_SECTION_VARS_START_ADDR(section_name) + i * sizeof(data_type))
<> 162:e13f6fdb2ac4 253
<> 162:e13f6fdb2ac4 254 #elif defined(__GNUC__)
<> 162:e13f6fdb2ac4 255
<> 162:e13f6fdb2ac4 256 #define NRF_SECTION_VARS_GET(i, data_type, section_name) \
<> 162:e13f6fdb2ac4 257 (data_type*)(NRF_SECTION_VARS_START_ADDR(section_name) + i * sizeof(data_type))
<> 162:e13f6fdb2ac4 258
<> 162:e13f6fdb2ac4 259 #elif defined(__ICCARM__)
<> 162:e13f6fdb2ac4 260
<> 162:e13f6fdb2ac4 261 #define NRF_SECTION_VARS_GET(i, data_type, section_name) \
<> 162:e13f6fdb2ac4 262 (data_type*)(NRF_SECTION_VARS_START_ADDR(section_name) + i * sizeof(data_type))
<> 162:e13f6fdb2ac4 263
<> 162:e13f6fdb2ac4 264 #endif
<> 162:e13f6fdb2ac4 265
<> 162:e13f6fdb2ac4 266
<> 162:e13f6fdb2ac4 267 /**@brief Macro to get number of variables registered in a section.
<> 162:e13f6fdb2ac4 268 *
<> 162:e13f6fdb2ac4 269 * @param[in] data_type Data type of the variables in the section.
<> 162:e13f6fdb2ac4 270 * @param[in] section_name Name of the section.
<> 162:e13f6fdb2ac4 271 */
<> 162:e13f6fdb2ac4 272 #define NRF_SECTION_VARS_COUNT(data_type, section_name) \
<> 162:e13f6fdb2ac4 273 NRF_SECTION_VARS_LENGTH(section_name) / sizeof(data_type)
<> 162:e13f6fdb2ac4 274
<> 162:e13f6fdb2ac4 275 /** @} */
<> 162:e13f6fdb2ac4 276
<> 162:e13f6fdb2ac4 277
<> 162:e13f6fdb2ac4 278 #ifdef __cplusplus
<> 162:e13f6fdb2ac4 279 }
<> 162:e13f6fdb2ac4 280 #endif
<> 162:e13f6fdb2ac4 281
<> 162:e13f6fdb2ac4 282 #endif // SECTION_VARS_H__