mediCAL's first BLE project

Dependents:   BLE_mediCAL

Fork of nRF51822 by Nordic Semiconductor

Committer:
Rohit Grover
Date:
Mon Jul 07 13:43:31 2014 +0100
Revision:
37:c29c330d942c
Parent:
0:eff01767de02
Child:
48:895748db3357
changes required to upgrade to V7 of the soft-device

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bogdanm 0:eff01767de02 1 /* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved.
bogdanm 0:eff01767de02 2 *
bogdanm 0:eff01767de02 3 * The information contained herein is property of Nordic Semiconductor ASA.
bogdanm 0:eff01767de02 4 * Terms and conditions of usage are described in detail in NORDIC
bogdanm 0:eff01767de02 5 * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
bogdanm 0:eff01767de02 6 *
bogdanm 0:eff01767de02 7 * Licensees are granted free, non-transferable use of the information. NO
bogdanm 0:eff01767de02 8 * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
bogdanm 0:eff01767de02 9 * the file.
bogdanm 0:eff01767de02 10 *
bogdanm 0:eff01767de02 11 */
bogdanm 0:eff01767de02 12
bogdanm 0:eff01767de02 13 /**@file
bogdanm 0:eff01767de02 14 *
bogdanm 0:eff01767de02 15 * @defgroup persistent_storage Persistent Storage Interface
bogdanm 0:eff01767de02 16 * @{
bogdanm 0:eff01767de02 17 * @ingroup app_common
bogdanm 0:eff01767de02 18 * @brief Abstracted flash interface.
bogdanm 0:eff01767de02 19 *
bogdanm 0:eff01767de02 20 * @details In order to ensure that the SDK and application be moved to alternate persistent storage
bogdanm 0:eff01767de02 21 * options other than the default provided with NRF solution, an abstracted interface is provided
bogdanm 0:eff01767de02 22 * by the module to ensure SDK modules and application can be ported to alternate option with ease.
bogdanm 0:eff01767de02 23 */
bogdanm 0:eff01767de02 24
bogdanm 0:eff01767de02 25 #ifndef PSTORAGE_H__
bogdanm 0:eff01767de02 26 #define PSTORAGE_H__
bogdanm 0:eff01767de02 27
bogdanm 0:eff01767de02 28 #include "pstorage_platform.h"
bogdanm 0:eff01767de02 29
bogdanm 0:eff01767de02 30
bogdanm 0:eff01767de02 31 /**@defgroup ps_opcode Persistent Storage Access Operation Codes
bogdanm 0:eff01767de02 32 * @{
bogdanm 0:eff01767de02 33 * @brief Persistent Storage Access Operation Codes. These are used to report any error during
bogdanm 0:eff01767de02 34 * a persistent storage access operation or any general error that may occur in the
bogdanm 0:eff01767de02 35 * interface.
bogdanm 0:eff01767de02 36 *
bogdanm 0:eff01767de02 37 * @details Persistent Storage Access Operation Codes used in error notification callback
bogdanm 0:eff01767de02 38 * registered with the interface to report any error during an persistent storage access
bogdanm 0:eff01767de02 39 * operation or any general error that may occur in the interface.
bogdanm 0:eff01767de02 40 */
Rohit Grover 37:c29c330d942c 41 #define PSTORAGE_ERROR_OP_CODE 0x01 /**< General Error Code */
Rohit Grover 37:c29c330d942c 42 #define PSTORAGE_STORE_OP_CODE 0x02 /**< Error when Store Operation was requested */
Rohit Grover 37:c29c330d942c 43 #define PSTORAGE_LOAD_OP_CODE 0x03 /**< Error when Load Operation was requested */
Rohit Grover 37:c29c330d942c 44 #define PSTORAGE_CLEAR_OP_CODE 0x04 /**< Error when Clear Operation was requested */
Rohit Grover 37:c29c330d942c 45 #define PSTORAGE_UPDATE_OP_CODE 0x05 /**< Update an already touched storage block */
bogdanm 0:eff01767de02 46
bogdanm 0:eff01767de02 47 /**@} */
bogdanm 0:eff01767de02 48
bogdanm 0:eff01767de02 49 /**@defgroup pstorage_data_types Persistent Memory Interface Data Types
bogdanm 0:eff01767de02 50 * @{
bogdanm 0:eff01767de02 51 * @brief Data Types needed for interfacing with persistent memory.
bogdanm 0:eff01767de02 52 *
bogdanm 0:eff01767de02 53 * @details Data Types needed for interfacing with persistent memory.
bogdanm 0:eff01767de02 54 */
bogdanm 0:eff01767de02 55
bogdanm 0:eff01767de02 56 /**@brief Persistent Storage Error Reporting Callback
bogdanm 0:eff01767de02 57 *
bogdanm 0:eff01767de02 58 * @details Persistent Storage Error Reporting Callback that is used by the interface to report
Rohit Grover 37:c29c330d942c 59 * success or failure of a flash operation. Therefore, for any operations, application
Rohit Grover 37:c29c330d942c 60 * can know when the procedure was complete. For store operation, since no data copy
Rohit Grover 37:c29c330d942c 61 * is made, receiving a success or failure notification, indicated by the reason
Rohit Grover 37:c29c330d942c 62 * parameter of callback is an indication that the resident memory could now be reused
Rohit Grover 37:c29c330d942c 63 * or freed, as the case may be.
bogdanm 0:eff01767de02 64 *
Rohit Grover 37:c29c330d942c 65 * @param[in] handle Identifies module and block for which callback is received.
Rohit Grover 37:c29c330d942c 66 * @param[in] op_code Identifies the operation for which the event is notified.
Rohit Grover 37:c29c330d942c 67 * @param[in] result Identifies the result of flash access operation.
Rohit Grover 37:c29c330d942c 68 * NRF_SUCCESS implies, operation succeeded.
Rohit Grover 37:c29c330d942c 69 * @param[in] p_data Identifies the application data pointer. In case of store operation, this
Rohit Grover 37:c29c330d942c 70 * points to the resident source of application memory that application can now
Rohit Grover 37:c29c330d942c 71 * free or reuse. In case of clear, this is NULL as no application pointer is
Rohit Grover 37:c29c330d942c 72 * needed for this operation.
Rohit Grover 37:c29c330d942c 73 * @param[in] data_len Length data application had provided for the operation.
bogdanm 0:eff01767de02 74 *
bogdanm 0:eff01767de02 75 */
bogdanm 0:eff01767de02 76 typedef void (*pstorage_ntf_cb_t)(pstorage_handle_t * p_handle,
bogdanm 0:eff01767de02 77 uint8_t op_code,
bogdanm 0:eff01767de02 78 uint32_t result,
bogdanm 0:eff01767de02 79 uint8_t * p_data,
bogdanm 0:eff01767de02 80 uint32_t data_len);
bogdanm 0:eff01767de02 81
bogdanm 0:eff01767de02 82
Rohit Grover 37:c29c330d942c 83 typedef struct
bogdanm 0:eff01767de02 84 {
Rohit Grover 37:c29c330d942c 85 pstorage_ntf_cb_t cb; /**< Callback registered with the module to be notified of any error occurring in persistent memory management */
Rohit Grover 37:c29c330d942c 86 pstorage_size_t block_size; /**< Desired block size for persistent memory storage, for example, if a module has a table with 10 entries, each entry is size 64 bytes,
Rohit Grover 37:c29c330d942c 87 * it can request 10 blocks with block size 64 bytes. On the other hand, the module can also request one block of size 640 based on
Rohit Grover 37:c29c330d942c 88 * how it would like to access or alter memory in persistent memory.
Rohit Grover 37:c29c330d942c 89 * First option is preferred when single entries that need to be updated often when having no impact on the other entries.
Rohit Grover 37:c29c330d942c 90 * While second option is preferred when entries of table are not changed on individually but have common point of loading and storing
Rohit Grover 37:c29c330d942c 91 * data. */
Rohit Grover 37:c29c330d942c 92 pstorage_size_t block_count; /** Number of blocks requested by the module, minimum values is 1. */
bogdanm 0:eff01767de02 93 } pstorage_module_param_t;
bogdanm 0:eff01767de02 94
bogdanm 0:eff01767de02 95 /**@} */
bogdanm 0:eff01767de02 96
bogdanm 0:eff01767de02 97 /**@defgroup pstorage_routines Persistent Storage Access Routines
bogdanm 0:eff01767de02 98 * @{
bogdanm 0:eff01767de02 99 * @brief Functions/Interface SDK modules use to persistently store data.
bogdanm 0:eff01767de02 100 *
bogdanm 0:eff01767de02 101 * @details Interface for Application & SDK module to load/store information persistently.
bogdanm 0:eff01767de02 102 * Note: that while implementation of each of the persistent storage access function
bogdanm 0:eff01767de02 103 * depends on the system and can specific to system/solution, the signature of the
bogdanm 0:eff01767de02 104 * interface routines should not be altered.
bogdanm 0:eff01767de02 105 */
bogdanm 0:eff01767de02 106
bogdanm 0:eff01767de02 107 /**@brief Module Initialization Routine.
bogdanm 0:eff01767de02 108 *
bogdanm 0:eff01767de02 109 * @details Initializes module. To be called once before any other APIs of the module are used.
bogdanm 0:eff01767de02 110 *
Rohit Grover 37:c29c330d942c 111 * @retval NRF_SUCCESS on success, else an error code indicating reason for failure.
bogdanm 0:eff01767de02 112 */
bogdanm 0:eff01767de02 113 uint32_t pstorage_init(void);
bogdanm 0:eff01767de02 114
bogdanm 0:eff01767de02 115
bogdanm 0:eff01767de02 116 /**@brief Register with persistent storage interface.
bogdanm 0:eff01767de02 117 *
bogdanm 0:eff01767de02 118 * @param[in] p_module_param Module registration param.
Rohit Grover 37:c29c330d942c 119 * @param[out] p_block_id Block identifier to identify persistent memory blocks in case
Rohit Grover 37:c29c330d942c 120 * registration succeeds. Application is expected to use the block ids
Rohit Grover 37:c29c330d942c 121 * for subsequent operations on requested persistent memory. Maximum
Rohit Grover 37:c29c330d942c 122 * registrations permitted is determined by configuration parameter
Rohit Grover 37:c29c330d942c 123 * PSTORAGE_MAX_APPLICATIONS.
bogdanm 0:eff01767de02 124 * In case more than one memory blocks are requested, the identifier provided here is
bogdanm 0:eff01767de02 125 * the base identifier for the first block and to identify subsequent block,
bogdanm 0:eff01767de02 126 * application shall use \@ref pstorage_block_identifier_get with this base identifier
bogdanm 0:eff01767de02 127 * and block number. Therefore if 10 blocks of size 64 are requested and application
bogdanm 0:eff01767de02 128 * wishes to store memory in 6th block, it shall use
bogdanm 0:eff01767de02 129 * \@ref pstorage_block_identifier_get with based id and provide a block number of 5.
bogdanm 0:eff01767de02 130 * This way application is only expected to remember the base block identifier.
bogdanm 0:eff01767de02 131 *
Rohit Grover 37:c29c330d942c 132 * @retval NRF_SUCCESS on success, else an error code indicating reason for failure.
bogdanm 0:eff01767de02 133 * @retval NRF_ERROR_INVALID_STATE is returned is API is called without module initialization.
Rohit Grover 37:c29c330d942c 134 * @retval NRF_ERROR_NULL if NULL parameter has been passed.
bogdanm 0:eff01767de02 135 * @retval NRF_ERROR_INVALID_PARAM if invalid parameters are passed to the API.
Rohit Grover 37:c29c330d942c 136 * @retval NRF_ERROR_NO_MEM in case no more registrations can be supported.
bogdanm 0:eff01767de02 137 */
bogdanm 0:eff01767de02 138 uint32_t pstorage_register(pstorage_module_param_t * p_module_param,
Rohit Grover 37:c29c330d942c 139 pstorage_handle_t * p_block_id);
bogdanm 0:eff01767de02 140
bogdanm 0:eff01767de02 141
bogdanm 0:eff01767de02 142 /**
bogdanm 0:eff01767de02 143 * @brief Function to get block id with reference to base block identifier provided at time of
bogdanm 0:eff01767de02 144 * registration.
bogdanm 0:eff01767de02 145 *
bogdanm 0:eff01767de02 146 * @details Function to get block id with reference to base block identifier provided at time of
bogdanm 0:eff01767de02 147 * registration.
bogdanm 0:eff01767de02 148 * In case more than one memory blocks were requested when registering, the identifier
bogdanm 0:eff01767de02 149 * provided here is the base identifier for the first block and to identify subsequent
bogdanm 0:eff01767de02 150 * block, application shall use this routine to get block identifier providing input as
bogdanm 0:eff01767de02 151 * base identifier and block number. Therefore if 10 blocks of size 64 are requested and
bogdanm 0:eff01767de02 152 * application wishes to store memory in 6th block, it shall use
bogdanm 0:eff01767de02 153 * \@ref pstorage_block_identifier_get with based id and provide a block number of 5.
bogdanm 0:eff01767de02 154 * This way application is only expected to remember the base block identifier.
bogdanm 0:eff01767de02 155 *
Rohit Grover 37:c29c330d942c 156 * @param[in] p_base_id Base block id received at the time of registration.
Rohit Grover 37:c29c330d942c 157 * @param[in] block_num Block Number, with first block numbered zero.
bogdanm 0:eff01767de02 158 * @param[out] p_block_id Block identifier for the block number requested in case the API succeeds.
bogdanm 0:eff01767de02 159 *
Rohit Grover 37:c29c330d942c 160 * @retval NRF_SUCCESS on success, else an error code indicating reason for failure.
bogdanm 0:eff01767de02 161 * @retval NRF_ERROR_INVALID_STATE is returned is API is called without module initialization.
Rohit Grover 37:c29c330d942c 162 * @retval NRF_ERROR_NULL if NULL parameter has been passed.
bogdanm 0:eff01767de02 163 * @retval NRF_ERROR_INVALID_PARAM if invalid parameters are passed to the API.
bogdanm 0:eff01767de02 164 */
bogdanm 0:eff01767de02 165 uint32_t pstorage_block_identifier_get(pstorage_handle_t * p_base_id,
bogdanm 0:eff01767de02 166 pstorage_size_t block_num,
bogdanm 0:eff01767de02 167 pstorage_handle_t * p_block_id);
bogdanm 0:eff01767de02 168
bogdanm 0:eff01767de02 169
bogdanm 0:eff01767de02 170 /**@brief Routine to persistently store data of length 'size' contained in 'p_src' address
bogdanm 0:eff01767de02 171 * in storage module at 'p_dest' address; Equivalent to Storage Write.
bogdanm 0:eff01767de02 172 *
bogdanm 0:eff01767de02 173 * @param[in] p_dest Destination address where data is to be stored persistently.
bogdanm 0:eff01767de02 174 * @param[in] p_src Source address containing data to be stored. API assumes this to be resident
bogdanm 0:eff01767de02 175 * memory and no intermediate copy of data is made by the API.
bogdanm 0:eff01767de02 176 * @param[in] size Size of data to be stored expressed in bytes. Should be word aligned.
bogdanm 0:eff01767de02 177 * @param[in] offset Offset in bytes to be applied when writing to the block.
bogdanm 0:eff01767de02 178 * For example, if within a block of 100 bytes, application wishes to
bogdanm 0:eff01767de02 179 * write 20 bytes at offset of 12, then this field should be set to 12.
bogdanm 0:eff01767de02 180 * Should be word aligned.
bogdanm 0:eff01767de02 181 *
Rohit Grover 37:c29c330d942c 182 * @retval NRF_SUCCESS on success, else an error code indicating reason for failure.
bogdanm 0:eff01767de02 183 * @retval NRF_ERROR_INVALID_STATE is returned is API is called without module initialization.
Rohit Grover 37:c29c330d942c 184 * @retval NRF_ERROR_NULL if NULL parameter has been passed.
bogdanm 0:eff01767de02 185 * @retval NRF_ERROR_INVALID_PARAM if invalid parameters are passed to the API.
Rohit Grover 37:c29c330d942c 186 * @retval NRF_ERROR_INVALID_ADDR in case data address 'p_src' is not aligned.
Rohit Grover 37:c29c330d942c 187 * @retval NRF_ERROR_NO_MEM in case request cannot be processed.
bogdanm 0:eff01767de02 188 *
bogdanm 0:eff01767de02 189 * @warning No copy of the data is made, and hence memory provided for data source to be written
bogdanm 0:eff01767de02 190 * to flash cannot be freed or reused by the application until this procedure
bogdanm 0:eff01767de02 191 * is complete. End of this procedure is notified to the application using the
bogdanm 0:eff01767de02 192 * notification callback registered by the application.
bogdanm 0:eff01767de02 193 */
bogdanm 0:eff01767de02 194 uint32_t pstorage_store(pstorage_handle_t * p_dest,
bogdanm 0:eff01767de02 195 uint8_t * p_src,
bogdanm 0:eff01767de02 196 pstorage_size_t size,
bogdanm 0:eff01767de02 197 pstorage_size_t offset);
bogdanm 0:eff01767de02 198
Rohit Grover 37:c29c330d942c 199 /**@brief Routine to update persistently stored data of length 'size' contained in 'p_src' address
Rohit Grover 37:c29c330d942c 200 * in storage module at 'p_dest' address.
Rohit Grover 37:c29c330d942c 201 *
Rohit Grover 37:c29c330d942c 202 * @param[in] p_dest Destination address where data is to be updated.
Rohit Grover 37:c29c330d942c 203 * @param[in] p_src Source address containing data to be stored. API assumes this to be resident
Rohit Grover 37:c29c330d942c 204 * memory and no intermediate copy of data is made by the API.
Rohit Grover 37:c29c330d942c 205 * @param[in] size Size of data to be stored expressed in bytes. Should be word aligned.
Rohit Grover 37:c29c330d942c 206 * @param[in] offset Offset in bytes to be applied when writing to the block.
Rohit Grover 37:c29c330d942c 207 * For example, if within a block of 100 bytes, application wishes to
Rohit Grover 37:c29c330d942c 208 * write 20 bytes at offset of 12, then this field should be set to 12.
Rohit Grover 37:c29c330d942c 209 * Should be word aligned.
Rohit Grover 37:c29c330d942c 210 *
Rohit Grover 37:c29c330d942c 211 * @retval NRF_SUCCESS on success, else an error code indicating reason for failure.
Rohit Grover 37:c29c330d942c 212 * @retval NRF_ERROR_INVALID_STATE is returned is API is called without module initialization.
Rohit Grover 37:c29c330d942c 213 * @retval NRF_ERROR_NULL if NULL parameter has been passed.
Rohit Grover 37:c29c330d942c 214 * @retval NRF_ERROR_INVALID_PARAM if invalid parameters are passed to the API.
Rohit Grover 37:c29c330d942c 215 * @retval NRF_ERROR_INVALID_ADDR in case data address 'p_src' is not aligned.
Rohit Grover 37:c29c330d942c 216 * @retval NRF_ERROR_NO_MEM in case request cannot be processed.
Rohit Grover 37:c29c330d942c 217 *
Rohit Grover 37:c29c330d942c 218 * @warning No copy of the data is made, and hence memory provided for data source to be written
Rohit Grover 37:c29c330d942c 219 * to flash cannot be freed or reused by the application until this procedure
Rohit Grover 37:c29c330d942c 220 * is complete. End of this procedure is notified to the application using the
Rohit Grover 37:c29c330d942c 221 * notification callback registered by the application.
Rohit Grover 37:c29c330d942c 222 */
Rohit Grover 37:c29c330d942c 223 uint32_t pstorage_update(pstorage_handle_t * p_dest,
Rohit Grover 37:c29c330d942c 224 uint8_t * p_src,
Rohit Grover 37:c29c330d942c 225 pstorage_size_t size,
Rohit Grover 37:c29c330d942c 226 pstorage_size_t offset);
bogdanm 0:eff01767de02 227
bogdanm 0:eff01767de02 228 /**@brief Routine to load persistently stored data of length 'size' from 'p_src' address
bogdanm 0:eff01767de02 229 * to 'p_dest' address; Equivalent to Storage Read.
bogdanm 0:eff01767de02 230 *
bogdanm 0:eff01767de02 231 * @param[in] p_dest Destination address where persistently stored data is to be loaded.
bogdanm 0:eff01767de02 232 * @param[in] p_src Source from where data is to be loaded from persistent memory.
bogdanm 0:eff01767de02 233 * @param[in] size Size of data to be loaded from persistent memory expressed in bytes.
bogdanm 0:eff01767de02 234 * Should be word aligned.
bogdanm 0:eff01767de02 235 * @param[in] offset Offset in bytes to be applied when loading from the block.
bogdanm 0:eff01767de02 236 * For example, if within a block of 100 bytes, application wishes to
bogdanm 0:eff01767de02 237 * load 20 bytes from offset of 12, then this field should be set to 12.
bogdanm 0:eff01767de02 238 * Should be word aligned.
bogdanm 0:eff01767de02 239 *
Rohit Grover 37:c29c330d942c 240 * @retval NRF_SUCCESS on success, else an error code indicating reason for failure.
bogdanm 0:eff01767de02 241 * @retval NRF_ERROR_INVALID_STATE is returned is API is called without module initialization.
Rohit Grover 37:c29c330d942c 242 * @retval NRF_ERROR_NULL if NULL parameter has been passed.
bogdanm 0:eff01767de02 243 * @retval NRF_ERROR_INVALID_PARAM if invalid parameters are passed to the API.
Rohit Grover 37:c29c330d942c 244 * @retval NRF_ERROR_INVALID_ADDR in case data address 'p_dst' is not aligned.
Rohit Grover 37:c29c330d942c 245 * @retval NRF_ERROR_NO_MEM in case request cannot be processed.
bogdanm 0:eff01767de02 246 */
bogdanm 0:eff01767de02 247 uint32_t pstorage_load(uint8_t * p_dest,
bogdanm 0:eff01767de02 248 pstorage_handle_t * p_src,
bogdanm 0:eff01767de02 249 pstorage_size_t size,
bogdanm 0:eff01767de02 250 pstorage_size_t offset);
bogdanm 0:eff01767de02 251
bogdanm 0:eff01767de02 252 /**@brief Routine to clear data in persistent memory.
bogdanm 0:eff01767de02 253 *
bogdanm 0:eff01767de02 254 * @param[in] p_base_id Base block identifier in persistent memory that needs to cleared;
bogdanm 0:eff01767de02 255 * Equivalent to an Erase Operation.
bogdanm 0:eff01767de02 256 *
bogdanm 0:eff01767de02 257 * @param[in] size Size of data to be cleared from persistent memory expressed in bytes.
Rohit Grover 37:c29c330d942c 258 * This parameter is to provision for clearing of certain blocks
Rohit Grover 37:c29c330d942c 259 * of memory, or all memory blocks in a registered module. If the total size
Rohit Grover 37:c29c330d942c 260 * of the application module is used (blocks * block size) in combination with
Rohit Grover 37:c29c330d942c 261 * the identifier for the first block in the module, all blocks in the
Rohit Grover 37:c29c330d942c 262 * module will be erased.
bogdanm 0:eff01767de02 263 *
Rohit Grover 37:c29c330d942c 264 * @retval NRF_SUCCESS on success, else an error code indicating reason for failure.
bogdanm 0:eff01767de02 265 * @retval NRF_ERROR_INVALID_STATE is returned is API is called without module initialization.
Rohit Grover 37:c29c330d942c 266 * @retval NRF_ERROR_NULL if NULL parameter has been passed.
bogdanm 0:eff01767de02 267 * @retval NRF_ERROR_INVALID_PARAM if invalid parameters are passed to the API.
Rohit Grover 37:c29c330d942c 268 * @retval NRF_ERROR_INVALID_ADDR in case data address 'p_dst' is not aligned.
Rohit Grover 37:c29c330d942c 269 * @retval NRF_ERROR_NO_MEM in case request cannot be processed.
bogdanm 0:eff01767de02 270 *
bogdanm 0:eff01767de02 271 * @note Clear operations may take time. This API however, does not block until the clear
bogdanm 0:eff01767de02 272 * procedure is complete. Application is notified of procedure completion using
bogdanm 0:eff01767de02 273 * notification callback registered by the application. 'result' parameter of the
bogdanm 0:eff01767de02 274 * callback suggests if the procedure was successful or not.
bogdanm 0:eff01767de02 275 */
bogdanm 0:eff01767de02 276 uint32_t pstorage_clear(pstorage_handle_t * p_base_id, pstorage_size_t size);
bogdanm 0:eff01767de02 277
Rohit Grover 37:c29c330d942c 278 /**
Rohit Grover 37:c29c330d942c 279 * @brief API to get status of number of pending operations with the module.
Rohit Grover 37:c29c330d942c 280 *
Rohit Grover 37:c29c330d942c 281 * @param[out] p_count Number of storage operations pending with the module, if 0,
Rohit Grover 37:c29c330d942c 282 * there are no outstanding requests.
Rohit Grover 37:c29c330d942c 283 *
Rohit Grover 37:c29c330d942c 284 * @retval NRF_SUCCESS on success, else an error code indicating reason for failure.
Rohit Grover 37:c29c330d942c 285 * @retval NRF_ERROR_INVALID_STATE is returned is API is called without module initialization.
Rohit Grover 37:c29c330d942c 286 * @retval NRF_ERROR_NULL if NULL parameter has been passed.
Rohit Grover 37:c29c330d942c 287 */
Rohit Grover 37:c29c330d942c 288 uint32_t pstorage_access_status_get(uint32_t * p_count);
Rohit Grover 37:c29c330d942c 289
bogdanm 0:eff01767de02 290 #ifdef PSTORAGE_RAW_MODE_ENABLE
bogdanm 0:eff01767de02 291
bogdanm 0:eff01767de02 292 /**@brief Function for registering with persistent storage interface.
bogdanm 0:eff01767de02 293 *
bogdanm 0:eff01767de02 294 * @param[in] p_module_param Module registration param.
Rohit Grover 37:c29c330d942c 295 * @param[out] p_block_id Block identifier to identify persistent memory blocks in case
Rohit Grover 37:c29c330d942c 296 * registration succeeds. Application is expected to use the block ids
Rohit Grover 37:c29c330d942c 297 * for subsequent operations on requested persistent memory.
bogdanm 0:eff01767de02 298 * In case more than one memory blocks are requested, the identifier provided here is
bogdanm 0:eff01767de02 299 * the base identifier for the first block and to identify subsequent block,
bogdanm 0:eff01767de02 300 * application shall use \@ref pstorage_block_identifier_get with this base identifier
bogdanm 0:eff01767de02 301 * and block number. Therefore if 10 blocks of size 64 are requested and application
bogdanm 0:eff01767de02 302 * wishes to store memory in 6th block, it shall use
bogdanm 0:eff01767de02 303 * \@ref pstorage_block_identifier_get with based id and provide a block number of 5.
bogdanm 0:eff01767de02 304 * This way application is only expected to remember the base block identifier.
bogdanm 0:eff01767de02 305 *
Rohit Grover 37:c29c330d942c 306 * @retval NRF_SUCCESS on success, else an error code indicating reason for failure.
bogdanm 0:eff01767de02 307 * @retval NRF_ERROR_INVALID_STATE is returned is API is called without module initialization.
Rohit Grover 37:c29c330d942c 308 * @retval NRF_ERROR_NULL if NULL parameter has been passed.
bogdanm 0:eff01767de02 309 * @retval NRF_ERROR_INVALID_PARAM if invalid parameters are passed to the API.
Rohit Grover 37:c29c330d942c 310 * @retval NRF_ERROR_NO_MEM in case no more registrations can be supported.
bogdanm 0:eff01767de02 311 */
bogdanm 0:eff01767de02 312 uint32_t pstorage_raw_register(pstorage_module_param_t * p_module_param,
bogdanm 0:eff01767de02 313 pstorage_handle_t * p_block_id);
bogdanm 0:eff01767de02 314
bogdanm 0:eff01767de02 315 /**@brief Raw mode function for persistently storing data of length 'size' contained in 'p_src'
bogdanm 0:eff01767de02 316 * address in storage module at 'p_dest' address; Equivalent to Storage Write.
bogdanm 0:eff01767de02 317 *
bogdanm 0:eff01767de02 318 * @param[in] p_dest Destination address where data is to be stored persistently.
bogdanm 0:eff01767de02 319 * @param[in] p_src Source address containing data to be stored. API assumes this to be resident
bogdanm 0:eff01767de02 320 * memory and no intermediate copy of data is made by the API.
bogdanm 0:eff01767de02 321 * @param[in] size Size of data to be stored expressed in bytes. Should be word aligned.
Rohit Grover 37:c29c330d942c 322 * @param[in] offset Offset in bytes to be applied when writing to the block.
bogdanm 0:eff01767de02 323 * For example, if within a block of 100 bytes, application wishes to
bogdanm 0:eff01767de02 324 * write 20 bytes at offset of 12, then this field should be set to 12.
bogdanm 0:eff01767de02 325 * Should be word aligned.
bogdanm 0:eff01767de02 326 *
Rohit Grover 37:c29c330d942c 327 * @retval NRF_SUCCESS on success, else an error code indicating reason for failure.
bogdanm 0:eff01767de02 328 * @retval NRF_ERROR_INVALID_STATE is returned is API is called without module initialization.
Rohit Grover 37:c29c330d942c 329 * @retval NRF_ERROR_NULL if NULL parameter has been passed.
bogdanm 0:eff01767de02 330 * @retval NRF_ERROR_INVALID_PARAM if invalid parameters are passed to the API.
Rohit Grover 37:c29c330d942c 331 * @retval NRF_ERROR_INVALID_ADDR in case data address 'p_src' is not aligned.
Rohit Grover 37:c29c330d942c 332 * @retval NRF_ERROR_NO_MEM in case request cannot be processed.
bogdanm 0:eff01767de02 333 *
bogdanm 0:eff01767de02 334 * @warning No copy of the data is made, and hence memory provided for data source to be written
bogdanm 0:eff01767de02 335 * to flash cannot be freed or reused by the application until this procedure
bogdanm 0:eff01767de02 336 * is complete. End of this procedure is notified to the application using the
bogdanm 0:eff01767de02 337 * notification callback registered by the application.
bogdanm 0:eff01767de02 338 */
bogdanm 0:eff01767de02 339 uint32_t pstorage_raw_store(pstorage_handle_t * p_dest,
bogdanm 0:eff01767de02 340 uint8_t * p_src,
bogdanm 0:eff01767de02 341 pstorage_size_t size,
bogdanm 0:eff01767de02 342 pstorage_size_t offset);
bogdanm 0:eff01767de02 343
bogdanm 0:eff01767de02 344 /**@brief Function for clearing data in persistent memory in raw mode.
bogdanm 0:eff01767de02 345 *
Rohit Grover 37:c29c330d942c 346 * @param[in] p_dest Base block identifier in persistent memory that needs to cleared;
Rohit Grover 37:c29c330d942c 347 * Equivalent to an Erase Operation.
Rohit Grover 37:c29c330d942c 348 * @param[in] size Size of data to be cleared from persistent memory expressed in bytes.
Rohit Grover 37:c29c330d942c 349 * This is currently unused. And a clear would mean clearing all blocks,
Rohit Grover 37:c29c330d942c 350 * however, this parameter is to provision for clearing of certain blocks
Rohit Grover 37:c29c330d942c 351 * of memory only and not all if need be.
bogdanm 0:eff01767de02 352 *
Rohit Grover 37:c29c330d942c 353 * @retval NRF_SUCCESS on success, else an error code indicating reason for failure.
bogdanm 0:eff01767de02 354 * @retval NRF_ERROR_INVALID_STATE is returned is API is called without module initialization.
Rohit Grover 37:c29c330d942c 355 * @retval NRF_ERROR_NULL if NULL parameter has been passed.
bogdanm 0:eff01767de02 356 * @retval NRF_ERROR_INVALID_PARAM if invalid parameters are passed to the API.
Rohit Grover 37:c29c330d942c 357 * @retval NRF_ERROR_NO_MEM in case request cannot be processed.
bogdanm 0:eff01767de02 358 *
bogdanm 0:eff01767de02 359 * @note Clear operations may take time. This API however, does not block until the clear
bogdanm 0:eff01767de02 360 * procedure is complete. Application is notified of procedure completion using
bogdanm 0:eff01767de02 361 * notification callback registered by the application. 'result' parameter of the
bogdanm 0:eff01767de02 362 * callback suggests if the procedure was successful or not.
bogdanm 0:eff01767de02 363 */
bogdanm 0:eff01767de02 364 uint32_t pstorage_raw_clear(pstorage_handle_t * p_dest, pstorage_size_t size);
bogdanm 0:eff01767de02 365
bogdanm 0:eff01767de02 366 #endif // PSTORAGE_RAW_MODE_ENABLE
bogdanm 0:eff01767de02 367
bogdanm 0:eff01767de02 368 /**@} */
bogdanm 0:eff01767de02 369 /**@} */
bogdanm 0:eff01767de02 370
bogdanm 0:eff01767de02 371 #endif // PSTORAGE_H__
bogdanm 0:eff01767de02 372