nrfxlib API 2.8.99
Loading...
Searching...
No Matches
nrf_dm.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2022 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5 */
6
16#ifndef __NRF_DM_H_
17#define __NRF_DM_H_
18
19#include <stdint.h>
20#include "nrf.h"
21#include "nrf_dm_version.h"
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
36
46
57
67
75
79typedef struct {
81 float i_local[80];
83 float q_local[80];
85 float i_remote[80];
87 float q_remote[80];
89
90typedef struct {
92 nrf_dm_sinr_indicator_t sinr_indicator_local[80];
94 nrf_dm_sinr_indicator_t sinr_indicator_remote[80];
96
101typedef union {
102 struct _mcpd {
104 float ifft;
110 float best;
111 } mcpd;
112
113 struct _rtt {
115 float rtt;
116 } rtt;
118
141
187
188typedef struct {
190 uint8_t gpio;
192 uint8_t gpio_te;
194
211
212#define NRF_DM_DEFAULT_SINGLE_ANTENNA_CONFIG \
213 ((nrf_dm_antenna_config_t){ \
214 .antenna_gpios_count = 0, \
215 .antenna_gpios = NULL, \
216 .switch_pattern_count = 0, \
217 .switch_pattern = NULL, \
218 })
219
220typedef struct {
224 uint8_t *ppi_chan;
226
243
244#if defined(RADIO_TXPOWER_TXPOWER_Pos8dBm)
245#define NRF_DM_DEFAULT_TX_POWER RADIO_TXPOWER_TXPOWER_Pos8dBm
246#elif defined(RADIO_TXPOWER_TXPOWER_Pos4dBm)
247#define NRF_DM_DEFAULT_TX_POWER RADIO_TXPOWER_TXPOWER_Pos4dBm
248#elif defined(RADIO_TXPOWER_TXPOWER_Pos1dBm)
249#define NRF_DM_DEFAULT_TX_POWER RADIO_TXPOWER_TXPOWER_Pos1dBm
250#elif defined(RADIO_TXPOWER_TXPOWER_0dBm)
251#define NRF_DM_DEFAULT_TX_POWER RADIO_TXPOWER_TXPOWER_0dBm
252#endif
253
254#define NRF_DM_DEFAULT_ANTENNA_COMP (NRF_DM_ANTENNA_COMP_1_1)
259#define NRF_DM_DEFAULT_CONFIG \
260 ((nrf_dm_config_t){ \
261 .role = NRF_DM_ROLE_NONE, \
262 .ranging_mode = NRF_DM_RANGING_MODE_MCPD, \
263 .rng_seed = 0, \
264 .tx_power_dbm = NRF_DM_DEFAULT_TX_POWER, \
265 .ant_comp = NRF_DM_DEFAULT_ANTENNA_COMP, \
266 })
267
268
280void nrf_dm_init(const nrf_dm_ppi_config_t *ppi_cfg, const nrf_dm_antenna_config_t *antenna_cfg,
281 NRF_TIMER_Type * timer);
282
289
306
314#define NRF_DM_PROC_EXECUTE_DURATION_OVERHEAD_US (200)
315
316
335
342
346#define NRF_DM_CHANNEL_MAP_LEN 75
347
357 uint8_t hopping_sequence[NRF_DM_CHANNEL_MAP_LEN]);
358
370
380
385
386#ifdef __cplusplus
387}
388#endif
389
390#endif // __NRF_DM_H_
391
void nrf_dm_populate_report(nrf_dm_report_t *p_report)
Partially populate the report. This populates the report but does not set the distance estimates and ...
nrf_dm_sinr_indicator_t
SINR indicator for IQ measurements.
Definition nrf_dm.h:40
@ NRF_DM_SINR_INDICATOR_VERY_LOW
Definition nrf_dm.h:44
@ NRF_DM_SINR_INDICATOR_MEDIUM
Definition nrf_dm.h:42
@ NRF_DM_SINR_INDICATOR_HIGH
Definition nrf_dm.h:41
@ NRF_DM_SINR_INDICATOR_LOW
Definition nrf_dm.h:43
#define NRF_DM_CHANNEL_MAP_LEN
This is the length, in number of channels, of the channel map used within the library.
Definition nrf_dm.h:346
float nrf_dm_high_precision_calc(nrf_dm_report_t *p_report)
Estimate the distance with more computation-intensive higher precision algorithm.
nrf_dm_quality_t nrf_dm_calc(nrf_dm_report_t *p_report)
Estimate the distance Fills nrf_dm_report_t with distance estimates either mcpd or rtt according to t...
nrf_dm_ranging_mode_t
Ranging modes.
Definition nrf_dm.h:71
@ NRF_DM_RANGING_MODE_MCPD
Definition nrf_dm.h:73
@ NRF_DM_RANGING_MODE_RTT
Definition nrf_dm.h:72
nrf_dm_quality_t
Quality of the procedure.
Definition nrf_dm.h:30
@ NRF_DM_QUALITY_OK
Definition nrf_dm.h:31
@ NRF_DM_QUALITY_POOR
Definition nrf_dm.h:32
@ NRF_DM_QUALITY_DO_NOT_USE
Definition nrf_dm.h:33
@ NRF_DM_QUALITY_CRC_FAIL
Definition nrf_dm.h:34
void nrf_dm_init(const nrf_dm_ppi_config_t *ppi_cfg, const nrf_dm_antenna_config_t *antenna_cfg, NRF_TIMER_Type *timer)
Initialize the distance measurement procedure.
uint32_t nrf_dm_get_duration_us(const nrf_dm_config_t *config)
Get the duration in microseconds that it will take to execute the distance measurement in initiator r...
nrf_dm_status_t nrf_dm_proc_execute(uint32_t timeout_us)
Start the distance measurement.
nrf_dm_antenna_composition_t
Configuration options for antenna configurations.
Definition nrf_dm.h:123
@ NRF_DM_ANTENNA_COMP_2_1
Definition nrf_dm.h:127
@ NRF_DM_ANTENNA_COMP_1_2
Definition nrf_dm.h:133
@ NRF_DM_ANTENNA_COMP_1_4
Definition nrf_dm.h:137
@ NRF_DM_ANTENNA_COMP_2_2
Definition nrf_dm.h:139
@ NRF_DM_ANTENNA_COMP_3_1
Definition nrf_dm.h:129
@ NRF_DM_ANTENNA_COMP_1_1
Definition nrf_dm.h:125
@ NRF_DM_ANTENNA_COMP_4_1
Definition nrf_dm.h:131
@ NRF_DM_ANTENNA_COMP_1_3
Definition nrf_dm.h:135
nrf_dm_status_t nrf_dm_configure(const nrf_dm_config_t *config)
Configures the distance measurement procedure.
nrf_dm_role_t
Role definition.
Definition nrf_dm.h:50
@ NRF_DM_ROLE_NONE
Definition nrf_dm.h:51
@ NRF_DM_ROLE_REFLECTOR
Definition nrf_dm.h:55
@ NRF_DM_ROLE_INITIATOR
Definition nrf_dm.h:53
void nrf_dm_get_hopping_sequence(const nrf_dm_config_t *config, uint8_t hopping_sequence[75])
Get the channel hopping sequence used for a given configuration instance.
const char * nrf_dm_version_string_get(void)
Get a null-terminated string containing the library revision.
nrf_dm_status_t
Status of the procedure.
Definition nrf_dm.h:61
@ NRF_DM_STATUS_CONF_INVALID
Definition nrf_dm.h:65
@ NRF_DM_STATUS_EVENT_FAIL_TIMEOUT
Definition nrf_dm.h:64
@ NRF_DM_STATUS_SUCCESS
Definition nrf_dm.h:62
@ NRF_DM_STATUS_FAIL_SYNC
Definition nrf_dm.h:63
#define NRF_DM_MAX_NUM_ANT
Definition nrf_dm_version.h:14
uint32_t * switch_pattern
Definition nrf_dm.h:209
uint8_t switch_pattern_count
Definition nrf_dm.h:201
uint8_t antenna_gpios_count
Definition nrf_dm.h:197
nrf_dm_antenna_gpio_t * antenna_gpios
Definition nrf_dm.h:199
Definition nrf_dm.h:195
uint8_t gpio
Definition nrf_dm.h:190
uint8_t gpio_te
Definition nrf_dm.h:192
Definition nrf_dm.h:188
uint32_t tx_power_dbm
Definition nrf_dm.h:239
uint32_t rng_seed
Definition nrf_dm.h:235
nrf_dm_antenna_composition_t ant_comp
Definition nrf_dm.h:241
nrf_dm_role_t role
Definition nrf_dm.h:229
nrf_dm_ranging_mode_t ranging_mode
Definition nrf_dm.h:231
Definition nrf_dm.h:227
float phase_slope
Definition nrf_dm.h:106
float rssi_openspace
Definition nrf_dm.h:108
float best
Definition nrf_dm.h:110
float ifft
Definition nrf_dm.h:104
Definition nrf_dm.h:102
float rtt
Definition nrf_dm.h:115
Definition nrf_dm.h:113
Definition nrf_dm.h:90
Container of IQ values for local and remote measured tones.
Definition nrf_dm.h:79
uint8_t * ppi_chan
Definition nrf_dm.h:224
uint8_t ppi_chan_count
Definition nrf_dm.h:222
Definition nrf_dm.h:220
nrf_dm_quality_t quality
Definition nrf_dm.h:179
uint8_t rssi_remote
Definition nrf_dm.h:171
uint8_t rtt_count
Definition nrf_dm.h:185
nrf_dm_iq_tones_sinr_indicator_t tone_sinr_indicators
Definition nrf_dm.h:155
int8_t txpwr_local
Definition nrf_dm.h:174
uint8_t link_loss
Definition nrf_dm.h:166
nrf_dm_dist_estimates_t distance_estimates
Definition nrf_dm.h:160
nrf_dm_ranging_mode_t ranging_mode
Definition nrf_dm.h:158
int32_t rtt_accumulated_ns
Definition nrf_dm.h:182
nrf_dm_status_t status
Definition nrf_dm.h:163
uint8_t rssi_local
Definition nrf_dm.h:169
int8_t txpwr_remote
Definition nrf_dm.h:176
Output data for distance estimation.
Definition nrf_dm.h:145
Container of distance estimate results for a number of different methods, in meters.
Definition nrf_dm.h:101