project for nrf51822 qfab

Dependencies:   eddystone_URL mbed

Fork of eddystone_URL by vo dung

Committer:
jksoft
Date:
Wed Nov 12 02:40:34 2014 +0000
Revision:
0:76dfa9657d9d
????????

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jksoft 0:76dfa9657d9d 1 /* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved.
jksoft 0:76dfa9657d9d 2 *
jksoft 0:76dfa9657d9d 3 * The information contained herein is property of Nordic Semiconductor ASA.
jksoft 0:76dfa9657d9d 4 * Terms and conditions of usage are described in detail in NORDIC
jksoft 0:76dfa9657d9d 5 * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
jksoft 0:76dfa9657d9d 6 *
jksoft 0:76dfa9657d9d 7 * Licensees are granted free, non-transferable use of the information. NO
jksoft 0:76dfa9657d9d 8 * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
jksoft 0:76dfa9657d9d 9 * the file.
jksoft 0:76dfa9657d9d 10 *
jksoft 0:76dfa9657d9d 11 */
jksoft 0:76dfa9657d9d 12
jksoft 0:76dfa9657d9d 13 /** @cond To make doxygen skip this file */
jksoft 0:76dfa9657d9d 14
jksoft 0:76dfa9657d9d 15 /** @file
jksoft 0:76dfa9657d9d 16 * This header contains defines with respect persistent storage that are specific to
jksoft 0:76dfa9657d9d 17 * persistent storage implementation and application use case.
jksoft 0:76dfa9657d9d 18 */
jksoft 0:76dfa9657d9d 19 #ifndef PSTORAGE_PL_H__
jksoft 0:76dfa9657d9d 20 #define PSTORAGE_PL_H__
jksoft 0:76dfa9657d9d 21
jksoft 0:76dfa9657d9d 22 #include <stdint.h>
jksoft 0:76dfa9657d9d 23 #include "nordic_global.h"
jksoft 0:76dfa9657d9d 24
jksoft 0:76dfa9657d9d 25 #ifdef __cplusplus
jksoft 0:76dfa9657d9d 26 extern "C" {
jksoft 0:76dfa9657d9d 27 #endif // #ifdef __cplusplus
jksoft 0:76dfa9657d9d 28
jksoft 0:76dfa9657d9d 29 #define PSTORAGE_FLASH_PAGE_SIZE ((uint16_t)NRF_FICR->CODEPAGESIZE) /**< Size of one flash page. */
jksoft 0:76dfa9657d9d 30 #define PSTORAGE_FLASH_EMPTY_MASK 0xFFFFFFFF /**< Bit mask that defines an empty address in flash. */
jksoft 0:76dfa9657d9d 31
jksoft 0:76dfa9657d9d 32 #define PSTORAGE_FLASH_PAGE_END \
jksoft 0:76dfa9657d9d 33 ((NRF_UICR->BOOTLOADERADDR != PSTORAGE_FLASH_EMPTY_MASK) \
jksoft 0:76dfa9657d9d 34 ? (NRF_UICR->BOOTLOADERADDR / PSTORAGE_FLASH_PAGE_SIZE) \
jksoft 0:76dfa9657d9d 35 : NRF_FICR->CODESIZE)
jksoft 0:76dfa9657d9d 36
jksoft 0:76dfa9657d9d 37
jksoft 0:76dfa9657d9d 38 #define PSTORAGE_MAX_APPLICATIONS 2 /**< Maximum number of applications that can be registered with the module, configurable based on system requirements. */
jksoft 0:76dfa9657d9d 39 #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. */
jksoft 0:76dfa9657d9d 40
jksoft 0:76dfa9657d9d 41 #define PSTORAGE_DATA_START_ADDR ((PSTORAGE_FLASH_PAGE_END - PSTORAGE_MAX_APPLICATIONS) \
jksoft 0:76dfa9657d9d 42 * PSTORAGE_FLASH_PAGE_SIZE) /**< Start address for persistent data, configurable according to system requirements. */
jksoft 0:76dfa9657d9d 43 #define PSTORAGE_DATA_END_ADDR (PSTORAGE_FLASH_PAGE_END * PSTORAGE_FLASH_PAGE_SIZE) /**< End address for persistent data, configurable according to system requirements. */
jksoft 0:76dfa9657d9d 44
jksoft 0:76dfa9657d9d 45 #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. */
jksoft 0:76dfa9657d9d 46 #define PSTORAGE_CMD_QUEUE_SIZE 30 /**< Maximum number of flash access commands that can be maintained by the module for all applications. Configurable. */
jksoft 0:76dfa9657d9d 47
jksoft 0:76dfa9657d9d 48
jksoft 0:76dfa9657d9d 49 /** Abstracts persistently memory block identifier. */
jksoft 0:76dfa9657d9d 50 typedef uint32_t pstorage_block_t;
jksoft 0:76dfa9657d9d 51
jksoft 0:76dfa9657d9d 52 typedef struct
jksoft 0:76dfa9657d9d 53 {
jksoft 0:76dfa9657d9d 54 uint32_t module_id; /**< Module ID.*/
jksoft 0:76dfa9657d9d 55 pstorage_block_t block_id; /**< Block ID.*/
jksoft 0:76dfa9657d9d 56 } pstorage_handle_t;
jksoft 0:76dfa9657d9d 57
jksoft 0:76dfa9657d9d 58 typedef uint16_t pstorage_size_t; /** Size of length and offset fields. */
jksoft 0:76dfa9657d9d 59
jksoft 0:76dfa9657d9d 60 /**@brief Handles Flash Access Result Events. To be called in the system event dispatcher of the application. */
jksoft 0:76dfa9657d9d 61 void pstorage_sys_event_handler (uint32_t sys_evt);
jksoft 0:76dfa9657d9d 62
jksoft 0:76dfa9657d9d 63 #ifdef __cplusplus
jksoft 0:76dfa9657d9d 64 }
jksoft 0:76dfa9657d9d 65 #endif // #ifdef __cplusplus
jksoft 0:76dfa9657d9d 66
jksoft 0:76dfa9657d9d 67 #endif // PSTORAGE_PL_H__
jksoft 0:76dfa9657d9d 68
jksoft 0:76dfa9657d9d 69 /** @} */
jksoft 0:76dfa9657d9d 70 /** @endcond */