ruuvi.drivers.c  ${PROJECT_VERSION}
Drivers for external sensors and peripherals on embedded systems.
fds_internal_defs.h File Reference
#include "sdk_config.h"
#include <stdint.h>
#include <stdbool.h>

Go to the source code of this file.

Data Structures

struct  fds_page_t
 
struct  fds_swap_page_t
 
struct  fds_op_t
 
struct  fds_gc_data_t
 

Macros

#define FDS_PAGE_TAG_SIZE   (2)
 
#define FDS_PAGE_TAG_WORD_0   (0)
 
#define FDS_PAGE_TAG_WORD_1   (1)
 
#define FDS_PAGE_TAG_MAGIC   (0xDEADC0DE)
 
#define FDS_PAGE_TAG_SWAP   (0xF11E01FF)
 
#define FDS_PAGE_TAG_DATA   (0xF11E01FE)
 
#define FDS_ERASED_WORD   (0xFFFFFFFF)
 
#define FDS_OFFSET_TL   (0)
 
#define FDS_OFFSET_IC   (1)
 
#define FDS_OFFSET_ID   (2)
 
#define FDS_OFFSET_DATA   (3)
 
#define FDS_HEADER_SIZE_TL   (1)
 
#define FDS_HEADER_SIZE_IC   (1)
 
#define FDS_HEADER_SIZE_ID   (1)
 
#define FDS_HEADER_SIZE   (3)
 
#define FDS_OP_EXECUTING   (NRF_SUCCESS)
 
#define FDS_OP_COMPLETED   (0x1D1D)
 
#define NRF_FSTORAGE_NVMC   1
 
#define NRF_FSTORAGE_SD   2
 
#define FDS_PHY_PAGE_SIZE   (1024)
 
#define FDS_PHY_PAGES   ((FDS_VIRTUAL_PAGES * FDS_VIRTUAL_PAGE_SIZE) / FDS_PHY_PAGE_SIZE)
 
#define FDS_PHY_PAGES_RESERVED   ((FDS_VIRTUAL_PAGES_RESERVED * FDS_VIRTUAL_PAGE_SIZE) / FDS_PHY_PAGE_SIZE)
 
#define FDS_PHY_PAGES_IN_VPAGE   (FDS_VIRTUAL_PAGE_SIZE / FDS_PHY_PAGE_SIZE)
 
#define FDS_DATA_PAGES   (FDS_VIRTUAL_PAGES - 1)
 
#define FDS_PAGE_SIZE   (FDS_VIRTUAL_PAGE_SIZE)
 
#define CRITICAL_SECTION_ENTER()
 
#define CRITICAL_SECTION_EXIT()
 

Enumerations

enum  fds_page_type_t { FDS_PAGE_DATA , FDS_PAGE_SWAP , FDS_PAGE_ERASED , FDS_PAGE_UNDEFINED }
 
enum  fds_header_status_t { FDS_HEADER_VALID , FDS_HEADER_DIRTY , FDS_HEADER_CORRUPT }
 
enum  fds_op_code_t {
  FDS_OP_NONE , FDS_OP_INIT , FDS_OP_WRITE , FDS_OP_UPDATE ,
  FDS_OP_DEL_RECORD , FDS_OP_DEL_FILE , FDS_OP_GC
}
 
enum  fds_init_step_t { FDS_OP_INIT_TAG_SWAP , FDS_OP_INIT_TAG_DATA , FDS_OP_INIT_ERASE_SWAP , FDS_OP_INIT_PROMOTE_SWAP }
 
enum  fds_write_step_t {
  FDS_OP_WRITE_HEADER_BEGIN , FDS_OP_WRITE_HEADER_FINALIZE , FDS_OP_WRITE_RECORD_ID , FDS_OP_WRITE_DATA ,
  FDS_OP_WRITE_FIND_RECORD , FDS_OP_WRITE_FLAG_DIRTY , FDS_OP_WRITE_DONE
}
 
enum  fds_delete_step_t { FDS_OP_DEL_RECORD_FLAG_DIRTY , FDS_OP_DEL_FILE_FLAG_DIRTY , FDS_OP_DEL_DONE }
 
enum  { PAGE_ERASED = 0x1 , PAGE_DATA = 0x2 , PAGE_SWAP_CLEAN = 0x4 , PAGE_SWAP_DIRTY = 0x8 }
 
enum  fds_init_opts_t {
  NO_PAGES , NO_SWAP = (PAGE_DATA) , FRESH_INSTALL = (PAGE_ERASED) , TAG_SWAP = (PAGE_ERASED | PAGE_DATA) ,
  TAG_DATA = (PAGE_ERASED | PAGE_SWAP_CLEAN) , TAG_DATA_INST = (PAGE_ERASED | PAGE_DATA | PAGE_SWAP_CLEAN) , PROMOTE_SWAP = (PAGE_ERASED | PAGE_SWAP_DIRTY) , PROMOTE_SWAP_INST = (PAGE_ERASED | PAGE_DATA | PAGE_SWAP_DIRTY) ,
  DISCARD_SWAP = (PAGE_DATA | PAGE_SWAP_DIRTY) , ALREADY_INSTALLED = (PAGE_DATA | PAGE_SWAP_CLEAN)
}
 
enum  fds_gc_state_t {
  GC_BEGIN , GC_NEXT_PAGE , GC_FIND_NEXT_RECORD , GC_COPY_RECORD ,
  GC_ERASE_PAGE , GC_DISCARD_SWAP , GC_PROMOTE_SWAP , GC_TAG_NEW_SWAP
}
 

Macro Definition Documentation

◆ CRITICAL_SECTION_ENTER

#define CRITICAL_SECTION_ENTER ( )

Definition at line 319 of file fds_internal_defs.h.

◆ CRITICAL_SECTION_EXIT

#define CRITICAL_SECTION_EXIT ( )

Definition at line 320 of file fds_internal_defs.h.

◆ FDS_DATA_PAGES

#define FDS_DATA_PAGES   (FDS_VIRTUAL_PAGES - 1)

Definition at line 99 of file fds_internal_defs.h.

◆ FDS_ERASED_WORD

#define FDS_ERASED_WORD   (0xFFFFFFFF)

Definition at line 64 of file fds_internal_defs.h.

◆ FDS_HEADER_SIZE

#define FDS_HEADER_SIZE   (3)

Definition at line 74 of file fds_internal_defs.h.

◆ FDS_HEADER_SIZE_IC

#define FDS_HEADER_SIZE_IC   (1)

Definition at line 72 of file fds_internal_defs.h.

◆ FDS_HEADER_SIZE_ID

#define FDS_HEADER_SIZE_ID   (1)

Definition at line 73 of file fds_internal_defs.h.

◆ FDS_HEADER_SIZE_TL

#define FDS_HEADER_SIZE_TL   (1)

Definition at line 71 of file fds_internal_defs.h.

◆ FDS_OFFSET_DATA

#define FDS_OFFSET_DATA   (3)

Definition at line 69 of file fds_internal_defs.h.

◆ FDS_OFFSET_IC

#define FDS_OFFSET_IC   (1)

Definition at line 67 of file fds_internal_defs.h.

◆ FDS_OFFSET_ID

#define FDS_OFFSET_ID   (2)

Definition at line 68 of file fds_internal_defs.h.

◆ FDS_OFFSET_TL

#define FDS_OFFSET_TL   (0)

Definition at line 66 of file fds_internal_defs.h.

◆ FDS_OP_COMPLETED

#define FDS_OP_COMPLETED   (0x1D1D)

Definition at line 77 of file fds_internal_defs.h.

◆ FDS_OP_EXECUTING

#define FDS_OP_EXECUTING   (NRF_SUCCESS)

Definition at line 76 of file fds_internal_defs.h.

◆ FDS_PAGE_SIZE

#define FDS_PAGE_SIZE   (FDS_VIRTUAL_PAGE_SIZE)

Definition at line 102 of file fds_internal_defs.h.

◆ FDS_PAGE_TAG_DATA

#define FDS_PAGE_TAG_DATA   (0xF11E01FE)

Definition at line 62 of file fds_internal_defs.h.

◆ FDS_PAGE_TAG_MAGIC

#define FDS_PAGE_TAG_MAGIC   (0xDEADC0DE)

Definition at line 60 of file fds_internal_defs.h.

◆ FDS_PAGE_TAG_SIZE

#define FDS_PAGE_TAG_SIZE   (2)

Copyright (c) 2015 - 2019, Nordic Semiconductor ASA

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form, except as embedded into a Nordic Semiconductor ASA integrated circuit in a product or a software update for such product, must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of Nordic Semiconductor ASA nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
  4. This software, with or without modification, must only be used with a Nordic Semiconductor ASA integrated circuit.
  5. Any software provided in binary form under this license must not be reverse engineered, decompiled, modified and/or disassembled.

THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Definition at line 55 of file fds_internal_defs.h.

◆ FDS_PAGE_TAG_SWAP

#define FDS_PAGE_TAG_SWAP   (0xF11E01FF)

Definition at line 61 of file fds_internal_defs.h.

◆ FDS_PAGE_TAG_WORD_0

#define FDS_PAGE_TAG_WORD_0   (0)

Definition at line 56 of file fds_internal_defs.h.

◆ FDS_PAGE_TAG_WORD_1

#define FDS_PAGE_TAG_WORD_1   (1)

Definition at line 57 of file fds_internal_defs.h.

◆ FDS_PHY_PAGE_SIZE

#define FDS_PHY_PAGE_SIZE   (1024)

Definition at line 86 of file fds_internal_defs.h.

◆ FDS_PHY_PAGES

#define FDS_PHY_PAGES   ((FDS_VIRTUAL_PAGES * FDS_VIRTUAL_PAGE_SIZE) / FDS_PHY_PAGE_SIZE)

Definition at line 90 of file fds_internal_defs.h.

◆ FDS_PHY_PAGES_IN_VPAGE

#define FDS_PHY_PAGES_IN_VPAGE   (FDS_VIRTUAL_PAGE_SIZE / FDS_PHY_PAGE_SIZE)

Definition at line 96 of file fds_internal_defs.h.

◆ FDS_PHY_PAGES_RESERVED

#define FDS_PHY_PAGES_RESERVED   ((FDS_VIRTUAL_PAGES_RESERVED * FDS_VIRTUAL_PAGE_SIZE) / FDS_PHY_PAGE_SIZE)

Definition at line 93 of file fds_internal_defs.h.

◆ NRF_FSTORAGE_NVMC

#define NRF_FSTORAGE_NVMC   1

Definition at line 79 of file fds_internal_defs.h.

◆ NRF_FSTORAGE_SD

#define NRF_FSTORAGE_SD   2

Definition at line 80 of file fds_internal_defs.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
PAGE_ERASED 
PAGE_DATA 
PAGE_SWAP_CLEAN 
PAGE_SWAP_DIRTY 

Definition at line 236 of file fds_internal_defs.h.

◆ fds_delete_step_t

Enumerator
FDS_OP_DEL_RECORD_FLAG_DIRTY 
FDS_OP_DEL_FILE_FLAG_DIRTY 
FDS_OP_DEL_DONE 

Definition at line 183 of file fds_internal_defs.h.

◆ fds_gc_state_t

Enumerator
GC_BEGIN 
GC_NEXT_PAGE 
GC_FIND_NEXT_RECORD 
GC_COPY_RECORD 
GC_ERASE_PAGE 
GC_DISCARD_SWAP 
GC_PROMOTE_SWAP 
GC_TAG_NEW_SWAP 

Definition at line 286 of file fds_internal_defs.h.

◆ fds_header_status_t

Enumerator
FDS_HEADER_VALID 
FDS_HEADER_DIRTY 
FDS_HEADER_CORRUPT 

Definition at line 123 of file fds_internal_defs.h.

◆ fds_init_opts_t

Enumerator
NO_PAGES 
NO_SWAP 
FRESH_INSTALL 
TAG_SWAP 
TAG_DATA 
TAG_DATA_INST 
PROMOTE_SWAP 
PROMOTE_SWAP_INST 
DISCARD_SWAP 
ALREADY_INSTALLED 

Definition at line 245 of file fds_internal_defs.h.

◆ fds_init_step_t

Enumerator
FDS_OP_INIT_TAG_SWAP 
FDS_OP_INIT_TAG_DATA 
FDS_OP_INIT_ERASE_SWAP 
FDS_OP_INIT_PROMOTE_SWAP 

Definition at line 162 of file fds_internal_defs.h.

◆ fds_op_code_t

Enumerator
FDS_OP_NONE 
FDS_OP_INIT 
FDS_OP_WRITE 
FDS_OP_UPDATE 
FDS_OP_DEL_RECORD 
FDS_OP_DEL_FILE 
FDS_OP_GC 

Definition at line 150 of file fds_internal_defs.h.

◆ fds_page_type_t

Enumerator
FDS_PAGE_DATA 
FDS_PAGE_SWAP 
FDS_PAGE_ERASED 
FDS_PAGE_UNDEFINED 

Definition at line 114 of file fds_internal_defs.h.

◆ fds_write_step_t

Enumerator
FDS_OP_WRITE_HEADER_BEGIN 
FDS_OP_WRITE_HEADER_FINALIZE 
FDS_OP_WRITE_RECORD_ID 
FDS_OP_WRITE_DATA 
FDS_OP_WRITE_FIND_RECORD 
FDS_OP_WRITE_FLAG_DIRTY 
FDS_OP_WRITE_DONE 

Definition at line 171 of file fds_internal_defs.h.