dragoon  4383
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
nrf_sdm.h
1 /*
2  * Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without modification,
6  * are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice, this
9  * list of conditions and the following disclaimer.
10  *
11  * 2. Redistributions in binary form, except as embedded into a Nordic
12  * Semiconductor ASA integrated circuit in a product or a software update for
13  * such product, must reproduce the above copyright notice, this list of
14  * conditions and the following disclaimer in the documentation and/or other
15  * materials provided with the distribution.
16  *
17  * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
18  * contributors may be used to endorse or promote products derived from this
19  * software without specific prior written permission.
20  *
21  * 4. This software, with or without modification, must only be used with a
22  * Nordic Semiconductor ASA integrated circuit.
23  *
24  * 5. Any software provided in binary form under this license must not be reverse
25  * engineered, decompiled, modified and/or disassembled.
26  *
27  * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
28  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
29  * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
30  * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
31  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
33  * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
36  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37  */
38 
47 #ifndef NRF_SDM_H__
48 #define NRF_SDM_H__
49 
50 #include "nrf_svc.h"
51 #include "nrf.h"
52 #include "nrf_soc.h"
53 #include "nrf_error_sdm.h"
54 
55 #ifdef __cplusplus
56 extern "C" {
57 #endif
58 
61 #ifdef NRFSOC_DOXYGEN
62 
63 #define MBR_SIZE 0
64 #warning test
65 #endif
66 
68 #define SD_MAJOR_VERSION (5)
69 
71 #define SD_MINOR_VERSION (0)
72 
74 #define SD_BUGFIX_VERSION (0)
75 
81 #define SD_VERSION (SD_MAJOR_VERSION * 1000000 + SD_MINOR_VERSION * 1000 + SD_BUGFIX_VERSION)
82 
84 #define SDM_SVC_BASE 0x10
85 
87 #define SDM_INFO_FIELD_INVALID (0)
88 
91 #define SOFTDEVICE_INFO_STRUCT_OFFSET (0x2000)
92 
95 #define SOFTDEVICE_INFO_STRUCT_ADDRESS (SOFTDEVICE_INFO_STRUCT_OFFSET + MBR_SIZE)
96 
99 #define SD_INFO_STRUCT_SIZE_OFFSET (SOFTDEVICE_INFO_STRUCT_OFFSET)
100 
103 #define SD_SIZE_OFFSET (SOFTDEVICE_INFO_STRUCT_OFFSET + 0x08)
104 
107 #define SD_FWID_OFFSET (SOFTDEVICE_INFO_STRUCT_OFFSET + 0x0C)
108 
111 #define SD_ID_OFFSET (SOFTDEVICE_INFO_STRUCT_OFFSET + 0x10)
112 
115 #define SD_VERSION_OFFSET (SOFTDEVICE_INFO_STRUCT_OFFSET + 0x14)
116 
120 #define SD_INFO_STRUCT_SIZE_GET(baseaddr) (*((uint8_t *) ((baseaddr) + SD_INFO_STRUCT_SIZE_OFFSET)))
121 
125 #define SD_SIZE_GET(baseaddr) (*((uint32_t *) ((baseaddr) + SD_SIZE_OFFSET)))
126 
130 #define SD_FWID_GET(baseaddr) (*((uint16_t *) ((baseaddr) + SD_FWID_OFFSET)))
131 
135 #define SD_ID_GET(baseaddr) ((SD_INFO_STRUCT_SIZE_GET(baseaddr) > (SD_ID_OFFSET - SOFTDEVICE_INFO_STRUCT_OFFSET)) \
136  ? (*((uint32_t *) ((baseaddr) + SD_ID_OFFSET))) : SDM_INFO_FIELD_INVALID)
137 
141 #define SD_VERSION_GET(baseaddr) ((SD_INFO_STRUCT_SIZE_GET(baseaddr) > (SD_VERSION_OFFSET - SOFTDEVICE_INFO_STRUCT_OFFSET)) \
142  ? (*((uint32_t *) ((baseaddr) + SD_VERSION_OFFSET))) : SDM_INFO_FIELD_INVALID)
143 
146 #define NRF_FAULT_ID_SD_RANGE_START 0x00000000
147 #define NRF_FAULT_ID_APP_RANGE_START 0x00001000
152 #define NRF_FAULT_ID_SD_ASSERT (NRF_FAULT_ID_SD_RANGE_START + 1)
153 #define NRF_FAULT_ID_APP_MEMACC (NRF_FAULT_ID_APP_RANGE_START + 1)
166 enum NRF_SD_SVCS
167 {
173 };
183 #define NRF_CLOCK_LF_ACCURACY_250_PPM (0)
184 #define NRF_CLOCK_LF_ACCURACY_500_PPM (1)
185 #define NRF_CLOCK_LF_ACCURACY_150_PPM (2)
186 #define NRF_CLOCK_LF_ACCURACY_100_PPM (3)
187 #define NRF_CLOCK_LF_ACCURACY_75_PPM (4)
188 #define NRF_CLOCK_LF_ACCURACY_50_PPM (5)
189 #define NRF_CLOCK_LF_ACCURACY_30_PPM (6)
190 #define NRF_CLOCK_LF_ACCURACY_20_PPM (7)
191 #define NRF_CLOCK_LF_ACCURACY_10_PPM (8)
192 #define NRF_CLOCK_LF_ACCURACY_5_PPM (9)
193 #define NRF_CLOCK_LF_ACCURACY_2_PPM (10)
194 #define NRF_CLOCK_LF_ACCURACY_1_PPM (11)
201 #define NRF_CLOCK_LF_SRC_RC (0)
202 #define NRF_CLOCK_LF_SRC_XTAL (1)
203 #define NRF_CLOCK_LF_SRC_SYNTH (2)
213 typedef struct
214 {
215  uint8_t source;
216  uint8_t rc_ctiv;
223  uint8_t rc_temp_ctiv;
241  uint8_t accuracy;
244 
261 typedef void (*nrf_fault_handler_t)(uint32_t id, uint32_t pc, uint32_t info);
262 
296 SVCALL(SD_SOFTDEVICE_ENABLE, uint32_t, sd_softdevice_enable(nrf_clock_lf_cfg_t const * p_clock_lf_cfg, nrf_fault_handler_t fault_handler));
297 
298 
312 SVCALL(SD_SOFTDEVICE_DISABLE, uint32_t, sd_softdevice_disable(void));
313 
320 SVCALL(SD_SOFTDEVICE_IS_ENABLED, uint32_t, sd_softdevice_is_enabled(uint8_t * p_softdevice_enabled));
321 
331 
334 #ifdef __cplusplus
335 }
336 #endif
337 #endif // NRF_SDM_H__
338