Nordic stack and drivers for the mbed BLE API
Dependents: Sensen-classic-v8-IAQ_copy_4
Fork of nRF51822 by
TARGET_MCU_NRF51822/sdk/source/libraries/fstorage/fstorage_config.h@638:c90ae1400bf2, 2016-09-14 (annotated)
- Committer:
- Vincent Coubard
- Date:
- Wed Sep 14 14:39:43 2016 +0100
- Revision:
- 638:c90ae1400bf2
Sync with bdab10dc0f90748b6989c8b577771bb403ca6bd8 from ARMmbed/mbed-os.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Vincent Coubard |
638:c90ae1400bf2 | 1 | /* |
Vincent Coubard |
638:c90ae1400bf2 | 2 | * Copyright (c) Nordic Semiconductor ASA |
Vincent Coubard |
638:c90ae1400bf2 | 3 | * All rights reserved. |
Vincent Coubard |
638:c90ae1400bf2 | 4 | * |
Vincent Coubard |
638:c90ae1400bf2 | 5 | * Redistribution and use in source and binary forms, with or without modification, |
Vincent Coubard |
638:c90ae1400bf2 | 6 | * are permitted provided that the following conditions are met: |
Vincent Coubard |
638:c90ae1400bf2 | 7 | * |
Vincent Coubard |
638:c90ae1400bf2 | 8 | * 1. Redistributions of source code must retain the above copyright notice, this |
Vincent Coubard |
638:c90ae1400bf2 | 9 | * list of conditions and the following disclaimer. |
Vincent Coubard |
638:c90ae1400bf2 | 10 | * |
Vincent Coubard |
638:c90ae1400bf2 | 11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this |
Vincent Coubard |
638:c90ae1400bf2 | 12 | * list of conditions and the following disclaimer in the documentation and/or |
Vincent Coubard |
638:c90ae1400bf2 | 13 | * other materials provided with the distribution. |
Vincent Coubard |
638:c90ae1400bf2 | 14 | * |
Vincent Coubard |
638:c90ae1400bf2 | 15 | * 3. Neither the name of Nordic Semiconductor ASA nor the names of other |
Vincent Coubard |
638:c90ae1400bf2 | 16 | * contributors to this software may be used to endorse or promote products |
Vincent Coubard |
638:c90ae1400bf2 | 17 | * derived from this software without specific prior written permission. |
Vincent Coubard |
638:c90ae1400bf2 | 18 | * |
Vincent Coubard |
638:c90ae1400bf2 | 19 | * |
Vincent Coubard |
638:c90ae1400bf2 | 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
Vincent Coubard |
638:c90ae1400bf2 | 21 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
Vincent Coubard |
638:c90ae1400bf2 | 22 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
Vincent Coubard |
638:c90ae1400bf2 | 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR |
Vincent Coubard |
638:c90ae1400bf2 | 24 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
Vincent Coubard |
638:c90ae1400bf2 | 25 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
Vincent Coubard |
638:c90ae1400bf2 | 26 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON |
Vincent Coubard |
638:c90ae1400bf2 | 27 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
Vincent Coubard |
638:c90ae1400bf2 | 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
Vincent Coubard |
638:c90ae1400bf2 | 29 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Vincent Coubard |
638:c90ae1400bf2 | 30 | * |
Vincent Coubard |
638:c90ae1400bf2 | 31 | */ |
Vincent Coubard |
638:c90ae1400bf2 | 32 | |
Vincent Coubard |
638:c90ae1400bf2 | 33 | #ifndef FS_CONFIG_H__ |
Vincent Coubard |
638:c90ae1400bf2 | 34 | #define FS_CONFIG_H__ |
Vincent Coubard |
638:c90ae1400bf2 | 35 | |
Vincent Coubard |
638:c90ae1400bf2 | 36 | #include <stdint.h> |
Vincent Coubard |
638:c90ae1400bf2 | 37 | #include "nrf.h" |
Vincent Coubard |
638:c90ae1400bf2 | 38 | |
Vincent Coubard |
638:c90ae1400bf2 | 39 | /** |
Vincent Coubard |
638:c90ae1400bf2 | 40 | * @defgroup fstorage_config FStorage configuration |
Vincent Coubard |
638:c90ae1400bf2 | 41 | * @ingroup fstorage |
Vincent Coubard |
638:c90ae1400bf2 | 42 | * @{ |
Vincent Coubard |
638:c90ae1400bf2 | 43 | * @brief FStorage configuration. |
Vincent Coubard |
638:c90ae1400bf2 | 44 | */ |
Vincent Coubard |
638:c90ae1400bf2 | 45 | |
Vincent Coubard |
638:c90ae1400bf2 | 46 | |
Vincent Coubard |
638:c90ae1400bf2 | 47 | /**@brief Macro for max number of operations in the fs cmd queue. |
Vincent Coubard |
638:c90ae1400bf2 | 48 | */ |
Vincent Coubard |
638:c90ae1400bf2 | 49 | #define FS_CMD_QUEUE_SIZE (8) |
Vincent Coubard |
638:c90ae1400bf2 | 50 | |
Vincent Coubard |
638:c90ae1400bf2 | 51 | |
Vincent Coubard |
638:c90ae1400bf2 | 52 | /**@brief Macro for max number of retries for a flash command before it notifies as failed. |
Vincent Coubard |
638:c90ae1400bf2 | 53 | */ |
Vincent Coubard |
638:c90ae1400bf2 | 54 | #define FS_CMD_MAX_RETRIES (3) |
Vincent Coubard |
638:c90ae1400bf2 | 55 | |
Vincent Coubard |
638:c90ae1400bf2 | 56 | |
Vincent Coubard |
638:c90ae1400bf2 | 57 | /**@brief Macro for the content of a flash address that has not been written to. |
Vincent Coubard |
638:c90ae1400bf2 | 58 | */ |
Vincent Coubard |
638:c90ae1400bf2 | 59 | #define FS_EMPTY_MASK (0xFFFFFFFF) |
Vincent Coubard |
638:c90ae1400bf2 | 60 | |
Vincent Coubard |
638:c90ae1400bf2 | 61 | |
Vincent Coubard |
638:c90ae1400bf2 | 62 | /**@brief Macro for flash page size according to chip family |
Vincent Coubard |
638:c90ae1400bf2 | 63 | */ |
Vincent Coubard |
638:c90ae1400bf2 | 64 | #if defined (NRF51) |
Vincent Coubard |
638:c90ae1400bf2 | 65 | #define FS_PAGE_SIZE (1024) |
Vincent Coubard |
638:c90ae1400bf2 | 66 | #elif defined (NRF52) |
Vincent Coubard |
638:c90ae1400bf2 | 67 | #define FS_PAGE_SIZE (4096) |
Vincent Coubard |
638:c90ae1400bf2 | 68 | #else |
Vincent Coubard |
638:c90ae1400bf2 | 69 | #error "Device family must be defined. See nrf.h." |
Vincent Coubard |
638:c90ae1400bf2 | 70 | #endif |
Vincent Coubard |
638:c90ae1400bf2 | 71 | |
Vincent Coubard |
638:c90ae1400bf2 | 72 | |
Vincent Coubard |
638:c90ae1400bf2 | 73 | /*@brief Macro for flash page size according to chip family |
Vincent Coubard |
638:c90ae1400bf2 | 74 | */ |
Vincent Coubard |
638:c90ae1400bf2 | 75 | #define FS_PAGE_SIZE_WORDS (FS_PAGE_SIZE/4) |
Vincent Coubard |
638:c90ae1400bf2 | 76 | |
Vincent Coubard |
638:c90ae1400bf2 | 77 | |
Vincent Coubard |
638:c90ae1400bf2 | 78 | /**@brief Static inline function that provides last page address |
Vincent Coubard |
638:c90ae1400bf2 | 79 | * |
Vincent Coubard |
638:c90ae1400bf2 | 80 | * @note If there is a bootloader present the bootloader address read from UICR |
Vincent Coubard |
638:c90ae1400bf2 | 81 | * will act as the page beyond the end of the available flash storage |
Vincent Coubard |
638:c90ae1400bf2 | 82 | */ |
Vincent Coubard |
638:c90ae1400bf2 | 83 | static __INLINE uint32_t fs_flash_page_end_addr() |
Vincent Coubard |
638:c90ae1400bf2 | 84 | { |
Vincent Coubard |
638:c90ae1400bf2 | 85 | uint32_t const bootloader_addr = NRF_UICR->NRFFW[0]; |
Vincent Coubard |
638:c90ae1400bf2 | 86 | return ((bootloader_addr != FS_EMPTY_MASK) ? |
Vincent Coubard |
638:c90ae1400bf2 | 87 | bootloader_addr : NRF_FICR->CODESIZE * FS_PAGE_SIZE); |
Vincent Coubard |
638:c90ae1400bf2 | 88 | } |
Vincent Coubard |
638:c90ae1400bf2 | 89 | |
Vincent Coubard |
638:c90ae1400bf2 | 90 | |
Vincent Coubard |
638:c90ae1400bf2 | 91 | /**@brief Macro for last page address |
Vincent Coubard |
638:c90ae1400bf2 | 92 | * |
Vincent Coubard |
638:c90ae1400bf2 | 93 | * @note If there is a bootloader present the bootloader address read from UICR |
Vincent Coubard |
638:c90ae1400bf2 | 94 | * will act as the page beyond the end of the available flash storage |
Vincent Coubard |
638:c90ae1400bf2 | 95 | */ |
Vincent Coubard |
638:c90ae1400bf2 | 96 | #define FS_PAGE_END_ADDR fs_flash_page_end_addr() |
Vincent Coubard |
638:c90ae1400bf2 | 97 | |
Vincent Coubard |
638:c90ae1400bf2 | 98 | |
Vincent Coubard |
638:c90ae1400bf2 | 99 | /**@brief Macro to describe the write |
Vincent Coubard |
638:c90ae1400bf2 | 100 | * |
Vincent Coubard |
638:c90ae1400bf2 | 101 | */ |
Vincent Coubard |
638:c90ae1400bf2 | 102 | #if defined (NRF51) |
Vincent Coubard |
638:c90ae1400bf2 | 103 | #define FS_MAX_WRITE_SIZE_WORDS (256) |
Vincent Coubard |
638:c90ae1400bf2 | 104 | #elif defined (NRF52) |
Vincent Coubard |
638:c90ae1400bf2 | 105 | #define FS_MAX_WRITE_SIZE_WORDS (1024) |
Vincent Coubard |
638:c90ae1400bf2 | 106 | #else |
Vincent Coubard |
638:c90ae1400bf2 | 107 | #error "Device family must be defined. see nrf.h" |
Vincent Coubard |
638:c90ae1400bf2 | 108 | #endif |
Vincent Coubard |
638:c90ae1400bf2 | 109 | |
Vincent Coubard |
638:c90ae1400bf2 | 110 | /** @} */ |
Vincent Coubard |
638:c90ae1400bf2 | 111 | |
Vincent Coubard |
638:c90ae1400bf2 | 112 | #endif // FS_CONFIG_H__ |
Vincent Coubard |
638:c90ae1400bf2 | 113 |