nrfxlib API 0.1.0
Loading...
Searching...
No Matches
nrf_gzll.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2021 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5 */
6
12#ifndef NRF_GZLL_H__
13#define NRF_GZLL_H__
14
15#include <stdbool.h>
16#include "nrf.h"
17#include "nrf_gzll_constants.h"
18
19#ifdef __cplusplus
20extern "C" {
21#endif
22
23
35typedef enum
36{
41
47typedef enum
48{
52
57typedef enum
58{
72#ifdef NRF51
73 NRF_GZLL_TX_POWER_N30_DBM
74#else
76#endif
78
83typedef enum
84{
85#ifdef NRF51
86 NRF_GZLL_DATARATE_250KBIT = 0,
87#endif
93
100typedef enum
101{
105
110typedef enum
111{
131
137typedef struct
138{
142 int8_t rssi;
143 uint8_t rf_channel;
145
146
152typedef struct
153{
155 int8_t rssi;
156 uint8_t rf_channel;
158
159
160typedef struct
161{
162 uint32_t packets_num;
163 uint32_t timeouts_num;
164 uint32_t channel_timeouts[NRF_GZLL_CONST_MAX_CHANNEL_TABLE_SIZE];
165 uint32_t channel_packets[NRF_GZLL_CONST_MAX_CHANNEL_TABLE_SIZE];
167
168
170typedef void (*nrf_gzll_tx_timeout_callback)(uint32_t pipe, uint8_t rf_channel);
171
172
174typedef void (*nrf_gzll_crc_failure_callback)(uint32_t pipe, uint8_t rf_channel);
175
176
179
180
181#if defined(NRF52_SERIES) || defined(__SDK_DOXYGEN__)
186typedef struct
187{
188 bool pa_enabled;
189 bool pa_active_high;
190 uint8_t pa_gpio_pin;
191 uint8_t pa_gpiote_channel;
192 bool lna_enabled;
193 bool lna_active_high;
194 uint8_t lna_gpio_pin;
195 uint8_t lna_gpiote_channel;
196 NRF_TIMER_Type * timer;
197 uint8_t ppi_channels[NRF_GZLL_PA_LNA_PPI_CHANNELS_NUM];
198 uint8_t ramp_up_time;
199} nrf_gzll_pa_lna_cfg_t;
200#endif
201
202/******************************************************************************/
205/******************************************************************************/
206
216
227
241
248
251/******************************************************************************/
254/******************************************************************************/
255
268
281
284/******************************************************************************/
287/******************************************************************************/
288
299
302/******************************************************************************/
305/******************************************************************************/
306
315
323
326/******************************************************************************/
329/******************************************************************************/
330
345bool nrf_gzll_add_packet_to_tx_fifo(uint32_t pipe, uint8_t const * p_payload, uint32_t length);
346
358bool nrf_gzll_fetch_packet_from_rx_fifo(uint32_t pipe, uint8_t * p_payload, uint32_t * p_length);
359
369
378
388
401
415bool nrf_gzll_flush_tx_fifo(uint32_t pipe);
416
427bool nrf_gzll_flush_rx_fifo(uint32_t pipe);
428
437
442
451bool nrf_gzll_get_channel_timeouts(uint8_t channel_index, uint32_t *p_timeouts);
452
457
460/******************************************************************************/
469/******************************************************************************/
470
475
476
481
482
497
504
523bool nrf_gzll_set_base_address_0(uint32_t base_address);
524
531
542bool nrf_gzll_set_base_address_1(uint32_t base_address);
543
550
566bool nrf_gzll_set_address_prefix_byte(uint32_t pipe, uint8_t address_prefix_byte);
567
580bool nrf_gzll_get_address_prefix_byte(uint32_t pipe, uint8_t * p_out_address_prefix_byte);
581
595bool nrf_gzll_set_rx_pipes_enabled(uint32_t pipes);
596
603
621bool nrf_gzll_set_timeslot_period(uint32_t period_us);
622
629
653
660
680bool nrf_gzll_set_timeslots_per_channel(uint32_t timeslots);
681
688
709
717
729bool nrf_gzll_set_sync_lifetime(uint32_t lifetime);
730
737
749void nrf_gzll_set_max_tx_attempts(uint16_t max_tx_attempts);
750
757
773bool nrf_gzll_set_channel_table(uint8_t * p_channel_table, uint32_t size);
774
787bool nrf_gzll_get_channel_table(uint8_t * p_channel_table, uint32_t * p_size);
788
795
805
812
822
829
850
857
864void nrf_gzll_set_auto_disable(uint32_t num_ticks);
865
866#if defined(NRF52_SERIES) || defined(__SDK_DOXYGEN__)
872bool nrf_gzll_set_pa_lna_cfg(nrf_gzll_pa_lna_cfg_t const * p_pa_lna_cfg);
873#endif
874
883
890
901
904/******************************************************************************/
907/******************************************************************************/
908
915
916
923
928#ifdef __cplusplus
929}
930#endif
931
932#endif
void nrf_gzll_device_tx_failed(uint32_t pipe, nrf_gzll_device_tx_info_t tx_info)
Transmission failed callback (Device mode only).
void nrf_gzll_host_rx_data_ready(uint32_t pipe, nrf_gzll_host_rx_info_t rx_info)
Data packet received callback (Host mode only).
uint32_t nrf_gzll_get_timeslots_per_channel_when_device_out_of_sync(void)
Get function counterpart to nrf_gzll_set_timeslots_per_channel_when_device_out_of_sync().
bool nrf_gzll_get_channel_timeouts(uint8_t channel_index, uint32_t *p_timeouts)
Function for obtaining number of transmission timeouts for specific channel.
bool nrf_gzll_set_xosc_ctl(nrf_gzll_xosc_ctl_t xosc_ctl)
Set whether start/stop of external oscillator (XOSC) shall be handled automatically inside Gazell or ...
bool nrf_gzll_set_sync_lifetime(uint32_t lifetime)
Set the number of timeslots after a successful reception of a Device or Host packet that the Gazell L...
void nrf_gzll_disable(void)
Disable Gazell.
nrf_gzll_mode_t
Enumerator used for selecting Gazell mode.
Definition: nrf_gzll.h:36
@ NRF_GZLL_MODE_SUSPEND
Suspend mode ("disabled with timer running")
Definition: nrf_gzll.h:39
@ NRF_GZLL_MODE_HOST
Host mode.
Definition: nrf_gzll.h:38
@ NRF_GZLL_MODE_DEVICE
Device mode.
Definition: nrf_gzll.h:37
bool nrf_gzll_set_channel_table(uint8_t *p_channel_table, uint32_t size)
Set the table of Radio Frequency (RF) channels.
void nrf_gzll_reset_tx_statistics(void)
Function for clearing transmission statistic structure.
bool nrf_gzll_set_datarate(nrf_gzll_datarate_t data_rate)
Set the radio datarate.
bool nrf_gzll_set_timeslot_period(uint32_t period_us)
Set the timeslot period.
uint32_t nrf_gzll_get_base_address_1(void)
Get function counterpart to nrf_gzll_set_base_address_1().
void nrf_gzll_set_auto_disable(uint32_t num_ticks)
Set Gazell to disable automatically after a certain number of timeslot ticks.
nrf_gzll_tx_power_t nrf_gzll_get_tx_power(void)
Get function counterpart to nrf_gzll_set_tx_power().
void nrf_gzll_mode_changed(void)
Mode changed callback.
uint32_t nrf_gzll_get_timeslot_period(void)
Get function counterpart to nrf_gzll_get_timeslot_period().
nrf_gzll_xosc_ctl_t
Enumerator used for specifying whether switching the external high frequency oscillator on/off shall ...
Definition: nrf_gzll.h:101
@ NRF_GZLL_XOSC_CTL_AUTO
Switch XOSC on/off automatically.
Definition: nrf_gzll.h:102
@ NRF_GZLL_XOSC_CTL_MANUAL
Switch XOSC on/off manually.
Definition: nrf_gzll.h:103
bool nrf_gzll_set_tx_power(nrf_gzll_tx_power_t tx_power)
Set the radio TX power.
void nrf_gzll_crc_failure_callback_register(nrf_gzll_crc_failure_callback callback)
Function for registering callback to be called on the packet CRC failure.
bool nrf_gzll_set_device_channel_selection_policy(nrf_gzll_device_channel_selection_policy_t policy)
Set the Device channel selection policy.
bool nrf_gzll_ok_to_add_packet_to_tx_fifo(uint32_t pipe)
Check if adding a packet to a pipe's TX FIFO should be successful.
void nrf_gzll_disabled(void)
Disabled callback.
uint32_t nrf_gzll_get_total_allocated_packet_count(void)
Get the total number of packets residing in all TX and RX FIFOs.
void nrf_gzll_clear_tick_count(void)
Clear the internal timeslot tick count variable that is read by nrf_gzll_get_tick_count().
bool nrf_gzll_set_rx_pipes_enabled(uint32_t pipes)
Set which pipes shall listen for packets in Host mode.
uint32_t nrf_gzll_get_timeslots_per_channel(void)
Get function counterpart to nrf_gzll_set_timeslots_per_channel().
nrf_gzll_device_channel_selection_policy_t nrf_gzll_get_device_channel_selection_policy(void)
Get function counterpart to nrf_gzll_set_device_channel_selection_policy().
nrf_gzll_tx_power_t
Enumerator used for selecting the transmit (TX) power.
Definition: nrf_gzll.h:58
@ NRF_GZLL_TX_POWER_N8_DBM
-8 dBm transmit power.
Definition: nrf_gzll.h:68
@ NRF_GZLL_TX_POWER_N20_DBM
-20 dBm transmit power.
Definition: nrf_gzll.h:71
@ NRF_GZLL_TX_POWER_4_DBM
4 dBm transmit power.
Definition: nrf_gzll.h:63
@ NRF_GZLL_TX_POWER_5_DBM
5 dBm transmit power.
Definition: nrf_gzll.h:62
@ NRF_GZLL_TX_POWER_0_DBM
0 dBm transmit power.
Definition: nrf_gzll.h:66
@ NRF_GZLL_TX_POWER_3_DBM
3 dBm transmit power.
Definition: nrf_gzll.h:64
@ NRF_GZLL_TX_POWER_8_DBM
8 dBm transmit power.
Definition: nrf_gzll.h:59
@ NRF_GZLL_TX_POWER_6_DBM
6 dBm transmit power.
Definition: nrf_gzll.h:61
@ NRF_GZLL_TX_POWER_7_DBM
7 dBm transmit power.
Definition: nrf_gzll.h:60
@ NRF_GZLL_TX_POWER_N16_DBM
-16 dBm transmit power.
Definition: nrf_gzll.h:70
@ NRF_GZLL_TX_POWER_N12_DBM
-12 dBm transmit power.
Definition: nrf_gzll.h:69
@ NRF_GZLL_TX_POWER_2_DBM
2 dBm transmit power.
Definition: nrf_gzll.h:65
@ NRF_GZLL_TX_POWER_N40_DBM
-40 dBm transmit power.
Definition: nrf_gzll.h:75
@ NRF_GZLL_TX_POWER_N4_DBM
-4 dBm transmit power.
Definition: nrf_gzll.h:67
bool nrf_gzll_flush_tx_fifo(uint32_t pipe)
Flush the RX FIFO for a specific pipe.
bool nrf_gzll_set_timeslots_per_channel_when_device_out_of_sync(uint32_t timeslots)
Set the number of timeslots that a Gazell shall reside on a single channel before switching to anothe...
void(* nrf_gzll_tick_timer_expired_callback)(void)
Definition: nrf_gzll.h:178
bool nrf_gzll_set_address_prefix_byte(uint32_t pipe, uint8_t address_prefix_byte)
Set the address prefix byte for a specific pipe.
void nrf_gzll_tx_statistics_disable(void)
Function for disabling transmission statistics.
nrf_gzll_xosc_ctl_t nrf_gzll_get_xosc_ctl(void)
nrf_gzll_error_code_t
Enumerator used for error codes for Gazell API functions.
Definition: nrf_gzll.h:111
@ NRF_GZLL_ERROR_CODE_INTERNAL_ASSERT_OCCURRED
An internal assert occurred.
Definition: nrf_gzll.h:126
@ NRF_GZLL_ERROR_CODE_CALLBACK_NOT_IMPLEMENTED
A callback was called but not implemented by the application.
Definition: nrf_gzll.h:127
@ NRF_GZLL_ERROR_CODE_ATTEMPTED_TO_CONFIGURE_WHEN_ENABLED
A call to a configuration 'set' function was made while Gazell was enabled.
Definition: nrf_gzll.h:114
@ NRF_GZLL_ERROR_CODE_FAILED_TO_INITIALIZE
The function NRF_GZLL_init failed.
Definition: nrf_gzll.h:113
@ NRF_GZLL_ERROR_CODE_INVALID_MODE
An invalid value for the nrf_gzll_mode_t enumerator was given as input to a function.
Definition: nrf_gzll.h:117
@ NRF_GZLL_ERROR_CODE_NO_SPACE_IN_RX_FIFO_FOR_ACK
There is insufficient space in the RX FIFO for the ACK.
Definition: nrf_gzll.h:122
@ NRF_GZLL_ERROR_CODE_INSUFFICIENT_PACKETS_AVAILABLE
There are insufficient packets in the Gazell memory pool to successfully execute the operation.
Definition: nrf_gzll.h:120
@ NRF_GZLL_ERROR_CODE_INVALID_PAYLOAD_LENGTH
An invalid payload length was given as an input to a function.
Definition: nrf_gzll.h:118
@ NRF_GZLL_ERROR_CODE_ATTEMPTED_TO_ADD_TO_FULL_FIFO
There is insufficient space in the TX FIFO for the data packet.
Definition: nrf_gzll.h:121
@ NRF_GZLL_ERROR_CODE_ATTEMPTED_TO_FETCH_FROM_EMPTY_FIFO
Attempted to fetch a packet from an empty FIFO. Use the functions nrf_gzll_get_tx_fifo_packet_count()...
Definition: nrf_gzll.h:123
@ NRF_GZLL_ERROR_CODE_INVALID_PIPE
An invalid pipe number was given as an input to a function.
Definition: nrf_gzll.h:116
@ NRF_GZLL_ERROR_CODE_INVALID_CHANNEL_TABLE_SIZE
An invalid channel table size was given as an input to a function.
Definition: nrf_gzll.h:119
@ NRF_GZLL_ERROR_CODE_NO_ERROR
No error has been detected.
Definition: nrf_gzll.h:112
@ NRF_GZLL_ERROR_CODE_ATTEMPTED_TO_FLUSH_WHEN_ENABLED
Attempted to fetch a packet from an empty FIFO. Use the functions nrf_gzll_get_tx_fifo_packet_count()...
Definition: nrf_gzll.h:124
@ NRF_GZLL_ERROR_CODE_NUMBER_OF_ERROR_CODES
Number of possible error codes.
Definition: nrf_gzll.h:129
@ NRF_GZLL_ERROR_CODE_POINTER_IS_NULL
A null pointer was given as an input to a function.
Definition: nrf_gzll.h:115
@ NRF_GZLL_ERROR_CODE_INVALID_ADDRESS
Invalid pipe 0 address detected, see Anomaly 107 at nRF52832 errata document.
Definition: nrf_gzll.h:128
@ NRF_GZLL_ERROR_CODE_INVALID_PARAMETER
Attempted to set a variable which was not valid.
Definition: nrf_gzll.h:125
uint32_t nrf_gzll_get_tick_count(void)
Get the number of timeslot ticks that have occurred since nrf_gzll_init() was called.
bool nrf_gzll_get_channel_table(uint8_t *p_channel_table, uint32_t *p_size)
Get the table of Radio Frequency (RF) channels.
bool nrf_gzll_set_mode(nrf_gzll_mode_t mode)
Set the mode.
int32_t nrf_gzll_get_tx_fifo_packet_count(uint32_t pipe)
Get the number of packets in the TX FIFO on a specific pipe.
uint32_t nrf_gzll_get_base_address_0(void)
Get function counterpart to nrf_gzll_set_base_address_0().
bool nrf_gzll_is_enabled(void)
nrf_gzll_error_code_t nrf_gzll_get_error_code(void)
Gets the Gazell error code.
void(* nrf_gzll_tx_timeout_callback)(uint32_t pipe, uint8_t rf_channel)
Definition: nrf_gzll.h:170
bool nrf_gzll_add_packet_to_tx_fifo(uint32_t pipe, uint8_t const *p_payload, uint32_t length)
Add a packet to the tail of the TX FIFO.
nrf_gzll_datarate_t
Enumerator used for selecting the radio datarate.
Definition: nrf_gzll.h:84
@ NRF_GZLL_DATARATE_1MBIT
1 Mbps datarate.
Definition: nrf_gzll.h:88
@ NRF_GZLL_DATARATE_2MBIT
2 Mbps datarate.
Definition: nrf_gzll.h:89
@ NRF_GZLL_DATARATE_2MBIT_BLE
2 Mbps datarate. BLE.
Definition: nrf_gzll.h:91
@ NRF_GZLL_DATARATE_1MBIT_BLE
1 Mbps datarate. BLE.
Definition: nrf_gzll.h:90
uint32_t nrf_gzll_get_sync_lifetime(void)
Get function counterpart to nrf_gzll_set_sync_lifetime().
void nrf_gzll_device_tx_success(uint32_t pipe, nrf_gzll_device_tx_info_t tx_info)
ACK received callback (Device mode only).
uint32_t nrf_gzll_get_rx_pipes_enabled(void)
Get function counterpart to nrf_gzll_set_rx_pipes_enabled().
bool nrf_gzll_tx_statistics_enable(nrf_gzll_tx_statistics_t *p_statistics)
Function for enabling transmission statistics.
void nrf_gzll_tx_timeout_callback_register(nrf_gzll_tx_timeout_callback callback)
Function for registering callback to be called on the transmission timeout.
nrf_gzll_datarate_t nrf_gzll_get_datarate(void)
Get function counterpart to nrf_gzll_set_datarate().
bool nrf_gzll_init(nrf_gzll_mode_t mode)
Initialize Gazell.
nrf_gzll_device_channel_selection_policy_t
Enumerator used for selecting Gazell Device channel selection policy.
Definition: nrf_gzll.h:48
@ NRF_GZLL_DEVICE_CHANNEL_SELECTION_POLICY_USE_SUCCESSFUL
Start on previous successful channel.
Definition: nrf_gzll.h:49
@ NRF_GZLL_DEVICE_CHANNEL_SELECTION_POLICY_USE_CURRENT
Start on channel currently monitored by Host.
Definition: nrf_gzll.h:50
uint32_t nrf_gzll_get_channel_table_size(void)
Get the current channel table size.
bool nrf_gzll_set_base_address_0(uint32_t base_address)
Set the base address for pipe 0.
bool nrf_gzll_fetch_packet_from_rx_fifo(uint32_t pipe, uint8_t *p_payload, uint32_t *p_length)
Fetch a packet from the head of the RX FIFO.
int32_t nrf_gzll_get_rx_fifo_packet_count(uint32_t pipe)
Get the number of packets in the RX FIFO on a specific pipe.
void(* nrf_gzll_crc_failure_callback)(uint32_t pipe, uint8_t rf_channel)
Definition: nrf_gzll.h:174
bool nrf_gzll_enable(void)
Enable Gazell.
bool nrf_gzll_get_address_prefix_byte(uint32_t pipe, uint8_t *p_out_address_prefix_byte)
Get function counterpart to nrf_gzll_set_address_prefix_byte().
void nrf_gzll_reset_error_code(void)
Reset the Gazell error code.
nrf_gzll_mode_t nrf_gzll_get_mode(void)
Get function counterpart to nrf_gzll_set_mode().
void nrf_gzll_set_max_tx_attempts(uint16_t max_tx_attempts)
Set the maximum number of TX attempts that can be used for a single packet.
bool nrf_gzll_flush_rx_fifo(uint32_t pipe)
Flush the RX FIFO for a specific pipe.
bool nrf_gzll_set_timeslots_per_channel(uint32_t timeslots)
Set the number of timeslots that Gazell shall reside on a single channel before switching to another ...
uint16_t nrf_gzll_get_max_tx_attempts(void)
Get function counterpart to nrf_gzll_set_max_tx_attempts().
bool nrf_gzll_set_base_address_1(uint32_t base_address)
Set the base address for pipes 1-7.
bool nrf_gzll_set_tick_timer(uint32_t num_ticks, nrf_gzll_tick_timer_expired_callback callback)
Set a timeslot tick timer.
#define NRF_GZLL_CONST_MAX_CHANNEL_TABLE_SIZE
Maximum channel table size allowed by Gazell.
Definition: nrf_gzll_constants.h:87
#define NRF_GZLL_PA_LNA_PPI_CHANNELS_NUM
Number of PPI channels used for front end control.
Definition: nrf_gzll_constants.h:134
Gazell Link Layer constants and default values.
int8_t rssi
Received signal strength indicator in dBm.
Definition: nrf_gzll.h:142
uint16_t num_channel_switches
Number of channel switches needed during previous packet transmission.
Definition: nrf_gzll.h:141
uint16_t num_tx_attempts
Number of attempts used on previous Device packet transmission.
Definition: nrf_gzll.h:140
bool payload_received_in_ack
A payload was received in the ACK.
Definition: nrf_gzll.h:139
uint8_t rf_channel
Channel on which packet has been transmitted.
Definition: nrf_gzll.h:143
Data structure containing information about the last packet transmission.
Definition: nrf_gzll.h:138
bool packet_removed_from_tx_fifo
A payload was received in the ACK.
Definition: nrf_gzll.h:154
int8_t rssi
Received signal strength indicator in dBm.
Definition: nrf_gzll.h:155
uint8_t rf_channel
Channel on which packet has been received.
Definition: nrf_gzll.h:156
Data structure containing information about the last packet received.
Definition: nrf_gzll.h:153
uint32_t packets_num
Number of succesfully transmitted packets.
Definition: nrf_gzll.h:162
uint32_t timeouts_num
Total timeouts number.
Definition: nrf_gzll.h:163
Definition: nrf_gzll.h:161