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.
TARGET_SDT51822B/TOOLCHAIN_IAR/pstorage.h@172:65be27845400, 2019-02-20 (annotated)
- 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?
User | Revision | Line number | New 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 | /**@file |
AnnaBridge | 146:22da6e220af6 | 41 | * |
AnnaBridge | 146:22da6e220af6 | 42 | * @defgroup persistent_storage Persistent Storage Interface |
AnnaBridge | 146:22da6e220af6 | 43 | * @{ |
AnnaBridge | 146:22da6e220af6 | 44 | * @ingroup app_common |
AnnaBridge | 146:22da6e220af6 | 45 | * @brief Abstracted flash interface. |
AnnaBridge | 146:22da6e220af6 | 46 | * |
AnnaBridge | 146:22da6e220af6 | 47 | * @details An abstracted interface is provided by the module to easily port the application and |
AnnaBridge | 146:22da6e220af6 | 48 | * SDK modules to an alternate option. This ensures that the SDK and application are moved |
AnnaBridge | 146:22da6e220af6 | 49 | * to alternate persistent storage instead of the one provided by default. |
AnnaBridge | 146:22da6e220af6 | 50 | */ |
AnnaBridge | 146:22da6e220af6 | 51 | |
AnnaBridge | 146:22da6e220af6 | 52 | #ifndef PSTORAGE_H__ |
AnnaBridge | 146:22da6e220af6 | 53 | #define PSTORAGE_H__ |
AnnaBridge | 146:22da6e220af6 | 54 | |
AnnaBridge | 146:22da6e220af6 | 55 | #include "pstorage_platform.h" |
AnnaBridge | 146:22da6e220af6 | 56 | |
AnnaBridge | 146:22da6e220af6 | 57 | |
AnnaBridge | 146:22da6e220af6 | 58 | /**@defgroup ps_opcode Persistent Storage Access Operation Codes |
AnnaBridge | 146:22da6e220af6 | 59 | * @{ |
AnnaBridge | 146:22da6e220af6 | 60 | * @brief Persistent Storage Access Operation Codes. |
AnnaBridge | 146:22da6e220af6 | 61 | * |
AnnaBridge | 146:22da6e220af6 | 62 | * @details Persistent Storage Access Operation Codes are used by Persistent storage operation |
AnnaBridge | 146:22da6e220af6 | 63 | * completion callback @ref pstorage_ntf_cb_t to identify the operation type requested by |
AnnaBridge | 146:22da6e220af6 | 64 | * the application. |
AnnaBridge | 146:22da6e220af6 | 65 | */ |
AnnaBridge | 146:22da6e220af6 | 66 | #define PSTORAGE_STORE_OP_CODE 0x01 /**< Store Operation type. */ |
AnnaBridge | 146:22da6e220af6 | 67 | #define PSTORAGE_LOAD_OP_CODE 0x02 /**< Load Operation type. */ |
AnnaBridge | 146:22da6e220af6 | 68 | #define PSTORAGE_CLEAR_OP_CODE 0x03 /**< Clear Operation type. */ |
AnnaBridge | 146:22da6e220af6 | 69 | #define PSTORAGE_UPDATE_OP_CODE 0x04 /**< Update Operation type. */ |
AnnaBridge | 146:22da6e220af6 | 70 | |
AnnaBridge | 146:22da6e220af6 | 71 | /**@} */ |
AnnaBridge | 146:22da6e220af6 | 72 | |
AnnaBridge | 146:22da6e220af6 | 73 | /**@defgroup pstorage_data_types Persistent Memory Interface Data Types |
AnnaBridge | 146:22da6e220af6 | 74 | * @{ |
AnnaBridge | 146:22da6e220af6 | 75 | * @brief Data Types needed for interfacing with persistent memory. |
AnnaBridge | 146:22da6e220af6 | 76 | * |
AnnaBridge | 146:22da6e220af6 | 77 | * @details Data Types needed for interfacing with persistent memory. |
AnnaBridge | 146:22da6e220af6 | 78 | */ |
AnnaBridge | 146:22da6e220af6 | 79 | |
AnnaBridge | 146:22da6e220af6 | 80 | /**@brief Persistent storage operation completion callback function type. |
AnnaBridge | 146:22da6e220af6 | 81 | * |
AnnaBridge | 146:22da6e220af6 | 82 | * @details The persistent storage operation completion callback is used by the interface to report |
AnnaBridge | 146:22da6e220af6 | 83 | * success or failure of a flash operation. Since data is not copied for a store operation, |
AnnaBridge | 146:22da6e220af6 | 84 | * a callback is an indication that the resident memory can now be reused or freed. |
AnnaBridge | 146:22da6e220af6 | 85 | * |
AnnaBridge | 146:22da6e220af6 | 86 | * @param[in] handle Identifies the module and block for the callback that is received. |
AnnaBridge | 146:22da6e220af6 | 87 | * @param[in] op_code Identifies the operation for the event that is notified. |
AnnaBridge | 146:22da6e220af6 | 88 | * @param[in] result Identifies the result of a flash access operation. NRF_SUCCESS implies |
AnnaBridge | 146:22da6e220af6 | 89 | * operation succeeded. |
AnnaBridge | 146:22da6e220af6 | 90 | * |
AnnaBridge | 146:22da6e220af6 | 91 | * @note Unmanaged (abnormal behaviour) error codes from the SoftDevice flash |
AnnaBridge | 146:22da6e220af6 | 92 | * access API are forwarded as is and are expected to be handled by the |
AnnaBridge | 146:22da6e220af6 | 93 | * application. For details refer to the implementation file and corresponding |
AnnaBridge | 146:22da6e220af6 | 94 | * SoftDevice flash API documentation. |
AnnaBridge | 146:22da6e220af6 | 95 | * |
AnnaBridge | 146:22da6e220af6 | 96 | * @param[in] p_data Identifies the application data pointer. For a store operation, this points |
AnnaBridge | 146:22da6e220af6 | 97 | * to the resident source of application memory that the application can now |
AnnaBridge | 146:22da6e220af6 | 98 | * free or reuse. When there is a clear operation, this is NULL since no |
AnnaBridge | 146:22da6e220af6 | 99 | * application pointer is needed for this operation. |
AnnaBridge | 146:22da6e220af6 | 100 | * @param[in] data_len Length data the application provided for the operation. |
AnnaBridge | 146:22da6e220af6 | 101 | */ |
AnnaBridge | 146:22da6e220af6 | 102 | typedef void (*pstorage_ntf_cb_t)(pstorage_handle_t * p_handle, |
AnnaBridge | 146:22da6e220af6 | 103 | uint8_t op_code, |
AnnaBridge | 146:22da6e220af6 | 104 | uint32_t result, |
AnnaBridge | 146:22da6e220af6 | 105 | uint8_t * p_data, |
AnnaBridge | 146:22da6e220af6 | 106 | uint32_t data_len); |
AnnaBridge | 146:22da6e220af6 | 107 | |
AnnaBridge | 146:22da6e220af6 | 108 | /**@brief Struct containing module registration context. */ |
AnnaBridge | 146:22da6e220af6 | 109 | typedef struct |
AnnaBridge | 146:22da6e220af6 | 110 | { |
AnnaBridge | 146:22da6e220af6 | 111 | pstorage_ntf_cb_t cb; /**< Persistent storage operation completion callback function @ref pstorage_ntf_cb_t. */ |
AnnaBridge | 146:22da6e220af6 | 112 | pstorage_size_t block_size; /**< Desired block size for persistent memory storage. For example, if a module has a table with 10 entries, and each entry is 64 bytes in size, |
AnnaBridge | 146:22da6e220af6 | 113 | * it can request 10 blocks with a block size of 64 bytes. The module can also request one block that is 640 bytes depending |
AnnaBridge | 146:22da6e220af6 | 114 | * on how it would like to access or alter the memory in persistent memory. |
AnnaBridge | 146:22da6e220af6 | 115 | * The first option is preferred when it is a single entry that needs to be updated often and doesn't impact the other entries. |
AnnaBridge | 146:22da6e220af6 | 116 | * The second option is preferred when table entries are not changed individually but have a common point of loading and storing |
AnnaBridge | 146:22da6e220af6 | 117 | * data. */ |
AnnaBridge | 146:22da6e220af6 | 118 | pstorage_size_t block_count; /** Number of blocks requested by the module; minimum values is 1. */ |
AnnaBridge | 146:22da6e220af6 | 119 | } pstorage_module_param_t; |
AnnaBridge | 146:22da6e220af6 | 120 | |
AnnaBridge | 146:22da6e220af6 | 121 | /**@} */ |
AnnaBridge | 146:22da6e220af6 | 122 | |
AnnaBridge | 146:22da6e220af6 | 123 | /**@defgroup pstorage_routines Persistent Storage Access Routines |
AnnaBridge | 146:22da6e220af6 | 124 | * @{ |
AnnaBridge | 146:22da6e220af6 | 125 | * @brief Functions/Interface SDK modules used to persistently store data. |
AnnaBridge | 146:22da6e220af6 | 126 | * |
AnnaBridge | 146:22da6e220af6 | 127 | * @details Interface for the Application and SDK modules to load/store information persistently. |
AnnaBridge | 146:22da6e220af6 | 128 | * Note: While implementation of each of the persistent storage access functions |
AnnaBridge | 146:22da6e220af6 | 129 | * depends on the system and is specific to system/solution, the signature of the |
AnnaBridge | 146:22da6e220af6 | 130 | * interface routines should not be altered. |
AnnaBridge | 146:22da6e220af6 | 131 | */ |
AnnaBridge | 146:22da6e220af6 | 132 | |
AnnaBridge | 146:22da6e220af6 | 133 | /**@brief Function for initializing the module. |
AnnaBridge | 146:22da6e220af6 | 134 | * |
AnnaBridge | 146:22da6e220af6 | 135 | * @details Function for initializing the module. This function is called once before any other APIs |
AnnaBridge | 146:22da6e220af6 | 136 | * of the module are used. |
AnnaBridge | 146:22da6e220af6 | 137 | * |
AnnaBridge | 146:22da6e220af6 | 138 | * @retval NRF_SUCCESS Operation success. |
AnnaBridge | 146:22da6e220af6 | 139 | */ |
AnnaBridge | 146:22da6e220af6 | 140 | uint32_t pstorage_init(void); |
AnnaBridge | 146:22da6e220af6 | 141 | |
AnnaBridge | 146:22da6e220af6 | 142 | /**@brief Function for registering with persistent storage interface. |
AnnaBridge | 146:22da6e220af6 | 143 | * |
AnnaBridge | 146:22da6e220af6 | 144 | * @param[in] p_module_param Module registration parameter. |
AnnaBridge | 146:22da6e220af6 | 145 | * @param[out] p_block_id Block identifier to identify persistent memory blocks when |
AnnaBridge | 146:22da6e220af6 | 146 | * registration succeeds. Application is expected to use the block IDs |
AnnaBridge | 146:22da6e220af6 | 147 | * for subsequent operations on requested persistent memory. Maximum |
AnnaBridge | 146:22da6e220af6 | 148 | * registrations permitted is determined by the configuration of the |
AnnaBridge | 146:22da6e220af6 | 149 | * parameter PSTORAGE_NUM_OF_PAGES. If more than one memory block is |
AnnaBridge | 146:22da6e220af6 | 150 | * requested, the identifier provided here is the base identifier for the |
AnnaBridge | 146:22da6e220af6 | 151 | * first block and used to identify the subsequent block. The application |
AnnaBridge | 146:22da6e220af6 | 152 | * uses \@ref pstorage_block_identifier_get with this base identifier and |
AnnaBridge | 146:22da6e220af6 | 153 | * block number. Therefore if 10 blocks of size 64 are requested and the |
AnnaBridge | 146:22da6e220af6 | 154 | * application wishes to store memory in the 6th block, it shall use |
AnnaBridge | 146:22da6e220af6 | 155 | * \@ref pstorage_block_identifier_get with the base ID and provide a |
AnnaBridge | 146:22da6e220af6 | 156 | * block number of 5. This way the application is only expected to |
AnnaBridge | 146:22da6e220af6 | 157 | * remember the base block identifier. |
AnnaBridge | 146:22da6e220af6 | 158 | * |
AnnaBridge | 146:22da6e220af6 | 159 | * @retval NRF_SUCCESS Operation success. |
AnnaBridge | 146:22da6e220af6 | 160 | * @retval NRF_ERROR_INVALID_STATE Operation failure. API is called without module |
AnnaBridge | 146:22da6e220af6 | 161 | * initialization. |
AnnaBridge | 146:22da6e220af6 | 162 | * @retval NRF_ERROR_NULL Operation failure. NULL parameter has been passed. |
AnnaBridge | 146:22da6e220af6 | 163 | * @retval NRF_ERROR_INVALID_PARAM Operation failure. Invalid parameter has been passed. |
AnnaBridge | 146:22da6e220af6 | 164 | * @retval NRF_ERROR_NO_MEM Operation failure. Additional registrations can't be |
AnnaBridge | 146:22da6e220af6 | 165 | * supported. |
AnnaBridge | 146:22da6e220af6 | 166 | */ |
AnnaBridge | 146:22da6e220af6 | 167 | uint32_t pstorage_register(pstorage_module_param_t * p_module_param, |
AnnaBridge | 146:22da6e220af6 | 168 | pstorage_handle_t * p_block_id); |
AnnaBridge | 146:22da6e220af6 | 169 | |
AnnaBridge | 146:22da6e220af6 | 170 | /**@brief Function for getting block ID with reference to base block identifier provided at the time |
AnnaBridge | 146:22da6e220af6 | 171 | * of registration. |
AnnaBridge | 146:22da6e220af6 | 172 | * |
AnnaBridge | 146:22da6e220af6 | 173 | * @details Function to get the block ID with reference to base block identifier provided at the |
AnnaBridge | 146:22da6e220af6 | 174 | * time of registration. |
AnnaBridge | 146:22da6e220af6 | 175 | * If more than one memory block was requested when registering, the identifier provided |
AnnaBridge | 146:22da6e220af6 | 176 | * here is the base identifier for the first block which is used to identify subsequent |
AnnaBridge | 146:22da6e220af6 | 177 | * blocks. The application shall use this routine to get the block identifier, providing |
AnnaBridge | 146:22da6e220af6 | 178 | * input as base identifier and block number. Therefore, if 10 blocks of size 64 are |
AnnaBridge | 146:22da6e220af6 | 179 | * requested and the application wishes to store memory in the 6th block, it shall use |
AnnaBridge | 146:22da6e220af6 | 180 | * \@ref pstorage_block_identifier_get with the base ID and provide a block number of 5. |
AnnaBridge | 146:22da6e220af6 | 181 | * This way the application is only expected to remember the base block identifier. |
AnnaBridge | 146:22da6e220af6 | 182 | * |
AnnaBridge | 146:22da6e220af6 | 183 | * @param[in] p_base_id Base block ID received at the time of registration. |
AnnaBridge | 146:22da6e220af6 | 184 | * @param[in] block_num Block Number, with first block numbered zero. |
AnnaBridge | 146:22da6e220af6 | 185 | * @param[out] p_block_id Block identifier for the block number requested when the API succeeds. |
AnnaBridge | 146:22da6e220af6 | 186 | * |
AnnaBridge | 146:22da6e220af6 | 187 | * @retval NRF_SUCCESS Operation success. |
AnnaBridge | 146:22da6e220af6 | 188 | * @retval NRF_ERROR_INVALID_STATE Operation failure. API is called without module |
AnnaBridge | 146:22da6e220af6 | 189 | * initialization. |
AnnaBridge | 146:22da6e220af6 | 190 | * @retval NRF_ERROR_NULL Operation failure. NULL parameter has been passed. |
AnnaBridge | 146:22da6e220af6 | 191 | * @retval NRF_ERROR_INVALID_PARAM Operation failure. Invalid parameter has been passed. |
AnnaBridge | 146:22da6e220af6 | 192 | */ |
AnnaBridge | 146:22da6e220af6 | 193 | uint32_t pstorage_block_identifier_get(pstorage_handle_t * p_base_id, |
AnnaBridge | 146:22da6e220af6 | 194 | pstorage_size_t block_num, |
AnnaBridge | 146:22da6e220af6 | 195 | pstorage_handle_t * p_block_id); |
AnnaBridge | 146:22da6e220af6 | 196 | |
AnnaBridge | 146:22da6e220af6 | 197 | /**@brief Function for persistently storing data of length 'size' contained in the 'p_src' address |
AnnaBridge | 146:22da6e220af6 | 198 | * in the storage module at 'p_dest' address. Equivalent to Storage Write. |
AnnaBridge | 146:22da6e220af6 | 199 | * |
AnnaBridge | 146:22da6e220af6 | 200 | * @param[in] p_dest Destination address where data is to be stored persistently. |
AnnaBridge | 146:22da6e220af6 | 201 | * @param[in] p_src Source address containing data to be stored. API assumes this to be resident |
AnnaBridge | 146:22da6e220af6 | 202 | * memory and no intermediate copy of data is made by the API. Must be word |
AnnaBridge | 146:22da6e220af6 | 203 | * aligned. |
AnnaBridge | 146:22da6e220af6 | 204 | * @param[in] size Size of data to be stored expressed in bytes. Must be word aligned and size + |
AnnaBridge | 146:22da6e220af6 | 205 | * offset must be <= block size. |
AnnaBridge | 146:22da6e220af6 | 206 | * @param[in] offset Offset in bytes to be applied when writing to the block. |
AnnaBridge | 146:22da6e220af6 | 207 | * For example, if within a block of 100 bytes, the application wishes to |
AnnaBridge | 146:22da6e220af6 | 208 | * write 20 bytes at an offset of 12, then this field should be set to 12. |
AnnaBridge | 146:22da6e220af6 | 209 | * Must be word aligned. |
AnnaBridge | 146:22da6e220af6 | 210 | * |
AnnaBridge | 146:22da6e220af6 | 211 | * @retval NRF_SUCCESS Operation success. |
AnnaBridge | 146:22da6e220af6 | 212 | * @retval NRF_ERROR_INVALID_STATE Operation failure. API is called without module |
AnnaBridge | 146:22da6e220af6 | 213 | * initialization. |
AnnaBridge | 146:22da6e220af6 | 214 | * @retval NRF_ERROR_NULL Operation failure. NULL parameter has been passed. |
AnnaBridge | 146:22da6e220af6 | 215 | * @retval NRF_ERROR_INVALID_PARAM Operation failure. Invalid parameter has been passed. |
AnnaBridge | 146:22da6e220af6 | 216 | * @retval NRF_ERROR_INVALID_ADDR Operation failure. Parameter is not aligned. |
AnnaBridge | 146:22da6e220af6 | 217 | * @retval NRF_ERROR_NO_MEM Operation failure. No storage space available. |
AnnaBridge | 146:22da6e220af6 | 218 | * |
AnnaBridge | 146:22da6e220af6 | 219 | * @warning No copy of the data is made, meaning memory provided for the data source that is to |
AnnaBridge | 146:22da6e220af6 | 220 | * be written to flash cannot be freed or reused by the application until this procedure |
AnnaBridge | 146:22da6e220af6 | 221 | * is complete. The application is notified when the procedure is finished using the |
AnnaBridge | 146:22da6e220af6 | 222 | * notification callback registered by the application. |
AnnaBridge | 146:22da6e220af6 | 223 | */ |
AnnaBridge | 146:22da6e220af6 | 224 | uint32_t pstorage_store(pstorage_handle_t * p_dest, |
AnnaBridge | 146:22da6e220af6 | 225 | uint8_t * p_src, |
AnnaBridge | 146:22da6e220af6 | 226 | pstorage_size_t size, |
AnnaBridge | 146:22da6e220af6 | 227 | pstorage_size_t offset); |
AnnaBridge | 146:22da6e220af6 | 228 | |
AnnaBridge | 146:22da6e220af6 | 229 | /**@brief Function for updating persistently stored data of length 'size' contained in the 'p_src' |
AnnaBridge | 146:22da6e220af6 | 230 | * address in the storage module at 'p_dest' address. |
AnnaBridge | 146:22da6e220af6 | 231 | * |
AnnaBridge | 146:22da6e220af6 | 232 | * @param[in] p_dest Destination address where data is to be updated. |
AnnaBridge | 146:22da6e220af6 | 233 | * @param[in] p_src Source address containing data to be stored. API assumes this to be resident |
AnnaBridge | 146:22da6e220af6 | 234 | * memory and no intermediate copy of data is made by the API. |
AnnaBridge | 146:22da6e220af6 | 235 | * @param[in] size Size of data to be stored expressed in bytes. Must be word aligned and size + |
AnnaBridge | 146:22da6e220af6 | 236 | * offset must be <= block size. |
AnnaBridge | 146:22da6e220af6 | 237 | * @param[in] offset Offset in bytes to be applied when writing to the block. |
AnnaBridge | 146:22da6e220af6 | 238 | * For example, if within a block of 100 bytes, the application wishes to |
AnnaBridge | 146:22da6e220af6 | 239 | * write 20 bytes at an offset of 12 bytes, then this field should be set to 12. |
AnnaBridge | 146:22da6e220af6 | 240 | * Must be word aligned. |
AnnaBridge | 146:22da6e220af6 | 241 | * |
AnnaBridge | 146:22da6e220af6 | 242 | * @retval NRF_SUCCESS Operation success. |
AnnaBridge | 146:22da6e220af6 | 243 | * @retval NRF_ERROR_INVALID_STATE Operation failure. API is called without module |
AnnaBridge | 146:22da6e220af6 | 244 | * initialization. |
AnnaBridge | 146:22da6e220af6 | 245 | * @retval NRF_ERROR_NULL Operation failure. NULL parameter has been passed. |
AnnaBridge | 146:22da6e220af6 | 246 | * @retval NRF_ERROR_INVALID_PARAM Operation failure. Invalid parameter has been passed. |
AnnaBridge | 146:22da6e220af6 | 247 | * @retval NRF_ERROR_INVALID_ADDR Operation failure. Parameter is not aligned. |
AnnaBridge | 146:22da6e220af6 | 248 | * @retval NRF_ERROR_NO_MEM Operation failure. No storage space available. |
AnnaBridge | 146:22da6e220af6 | 249 | * |
AnnaBridge | 146:22da6e220af6 | 250 | * @warning No copy of the data is made, meaning memory provided for the data source that is to |
AnnaBridge | 146:22da6e220af6 | 251 | * be written to flash cannot be freed or reused by the application until this procedure |
AnnaBridge | 146:22da6e220af6 | 252 | * is complete. The application is notified when the procedure is finished using the |
AnnaBridge | 146:22da6e220af6 | 253 | * notification callback registered by the application. |
AnnaBridge | 146:22da6e220af6 | 254 | */ |
AnnaBridge | 146:22da6e220af6 | 255 | uint32_t pstorage_update(pstorage_handle_t * p_dest, |
AnnaBridge | 146:22da6e220af6 | 256 | uint8_t * p_src, |
AnnaBridge | 146:22da6e220af6 | 257 | pstorage_size_t size, |
AnnaBridge | 146:22da6e220af6 | 258 | pstorage_size_t offset); |
AnnaBridge | 146:22da6e220af6 | 259 | |
AnnaBridge | 146:22da6e220af6 | 260 | /**@brief Function for loading persistently stored data of length 'size' from 'p_src' address |
AnnaBridge | 146:22da6e220af6 | 261 | * to 'p_dest' address. Equivalent to Storage Read. |
AnnaBridge | 146:22da6e220af6 | 262 | * |
AnnaBridge | 146:22da6e220af6 | 263 | * @param[in] p_dest Destination address where persistently stored data is to be loaded. |
AnnaBridge | 146:22da6e220af6 | 264 | * @param[in] p_src Source where data is loaded from persistent memory. |
AnnaBridge | 146:22da6e220af6 | 265 | * @param[in] size Size of data to be loaded from persistent memory expressed in bytes. |
AnnaBridge | 146:22da6e220af6 | 266 | * Should be word aligned. |
AnnaBridge | 146:22da6e220af6 | 267 | * @param[in] offset Offset in bytes, to be applied when loading from the block. |
AnnaBridge | 146:22da6e220af6 | 268 | * For example, if within a block of 100 bytes, the application wishes to |
AnnaBridge | 146:22da6e220af6 | 269 | * load 20 bytes from offset of 12 bytes, then this field should be set to 12. |
AnnaBridge | 146:22da6e220af6 | 270 | * Should be word aligned. |
AnnaBridge | 146:22da6e220af6 | 271 | * |
AnnaBridge | 146:22da6e220af6 | 272 | * @retval NRF_SUCCESS Operation success. |
AnnaBridge | 146:22da6e220af6 | 273 | * @retval NRF_ERROR_INVALID_STATE Operation failure. API is called without module |
AnnaBridge | 146:22da6e220af6 | 274 | * initialization. |
AnnaBridge | 146:22da6e220af6 | 275 | * @retval NRF_ERROR_NULL Operation failure. NULL parameter has been passed. |
AnnaBridge | 146:22da6e220af6 | 276 | * @retval NRF_ERROR_INVALID_PARAM Operation failure. Invalid parameter has been passed. |
AnnaBridge | 146:22da6e220af6 | 277 | * @retval NRF_ERROR_INVALID_ADDR Operation failure. Parameter is not aligned. |
AnnaBridge | 146:22da6e220af6 | 278 | * @retval NRF_ERROR_NO_MEM Operation failure. No storage space available. |
AnnaBridge | 146:22da6e220af6 | 279 | */ |
AnnaBridge | 146:22da6e220af6 | 280 | uint32_t pstorage_load(uint8_t * p_dest, |
AnnaBridge | 146:22da6e220af6 | 281 | pstorage_handle_t * p_src, |
AnnaBridge | 146:22da6e220af6 | 282 | pstorage_size_t size, |
AnnaBridge | 146:22da6e220af6 | 283 | pstorage_size_t offset); |
AnnaBridge | 146:22da6e220af6 | 284 | |
AnnaBridge | 146:22da6e220af6 | 285 | /**@brief Function for clearing data in persistent memory. |
AnnaBridge | 146:22da6e220af6 | 286 | * |
AnnaBridge | 146:22da6e220af6 | 287 | * @param[in] p_base_id Base block identifier in persistent memory that needs to be cleared; |
AnnaBridge | 146:22da6e220af6 | 288 | * equivalent to an Erase Operation. |
AnnaBridge | 146:22da6e220af6 | 289 | * @param[in] size Size of data to be cleared from persistent memory expressed in bytes. |
AnnaBridge | 146:22da6e220af6 | 290 | * This parameter is to provision for clearing of certain blocks |
AnnaBridge | 146:22da6e220af6 | 291 | * of memory, or all memory blocks in a registered module. If the total size |
AnnaBridge | 146:22da6e220af6 | 292 | * of the application module is used (blocks * block size) in combination with |
AnnaBridge | 146:22da6e220af6 | 293 | * the identifier for the first block in the module, all blocks in the |
AnnaBridge | 146:22da6e220af6 | 294 | * module will be erased. Must be multiple of block size. |
AnnaBridge | 146:22da6e220af6 | 295 | * |
AnnaBridge | 146:22da6e220af6 | 296 | * @retval NRF_SUCCESS Operation success. |
AnnaBridge | 146:22da6e220af6 | 297 | * @retval NRF_ERROR_INVALID_STATE Operation failure. API is called without module |
AnnaBridge | 146:22da6e220af6 | 298 | * initialization. |
AnnaBridge | 146:22da6e220af6 | 299 | * @retval NRF_ERROR_NULL Operation failure. NULL parameter has been passed. |
AnnaBridge | 146:22da6e220af6 | 300 | * @retval NRF_ERROR_INVALID_PARAM Operation failure. Invalid parameter has been passed. |
AnnaBridge | 146:22da6e220af6 | 301 | * @retval NRF_ERROR_INVALID_ADDR Operation failure. Parameter is not aligned. |
AnnaBridge | 146:22da6e220af6 | 302 | * @retval NRF_ERROR_NO_MEM Operation failure. No storage space available. |
AnnaBridge | 146:22da6e220af6 | 303 | * |
AnnaBridge | 146:22da6e220af6 | 304 | * @note Clear operations may take time. This API however, does not block until the clear |
AnnaBridge | 146:22da6e220af6 | 305 | * procedure is complete. The application is notified of procedure completion using |
AnnaBridge | 146:22da6e220af6 | 306 | * a notification callback registered by the application. The 'result' parameter of the |
AnnaBridge | 146:22da6e220af6 | 307 | * callback indicates if the procedure was successful or not. |
AnnaBridge | 146:22da6e220af6 | 308 | */ |
AnnaBridge | 146:22da6e220af6 | 309 | uint32_t pstorage_clear(pstorage_handle_t * p_base_id, pstorage_size_t size); |
AnnaBridge | 146:22da6e220af6 | 310 | |
AnnaBridge | 146:22da6e220af6 | 311 | /**@brief Function for getting the number of pending operations with the module. |
AnnaBridge | 146:22da6e220af6 | 312 | * |
AnnaBridge | 146:22da6e220af6 | 313 | * @param[out] p_count Number of storage operations pending with the module. If 0, there are no |
AnnaBridge | 146:22da6e220af6 | 314 | * outstanding requests. |
AnnaBridge | 146:22da6e220af6 | 315 | * |
AnnaBridge | 146:22da6e220af6 | 316 | * @retval NRF_SUCCESS Operation success. |
AnnaBridge | 146:22da6e220af6 | 317 | * @retval NRF_ERROR_INVALID_STATE Operation failure. API is called without module |
AnnaBridge | 146:22da6e220af6 | 318 | * initialization. |
AnnaBridge | 146:22da6e220af6 | 319 | * @retval NRF_ERROR_NULL Operation failure. NULL parameter has been passed. |
AnnaBridge | 146:22da6e220af6 | 320 | */ |
AnnaBridge | 146:22da6e220af6 | 321 | uint32_t pstorage_access_status_get(uint32_t * p_count); |
AnnaBridge | 146:22da6e220af6 | 322 | |
AnnaBridge | 146:22da6e220af6 | 323 | #ifdef PSTORAGE_RAW_MODE_ENABLE |
AnnaBridge | 146:22da6e220af6 | 324 | |
AnnaBridge | 146:22da6e220af6 | 325 | /**@brief Function for registering with the persistent storage interface. |
AnnaBridge | 146:22da6e220af6 | 326 | * |
AnnaBridge | 146:22da6e220af6 | 327 | * @param[in] p_module_param Module registration parameter. |
AnnaBridge | 146:22da6e220af6 | 328 | * @param[out] p_block_id Block identifier used to identify persistent memory blocks upon |
AnnaBridge | 146:22da6e220af6 | 329 | * successful registration. The application is expected to use the block |
AnnaBridge | 146:22da6e220af6 | 330 | * IDs for subsequent operations on requested persistent memory. When |
AnnaBridge | 146:22da6e220af6 | 331 | * more than one memory block is requested, this identifier is the base |
AnnaBridge | 146:22da6e220af6 | 332 | * identifier for the first block and used to identify subsequent blocks. |
AnnaBridge | 146:22da6e220af6 | 333 | * The application shall use \@ref pstorage_block_identifier_get with |
AnnaBridge | 146:22da6e220af6 | 334 | * this base identifier and block number. Therefore if 10 blocks of size |
AnnaBridge | 146:22da6e220af6 | 335 | * 64 are requested and the application wishes to store memory in the 6th |
AnnaBridge | 146:22da6e220af6 | 336 | * block, it shall use \@ref pstorage_block_identifier_get with the base |
AnnaBridge | 146:22da6e220af6 | 337 | * ID and provide a block number of 5. Therefore, the application is only |
AnnaBridge | 146:22da6e220af6 | 338 | * expected to remember the base block identifier. |
AnnaBridge | 146:22da6e220af6 | 339 | * |
AnnaBridge | 146:22da6e220af6 | 340 | * @retval NRF_SUCCESS Operation success. |
AnnaBridge | 146:22da6e220af6 | 341 | * @retval NRF_ERROR_INVALID_STATE Operation failure. API is called without module |
AnnaBridge | 146:22da6e220af6 | 342 | * initialization. |
AnnaBridge | 146:22da6e220af6 | 343 | * @retval NRF_ERROR_NULL Operation failure. NULL parameter has been passed. |
AnnaBridge | 146:22da6e220af6 | 344 | * @retval NRF_ERROR_INVALID_PARAM Operation failure. Invalid parameter has been passed. |
AnnaBridge | 146:22da6e220af6 | 345 | * @retval NRF_ERROR_NO_MEM Operation failure. No storage space available. |
AnnaBridge | 146:22da6e220af6 | 346 | */ |
AnnaBridge | 146:22da6e220af6 | 347 | uint32_t pstorage_raw_register(pstorage_module_param_t * p_module_param, |
AnnaBridge | 146:22da6e220af6 | 348 | pstorage_handle_t * p_block_id); |
AnnaBridge | 146:22da6e220af6 | 349 | |
AnnaBridge | 146:22da6e220af6 | 350 | /**@brief Function for persistently storing data of length 'size' contained in 'p_src' address in |
AnnaBridge | 146:22da6e220af6 | 351 | * storage module at 'p_dest' address. Equivalent to Storage Write. |
AnnaBridge | 146:22da6e220af6 | 352 | * |
AnnaBridge | 146:22da6e220af6 | 353 | * @param[in] p_dest Destination address where data is to be stored persistently. |
AnnaBridge | 146:22da6e220af6 | 354 | * @param[in] p_src Source address containing data to be stored. The API assumes this is resident |
AnnaBridge | 146:22da6e220af6 | 355 | * memory and no intermediate copy of data is made by the API. Must be word |
AnnaBridge | 146:22da6e220af6 | 356 | * aligned. |
AnnaBridge | 146:22da6e220af6 | 357 | * @param[in] size Size of data to be stored expressed in bytes. Must be word aligned. |
AnnaBridge | 146:22da6e220af6 | 358 | * @param[in] offset Offset in bytes to be applied when writing to the block. |
AnnaBridge | 146:22da6e220af6 | 359 | * For example, if within a block of 100 bytes, the application wishes to |
AnnaBridge | 146:22da6e220af6 | 360 | * write 20 bytes at an offset of 12 bytes, this field should be set to 12. |
AnnaBridge | 146:22da6e220af6 | 361 | * Must be word aligned. |
AnnaBridge | 146:22da6e220af6 | 362 | * |
AnnaBridge | 146:22da6e220af6 | 363 | * @retval NRF_SUCCESS Operation success. |
AnnaBridge | 146:22da6e220af6 | 364 | * @retval NRF_ERROR_INVALID_STATE Operation failure. API is called without module |
AnnaBridge | 146:22da6e220af6 | 365 | * initialization. |
AnnaBridge | 146:22da6e220af6 | 366 | * @retval NRF_ERROR_NULL Operation failure. NULL parameter has been passed. |
AnnaBridge | 146:22da6e220af6 | 367 | * @retval NRF_ERROR_INVALID_PARAM Operation failure. Invalid parameter has been passed. |
AnnaBridge | 146:22da6e220af6 | 368 | * @retval NRF_ERROR_INVALID_ADDR Operation failure. Parameter is not aligned. |
AnnaBridge | 146:22da6e220af6 | 369 | * @retval NRF_ERROR_NO_MEM Operation failure. No storage space available. |
AnnaBridge | 146:22da6e220af6 | 370 | * |
AnnaBridge | 146:22da6e220af6 | 371 | * @warning No copy of the data is made, meaning memory provided for data source that is to be |
AnnaBridge | 146:22da6e220af6 | 372 | * written to flash cannot be freed or reused by the application until this procedure |
AnnaBridge | 146:22da6e220af6 | 373 | * is complete. The application is notified when the procedure is finished using the |
AnnaBridge | 146:22da6e220af6 | 374 | * notification callback registered by the application. |
AnnaBridge | 146:22da6e220af6 | 375 | */ |
AnnaBridge | 146:22da6e220af6 | 376 | uint32_t pstorage_raw_store(pstorage_handle_t * p_dest, |
AnnaBridge | 146:22da6e220af6 | 377 | uint8_t * p_src, |
AnnaBridge | 146:22da6e220af6 | 378 | pstorage_size_t size, |
AnnaBridge | 146:22da6e220af6 | 379 | pstorage_size_t offset); |
AnnaBridge | 146:22da6e220af6 | 380 | |
AnnaBridge | 146:22da6e220af6 | 381 | /**@brief Function for clearing data in persistent memory in raw mode. |
AnnaBridge | 146:22da6e220af6 | 382 | * |
AnnaBridge | 146:22da6e220af6 | 383 | * @param[in] p_dest Base block identifier in persistent memory that needs to be cleared. |
AnnaBridge | 146:22da6e220af6 | 384 | * Equivalent to an Erase Operation. |
AnnaBridge | 146:22da6e220af6 | 385 | * @param[in] size Size of data to be cleared from persistent memory expressed in bytes. |
AnnaBridge | 146:22da6e220af6 | 386 | * Not used. |
AnnaBridge | 146:22da6e220af6 | 387 | * |
AnnaBridge | 146:22da6e220af6 | 388 | * @retval NRF_SUCCESS Operation success. |
AnnaBridge | 146:22da6e220af6 | 389 | * @retval NRF_ERROR_INVALID_STATE Operation failure. API is called without module |
AnnaBridge | 146:22da6e220af6 | 390 | * initialization. |
AnnaBridge | 146:22da6e220af6 | 391 | * @retval NRF_ERROR_NULL Operation failure. NULL parameter has been passed. |
AnnaBridge | 146:22da6e220af6 | 392 | * @retval NRF_ERROR_INVALID_PARAM Operation failure. Invalid parameter has been passed. |
AnnaBridge | 146:22da6e220af6 | 393 | * @retval NRF_ERROR_NO_MEM Operation failure. No storage space available. |
AnnaBridge | 146:22da6e220af6 | 394 | * |
AnnaBridge | 146:22da6e220af6 | 395 | * @note Clear operations may take time. This API, however, does not block until the clear |
AnnaBridge | 146:22da6e220af6 | 396 | * procedure is complete. The application is notified of procedure completion using |
AnnaBridge | 146:22da6e220af6 | 397 | * a notification callback registered by the application. The 'result' parameter of the |
AnnaBridge | 146:22da6e220af6 | 398 | * callback indicates if the procedure was successful or not. |
AnnaBridge | 146:22da6e220af6 | 399 | */ |
AnnaBridge | 146:22da6e220af6 | 400 | uint32_t pstorage_raw_clear(pstorage_handle_t * p_dest, pstorage_size_t size); |
AnnaBridge | 146:22da6e220af6 | 401 | |
AnnaBridge | 146:22da6e220af6 | 402 | #endif // PSTORAGE_RAW_MODE_ENABLE |
AnnaBridge | 146:22da6e220af6 | 403 | |
AnnaBridge | 146:22da6e220af6 | 404 | /**@} */ |
AnnaBridge | 146:22da6e220af6 | 405 | /**@} */ |
AnnaBridge | 146:22da6e220af6 | 406 | |
AnnaBridge | 146:22da6e220af6 | 407 | #endif // PSTORAGE_H__ |
AnnaBridge | 146:22da6e220af6 | 408 |