Nordic stack and drivers for the mbed BLE API
Dependents: Sensen-classic-v8-IAQ_copy_4
Fork of nRF51822 by
TARGET_MCU_NRF51822/sdk/source/libraries/experimental_section_vars/section_vars.h@639:7f459d371b75, 2017-11-10 (annotated)
- Committer:
- amithy
- Date:
- Fri Nov 10 20:27:44 2017 +0000
- Revision:
- 639:7f459d371b75
- Parent:
- 638:c90ae1400bf2
t
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Vincent Coubard |
638:c90ae1400bf2 | 1 | /* |
Vincent Coubard |
638:c90ae1400bf2 | 2 | * Copyright (c) Nordic Semiconductor ASA |
Vincent Coubard |
638:c90ae1400bf2 | 3 | * All rights reserved. |
Vincent Coubard |
638:c90ae1400bf2 | 4 | * |
Vincent Coubard |
638:c90ae1400bf2 | 5 | * Redistribution and use in source and binary forms, with or without modification, |
Vincent Coubard |
638:c90ae1400bf2 | 6 | * are permitted provided that the following conditions are met: |
Vincent Coubard |
638:c90ae1400bf2 | 7 | * |
Vincent Coubard |
638:c90ae1400bf2 | 8 | * 1. Redistributions of source code must retain the above copyright notice, this |
Vincent Coubard |
638:c90ae1400bf2 | 9 | * list of conditions and the following disclaimer. |
Vincent Coubard |
638:c90ae1400bf2 | 10 | * |
Vincent Coubard |
638:c90ae1400bf2 | 11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this |
Vincent Coubard |
638:c90ae1400bf2 | 12 | * list of conditions and the following disclaimer in the documentation and/or |
Vincent Coubard |
638:c90ae1400bf2 | 13 | * other materials provided with the distribution. |
Vincent Coubard |
638:c90ae1400bf2 | 14 | * |
Vincent Coubard |
638:c90ae1400bf2 | 15 | * 3. Neither the name of Nordic Semiconductor ASA nor the names of other |
Vincent Coubard |
638:c90ae1400bf2 | 16 | * contributors to this software may be used to endorse or promote products |
Vincent Coubard |
638:c90ae1400bf2 | 17 | * derived from this software without specific prior written permission. |
Vincent Coubard |
638:c90ae1400bf2 | 18 | * |
Vincent Coubard |
638:c90ae1400bf2 | 19 | * |
Vincent Coubard |
638:c90ae1400bf2 | 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
Vincent Coubard |
638:c90ae1400bf2 | 21 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
Vincent Coubard |
638:c90ae1400bf2 | 22 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
Vincent Coubard |
638:c90ae1400bf2 | 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR |
Vincent Coubard |
638:c90ae1400bf2 | 24 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
Vincent Coubard |
638:c90ae1400bf2 | 25 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
Vincent Coubard |
638:c90ae1400bf2 | 26 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON |
Vincent Coubard |
638:c90ae1400bf2 | 27 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
Vincent Coubard |
638:c90ae1400bf2 | 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
Vincent Coubard |
638:c90ae1400bf2 | 29 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Vincent Coubard |
638:c90ae1400bf2 | 30 | * |
Vincent Coubard |
638:c90ae1400bf2 | 31 | */ |
Vincent Coubard |
638:c90ae1400bf2 | 32 | |
Vincent Coubard |
638:c90ae1400bf2 | 33 | #ifndef SECTION_VARS_H__ |
Vincent Coubard |
638:c90ae1400bf2 | 34 | #define SECTION_VARS_H__ |
Vincent Coubard |
638:c90ae1400bf2 | 35 | |
Vincent Coubard |
638:c90ae1400bf2 | 36 | #include "app_util.h" |
Vincent Coubard |
638:c90ae1400bf2 | 37 | |
Vincent Coubard |
638:c90ae1400bf2 | 38 | #if defined __ICC_ARM__ |
Vincent Coubard |
638:c90ae1400bf2 | 39 | |
Vincent Coubard |
638:c90ae1400bf2 | 40 | // turn on language extensions for iar |
Vincent Coubard |
638:c90ae1400bf2 | 41 | #pragma language=extended |
Vincent Coubard |
638:c90ae1400bf2 | 42 | |
Vincent Coubard |
638:c90ae1400bf2 | 43 | #endif |
Vincent Coubard |
638:c90ae1400bf2 | 44 | |
Vincent Coubard |
638:c90ae1400bf2 | 45 | /** |
Vincent Coubard |
638:c90ae1400bf2 | 46 | * @defgroup section_vars Section variables |
Vincent Coubard |
638:c90ae1400bf2 | 47 | * @ingroup app_common |
Vincent Coubard |
638:c90ae1400bf2 | 48 | * @{ |
Vincent Coubard |
638:c90ae1400bf2 | 49 | * @brief Section variables. |
Vincent Coubard |
638:c90ae1400bf2 | 50 | */ |
Vincent Coubard |
638:c90ae1400bf2 | 51 | |
Vincent Coubard |
638:c90ae1400bf2 | 52 | /**@brief Macro to delay macro expression of pragma |
Vincent Coubard |
638:c90ae1400bf2 | 53 | * |
Vincent Coubard |
638:c90ae1400bf2 | 54 | */ |
Vincent Coubard |
638:c90ae1400bf2 | 55 | #define NRF_PRAGMA(x) _Pragma(#x) |
Vincent Coubard |
638:c90ae1400bf2 | 56 | |
Vincent Coubard |
638:c90ae1400bf2 | 57 | |
Vincent Coubard |
638:c90ae1400bf2 | 58 | /**@brief Macro to register section by name in code |
Vincent Coubard |
638:c90ae1400bf2 | 59 | * |
Vincent Coubard |
638:c90ae1400bf2 | 60 | * @param[in] section_name Name of the section to register |
Vincent Coubard |
638:c90ae1400bf2 | 61 | **/ |
Vincent Coubard |
638:c90ae1400bf2 | 62 | #if defined __CC_ARM |
Vincent Coubard |
638:c90ae1400bf2 | 63 | |
Vincent Coubard |
638:c90ae1400bf2 | 64 | // Not required by this compiler |
Vincent Coubard |
638:c90ae1400bf2 | 65 | #define NRF_SECTION_VARS_REGISTER_SECTION(section_name) |
Vincent Coubard |
638:c90ae1400bf2 | 66 | |
Vincent Coubard |
638:c90ae1400bf2 | 67 | #elif defined __GNUC__ |
Vincent Coubard |
638:c90ae1400bf2 | 68 | |
Vincent Coubard |
638:c90ae1400bf2 | 69 | // Not required by this compiler |
Vincent Coubard |
638:c90ae1400bf2 | 70 | #define NRF_SECTION_VARS_REGISTER_SECTION(section_name) |
Vincent Coubard |
638:c90ae1400bf2 | 71 | |
Vincent Coubard |
638:c90ae1400bf2 | 72 | #elif defined __ICCARM__ |
Vincent Coubard |
638:c90ae1400bf2 | 73 | |
Vincent Coubard |
638:c90ae1400bf2 | 74 | #define NRF_SECTION_VARS_REGISTER_SECTION(section_name) NRF_PRAGMA(section = ## #section_name ) |
Vincent Coubard |
638:c90ae1400bf2 | 75 | |
Vincent Coubard |
638:c90ae1400bf2 | 76 | #else |
Vincent Coubard |
638:c90ae1400bf2 | 77 | |
Vincent Coubard |
638:c90ae1400bf2 | 78 | #error TODO |
Vincent Coubard |
638:c90ae1400bf2 | 79 | |
Vincent Coubard |
638:c90ae1400bf2 | 80 | #endif |
Vincent Coubard |
638:c90ae1400bf2 | 81 | |
Vincent Coubard |
638:c90ae1400bf2 | 82 | /*lint -save -e27 */ |
Vincent Coubard |
638:c90ae1400bf2 | 83 | |
Vincent Coubard |
638:c90ae1400bf2 | 84 | /**@brief Macro for accessing start of a named data section by symbol |
Vincent Coubard |
638:c90ae1400bf2 | 85 | * |
Vincent Coubard |
638:c90ae1400bf2 | 86 | * @details The symbol that this macro resolves to is used to access the section |
Vincent Coubard |
638:c90ae1400bf2 | 87 | * by start address. |
Vincent Coubard |
638:c90ae1400bf2 | 88 | * |
Vincent Coubard |
638:c90ae1400bf2 | 89 | * @param[in] section_name Name of the section |
Vincent Coubard |
638:c90ae1400bf2 | 90 | */ |
Vincent Coubard |
638:c90ae1400bf2 | 91 | #if defined __CC_ARM |
Vincent Coubard |
638:c90ae1400bf2 | 92 | |
Vincent Coubard |
638:c90ae1400bf2 | 93 | #define NRF_SECTION_VARS_START_SYMBOL(section_name) section_name ## $$Base |
Vincent Coubard |
638:c90ae1400bf2 | 94 | |
Vincent Coubard |
638:c90ae1400bf2 | 95 | #elif defined __GNUC__ |
Vincent Coubard |
638:c90ae1400bf2 | 96 | |
Vincent Coubard |
638:c90ae1400bf2 | 97 | #define NRF_SECTION_VARS_START_SYMBOL(section_name) __start_ ## section_name |
Vincent Coubard |
638:c90ae1400bf2 | 98 | |
Vincent Coubard |
638:c90ae1400bf2 | 99 | #elif defined __ICCARM__ |
Vincent Coubard |
638:c90ae1400bf2 | 100 | |
Vincent Coubard |
638:c90ae1400bf2 | 101 | #define NRF_SECTION_VARS_START_SYMBOL(section_name) __section_begin(#section_name) |
Vincent Coubard |
638:c90ae1400bf2 | 102 | |
Vincent Coubard |
638:c90ae1400bf2 | 103 | #else |
Vincent Coubard |
638:c90ae1400bf2 | 104 | |
Vincent Coubard |
638:c90ae1400bf2 | 105 | #error TODO |
Vincent Coubard |
638:c90ae1400bf2 | 106 | |
Vincent Coubard |
638:c90ae1400bf2 | 107 | #endif |
Vincent Coubard |
638:c90ae1400bf2 | 108 | |
Vincent Coubard |
638:c90ae1400bf2 | 109 | |
Vincent Coubard |
638:c90ae1400bf2 | 110 | /**@brief Macro for accessing end of a named data section by symbol |
Vincent Coubard |
638:c90ae1400bf2 | 111 | * |
Vincent Coubard |
638:c90ae1400bf2 | 112 | * @details The symbol that this macro resolves to is used to access the section |
Vincent Coubard |
638:c90ae1400bf2 | 113 | * by end address. |
Vincent Coubard |
638:c90ae1400bf2 | 114 | * |
Vincent Coubard |
638:c90ae1400bf2 | 115 | * @param[in] section_name Name of the section |
Vincent Coubard |
638:c90ae1400bf2 | 116 | */ |
Vincent Coubard |
638:c90ae1400bf2 | 117 | #if defined __CC_ARM |
Vincent Coubard |
638:c90ae1400bf2 | 118 | |
Vincent Coubard |
638:c90ae1400bf2 | 119 | #define NRF_SECTION_VARS_END_SYMBOL(section_name) section_name ## $$Limit |
Vincent Coubard |
638:c90ae1400bf2 | 120 | |
Vincent Coubard |
638:c90ae1400bf2 | 121 | #elif defined __GNUC__ |
Vincent Coubard |
638:c90ae1400bf2 | 122 | |
Vincent Coubard |
638:c90ae1400bf2 | 123 | #define NRF_SECTION_VARS_END_SYMBOL(section_name) __stop_ ## section_name |
Vincent Coubard |
638:c90ae1400bf2 | 124 | |
Vincent Coubard |
638:c90ae1400bf2 | 125 | #elif defined __ICCARM__ |
Vincent Coubard |
638:c90ae1400bf2 | 126 | |
Vincent Coubard |
638:c90ae1400bf2 | 127 | #define NRF_SECTION_VARS_END_SYMBOL(section_name) __section_end(#section_name) |
Vincent Coubard |
638:c90ae1400bf2 | 128 | |
Vincent Coubard |
638:c90ae1400bf2 | 129 | #endif |
Vincent Coubard |
638:c90ae1400bf2 | 130 | |
Vincent Coubard |
638:c90ae1400bf2 | 131 | /*lint -restore */ |
Vincent Coubard |
638:c90ae1400bf2 | 132 | |
Vincent Coubard |
638:c90ae1400bf2 | 133 | |
Vincent Coubard |
638:c90ae1400bf2 | 134 | /**@brief Macro for accessing Length of a named section |
Vincent Coubard |
638:c90ae1400bf2 | 135 | * |
Vincent Coubard |
638:c90ae1400bf2 | 136 | * @details This macro is used to get the size of a named section. |
Vincent Coubard |
638:c90ae1400bf2 | 137 | * |
Vincent Coubard |
638:c90ae1400bf2 | 138 | * @param[in] section_name Name of the section |
Vincent Coubard |
638:c90ae1400bf2 | 139 | */ |
Vincent Coubard |
638:c90ae1400bf2 | 140 | |
Vincent Coubard |
638:c90ae1400bf2 | 141 | #if defined __CC_ARM |
Vincent Coubard |
638:c90ae1400bf2 | 142 | |
Vincent Coubard |
638:c90ae1400bf2 | 143 | #define NRF_SECTION_VARS_LENGTH(section_name) \ |
Vincent Coubard |
638:c90ae1400bf2 | 144 | ((uint32_t)&NRF_SECTION_VARS_END_SYMBOL(section_name) - (uint32_t)&NRF_SECTION_VARS_START_SYMBOL(section_name)) |
Vincent Coubard |
638:c90ae1400bf2 | 145 | |
Vincent Coubard |
638:c90ae1400bf2 | 146 | #elif defined __GNUC__ |
Vincent Coubard |
638:c90ae1400bf2 | 147 | |
Vincent Coubard |
638:c90ae1400bf2 | 148 | #define NRF_SECTION_VARS_LENGTH(section_name) \ |
Vincent Coubard |
638:c90ae1400bf2 | 149 | ((uint32_t)&NRF_SECTION_VARS_END_SYMBOL(section_name) - (uint32_t)&NRF_SECTION_VARS_START_SYMBOL(section_name)) |
Vincent Coubard |
638:c90ae1400bf2 | 150 | |
Vincent Coubard |
638:c90ae1400bf2 | 151 | #elif defined __ICCARM__ |
Vincent Coubard |
638:c90ae1400bf2 | 152 | |
Vincent Coubard |
638:c90ae1400bf2 | 153 | #define NRF_SECTION_VARS_LENGTH(section_name) \ |
Vincent Coubard |
638:c90ae1400bf2 | 154 | ((uint32_t)NRF_SECTION_VARS_END_SYMBOL(section_name) - (uint32_t)NRF_SECTION_VARS_START_SYMBOL(section_name)) |
Vincent Coubard |
638:c90ae1400bf2 | 155 | |
Vincent Coubard |
638:c90ae1400bf2 | 156 | #else |
Vincent Coubard |
638:c90ae1400bf2 | 157 | |
Vincent Coubard |
638:c90ae1400bf2 | 158 | #error TODO |
Vincent Coubard |
638:c90ae1400bf2 | 159 | |
Vincent Coubard |
638:c90ae1400bf2 | 160 | #endif |
Vincent Coubard |
638:c90ae1400bf2 | 161 | |
Vincent Coubard |
638:c90ae1400bf2 | 162 | |
Vincent Coubard |
638:c90ae1400bf2 | 163 | /**@brief Macro for accessing the start address of a named section |
Vincent Coubard |
638:c90ae1400bf2 | 164 | * |
Vincent Coubard |
638:c90ae1400bf2 | 165 | * param[in] section_name Name of the section to get the start address from |
Vincent Coubard |
638:c90ae1400bf2 | 166 | */ |
Vincent Coubard |
638:c90ae1400bf2 | 167 | #if defined __CC_ARM |
Vincent Coubard |
638:c90ae1400bf2 | 168 | |
Vincent Coubard |
638:c90ae1400bf2 | 169 | #define NRF_SECTION_VARS_START_ADDR(section_name) (uint32_t)&NRF_SECTION_VARS_START_SYMBOL(section_name) |
Vincent Coubard |
638:c90ae1400bf2 | 170 | |
Vincent Coubard |
638:c90ae1400bf2 | 171 | #elif defined __GNUC__ |
Vincent Coubard |
638:c90ae1400bf2 | 172 | |
Vincent Coubard |
638:c90ae1400bf2 | 173 | #define NRF_SECTION_VARS_START_ADDR(section_name) (uint32_t)&NRF_SECTION_VARS_START_SYMBOL(section_name) |
Vincent Coubard |
638:c90ae1400bf2 | 174 | |
Vincent Coubard |
638:c90ae1400bf2 | 175 | #elif defined __ICCARM__ |
Vincent Coubard |
638:c90ae1400bf2 | 176 | |
Vincent Coubard |
638:c90ae1400bf2 | 177 | #define NRF_SECTION_VARS_START_ADDR(section_name) (uint32_t)iar_ ## section_name ## _start |
Vincent Coubard |
638:c90ae1400bf2 | 178 | |
Vincent Coubard |
638:c90ae1400bf2 | 179 | #else |
Vincent Coubard |
638:c90ae1400bf2 | 180 | |
Vincent Coubard |
638:c90ae1400bf2 | 181 | #error TODO |
Vincent Coubard |
638:c90ae1400bf2 | 182 | |
Vincent Coubard |
638:c90ae1400bf2 | 183 | #endif |
Vincent Coubard |
638:c90ae1400bf2 | 184 | |
Vincent Coubard |
638:c90ae1400bf2 | 185 | |
Vincent Coubard |
638:c90ae1400bf2 | 186 | /*@brief Macro for accessing the end address of a named section |
Vincent Coubard |
638:c90ae1400bf2 | 187 | * |
Vincent Coubard |
638:c90ae1400bf2 | 188 | * @param[in] section_name Name of the section to get end address from |
Vincent Coubard |
638:c90ae1400bf2 | 189 | */ |
Vincent Coubard |
638:c90ae1400bf2 | 190 | #if defined __CC_ARM |
Vincent Coubard |
638:c90ae1400bf2 | 191 | |
Vincent Coubard |
638:c90ae1400bf2 | 192 | #define NRF_SECTION_VARS_END_ADDR(section_name) (uint32_t)&NRF_SECTION_VARS_END_SYMBOL(section_name) |
Vincent Coubard |
638:c90ae1400bf2 | 193 | |
Vincent Coubard |
638:c90ae1400bf2 | 194 | #elif defined __GNUC__ |
Vincent Coubard |
638:c90ae1400bf2 | 195 | |
Vincent Coubard |
638:c90ae1400bf2 | 196 | #define NRF_SECTION_VARS_END_ADDR(section_name) (uint32_t)&NRF_SECTION_VARS_END_SYMBOL(section_name) |
Vincent Coubard |
638:c90ae1400bf2 | 197 | |
Vincent Coubard |
638:c90ae1400bf2 | 198 | #elif defined __ICCARM__ |
Vincent Coubard |
638:c90ae1400bf2 | 199 | |
Vincent Coubard |
638:c90ae1400bf2 | 200 | #define NRF_SECTION_VARS_END_ADDR(section_name) (uint32_t)iar_ ## section_name ## _end |
Vincent Coubard |
638:c90ae1400bf2 | 201 | |
Vincent Coubard |
638:c90ae1400bf2 | 202 | #else |
Vincent Coubard |
638:c90ae1400bf2 | 203 | |
Vincent Coubard |
638:c90ae1400bf2 | 204 | #error TODO |
Vincent Coubard |
638:c90ae1400bf2 | 205 | |
Vincent Coubard |
638:c90ae1400bf2 | 206 | #endif |
Vincent Coubard |
638:c90ae1400bf2 | 207 | |
Vincent Coubard |
638:c90ae1400bf2 | 208 | |
Vincent Coubard |
638:c90ae1400bf2 | 209 | /**@brief Macro for declaring symbols for named sections |
Vincent Coubard |
638:c90ae1400bf2 | 210 | * |
Vincent Coubard |
638:c90ae1400bf2 | 211 | * @note These external declarations of section specific symbols are required for the linker in GCC and Keil (not IAR) |
Vincent Coubard |
638:c90ae1400bf2 | 212 | * |
Vincent Coubard |
638:c90ae1400bf2 | 213 | * @param[in] type_name Name of the type stored in the section |
Vincent Coubard |
638:c90ae1400bf2 | 214 | * @param[in] section_name Name of the section |
Vincent Coubard |
638:c90ae1400bf2 | 215 | */ |
Vincent Coubard |
638:c90ae1400bf2 | 216 | #if defined __CC_ARM |
Vincent Coubard |
638:c90ae1400bf2 | 217 | |
Vincent Coubard |
638:c90ae1400bf2 | 218 | #define NRF_SECTION_VARS_REGISTER_SYMBOLS(type_name, section_name) \ |
Vincent Coubard |
638:c90ae1400bf2 | 219 | extern type_name* NRF_SECTION_VARS_START_SYMBOL(section_name); \ |
Vincent Coubard |
638:c90ae1400bf2 | 220 | extern void* NRF_SECTION_VARS_END_SYMBOL(section_name) |
Vincent Coubard |
638:c90ae1400bf2 | 221 | |
Vincent Coubard |
638:c90ae1400bf2 | 222 | #elif defined __GNUC__ |
Vincent Coubard |
638:c90ae1400bf2 | 223 | |
Vincent Coubard |
638:c90ae1400bf2 | 224 | #define NRF_SECTION_VARS_REGISTER_SYMBOLS(type_name, section_name) \ |
Vincent Coubard |
638:c90ae1400bf2 | 225 | extern type_name* NRF_SECTION_VARS_START_SYMBOL(section_name); \ |
Vincent Coubard |
638:c90ae1400bf2 | 226 | extern void* NRF_SECTION_VARS_END_SYMBOL(section_name) |
Vincent Coubard |
638:c90ae1400bf2 | 227 | |
Vincent Coubard |
638:c90ae1400bf2 | 228 | #elif defined __ICCARM__ |
Vincent Coubard |
638:c90ae1400bf2 | 229 | |
Vincent Coubard |
638:c90ae1400bf2 | 230 | // No symbol registration required for IAR |
Vincent Coubard |
638:c90ae1400bf2 | 231 | #define NRF_SECTION_VARS_REGISTER_SYMBOLS(type_name, section_name) \ |
Vincent Coubard |
638:c90ae1400bf2 | 232 | extern void* iar_ ## section_name ## _start = __section_begin(#section_name); \ |
Vincent Coubard |
638:c90ae1400bf2 | 233 | extern void* iar_ ## section_name ## _end = __section_end(#section_name) |
Vincent Coubard |
638:c90ae1400bf2 | 234 | |
Vincent Coubard |
638:c90ae1400bf2 | 235 | #else |
Vincent Coubard |
638:c90ae1400bf2 | 236 | |
Vincent Coubard |
638:c90ae1400bf2 | 237 | #error TODO |
Vincent Coubard |
638:c90ae1400bf2 | 238 | |
Vincent Coubard |
638:c90ae1400bf2 | 239 | #endif |
Vincent Coubard |
638:c90ae1400bf2 | 240 | |
Vincent Coubard |
638:c90ae1400bf2 | 241 | |
Vincent Coubard |
638:c90ae1400bf2 | 242 | /**@brief Macro to add symbols to a named section |
Vincent Coubard |
638:c90ae1400bf2 | 243 | * |
Vincent Coubard |
638:c90ae1400bf2 | 244 | * @details The symbols are placed in a named section. All calls to this macro |
Vincent Coubard |
638:c90ae1400bf2 | 245 | * will result in symbols being placed in a contiguous manner in the named section. |
Vincent Coubard |
638:c90ae1400bf2 | 246 | * This macro ensures that the symbol is not removed because of optimization level. |
Vincent Coubard |
638:c90ae1400bf2 | 247 | * |
Vincent Coubard |
638:c90ae1400bf2 | 248 | * @warning There is no guarantee for ordering of placement. If ordering is required |
Vincent Coubard |
638:c90ae1400bf2 | 249 | * |
Vincent Coubard |
638:c90ae1400bf2 | 250 | * @warning The symbols added in the named section must be word aligned to |
Vincent Coubard |
638:c90ae1400bf2 | 251 | * ensure that compilers do not pad the section during symbol placement. |
Vincent Coubard |
638:c90ae1400bf2 | 252 | * |
Vincent Coubard |
638:c90ae1400bf2 | 253 | * @param[in] section_name Name of the section |
Vincent Coubard |
638:c90ae1400bf2 | 254 | * @param[in] type_def Datatype of the symbol to place in the given section |
Vincent Coubard |
638:c90ae1400bf2 | 255 | */ |
Vincent Coubard |
638:c90ae1400bf2 | 256 | #if defined __CC_ARM |
Vincent Coubard |
638:c90ae1400bf2 | 257 | |
Vincent Coubard |
638:c90ae1400bf2 | 258 | #define NRF_SECTION_VARS_ADD(section_name, type_def) \ |
Vincent Coubard |
638:c90ae1400bf2 | 259 | static type_def __attribute__((section( #section_name ))) __attribute__((used)) |
Vincent Coubard |
638:c90ae1400bf2 | 260 | |
Vincent Coubard |
638:c90ae1400bf2 | 261 | #elif defined __GNUC__ |
Vincent Coubard |
638:c90ae1400bf2 | 262 | |
Vincent Coubard |
638:c90ae1400bf2 | 263 | #define NRF_SECTION_VARS_ADD(section_name, type_def) \ |
Vincent Coubard |
638:c90ae1400bf2 | 264 | static type_def __attribute__ ((section( #section_name ))) __attribute__ ((used)) |
Vincent Coubard |
638:c90ae1400bf2 | 265 | |
Vincent Coubard |
638:c90ae1400bf2 | 266 | #elif defined __ICCARM__ |
Vincent Coubard |
638:c90ae1400bf2 | 267 | |
Vincent Coubard |
638:c90ae1400bf2 | 268 | #define NRF_SECTION_VARS_ADD(section_name, type_def) \ |
Vincent Coubard |
638:c90ae1400bf2 | 269 | __root type_def @ #section_name |
Vincent Coubard |
638:c90ae1400bf2 | 270 | |
Vincent Coubard |
638:c90ae1400bf2 | 271 | #else |
Vincent Coubard |
638:c90ae1400bf2 | 272 | |
Vincent Coubard |
638:c90ae1400bf2 | 273 | #error TODO |
Vincent Coubard |
638:c90ae1400bf2 | 274 | |
Vincent Coubard |
638:c90ae1400bf2 | 275 | #endif |
Vincent Coubard |
638:c90ae1400bf2 | 276 | |
Vincent Coubard |
638:c90ae1400bf2 | 277 | |
Vincent Coubard |
638:c90ae1400bf2 | 278 | /**@brief Macro to get symbol from named section |
Vincent Coubard |
638:c90ae1400bf2 | 279 | * |
Vincent Coubard |
638:c90ae1400bf2 | 280 | * @warning The stored symbol can only be resolved using this macro if the |
Vincent Coubard |
638:c90ae1400bf2 | 281 | * type of the data is word aligned. The operation of acquiring |
Vincent Coubard |
638:c90ae1400bf2 | 282 | * the stored symbol relies on sizeof of the stored type, no |
Vincent Coubard |
638:c90ae1400bf2 | 283 | * padding can exist in the named section in between individual |
Vincent Coubard |
638:c90ae1400bf2 | 284 | * stored items or this macro will fail. |
Vincent Coubard |
638:c90ae1400bf2 | 285 | * |
Vincent Coubard |
638:c90ae1400bf2 | 286 | * @param[in] i Index of item in section |
Vincent Coubard |
638:c90ae1400bf2 | 287 | * @param[in] type_name Type name of item in section |
Vincent Coubard |
638:c90ae1400bf2 | 288 | * @param[in] section_name Name of the section |
Vincent Coubard |
638:c90ae1400bf2 | 289 | */ |
Vincent Coubard |
638:c90ae1400bf2 | 290 | |
Vincent Coubard |
638:c90ae1400bf2 | 291 | #if defined __CC_ARM |
Vincent Coubard |
638:c90ae1400bf2 | 292 | |
Vincent Coubard |
638:c90ae1400bf2 | 293 | #define NRF_SECTION_VARS_GET(i, type_name, section_name) \ |
Vincent Coubard |
638:c90ae1400bf2 | 294 | (type_name*)(NRF_SECTION_VARS_START_ADDR(section_name) + i * sizeof(type_name)) |
Vincent Coubard |
638:c90ae1400bf2 | 295 | |
Vincent Coubard |
638:c90ae1400bf2 | 296 | #elif defined __GNUC__ |
Vincent Coubard |
638:c90ae1400bf2 | 297 | |
Vincent Coubard |
638:c90ae1400bf2 | 298 | #define NRF_SECTION_VARS_GET(i, type_name, section_name) \ |
Vincent Coubard |
638:c90ae1400bf2 | 299 | (type_name*)(NRF_SECTION_VARS_START_ADDR(section_name) + i * sizeof(type_name)) |
Vincent Coubard |
638:c90ae1400bf2 | 300 | |
Vincent Coubard |
638:c90ae1400bf2 | 301 | #elif defined __ICCARM__ |
Vincent Coubard |
638:c90ae1400bf2 | 302 | |
Vincent Coubard |
638:c90ae1400bf2 | 303 | #define NRF_SECTION_VARS_GET(i, type_name, section_name) \ |
Vincent Coubard |
638:c90ae1400bf2 | 304 | (type_name*)iar_ ## section_name ## _start + (i * sizeof(type_name)) |
Vincent Coubard |
638:c90ae1400bf2 | 305 | |
Vincent Coubard |
638:c90ae1400bf2 | 306 | #else |
Vincent Coubard |
638:c90ae1400bf2 | 307 | |
Vincent Coubard |
638:c90ae1400bf2 | 308 | #error TODO |
Vincent Coubard |
638:c90ae1400bf2 | 309 | |
Vincent Coubard |
638:c90ae1400bf2 | 310 | #endif |
Vincent Coubard |
638:c90ae1400bf2 | 311 | |
Vincent Coubard |
638:c90ae1400bf2 | 312 | |
Vincent Coubard |
638:c90ae1400bf2 | 313 | /**@brief Macro to get number of items in named section |
Vincent Coubard |
638:c90ae1400bf2 | 314 | * |
Vincent Coubard |
638:c90ae1400bf2 | 315 | * @param[in] type_name Type name of item in section |
Vincent Coubard |
638:c90ae1400bf2 | 316 | * @param[in] section_name Name of the section |
Vincent Coubard |
638:c90ae1400bf2 | 317 | */ |
Vincent Coubard |
638:c90ae1400bf2 | 318 | #define NRF_SECTION_VARS_COUNT(type_name, section_name) \ |
Vincent Coubard |
638:c90ae1400bf2 | 319 | NRF_SECTION_VARS_LENGTH(section_name) / sizeof(type_name) |
Vincent Coubard |
638:c90ae1400bf2 | 320 | |
Vincent Coubard |
638:c90ae1400bf2 | 321 | /** @} */ |
Vincent Coubard |
638:c90ae1400bf2 | 322 | |
Vincent Coubard |
638:c90ae1400bf2 | 323 | #endif // SECTION_VARS_H__ |