R1 code for micro:bit based train controller code, requires second micro:bit running rx code to operate - see https://meanderingpi.wordpress.com/ for more information

Fork of nrf51-sdk by Lancaster University

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers fstorage_config.h Source File

fstorage_config.h

00001 /*
00002  * Copyright (c) Nordic Semiconductor ASA
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without modification,
00006  * are permitted provided that the following conditions are met:
00007  *
00008  *   1. Redistributions of source code must retain the above copyright notice, this
00009  *   list of conditions and the following disclaimer.
00010  *
00011  *   2. Redistributions in binary form must reproduce the above copyright notice, this
00012  *   list of conditions and the following disclaimer in the documentation and/or
00013  *   other materials provided with the distribution.
00014  *
00015  *   3. Neither the name of Nordic Semiconductor ASA nor the names of other
00016  *   contributors to this software may be used to endorse or promote products
00017  *   derived from this software without specific prior written permission.
00018  *
00019  *
00020  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
00021  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00022  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00023  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
00024  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00025  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00026  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
00027  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00028  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00029  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00030  *
00031  */
00032 
00033 #ifndef FS_CONFIG_H__
00034 #define FS_CONFIG_H__
00035 
00036 #include <stdint.h>
00037 #include "nrf.h"
00038 
00039 /**
00040  * @defgroup fstorage_config FStorage configuration
00041  * @ingroup fstorage
00042  * @{
00043  * @brief FStorage configuration.
00044  */
00045 
00046 
00047 /**@brief Macro for max number of operations in the fs cmd queue.
00048  */
00049 #define FS_CMD_QUEUE_SIZE   (8)
00050 
00051 
00052 /**@brief Macro for max number of retries for a flash command before it notifies as failed.
00053  */
00054 #define FS_CMD_MAX_RETRIES  (3)
00055 
00056 
00057 /**@brief Macro for the content of a flash address that has not been written to.
00058  */
00059 #define FS_EMPTY_MASK       (0xFFFFFFFF)
00060 
00061 
00062 /**@brief Macro for flash page size according to chip family
00063  */
00064 #if defined (NRF51)
00065     #define FS_PAGE_SIZE    (1024)
00066 #elif defined (NRF52)
00067     #define FS_PAGE_SIZE    (4096)
00068 #else
00069     #error "Device family must be defined. See nrf.h."
00070 #endif
00071 
00072 
00073 /*@brief Macro for flash page size according to chip family
00074 */
00075 #define FS_PAGE_SIZE_WORDS  (FS_PAGE_SIZE/4)
00076 
00077 
00078 /**@brief Static inline function that provides last page address
00079  *
00080  * @note    If there is a bootloader present the bootloader address read from UICR
00081  *          will act as the page beyond the end of the available flash storage
00082  */
00083 static __INLINE uint32_t fs_flash_page_end_addr()
00084 {
00085     uint32_t const bootloader_addr = NRF_UICR->NRFFW[0];
00086     return  ((bootloader_addr != FS_EMPTY_MASK) ?
00087              bootloader_addr : NRF_FICR->CODESIZE * FS_PAGE_SIZE);
00088 }
00089 
00090 
00091 /**@brief Macro for last page address
00092  *
00093  * @note    If there is a bootloader present the bootloader address read from UICR
00094  *          will act as the page beyond the end of the available flash storage
00095  */
00096 #define FS_PAGE_END_ADDR  fs_flash_page_end_addr()
00097 
00098 
00099 /**@brief Macro to describe the write
00100  *
00101  */
00102 #if defined (NRF51)
00103     #define FS_MAX_WRITE_SIZE_WORDS     (256)
00104 #elif defined (NRF52)
00105     #define FS_MAX_WRITE_SIZE_WORDS     (1024)
00106 #else
00107     #error "Device family must be defined. see nrf.h"
00108 #endif
00109 
00110 /** @} */
00111 
00112 #endif // FS_CONFIG_H__
00113