Nordic nrf51 sdk sources. Mirrored from https://github.com/ARMmbed/nrf51-sdk.
source/nordic_sdk/components/drivers_nrf/pstorage/config/pstorage_platform.h@28:041dac1366b2, 2016-04-07 (annotated)
- Committer:
- vcoubard
- Date:
- Thu Apr 07 17:37:56 2016 +0100
- Revision:
- 28:041dac1366b2
- Parent:
- 27:0fe148f1bca3
- Child:
- 29:286940b7ee5a
Synchronized with git rev 012b8118
Author: Liyou Zhou
Pull in files from sdk 10.0
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
vcoubard | 28:041dac1366b2 | 1 | /* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. |
vcoubard | 28:041dac1366b2 | 2 | * |
vcoubard | 28:041dac1366b2 | 3 | * The information contained herein is property of Nordic Semiconductor ASA. |
vcoubard | 28:041dac1366b2 | 4 | * Terms and conditions of usage are described in detail in NORDIC |
vcoubard | 28:041dac1366b2 | 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. |
vcoubard | 28:041dac1366b2 | 6 | * |
vcoubard | 28:041dac1366b2 | 7 | * Licensees are granted free, non-transferable use of the information. NO |
vcoubard | 28:041dac1366b2 | 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from |
vcoubard | 28:041dac1366b2 | 9 | * the file. |
vcoubard | 28:041dac1366b2 | 10 | * |
Vincent Coubard |
0:f2542974c862 | 11 | */ |
Vincent Coubard |
0:f2542974c862 | 12 | |
Vincent Coubard |
0:f2542974c862 | 13 | /** @cond To make doxygen skip this file */ |
Vincent Coubard |
0:f2542974c862 | 14 | |
Vincent Coubard |
0:f2542974c862 | 15 | /** @file |
Vincent Coubard |
0:f2542974c862 | 16 | * This header contains defines with respect persistent storage that are specific to |
Vincent Coubard |
0:f2542974c862 | 17 | * persistent storage implementation and application use case. |
Vincent Coubard |
0:f2542974c862 | 18 | */ |
Vincent Coubard |
0:f2542974c862 | 19 | #ifndef PSTORAGE_PL_H__ |
Vincent Coubard |
0:f2542974c862 | 20 | #define PSTORAGE_PL_H__ |
Vincent Coubard |
0:f2542974c862 | 21 | |
Vincent Coubard |
0:f2542974c862 | 22 | #include <stdint.h> |
vcoubard | 1:ebc0e0ef0a11 | 23 | #include "nrf.h" |
Vincent Coubard |
0:f2542974c862 | 24 | |
vcoubard | 1:ebc0e0ef0a11 | 25 | static __INLINE uint16_t pstorage_flash_page_size() |
vcoubard | 1:ebc0e0ef0a11 | 26 | { |
vcoubard | 1:ebc0e0ef0a11 | 27 | return (uint16_t)NRF_FICR->CODEPAGESIZE; |
vcoubard | 1:ebc0e0ef0a11 | 28 | } |
Vincent Coubard |
0:f2542974c862 | 29 | |
vcoubard | 1:ebc0e0ef0a11 | 30 | #define PSTORAGE_FLASH_PAGE_SIZE pstorage_flash_page_size() /**< Size of one flash page. */ |
Vincent Coubard |
0:f2542974c862 | 31 | #define PSTORAGE_FLASH_EMPTY_MASK 0xFFFFFFFF /**< Bit mask that defines an empty address in flash. */ |
Vincent Coubard |
0:f2542974c862 | 32 | |
vcoubard | 28:041dac1366b2 | 33 | #ifdef NRF51 |
vcoubard | 28:041dac1366b2 | 34 | #define BOOTLOADER_ADDRESS (NRF_UICR->BOOTLOADERADDR) |
vcoubard | 28:041dac1366b2 | 35 | #elif defined NRF52 |
vcoubard | 28:041dac1366b2 | 36 | #define BOOTLOADER_ADDRESS (PSTORAGE_FLASH_EMPTY_MASK) |
vcoubard | 28:041dac1366b2 | 37 | #endif |
vcoubard | 28:041dac1366b2 | 38 | |
vcoubard | 1:ebc0e0ef0a11 | 39 | static __INLINE uint32_t pstorage_flash_page_end() |
vcoubard | 1:ebc0e0ef0a11 | 40 | { |
vcoubard | 28:041dac1366b2 | 41 | uint32_t bootloader_addr = BOOTLOADER_ADDRESS; |
vcoubard | 1:ebc0e0ef0a11 | 42 | |
vcoubard | 1:ebc0e0ef0a11 | 43 | return ((bootloader_addr != PSTORAGE_FLASH_EMPTY_MASK) ? |
vcoubard | 1:ebc0e0ef0a11 | 44 | (bootloader_addr/ PSTORAGE_FLASH_PAGE_SIZE) : NRF_FICR->CODESIZE); |
vcoubard | 1:ebc0e0ef0a11 | 45 | } |
Vincent Coubard |
0:f2542974c862 | 46 | |
vcoubard | 1:ebc0e0ef0a11 | 47 | #define PSTORAGE_FLASH_PAGE_END pstorage_flash_page_end() |
Vincent Coubard |
0:f2542974c862 | 48 | |
vcoubard | 28:041dac1366b2 | 49 | #define PSTORAGE_NUM_OF_PAGES 1 /**< Number of flash pages allocated for the pstorage module excluding the swap page, configurable based on system requirements. */ |
Vincent Coubard |
0:f2542974c862 | 50 | #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. */ |
Vincent Coubard |
0:f2542974c862 | 51 | |
vcoubard | 28:041dac1366b2 | 52 | #define PSTORAGE_DATA_START_ADDR ((PSTORAGE_FLASH_PAGE_END - PSTORAGE_NUM_OF_PAGES - 1) \ |
Vincent Coubard |
0:f2542974c862 | 53 | * PSTORAGE_FLASH_PAGE_SIZE) /**< Start address for persistent data, configurable according to system requirements. */ |
Vincent Coubard |
0:f2542974c862 | 54 | #define PSTORAGE_DATA_END_ADDR ((PSTORAGE_FLASH_PAGE_END - 1) * PSTORAGE_FLASH_PAGE_SIZE) /**< End address for persistent data, configurable according to system requirements. */ |
Vincent Coubard |
0:f2542974c862 | 55 | #define PSTORAGE_SWAP_ADDR PSTORAGE_DATA_END_ADDR /**< Top-most page is used as swap area for clear and update. */ |
Vincent Coubard |
0:f2542974c862 | 56 | |
Vincent Coubard |
0:f2542974c862 | 57 | #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. */ |
vcoubard | 28:041dac1366b2 | 58 | #define PSTORAGE_CMD_QUEUE_SIZE 10 /**< Maximum number of flash access commands that can be maintained by the module for all applications. Configurable. */ |
Vincent Coubard |
0:f2542974c862 | 59 | |
Vincent Coubard |
0:f2542974c862 | 60 | |
Vincent Coubard |
0:f2542974c862 | 61 | /** Abstracts persistently memory block identifier. */ |
Vincent Coubard |
0:f2542974c862 | 62 | typedef uint32_t pstorage_block_t; |
Vincent Coubard |
0:f2542974c862 | 63 | |
Vincent Coubard |
0:f2542974c862 | 64 | typedef struct |
Vincent Coubard |
0:f2542974c862 | 65 | { |
Vincent Coubard |
0:f2542974c862 | 66 | uint32_t module_id; /**< Module ID.*/ |
Vincent Coubard |
0:f2542974c862 | 67 | pstorage_block_t block_id; /**< Block ID.*/ |
Vincent Coubard |
0:f2542974c862 | 68 | } pstorage_handle_t; |
Vincent Coubard |
0:f2542974c862 | 69 | |
Vincent Coubard |
0:f2542974c862 | 70 | typedef uint16_t pstorage_size_t; /** Size of length and offset fields. */ |
Vincent Coubard |
0:f2542974c862 | 71 | |
Vincent Coubard |
0:f2542974c862 | 72 | /**@brief Handles Flash Access Result Events. To be called in the system event dispatcher of the application. */ |
Vincent Coubard |
0:f2542974c862 | 73 | void pstorage_sys_event_handler (uint32_t sys_evt); |
Vincent Coubard |
0:f2542974c862 | 74 | |
Vincent Coubard |
0:f2542974c862 | 75 | #endif // PSTORAGE_PL_H__ |
Vincent Coubard |
0:f2542974c862 | 76 | |
Vincent Coubard |
0:f2542974c862 | 77 | /** @} */ |
vcoubard | 1:ebc0e0ef0a11 | 78 | /** @endcond */ |