Nordic stack and drivers for the mbed BLE API

Dependents:   BLE_Health_Thermometer2

Fork of nRF51822 by Nordic Semiconductor

Committer:
Rohit Grover
Date:
Mon Jul 21 08:28:53 2014 +0100
Revision:
48:895748db3357
Parent:
37:c29c330d942c
add __cplusplus guard to pstorage.h

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 48:895748db3357 63 * success or failure of a flash operation. Therefore, for any operations, application
Rohit Grover 48:895748db3357 64 * can know when the procedure was complete. For store operation, since no data copy
Rohit Grover 48:895748db3357 65 * is made, receiving a success or failure notification, indicated by the reason
Rohit Grover 48:895748db3357 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 48:895748db3357 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 48:895748db3357 73 * @param[in] p_data Identifies the application data pointer. In case of store operation, this
Rohit Grover 48:895748db3357 74 * points to the resident source of application memory that application can now
Rohit Grover 48:895748db3357 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 48:895748db3357 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 48:895748db3357 123 * @param[out] p_block_id Block identifier to identify persistent memory blocks in case
Rohit Grover 48:895748db3357 124 * registration succeeds. Application is expected to use the block ids
Rohit Grover 48:895748db3357 125 * for subsequent operations on requested persistent memory. Maximum
Rohit Grover 48:895748db3357 126 * registrations permitted is determined by configuration parameter
Rohit Grover 48:895748db3357 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 37:c29c330d942c 136 * @retval NRF_SUCCESS on success, else an error code indicating reason for failure.
bogdanm 0:eff01767de02 137 * @retval NRF_ERROR_INVALID_STATE is returned is API is called without module initialization.
Rohit Grover 37:c29c330d942c 138 * @retval NRF_ERROR_NULL if NULL parameter has been passed.
bogdanm 0:eff01767de02 139 * @retval NRF_ERROR_INVALID_PARAM if invalid parameters are passed to the API.
Rohit Grover 37:c29c330d942c 140 * @retval NRF_ERROR_NO_MEM in case no more registrations can be supported.
bogdanm 0:eff01767de02 141 */
bogdanm 0:eff01767de02 142 uint32_t pstorage_register(pstorage_module_param_t * p_module_param,
Rohit Grover 37:c29c330d942c 143 pstorage_handle_t * p_block_id);
bogdanm 0:eff01767de02 144
bogdanm 0:eff01767de02 145
bogdanm 0:eff01767de02 146 /**
bogdanm 0:eff01767de02 147 * @brief Function to get block id with reference to base block identifier provided at time of
bogdanm 0:eff01767de02 148 * registration.
bogdanm 0:eff01767de02 149 *
bogdanm 0:eff01767de02 150 * @details Function to get block id with reference to base block identifier provided at time of
bogdanm 0:eff01767de02 151 * registration.
bogdanm 0:eff01767de02 152 * In case more than one memory blocks were requested when registering, the identifier
bogdanm 0:eff01767de02 153 * provided here is the base identifier for the first block and to identify subsequent
bogdanm 0:eff01767de02 154 * block, application shall use this routine to get block identifier providing input as
bogdanm 0:eff01767de02 155 * base identifier and block number. Therefore if 10 blocks of size 64 are requested and
bogdanm 0:eff01767de02 156 * application wishes to store memory in 6th block, it shall use
bogdanm 0:eff01767de02 157 * \@ref pstorage_block_identifier_get with based id and provide a block number of 5.
bogdanm 0:eff01767de02 158 * This way application is only expected to remember the base block identifier.
bogdanm 0:eff01767de02 159 *
Rohit Grover 37:c29c330d942c 160 * @param[in] p_base_id Base block id received at the time of registration.
Rohit Grover 37:c29c330d942c 161 * @param[in] block_num Block Number, with first block numbered zero.
bogdanm 0:eff01767de02 162 * @param[out] p_block_id Block identifier for the block number requested in case the API succeeds.
bogdanm 0:eff01767de02 163 *
Rohit Grover 37:c29c330d942c 164 * @retval NRF_SUCCESS on success, else an error code indicating reason for failure.
bogdanm 0:eff01767de02 165 * @retval NRF_ERROR_INVALID_STATE is returned is API is called without module initialization.
Rohit Grover 37:c29c330d942c 166 * @retval NRF_ERROR_NULL if NULL parameter has been passed.
bogdanm 0:eff01767de02 167 * @retval NRF_ERROR_INVALID_PARAM if invalid parameters are passed to the API.
bogdanm 0:eff01767de02 168 */
bogdanm 0:eff01767de02 169 uint32_t pstorage_block_identifier_get(pstorage_handle_t * p_base_id,
bogdanm 0:eff01767de02 170 pstorage_size_t block_num,
bogdanm 0:eff01767de02 171 pstorage_handle_t * p_block_id);
bogdanm 0:eff01767de02 172
bogdanm 0:eff01767de02 173
bogdanm 0:eff01767de02 174 /**@brief Routine to persistently store data of length 'size' contained in 'p_src' address
bogdanm 0:eff01767de02 175 * in storage module at 'p_dest' address; Equivalent to Storage Write.
bogdanm 0:eff01767de02 176 *
bogdanm 0:eff01767de02 177 * @param[in] p_dest Destination address where data is to be stored persistently.
bogdanm 0:eff01767de02 178 * @param[in] p_src Source address containing data to be stored. API assumes this to be resident
bogdanm 0:eff01767de02 179 * memory and no intermediate copy of data is made by the API.
bogdanm 0:eff01767de02 180 * @param[in] size Size of data to be stored expressed in bytes. Should be word aligned.
bogdanm 0:eff01767de02 181 * @param[in] offset Offset in bytes to be applied when writing to the block.
bogdanm 0:eff01767de02 182 * For example, if within a block of 100 bytes, application wishes to
bogdanm 0:eff01767de02 183 * write 20 bytes at offset of 12, then this field should be set to 12.
bogdanm 0:eff01767de02 184 * Should be word aligned.
bogdanm 0:eff01767de02 185 *
Rohit Grover 37:c29c330d942c 186 * @retval NRF_SUCCESS on success, else an error code indicating reason for failure.
bogdanm 0:eff01767de02 187 * @retval NRF_ERROR_INVALID_STATE is returned is API is called without module initialization.
Rohit Grover 37:c29c330d942c 188 * @retval NRF_ERROR_NULL if NULL parameter has been passed.
bogdanm 0:eff01767de02 189 * @retval NRF_ERROR_INVALID_PARAM if invalid parameters are passed to the API.
Rohit Grover 37:c29c330d942c 190 * @retval NRF_ERROR_INVALID_ADDR in case data address 'p_src' is not aligned.
Rohit Grover 37:c29c330d942c 191 * @retval NRF_ERROR_NO_MEM in case request cannot be processed.
bogdanm 0:eff01767de02 192 *
bogdanm 0:eff01767de02 193 * @warning No copy of the data is made, and hence memory provided for data source to be written
bogdanm 0:eff01767de02 194 * to flash cannot be freed or reused by the application until this procedure
bogdanm 0:eff01767de02 195 * is complete. End of this procedure is notified to the application using the
bogdanm 0:eff01767de02 196 * notification callback registered by the application.
bogdanm 0:eff01767de02 197 */
bogdanm 0:eff01767de02 198 uint32_t pstorage_store(pstorage_handle_t * p_dest,
bogdanm 0:eff01767de02 199 uint8_t * p_src,
bogdanm 0:eff01767de02 200 pstorage_size_t size,
bogdanm 0:eff01767de02 201 pstorage_size_t offset);
bogdanm 0:eff01767de02 202
Rohit Grover 37:c29c330d942c 203 /**@brief Routine to update persistently stored data of length 'size' contained in 'p_src' address
Rohit Grover 37:c29c330d942c 204 * in storage module at 'p_dest' address.
Rohit Grover 37:c29c330d942c 205 *
Rohit Grover 37:c29c330d942c 206 * @param[in] p_dest Destination address where data is to be updated.
Rohit Grover 37:c29c330d942c 207 * @param[in] p_src Source address containing data to be stored. API assumes this to be resident
Rohit Grover 37:c29c330d942c 208 * memory and no intermediate copy of data is made by the API.
Rohit Grover 37:c29c330d942c 209 * @param[in] size Size of data to be stored expressed in bytes. Should be word aligned.
Rohit Grover 37:c29c330d942c 210 * @param[in] offset Offset in bytes to be applied when writing to the block.
Rohit Grover 37:c29c330d942c 211 * For example, if within a block of 100 bytes, application wishes to
Rohit Grover 37:c29c330d942c 212 * write 20 bytes at offset of 12, then this field should be set to 12.
Rohit Grover 37:c29c330d942c 213 * Should be word aligned.
Rohit Grover 37:c29c330d942c 214 *
Rohit Grover 37:c29c330d942c 215 * @retval NRF_SUCCESS on success, else an error code indicating reason for failure.
Rohit Grover 37:c29c330d942c 216 * @retval NRF_ERROR_INVALID_STATE is returned is API is called without module initialization.
Rohit Grover 37:c29c330d942c 217 * @retval NRF_ERROR_NULL if NULL parameter has been passed.
Rohit Grover 37:c29c330d942c 218 * @retval NRF_ERROR_INVALID_PARAM if invalid parameters are passed to the API.
Rohit Grover 37:c29c330d942c 219 * @retval NRF_ERROR_INVALID_ADDR in case data address 'p_src' is not aligned.
Rohit Grover 37:c29c330d942c 220 * @retval NRF_ERROR_NO_MEM in case request cannot be processed.
Rohit Grover 37:c29c330d942c 221 *
Rohit Grover 37:c29c330d942c 222 * @warning No copy of the data is made, and hence memory provided for data source to be written
Rohit Grover 37:c29c330d942c 223 * to flash cannot be freed or reused by the application until this procedure
Rohit Grover 37:c29c330d942c 224 * is complete. End of this procedure is notified to the application using the
Rohit Grover 37:c29c330d942c 225 * notification callback registered by the application.
Rohit Grover 37:c29c330d942c 226 */
Rohit Grover 37:c29c330d942c 227 uint32_t pstorage_update(pstorage_handle_t * p_dest,
Rohit Grover 37:c29c330d942c 228 uint8_t * p_src,
Rohit Grover 37:c29c330d942c 229 pstorage_size_t size,
Rohit Grover 37:c29c330d942c 230 pstorage_size_t offset);
bogdanm 0:eff01767de02 231
bogdanm 0:eff01767de02 232 /**@brief Routine to load persistently stored data of length 'size' from 'p_src' address
bogdanm 0:eff01767de02 233 * to 'p_dest' address; Equivalent to Storage Read.
bogdanm 0:eff01767de02 234 *
bogdanm 0:eff01767de02 235 * @param[in] p_dest Destination address where persistently stored data is to be loaded.
bogdanm 0:eff01767de02 236 * @param[in] p_src Source from where data is to be loaded from persistent memory.
bogdanm 0:eff01767de02 237 * @param[in] size Size of data to be loaded from persistent memory expressed in bytes.
bogdanm 0:eff01767de02 238 * Should be word aligned.
bogdanm 0:eff01767de02 239 * @param[in] offset Offset in bytes to be applied when loading from the block.
bogdanm 0:eff01767de02 240 * For example, if within a block of 100 bytes, application wishes to
bogdanm 0:eff01767de02 241 * load 20 bytes from offset of 12, then this field should be set to 12.
bogdanm 0:eff01767de02 242 * Should be word aligned.
bogdanm 0:eff01767de02 243 *
Rohit Grover 37:c29c330d942c 244 * @retval NRF_SUCCESS on success, else an error code indicating reason for failure.
bogdanm 0:eff01767de02 245 * @retval NRF_ERROR_INVALID_STATE is returned is API is called without module initialization.
Rohit Grover 37:c29c330d942c 246 * @retval NRF_ERROR_NULL if NULL parameter has been passed.
bogdanm 0:eff01767de02 247 * @retval NRF_ERROR_INVALID_PARAM if invalid parameters are passed to the API.
Rohit Grover 37:c29c330d942c 248 * @retval NRF_ERROR_INVALID_ADDR in case data address 'p_dst' is not aligned.
Rohit Grover 37:c29c330d942c 249 * @retval NRF_ERROR_NO_MEM in case request cannot be processed.
bogdanm 0:eff01767de02 250 */
bogdanm 0:eff01767de02 251 uint32_t pstorage_load(uint8_t * p_dest,
bogdanm 0:eff01767de02 252 pstorage_handle_t * p_src,
bogdanm 0:eff01767de02 253 pstorage_size_t size,
bogdanm 0:eff01767de02 254 pstorage_size_t offset);
bogdanm 0:eff01767de02 255
bogdanm 0:eff01767de02 256 /**@brief Routine to clear data in persistent memory.
bogdanm 0:eff01767de02 257 *
bogdanm 0:eff01767de02 258 * @param[in] p_base_id Base block identifier in persistent memory that needs to cleared;
bogdanm 0:eff01767de02 259 * Equivalent to an Erase Operation.
bogdanm 0:eff01767de02 260 *
bogdanm 0:eff01767de02 261 * @param[in] size Size of data to be cleared from persistent memory expressed in bytes.
Rohit Grover 37:c29c330d942c 262 * This parameter is to provision for clearing of certain blocks
Rohit Grover 48:895748db3357 263 * of memory, or all memory blocks in a registered module. If the total size
Rohit Grover 37:c29c330d942c 264 * of the application module is used (blocks * block size) in combination with
Rohit Grover 48:895748db3357 265 * the identifier for the first block in the module, all blocks in the
Rohit Grover 37:c29c330d942c 266 * module will be erased.
bogdanm 0:eff01767de02 267 *
Rohit Grover 37:c29c330d942c 268 * @retval NRF_SUCCESS on success, else an error code indicating reason for failure.
bogdanm 0:eff01767de02 269 * @retval NRF_ERROR_INVALID_STATE is returned is API is called without module initialization.
Rohit Grover 37:c29c330d942c 270 * @retval NRF_ERROR_NULL if NULL parameter has been passed.
bogdanm 0:eff01767de02 271 * @retval NRF_ERROR_INVALID_PARAM if invalid parameters are passed to the API.
Rohit Grover 37:c29c330d942c 272 * @retval NRF_ERROR_INVALID_ADDR in case data address 'p_dst' is not aligned.
Rohit Grover 37:c29c330d942c 273 * @retval NRF_ERROR_NO_MEM in case request cannot be processed.
bogdanm 0:eff01767de02 274 *
bogdanm 0:eff01767de02 275 * @note Clear operations may take time. This API however, does not block until the clear
bogdanm 0:eff01767de02 276 * procedure is complete. Application is notified of procedure completion using
bogdanm 0:eff01767de02 277 * notification callback registered by the application. 'result' parameter of the
bogdanm 0:eff01767de02 278 * callback suggests if the procedure was successful or not.
bogdanm 0:eff01767de02 279 */
bogdanm 0:eff01767de02 280 uint32_t pstorage_clear(pstorage_handle_t * p_base_id, pstorage_size_t size);
bogdanm 0:eff01767de02 281
Rohit Grover 37:c29c330d942c 282 /**
Rohit Grover 37:c29c330d942c 283 * @brief API to get status of number of pending operations with the module.
Rohit Grover 37:c29c330d942c 284 *
Rohit Grover 37:c29c330d942c 285 * @param[out] p_count Number of storage operations pending with the module, if 0,
Rohit Grover 37:c29c330d942c 286 * there are no outstanding requests.
Rohit Grover 37:c29c330d942c 287 *
Rohit Grover 37:c29c330d942c 288 * @retval NRF_SUCCESS on success, else an error code indicating reason for failure.
Rohit Grover 37:c29c330d942c 289 * @retval NRF_ERROR_INVALID_STATE is returned is API is called without module initialization.
Rohit Grover 37:c29c330d942c 290 * @retval NRF_ERROR_NULL if NULL parameter has been passed.
Rohit Grover 37:c29c330d942c 291 */
Rohit Grover 37:c29c330d942c 292 uint32_t pstorage_access_status_get(uint32_t * p_count);
Rohit Grover 37:c29c330d942c 293
bogdanm 0:eff01767de02 294 #ifdef PSTORAGE_RAW_MODE_ENABLE
bogdanm 0:eff01767de02 295
bogdanm 0:eff01767de02 296 /**@brief Function for registering with persistent storage interface.
bogdanm 0:eff01767de02 297 *
bogdanm 0:eff01767de02 298 * @param[in] p_module_param Module registration param.
Rohit Grover 48:895748db3357 299 * @param[out] p_block_id Block identifier to identify persistent memory blocks in case
Rohit Grover 48:895748db3357 300 * registration succeeds. Application is expected to use the block ids
Rohit Grover 37:c29c330d942c 301 * for subsequent operations on requested persistent memory.
bogdanm 0:eff01767de02 302 * In case more than one memory blocks are requested, the identifier provided here is
bogdanm 0:eff01767de02 303 * the base identifier for the first block and to identify subsequent block,
bogdanm 0:eff01767de02 304 * application shall use \@ref pstorage_block_identifier_get with this base identifier
bogdanm 0:eff01767de02 305 * and block number. Therefore if 10 blocks of size 64 are requested and application
bogdanm 0:eff01767de02 306 * wishes to store memory in 6th block, it shall use
bogdanm 0:eff01767de02 307 * \@ref pstorage_block_identifier_get with based id and provide a block number of 5.
bogdanm 0:eff01767de02 308 * This way application is only expected to remember the base block identifier.
bogdanm 0:eff01767de02 309 *
Rohit Grover 37:c29c330d942c 310 * @retval NRF_SUCCESS on success, else an error code indicating reason for failure.
bogdanm 0:eff01767de02 311 * @retval NRF_ERROR_INVALID_STATE is returned is API is called without module initialization.
Rohit Grover 37:c29c330d942c 312 * @retval NRF_ERROR_NULL if NULL parameter has been passed.
bogdanm 0:eff01767de02 313 * @retval NRF_ERROR_INVALID_PARAM if invalid parameters are passed to the API.
Rohit Grover 37:c29c330d942c 314 * @retval NRF_ERROR_NO_MEM in case no more registrations can be supported.
bogdanm 0:eff01767de02 315 */
bogdanm 0:eff01767de02 316 uint32_t pstorage_raw_register(pstorage_module_param_t * p_module_param,
bogdanm 0:eff01767de02 317 pstorage_handle_t * p_block_id);
bogdanm 0:eff01767de02 318
bogdanm 0:eff01767de02 319 /**@brief Raw mode function for persistently storing data of length 'size' contained in 'p_src'
bogdanm 0:eff01767de02 320 * address in storage module at 'p_dest' address; Equivalent to Storage Write.
bogdanm 0:eff01767de02 321 *
bogdanm 0:eff01767de02 322 * @param[in] p_dest Destination address where data is to be stored persistently.
bogdanm 0:eff01767de02 323 * @param[in] p_src Source address containing data to be stored. API assumes this to be resident
bogdanm 0:eff01767de02 324 * memory and no intermediate copy of data is made by the API.
bogdanm 0:eff01767de02 325 * @param[in] size Size of data to be stored expressed in bytes. Should be word aligned.
Rohit Grover 37:c29c330d942c 326 * @param[in] offset Offset in bytes to be applied when writing to the block.
bogdanm 0:eff01767de02 327 * For example, if within a block of 100 bytes, application wishes to
bogdanm 0:eff01767de02 328 * write 20 bytes at offset of 12, then this field should be set to 12.
bogdanm 0:eff01767de02 329 * Should be word aligned.
bogdanm 0:eff01767de02 330 *
Rohit Grover 37:c29c330d942c 331 * @retval NRF_SUCCESS on success, else an error code indicating reason for failure.
bogdanm 0:eff01767de02 332 * @retval NRF_ERROR_INVALID_STATE is returned is API is called without module initialization.
Rohit Grover 37:c29c330d942c 333 * @retval NRF_ERROR_NULL if NULL parameter has been passed.
bogdanm 0:eff01767de02 334 * @retval NRF_ERROR_INVALID_PARAM if invalid parameters are passed to the API.
Rohit Grover 37:c29c330d942c 335 * @retval NRF_ERROR_INVALID_ADDR in case data address 'p_src' is not aligned.
Rohit Grover 37:c29c330d942c 336 * @retval NRF_ERROR_NO_MEM in case request cannot be processed.
bogdanm 0:eff01767de02 337 *
bogdanm 0:eff01767de02 338 * @warning No copy of the data is made, and hence memory provided for data source to be written
bogdanm 0:eff01767de02 339 * to flash cannot be freed or reused by the application until this procedure
bogdanm 0:eff01767de02 340 * is complete. End of this procedure is notified to the application using the
bogdanm 0:eff01767de02 341 * notification callback registered by the application.
bogdanm 0:eff01767de02 342 */
bogdanm 0:eff01767de02 343 uint32_t pstorage_raw_store(pstorage_handle_t * p_dest,
bogdanm 0:eff01767de02 344 uint8_t * p_src,
bogdanm 0:eff01767de02 345 pstorage_size_t size,
bogdanm 0:eff01767de02 346 pstorage_size_t offset);
bogdanm 0:eff01767de02 347
bogdanm 0:eff01767de02 348 /**@brief Function for clearing data in persistent memory in raw mode.
bogdanm 0:eff01767de02 349 *
Rohit Grover 37:c29c330d942c 350 * @param[in] p_dest Base block identifier in persistent memory that needs to cleared;
Rohit Grover 37:c29c330d942c 351 * Equivalent to an Erase Operation.
Rohit Grover 37:c29c330d942c 352 * @param[in] size Size of data to be cleared from persistent memory expressed in bytes.
Rohit Grover 37:c29c330d942c 353 * This is currently unused. And a clear would mean clearing all blocks,
Rohit Grover 37:c29c330d942c 354 * however, this parameter is to provision for clearing of certain blocks
Rohit Grover 37:c29c330d942c 355 * of memory only and not all if need be.
bogdanm 0:eff01767de02 356 *
Rohit Grover 37:c29c330d942c 357 * @retval NRF_SUCCESS on success, else an error code indicating reason for failure.
bogdanm 0:eff01767de02 358 * @retval NRF_ERROR_INVALID_STATE is returned is API is called without module initialization.
Rohit Grover 37:c29c330d942c 359 * @retval NRF_ERROR_NULL if NULL parameter has been passed.
bogdanm 0:eff01767de02 360 * @retval NRF_ERROR_INVALID_PARAM if invalid parameters are passed to the API.
Rohit Grover 37:c29c330d942c 361 * @retval NRF_ERROR_NO_MEM in case request cannot be processed.
bogdanm 0:eff01767de02 362 *
bogdanm 0:eff01767de02 363 * @note Clear operations may take time. This API however, does not block until the clear
bogdanm 0:eff01767de02 364 * procedure is complete. Application is notified of procedure completion using
bogdanm 0:eff01767de02 365 * notification callback registered by the application. 'result' parameter of the
bogdanm 0:eff01767de02 366 * callback suggests if the procedure was successful or not.
bogdanm 0:eff01767de02 367 */
bogdanm 0:eff01767de02 368 uint32_t pstorage_raw_clear(pstorage_handle_t * p_dest, pstorage_size_t size);
bogdanm 0:eff01767de02 369
bogdanm 0:eff01767de02 370 #endif // PSTORAGE_RAW_MODE_ENABLE
bogdanm 0:eff01767de02 371
Rohit Grover 48:895748db3357 372 #ifdef __cplusplus
Rohit Grover 48:895748db3357 373 }
Rohit Grover 48:895748db3357 374 #endif /* #ifdef __cplusplus */
Rohit Grover 48:895748db3357 375
Rohit Grover 48:895748db3357 376
bogdanm 0:eff01767de02 377 /**@} */
bogdanm 0:eff01767de02 378 /**@} */
bogdanm 0:eff01767de02 379
bogdanm 0:eff01767de02 380 #endif // PSTORAGE_H__
bogdanm 0:eff01767de02 381