mbed library

Dependents:   Printf

Fork of mbed by mbed official

Committer:
bogdanm
Date:
Fri Sep 12 16:41:52 2014 +0100
Revision:
89:552587b429a1
Release 89 of the mbed library

Main changes:

- low power optimizations for Nordic targets
- code structure changes for Freescale K64F targets
- bug fixes in various backends

Who changed what in which revision?

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