The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

mbed 2

This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.

Committer:
AnnaBridge
Date:
Thu Nov 08 11:45:42 2018 +0000
Revision:
171:3a7713b1edbc
Parent:
TARGET_TY51822R3/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_11/drivers_nrf/pstorage/config/pstorage_platform.h@169:a7c7b631e539
mbed library. Release version 164

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AnnaBridge 143:86740a56073b 1 /*
AnnaBridge 143:86740a56073b 2 * Copyright (c) 2013 Nordic Semiconductor ASA
AnnaBridge 143:86740a56073b 3 * All rights reserved.
AnnaBridge 143:86740a56073b 4 *
AnnaBridge 143:86740a56073b 5 * Redistribution and use in source and binary forms, with or without modification,
AnnaBridge 143:86740a56073b 6 * are permitted provided that the following conditions are met:
AnnaBridge 143:86740a56073b 7 *
AnnaBridge 143:86740a56073b 8 * 1. Redistributions of source code must retain the above copyright notice, this list
AnnaBridge 143:86740a56073b 9 * of conditions and the following disclaimer.
AnnaBridge 143:86740a56073b 10 *
AnnaBridge 143:86740a56073b 11 * 2. Redistributions in binary form, except as embedded into a Nordic Semiconductor ASA
AnnaBridge 143:86740a56073b 12 * integrated circuit in a product or a software update for such product, must reproduce
AnnaBridge 143:86740a56073b 13 * the above copyright notice, this list of conditions and the following disclaimer in
AnnaBridge 143:86740a56073b 14 * the documentation and/or other materials provided with the distribution.
AnnaBridge 143:86740a56073b 15 *
AnnaBridge 143:86740a56073b 16 * 3. Neither the name of Nordic Semiconductor ASA nor the names of its contributors may be
AnnaBridge 143:86740a56073b 17 * used to endorse or promote products derived from this software without specific prior
AnnaBridge 143:86740a56073b 18 * written permission.
AnnaBridge 143:86740a56073b 19 *
AnnaBridge 143:86740a56073b 20 * 4. This software, with or without modification, must only be used with a
AnnaBridge 143:86740a56073b 21 * Nordic Semiconductor ASA integrated circuit.
AnnaBridge 143:86740a56073b 22 *
AnnaBridge 143:86740a56073b 23 * 5. Any software provided in binary or object form under this license must not be reverse
AnnaBridge 143:86740a56073b 24 * engineered, decompiled, modified and/or disassembled.
AnnaBridge 143:86740a56073b 25 *
AnnaBridge 143:86740a56073b 26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
AnnaBridge 143:86740a56073b 27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
AnnaBridge 143:86740a56073b 28 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
AnnaBridge 143:86740a56073b 29 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
AnnaBridge 143:86740a56073b 30 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
AnnaBridge 143:86740a56073b 31 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
AnnaBridge 143:86740a56073b 32 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
AnnaBridge 143:86740a56073b 33 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
AnnaBridge 143:86740a56073b 34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
AnnaBridge 143:86740a56073b 35 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
AnnaBridge 143:86740a56073b 36 *
AnnaBridge 143:86740a56073b 37 */
AnnaBridge 143:86740a56073b 38
AnnaBridge 143:86740a56073b 39
AnnaBridge 143:86740a56073b 40 /** @cond To make doxygen skip this file */
AnnaBridge 143:86740a56073b 41
AnnaBridge 143:86740a56073b 42 /** @file
AnnaBridge 143:86740a56073b 43 * This header contains defines with respect persistent storage that are specific to
AnnaBridge 143:86740a56073b 44 * persistent storage implementation and application use case.
AnnaBridge 143:86740a56073b 45 */
AnnaBridge 143:86740a56073b 46 #ifndef PSTORAGE_PL_H__
AnnaBridge 143:86740a56073b 47 #define PSTORAGE_PL_H__
AnnaBridge 143:86740a56073b 48
AnnaBridge 143:86740a56073b 49 #include <stdint.h>
AnnaBridge 143:86740a56073b 50 #include "nrf.h"
AnnaBridge 143:86740a56073b 51
AnnaBridge 143:86740a56073b 52 static __INLINE uint16_t pstorage_flash_page_size()
AnnaBridge 143:86740a56073b 53 {
AnnaBridge 143:86740a56073b 54 return (uint16_t)NRF_FICR->CODEPAGESIZE;
AnnaBridge 143:86740a56073b 55 }
AnnaBridge 143:86740a56073b 56
AnnaBridge 143:86740a56073b 57 #define PSTORAGE_FLASH_PAGE_SIZE pstorage_flash_page_size() /**< Size of one flash page. */
AnnaBridge 143:86740a56073b 58 #define PSTORAGE_FLASH_EMPTY_MASK 0xFFFFFFFF /**< Bit mask that defines an empty address in flash. */
AnnaBridge 143:86740a56073b 59
AnnaBridge 143:86740a56073b 60 static __INLINE uint32_t pstorage_flash_page_end()
AnnaBridge 143:86740a56073b 61 {
AnnaBridge 143:86740a56073b 62 uint32_t bootloader_addr = NRF_UICR->NRFFW[0];
AnnaBridge 143:86740a56073b 63
AnnaBridge 143:86740a56073b 64 return ((bootloader_addr != PSTORAGE_FLASH_EMPTY_MASK) ?
AnnaBridge 143:86740a56073b 65 (bootloader_addr/ PSTORAGE_FLASH_PAGE_SIZE) : NRF_FICR->CODESIZE);
AnnaBridge 143:86740a56073b 66 }
AnnaBridge 143:86740a56073b 67
AnnaBridge 143:86740a56073b 68 #define PSTORAGE_FLASH_PAGE_END pstorage_flash_page_end()
AnnaBridge 143:86740a56073b 69
AnnaBridge 143:86740a56073b 70 #ifndef PSTORAGE_NUM_OF_PAGES
AnnaBridge 143:86740a56073b 71 #define PSTORAGE_NUM_OF_PAGES 1 /**< Number of flash pages allocated for the pstorage module excluding the swap page, configurable based on system requirements. */
AnnaBridge 143:86740a56073b 72 #endif
AnnaBridge 143:86740a56073b 73
AnnaBridge 143:86740a56073b 74 #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. */
AnnaBridge 143:86740a56073b 75
AnnaBridge 143:86740a56073b 76 #define PSTORAGE_DATA_START_ADDR ((PSTORAGE_FLASH_PAGE_END - PSTORAGE_NUM_OF_PAGES - 1) \
AnnaBridge 143:86740a56073b 77 * PSTORAGE_FLASH_PAGE_SIZE) /**< Start address for persistent data, configurable according to system requirements. */
AnnaBridge 143:86740a56073b 78 #define PSTORAGE_DATA_END_ADDR ((PSTORAGE_FLASH_PAGE_END - 1) * PSTORAGE_FLASH_PAGE_SIZE) /**< End address for persistent data, configurable according to system requirements. */
AnnaBridge 143:86740a56073b 79 #define PSTORAGE_SWAP_ADDR PSTORAGE_DATA_END_ADDR /**< Top-most page is used as swap area for clear and update. */
AnnaBridge 143:86740a56073b 80
AnnaBridge 143:86740a56073b 81 #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. */
AnnaBridge 143:86740a56073b 82 #define PSTORAGE_CMD_QUEUE_SIZE 10 /**< Maximum number of flash access commands that can be maintained by the module for all applications. Configurable. */
AnnaBridge 143:86740a56073b 83
AnnaBridge 143:86740a56073b 84
AnnaBridge 143:86740a56073b 85 /** Abstracts persistently memory block identifier. */
AnnaBridge 143:86740a56073b 86 typedef uint32_t pstorage_block_t;
AnnaBridge 143:86740a56073b 87
AnnaBridge 143:86740a56073b 88 typedef struct
AnnaBridge 143:86740a56073b 89 {
AnnaBridge 143:86740a56073b 90 uint32_t module_id; /**< Module ID.*/
AnnaBridge 143:86740a56073b 91 pstorage_block_t block_id; /**< Block ID.*/
AnnaBridge 143:86740a56073b 92 } pstorage_handle_t;
AnnaBridge 143:86740a56073b 93
AnnaBridge 143:86740a56073b 94 typedef uint16_t pstorage_size_t; /** Size of length and offset fields. */
AnnaBridge 143:86740a56073b 95
AnnaBridge 143:86740a56073b 96 /**@brief Handles Flash Access Result Events. To be called in the system event dispatcher of the application. */
AnnaBridge 143:86740a56073b 97 void pstorage_sys_event_handler (uint32_t sys_evt);
AnnaBridge 143:86740a56073b 98
AnnaBridge 143:86740a56073b 99 #endif // PSTORAGE_PL_H__
AnnaBridge 143:86740a56073b 100
AnnaBridge 143:86740a56073b 101 /** @} */
AnnaBridge 143:86740a56073b 102 /** @endcond */