nochanges

Dependents:   BLE_Acceleration_Statejudging

Fork of nRF51822 by Nordic Semiconductor

Committer:
Rohit Grover
Date:
Mon Sep 08 17:21:46 2014 +0100
Revision:
65:98215c4f3a25
Parent:
48:895748db3357
Child:
100:422b051b7151
Release 0.1.3

Update to v6.1.0 of Nordic's SDK.

Bugfixes
~~~~~~~~

- Handle all valid disconnection reasons.

Compatible with Release 0.1.1 of the BLE_API.

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