SG RFID nRF51822 fork

Fork of nRF51822 by Nordic Semiconductor

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers pstorage_platform.h Source File

pstorage_platform.h

00001 /* Copyright (c)  2013 Nordic Semiconductor. All Rights Reserved.
00002  *
00003  * The information contained herein is property of Nordic Semiconductor ASA.
00004  * Terms and conditions of usage are described in detail in NORDIC
00005  * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
00006  *
00007  * Licensees are granted free, non-transferable use of the information. NO
00008  * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
00009  * the file.
00010  *
00011  */
00012 
00013  /** @cond To make doxygen skip this file */
00014 
00015 /** @file
00016  *  This header contains defines with respect persistent storage that are specific to
00017  *  persistent storage implementation and application use case.
00018  */
00019 #ifndef PSTORAGE_PL_H__
00020 #define PSTORAGE_PL_H__
00021 
00022 #include <stdint.h>
00023 
00024 #ifdef __cplusplus
00025 extern "C" {
00026 #endif // #ifdef __cplusplus
00027 
00028 #define PSTORAGE_FLASH_PAGE_SIZE    ((uint16_t)NRF_FICR->CODEPAGESIZE)   /**< Size of one flash page. */
00029 #define PSTORAGE_FLASH_EMPTY_MASK    0xFFFFFFFF                          /**< Bit mask that defines an empty address in flash. */
00030 
00031 #define PSTORAGE_FLASH_PAGE_END                                     \
00032         ((NRF_UICR->BOOTLOADERADDR != PSTORAGE_FLASH_EMPTY_MASK)    \
00033         ? (NRF_UICR->BOOTLOADERADDR / PSTORAGE_FLASH_PAGE_SIZE)     \
00034         : NRF_FICR->CODESIZE)
00035 
00036 
00037 #define PSTORAGE_MAX_APPLICATIONS   1                                                           /**< Maximum number of applications that can be registered with the module, configurable based on system requirements. */
00038 #define PSTORAGE_MIN_BLOCK_SIZE     0x0010                                                      /**< Minimum size of block that can be registered with the module. Should be configured based on system requirements, recommendation is not have this value to be at least size of word. */
00039 
00040 #define PSTORAGE_DATA_START_ADDR    ((PSTORAGE_FLASH_PAGE_END - PSTORAGE_MAX_APPLICATIONS - 1) \
00041                                     * PSTORAGE_FLASH_PAGE_SIZE)                                 /**< Start address for persistent data, configurable according to system requirements. */
00042 #define PSTORAGE_DATA_END_ADDR      ((PSTORAGE_FLASH_PAGE_END - 1) * PSTORAGE_FLASH_PAGE_SIZE)  /**< End address for persistent data, configurable according to system requirements. */
00043 #define PSTORAGE_SWAP_ADDR          PSTORAGE_DATA_END_ADDR                                      /**< Top-most page is used as swap area for clear and update. */
00044 
00045 #define PSTORAGE_MAX_BLOCK_SIZE     PSTORAGE_FLASH_PAGE_SIZE                                    /**< Maximum size of block that can be registered with the module. Should be configured based on system requirements. And should be greater than or equal to the minimum size. */
00046 #define PSTORAGE_CMD_QUEUE_SIZE     10                                                          /**< Maximum number of flash access commands that can be maintained by the module for all applications. Configurable. */
00047 
00048 
00049 /** Abstracts persistently memory block identifier. */
00050 typedef uint32_t pstorage_block_t;
00051 
00052 typedef struct
00053 {
00054     uint32_t            module_id;      /**< Module ID.*/
00055     pstorage_block_t    block_id;       /**< Block ID.*/
00056 } pstorage_handle_t;
00057 
00058 typedef uint16_t pstorage_size_t;      /** Size of length and offset fields. */
00059 
00060 /**@brief Handles Flash Access Result Events. To be called in the system event dispatcher of the application. */
00061 void pstorage_sys_event_handler (uint32_t sys_evt);
00062 
00063 #ifdef __cplusplus
00064 }
00065 #endif // #ifdef __cplusplus
00066 
00067 #endif // PSTORAGE_PL_H__
00068 
00069 /** @} */
00070 /** @endcond */