iOSのBLEコントローラアプリ「RCBController」と接続し、コントローラの操作を取得するサンプルプログラムです。 mbed HRM1017で動作を確認しています。 2014.08.20時点でのBLEライブラリに対応しました。

Dependencies:   BLE_API mbed

Fork of BLE_RCBController by Junichi Katsu

Committer:
jksoft
Date:
Wed Aug 20 13:41:01 2014 +0000
Revision:
4:ebda47d22091
Parent:
nRF51822/nordic/nrf-sdk/app_common/pstorage.h@1:48f6e08a3ac2
?????????

Who changed what in which revision?

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