Nordic stack and drivers for the mbed BLE API. Version to work around build bug.

Dependents:   microbit_rubber_ducky microbit_mouse_BLE microbit_mouse_BLE_daybreak_version microbit_presenter

Fork of nRF51822 by Nordic Semiconductor

Committer:
vincent.coubard@arm.com
Date:
Mon Jan 11 22:33:57 2016 +0000
Revision:
608:d9f8ffc6fc07
Child:
616:b52326e38ebd
sync with nordic sdk 2.2.0

Who changed what in which revision?

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