EVE 1.0
nvram.h
Go to the documentation of this file.
1 #ifndef NVRAM_H_INCLUDED
2 #define NVRAM_H_INCLUDED
3 /**********************************************************************/
4 /*
5  * Copyright (c) 2014-2016, Jetro AS
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without modification,
9  * are permitted provided that the following conditions are met:
10  *
11  * 1. Redistributions of source code must retain the above copyright notice,
12  * this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright notice,
14  * this list of conditions and the following disclaimer in the documentation
15  * and/or other materials provided with the distribution.
16  * 3. The name of the author may not be used to endorse or promote products
17  * derived from this software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONRIBUTORS ``AS IS'' AND ANY EXPRESS
20  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
22  * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
24  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
27  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
28  * OF SUCH DAMAGE.
29  *
30  * This file is part of the EVE platform.
31  */
32 
33 /**
34  * \file
35  * @brief Driver of the nRF52 non-volatile RAM.
36  *
37  * @author DT, Jetro AS
38  */ /******************************************************************/
39 
40 /**
41  * \defgroup nvram nRF52 nono-volatile RAM driver
42  * \ingroup nrf52
43  * \{
44  *
45  */
46 
47 /** Size of the NVRAM (µCU-specific) */
48 #define NVRAM_SIZE (0x1000 - NVRAM_BLD_PEER_DATA_SIZE)
49 
50 /** Address of the bootloader params area */
51 #define NVRAM_BLD_PEER_DATA_ADDR ((void *) (0x20000000 + NRF_FICR->INFO.RAM * 1024 - NVRAM_BLD_PEER_DATA_SIZE))
52 
53 /** Size of the bootloader params area */
54 #define NVRAM_BLD_PEER_DATA_SIZE (0x80)
55 
56 /** Address in the NVRAM space */
57 typedef uint16_t nvram_addr_t;
58 
59 /**********************************************************************/
60 /**
61  * @brief Name: nvram_write\n
62  * Writes a buffer into NVRAM.
63  *
64  * @param addr The address in NVRAM to which the buffer should be written.
65  * @param buf A pointer to the buffer from which data is to be read.
66  * @param size The number of bytes to write into NVRAM.
67  ***********************************************************************/
68 void nvram_write(nvram_addr_t addr, const void *buf, uint16_t size);
69 
70 /**********************************************************************/
71 /**
72  * @brief Name: nvram_write\n
73  * Reads data from the NVRAM.
74  *
75  * \param addr The address in NVRAM from which the data should be read.
76  * \param buf A pointer to the buffer to which the data should be stored.
77  * \param size The number of bytes to read.
78  ***********************************************************************/
79 void nvram_read(nvram_addr_t addr, void *buf, uint16_t size);
80 
81 /**********************************************************************/
82 /**
83  * @brief Name: nvram_init\n
84  * Initialize the NVRAM module.
85  *
86  ***********************************************************************/
87 void nvram_init(void);
88 
89 /** \} */
90 
91 #endif /* NVRAM_H_INCLUDED */
uint16_t nvram_addr_t
Definition: nvram.h:57
void nvram_init(void)
Name: nvram_init Initialize the NVRAM module.
void nvram_write(nvram_addr_t addr, const void *buf, uint16_t size)
Name: nvram_write Writes a buffer into NVRAM.
void nvram_read(nvram_addr_t addr, void *buf, uint16_t size)
Name: nvram_write Reads data from the NVRAM.