aconno flash API for nrf52832. (Modified mbed flash API)

Committer:
Dominik Bartolovic
Date:
Fri Dec 14 16:24:41 2018 +0100
Revision:
3:2852a2090e7b
Parent:
2:e5390f8eab8c
Added readme

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jurica238814 0:eb5ed8411c6f 1 /**
jurica238814 0:eb5ed8411c6f 2 * Made by Jurica Resetar @ aconno
jurica238814 0:eb5ed8411c6f 3 * ResetarJurica@gmail.com
jurica238814 0:eb5ed8411c6f 4 * More info @ aconno.de
jurica238814 0:eb5ed8411c6f 5 *
jurica238814 0:eb5ed8411c6f 6 */
jurica238814 0:eb5ed8411c6f 7
jurica238814 0:eb5ed8411c6f 8 /*
jurica238814 0:eb5ed8411c6f 9 * Copyright (c) 2017 Nordic Semiconductor ASA
jurica238814 0:eb5ed8411c6f 10 * All rights reserved.
jurica238814 0:eb5ed8411c6f 11 *
jurica238814 0:eb5ed8411c6f 12 * Redistribution and use in source and binary forms, with or without modification,
jurica238814 0:eb5ed8411c6f 13 * are permitted provided that the following conditions are met:
jurica238814 0:eb5ed8411c6f 14 *
jurica238814 0:eb5ed8411c6f 15 * 1. Redistributions of source code must retain the above copyright notice, this list
jurica238814 0:eb5ed8411c6f 16 * of conditions and the following disclaimer.
jurica238814 0:eb5ed8411c6f 17 *
jurica238814 0:eb5ed8411c6f 18 * 2. Redistributions in binary form, except as embedded into a Nordic Semiconductor ASA
jurica238814 0:eb5ed8411c6f 19 * integrated circuit in a product or a software update for such product, must reproduce
jurica238814 0:eb5ed8411c6f 20 * the above copyright notice, this list of conditions and the following disclaimer in
jurica238814 0:eb5ed8411c6f 21 * the documentation and/or other materials provided with the distribution.
jurica238814 0:eb5ed8411c6f 22 *
jurica238814 0:eb5ed8411c6f 23 * 3. Neither the name of Nordic Semiconductor ASA nor the names of its contributors may be
jurica238814 0:eb5ed8411c6f 24 * used to endorse or promote products derived from this software without specific prior
jurica238814 0:eb5ed8411c6f 25 * written permission.
jurica238814 0:eb5ed8411c6f 26 *
jurica238814 0:eb5ed8411c6f 27 * 4. This software, with or without modification, must only be used with a
jurica238814 0:eb5ed8411c6f 28 * Nordic Semiconductor ASA integrated circuit.
jurica238814 0:eb5ed8411c6f 29 *
jurica238814 0:eb5ed8411c6f 30 * 5. Any software provided in binary or object form under this license must not be reverse
jurica238814 0:eb5ed8411c6f 31 * engineered, decompiled, modified and/or disassembled.
jurica238814 0:eb5ed8411c6f 32 *
jurica238814 0:eb5ed8411c6f 33 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
jurica238814 0:eb5ed8411c6f 34 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
jurica238814 0:eb5ed8411c6f 35 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
jurica238814 0:eb5ed8411c6f 36 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
jurica238814 0:eb5ed8411c6f 37 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
jurica238814 0:eb5ed8411c6f 38 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
jurica238814 0:eb5ed8411c6f 39 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
jurica238814 0:eb5ed8411c6f 40 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
jurica238814 0:eb5ed8411c6f 41 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
jurica238814 0:eb5ed8411c6f 42 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
jurica238814 0:eb5ed8411c6f 43 *
jurica238814 0:eb5ed8411c6f 44 */
jurica238814 0:eb5ed8411c6f 45
jurica238814 0:eb5ed8411c6f 46 #if DEVICE_FLASH
jurica238814 0:eb5ed8411c6f 47
jurica238814 2:e5390f8eab8c 48 #include "aconno_flash.h"
jurica238814 0:eb5ed8411c6f 49 #include "hal/flash_api.h"
jurica238814 0:eb5ed8411c6f 50 #include "hal/lp_ticker_api.h"
jurica238814 0:eb5ed8411c6f 51
jurica238814 0:eb5ed8411c6f 52 #include "nrf_drv_common.h"
jurica238814 0:eb5ed8411c6f 53 #include "nrf_nvmc.h"
jurica238814 0:eb5ed8411c6f 54 #include "nrf_soc.h"
jurica238814 2:e5390f8eab8c 55 #include <string.h>
jurica238814 0:eb5ed8411c6f 56
jurica238814 0:eb5ed8411c6f 57 // Max. value from datasheet: 338 us
jurica238814 0:eb5ed8411c6f 58 // // Constant increased by the author experimentaly
jurica238814 0:eb5ed8411c6f 59 #define WORD_WRITE_TIMEOUT_US (1 * 100000)
jurica238814 0:eb5ed8411c6f 60 // Max. value from datasheet: 89.7 ms
jurica238814 0:eb5ed8411c6f 61 // Constant increased by the author experimentaly
jurica238814 0:eb5ed8411c6f 62 #define PAGE_ERASE_TIMEOUT_US (200 * 10000)
jurica238814 0:eb5ed8411c6f 63
jurica238814 0:eb5ed8411c6f 64 /* Macro for testing if the SoftDevice is active, regardless of whether the
jurica238814 0:eb5ed8411c6f 65 * application is build with the SoftDevice or not.
jurica238814 0:eb5ed8411c6f 66 */
jurica238814 0:eb5ed8411c6f 67 #if defined(SOFTDEVICE_PRESENT)
jurica238814 0:eb5ed8411c6f 68 #include "nrf_sdm.h"
jurica238814 0:eb5ed8411c6f 69
jurica238814 0:eb5ed8411c6f 70 static uint8_t wrapper(void) {
jurica238814 0:eb5ed8411c6f 71 uint8_t softdevice_is_enabled;
jurica238814 0:eb5ed8411c6f 72 ret_code_t result = sd_softdevice_is_enabled(&softdevice_is_enabled);
jurica238814 0:eb5ed8411c6f 73 return ((result == NRF_SUCCESS) && (softdevice_is_enabled == 1));
jurica238814 0:eb5ed8411c6f 74 }
jurica238814 0:eb5ed8411c6f 75
jurica238814 0:eb5ed8411c6f 76 #define NRF_HAL_SD_IS_ENABLED() wrapper()
jurica238814 0:eb5ed8411c6f 77 #else
jurica238814 0:eb5ed8411c6f 78 #define NRF_HAL_SD_IS_ENABLED() 0
jurica238814 0:eb5ed8411c6f 79 #endif
jurica238814 0:eb5ed8411c6f 80
jurica238814 1:954ac9003e99 81 int32_t aconno_flash_init(flash_t *obj)
jurica238814 0:eb5ed8411c6f 82 {
jurica238814 0:eb5ed8411c6f 83 (void)(obj);
jurica238814 0:eb5ed8411c6f 84
jurica238814 0:eb5ed8411c6f 85 /* Initialize low power ticker. Used for timeouts. */
jurica238814 0:eb5ed8411c6f 86 static bool first_init = true;
jurica238814 0:eb5ed8411c6f 87
jurica238814 0:eb5ed8411c6f 88 if(first_init)
jurica238814 0:eb5ed8411c6f 89 {
jurica238814 0:eb5ed8411c6f 90 first_init = false;
jurica238814 0:eb5ed8411c6f 91 lp_ticker_init();
jurica238814 0:eb5ed8411c6f 92 }
jurica238814 0:eb5ed8411c6f 93 return 0;
jurica238814 0:eb5ed8411c6f 94 }
jurica238814 0:eb5ed8411c6f 95
jurica238814 1:954ac9003e99 96 int32_t aconno_flash_free(flash_t *obj)
jurica238814 0:eb5ed8411c6f 97 {
jurica238814 0:eb5ed8411c6f 98 (void)(obj);
jurica238814 0:eb5ed8411c6f 99
jurica238814 0:eb5ed8411c6f 100 return 0;
jurica238814 0:eb5ed8411c6f 101 }
jurica238814 0:eb5ed8411c6f 102
jurica238814 1:954ac9003e99 103 int32_t aconno_flash_erase_sector(flash_t *obj, uint32_t address)
jurica238814 0:eb5ed8411c6f 104 {
jurica238814 0:eb5ed8411c6f 105 (void)(obj);
jurica238814 0:eb5ed8411c6f 106
jurica238814 0:eb5ed8411c6f 107 /* Return value defaults to error. */
jurica238814 0:eb5ed8411c6f 108 uint32_t result = NRF_ERROR_BUSY;
jurica238814 0:eb5ed8411c6f 109
jurica238814 0:eb5ed8411c6f 110 if(NRF_HAL_SD_IS_ENABLED())
jurica238814 0:eb5ed8411c6f 111 {
jurica238814 0:eb5ed8411c6f 112 /* Convert address to page number. */
jurica238814 0:eb5ed8411c6f 113 uint32_t page_number = address / NRF_FICR->CODEPAGESIZE;
jurica238814 0:eb5ed8411c6f 114
jurica238814 0:eb5ed8411c6f 115 /* Setup stop watch for timeout. */
jurica238814 0:eb5ed8411c6f 116 uint32_t start_us = lp_ticker_read();
jurica238814 0:eb5ed8411c6f 117 uint32_t now_us = start_us;
jurica238814 0:eb5ed8411c6f 118
jurica238814 0:eb5ed8411c6f 119 /* Retry if flash is busy until timeout is reached. */
jurica238814 0:eb5ed8411c6f 120 while(((now_us - start_us) < PAGE_ERASE_TIMEOUT_US) &&
jurica238814 0:eb5ed8411c6f 121 (result == NRF_ERROR_BUSY)){
jurica238814 0:eb5ed8411c6f 122
jurica238814 0:eb5ed8411c6f 123 result = sd_flash_page_erase(page_number);
jurica238814 0:eb5ed8411c6f 124 /* Read timeout timer. */
jurica238814 0:eb5ed8411c6f 125 now_us = lp_ticker_read();
jurica238814 0:eb5ed8411c6f 126 }
jurica238814 0:eb5ed8411c6f 127 }
jurica238814 0:eb5ed8411c6f 128 else
jurica238814 0:eb5ed8411c6f 129 {
jurica238814 0:eb5ed8411c6f 130 /* Raw API doesn't return error code, assume success. */
jurica238814 0:eb5ed8411c6f 131 nrf_nvmc_page_erase(address);
jurica238814 0:eb5ed8411c6f 132 result = NRF_SUCCESS;
jurica238814 0:eb5ed8411c6f 133 }
jurica238814 0:eb5ed8411c6f 134
jurica238814 0:eb5ed8411c6f 135 /* Convert Nordic error code to mbed HAL error code. */
jurica238814 0:eb5ed8411c6f 136 return (result == NRF_SUCCESS) ? 0 : -1;
jurica238814 0:eb5ed8411c6f 137 }
jurica238814 0:eb5ed8411c6f 138
jurica238814 2:e5390f8eab8c 139 int32_t aconno_flash_read(flash_t *obj, uint32_t address, uint8_t *data, uint32_t size)
jurica238814 2:e5390f8eab8c 140 {
jurica238814 2:e5390f8eab8c 141 memcpy(data, (const void *)address, size);
jurica238814 2:e5390f8eab8c 142 return 0;
jurica238814 2:e5390f8eab8c 143 }
jurica238814 2:e5390f8eab8c 144
jurica238814 1:954ac9003e99 145 int32_t aconno_flash_program_page(flash_t *obj, uint32_t address, const uint8_t *data, uint32_t size)
jurica238814 0:eb5ed8411c6f 146 {
jurica238814 0:eb5ed8411c6f 147 (void)(obj);
jurica238814 0:eb5ed8411c6f 148
jurica238814 0:eb5ed8411c6f 149 /* Return value defaults to error. */
jurica238814 0:eb5ed8411c6f 150 uint32_t result = NRF_ERROR_BUSY;
jurica238814 0:eb5ed8411c6f 151
jurica238814 0:eb5ed8411c6f 152 /* Convert size to words. */
jurica238814 0:eb5ed8411c6f 153 uint32_t words = size / sizeof(uint32_t);
jurica238814 0:eb5ed8411c6f 154
jurica238814 0:eb5ed8411c6f 155 if(NRF_HAL_SD_IS_ENABLED()){
jurica238814 0:eb5ed8411c6f 156 /* Setup stop watch for timeout. */
jurica238814 0:eb5ed8411c6f 157 uint32_t start_us = lp_ticker_read();
jurica238814 0:eb5ed8411c6f 158 uint32_t now_us = start_us;
jurica238814 0:eb5ed8411c6f 159
jurica238814 0:eb5ed8411c6f 160 /* Retry if flash is busy until timeout is reached. */
jurica238814 0:eb5ed8411c6f 161 while(((now_us - start_us) < (words * WORD_WRITE_TIMEOUT_US)) &&
jurica238814 0:eb5ed8411c6f 162 (result == NRF_ERROR_BUSY)){
jurica238814 0:eb5ed8411c6f 163 result = sd_flash_write((uint32_t *) address, (const uint32_t *) data, words);
jurica238814 0:eb5ed8411c6f 164 /* Read timeout timer. */
jurica238814 0:eb5ed8411c6f 165 now_us = lp_ticker_read();
jurica238814 0:eb5ed8411c6f 166 }
jurica238814 0:eb5ed8411c6f 167 }
jurica238814 0:eb5ed8411c6f 168 else
jurica238814 0:eb5ed8411c6f 169 {
jurica238814 0:eb5ed8411c6f 170 /* We will use *_words function to speed up flashing code.
jurica238814 0:eb5ed8411c6f 171 * Word means 32bit -> 4B or sizeof(uint32_t). */
jurica238814 0:eb5ed8411c6f 172 nrf_nvmc_write_words(address, (const uint32_t *) data, words);
jurica238814 0:eb5ed8411c6f 173 result = NRF_SUCCESS;
jurica238814 0:eb5ed8411c6f 174 }
jurica238814 0:eb5ed8411c6f 175
jurica238814 0:eb5ed8411c6f 176 /* Convert Nordic error code to mbed HAL error code. */
jurica238814 0:eb5ed8411c6f 177 return (result == NRF_SUCCESS) ? 0 : -1;
jurica238814 0:eb5ed8411c6f 178 }
jurica238814 0:eb5ed8411c6f 179
jurica238814 1:954ac9003e99 180 uint32_t aconno_flash_get_size(const flash_t *obj)
jurica238814 0:eb5ed8411c6f 181 {
jurica238814 0:eb5ed8411c6f 182 (void)(obj);
jurica238814 0:eb5ed8411c6f 183
jurica238814 0:eb5ed8411c6f 184 /* Just count flash size. */
jurica238814 0:eb5ed8411c6f 185 return NRF_FICR->CODESIZE * NRF_FICR->CODEPAGESIZE;
jurica238814 0:eb5ed8411c6f 186 }
jurica238814 0:eb5ed8411c6f 187
jurica238814 1:954ac9003e99 188 uint32_t aconno_flash_get_sector_size(const flash_t *obj, uint32_t address)
jurica238814 0:eb5ed8411c6f 189 {
jurica238814 0:eb5ed8411c6f 190 (void)(obj);
jurica238814 0:eb5ed8411c6f 191
jurica238814 0:eb5ed8411c6f 192 /* Test if passed address is in flash space. */
jurica238814 2:e5390f8eab8c 193 if (address < aconno_flash_get_size(obj)) {
jurica238814 0:eb5ed8411c6f 194 return NRF_FICR->CODEPAGESIZE;
jurica238814 0:eb5ed8411c6f 195 }
jurica238814 0:eb5ed8411c6f 196
jurica238814 0:eb5ed8411c6f 197 /* Something goes wrong, return invalid size error code. */
jurica238814 0:eb5ed8411c6f 198 return MBED_FLASH_INVALID_SIZE;
jurica238814 0:eb5ed8411c6f 199 }
jurica238814 0:eb5ed8411c6f 200
jurica238814 1:954ac9003e99 201 uint32_t aconno_flash_get_page_size(const flash_t *obj)
jurica238814 0:eb5ed8411c6f 202 {
jurica238814 0:eb5ed8411c6f 203 (void)(obj);
jurica238814 0:eb5ed8411c6f 204 /* Return minimum writeable size. Note that this is
jurica238814 0:eb5ed8411c6f 205 different from the erase page size. */
jurica238814 0:eb5ed8411c6f 206 return 4;
jurica238814 0:eb5ed8411c6f 207 }
jurica238814 0:eb5ed8411c6f 208
jurica238814 1:954ac9003e99 209 uint32_t aconno_flash_get_start_address(const flash_t *obj)
jurica238814 0:eb5ed8411c6f 210 {
jurica238814 0:eb5ed8411c6f 211 (void)(obj);
jurica238814 0:eb5ed8411c6f 212
jurica238814 0:eb5ed8411c6f 213 return 0;
jurica238814 0:eb5ed8411c6f 214 }
jurica238814 0:eb5ed8411c6f 215
jurica238814 2:e5390f8eab8c 216 /**
jurica238814 2:e5390f8eab8c 217 * Just leave the following function's declarations here!
jurica238814 2:e5390f8eab8c 218 * It's total mess if you try to put them somewhere else (mbed stuff...)
jurica238814 2:e5390f8eab8c 219 */
jurica238814 2:e5390f8eab8c 220 void nrf_nvmc_page_erase(uint32_t address)
jurica238814 2:e5390f8eab8c 221 {
jurica238814 2:e5390f8eab8c 222 // Enable erase.
jurica238814 2:e5390f8eab8c 223 NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Een;
jurica238814 2:e5390f8eab8c 224 while (NRF_NVMC->READY == NVMC_READY_READY_Busy)
jurica238814 2:e5390f8eab8c 225 {
jurica238814 2:e5390f8eab8c 226 }
jurica238814 2:e5390f8eab8c 227
jurica238814 2:e5390f8eab8c 228 // Erase the page
jurica238814 2:e5390f8eab8c 229 NRF_NVMC->ERASEPAGE = address;
jurica238814 2:e5390f8eab8c 230 while (NRF_NVMC->READY == NVMC_READY_READY_Busy)
jurica238814 2:e5390f8eab8c 231 {
jurica238814 2:e5390f8eab8c 232 }
jurica238814 2:e5390f8eab8c 233
jurica238814 2:e5390f8eab8c 234 NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren;
jurica238814 2:e5390f8eab8c 235 while (NRF_NVMC->READY == NVMC_READY_READY_Busy)
jurica238814 2:e5390f8eab8c 236 {
jurica238814 2:e5390f8eab8c 237 }
jurica238814 2:e5390f8eab8c 238 }
jurica238814 2:e5390f8eab8c 239
jurica238814 2:e5390f8eab8c 240 void nrf_nvmc_write_byte(uint32_t address, uint8_t value)
jurica238814 2:e5390f8eab8c 241 {
jurica238814 2:e5390f8eab8c 242 uint32_t byte_shift = address & (uint32_t)0x03;
jurica238814 2:e5390f8eab8c 243 uint32_t address32 = address & ~byte_shift; // Address to the word this byte is in.
jurica238814 2:e5390f8eab8c 244 uint32_t value32 = (*(uint32_t*)address32 & ~((uint32_t)0xFF << (byte_shift << (uint32_t)3)));
jurica238814 2:e5390f8eab8c 245 value32 = value32 + ((uint32_t)value << (byte_shift << 3));
jurica238814 2:e5390f8eab8c 246
jurica238814 2:e5390f8eab8c 247 // Enable write.
jurica238814 2:e5390f8eab8c 248 NRF_NVMC->CONFIG = (NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos);
jurica238814 2:e5390f8eab8c 249 while (NRF_NVMC->READY == NVMC_READY_READY_Busy)
jurica238814 2:e5390f8eab8c 250 {
jurica238814 2:e5390f8eab8c 251 }
jurica238814 2:e5390f8eab8c 252
jurica238814 2:e5390f8eab8c 253 *(uint32_t*)address32 = value32;
jurica238814 2:e5390f8eab8c 254 while(NRF_NVMC->READY == NVMC_READY_READY_Busy)
jurica238814 2:e5390f8eab8c 255 {
jurica238814 2:e5390f8eab8c 256 }
jurica238814 2:e5390f8eab8c 257
jurica238814 2:e5390f8eab8c 258 NRF_NVMC->CONFIG = (NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos);
jurica238814 2:e5390f8eab8c 259 {
jurica238814 2:e5390f8eab8c 260 }
jurica238814 2:e5390f8eab8c 261 }
jurica238814 2:e5390f8eab8c 262
jurica238814 2:e5390f8eab8c 263 void nrf_nvmc_write_word(uint32_t address, uint32_t value)
jurica238814 2:e5390f8eab8c 264 {
jurica238814 2:e5390f8eab8c 265 // Enable write.
jurica238814 2:e5390f8eab8c 266 NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen;
jurica238814 2:e5390f8eab8c 267 while (NRF_NVMC->READY == NVMC_READY_READY_Busy){
jurica238814 2:e5390f8eab8c 268 }
jurica238814 2:e5390f8eab8c 269
jurica238814 2:e5390f8eab8c 270 *(uint32_t*)address = value;
jurica238814 2:e5390f8eab8c 271 while (NRF_NVMC->READY == NVMC_READY_READY_Busy){
jurica238814 2:e5390f8eab8c 272 }
jurica238814 2:e5390f8eab8c 273
jurica238814 2:e5390f8eab8c 274 NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren;
jurica238814 2:e5390f8eab8c 275 while (NRF_NVMC->READY == NVMC_READY_READY_Busy)
jurica238814 2:e5390f8eab8c 276 {
jurica238814 2:e5390f8eab8c 277 }
jurica238814 2:e5390f8eab8c 278 }
jurica238814 2:e5390f8eab8c 279
jurica238814 2:e5390f8eab8c 280 void nrf_nvmc_write_bytes(uint32_t address, const uint8_t * src, uint32_t num_bytes)
jurica238814 2:e5390f8eab8c 281 {
jurica238814 2:e5390f8eab8c 282 uint32_t i;
jurica238814 2:e5390f8eab8c 283 for(i=0;i<num_bytes;i++)
jurica238814 2:e5390f8eab8c 284 {
jurica238814 2:e5390f8eab8c 285 nrf_nvmc_write_byte(address+i,src[i]);
jurica238814 2:e5390f8eab8c 286 }
jurica238814 2:e5390f8eab8c 287 }
jurica238814 2:e5390f8eab8c 288
jurica238814 2:e5390f8eab8c 289 void nrf_nvmc_write_words(uint32_t address, const uint32_t * src, uint32_t num_words)
jurica238814 2:e5390f8eab8c 290 {
jurica238814 2:e5390f8eab8c 291 uint32_t i;
jurica238814 2:e5390f8eab8c 292
jurica238814 2:e5390f8eab8c 293 // Enable write.
jurica238814 2:e5390f8eab8c 294 NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen;
jurica238814 2:e5390f8eab8c 295 while (NRF_NVMC->READY == NVMC_READY_READY_Busy)
jurica238814 2:e5390f8eab8c 296 {
jurica238814 2:e5390f8eab8c 297 }
jurica238814 2:e5390f8eab8c 298
jurica238814 2:e5390f8eab8c 299 for(i=0;i<num_words;i++)
jurica238814 2:e5390f8eab8c 300 {
jurica238814 2:e5390f8eab8c 301 ((uint32_t*)address)[i] = src[i];
jurica238814 2:e5390f8eab8c 302 while (NRF_NVMC->READY == NVMC_READY_READY_Busy)
jurica238814 2:e5390f8eab8c 303 {
jurica238814 2:e5390f8eab8c 304 }
jurica238814 2:e5390f8eab8c 305 }
jurica238814 2:e5390f8eab8c 306
jurica238814 2:e5390f8eab8c 307 NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren;
jurica238814 2:e5390f8eab8c 308 while (NRF_NVMC->READY == NVMC_READY_READY_Busy)
jurica238814 2:e5390f8eab8c 309 {
jurica238814 2:e5390f8eab8c 310 }
jurica238814 2:e5390f8eab8c 311 }
jurica238814 2:e5390f8eab8c 312
jurica238814 0:eb5ed8411c6f 313 #endif
jurica238814 0:eb5ed8411c6f 314 /** @}*/