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