18 #include "nrf_assert.h"
21 #include "app_error.h"
25 #include "softdevice_handler.h"
32 #define TX_PAYLOAD_LENGTH 32
33 #define ACK_PAYLOAD_LENGTH 32
35 #define WDBG_TIMESLOT_LEN 15000
37 #define WDBG_TIMESLOT_LEN 25000
39 #define WDBG_TIMESLOT_SUSPEND_GZLL 4000
40 #define WDBG_TIMESLOT_REQUEST_END 1000
41 #define WDBG_TIMESLOT_TIMEOUT 1000000
73 case NRF_EVT_RADIO_SIGNAL_CALLBACK_INVALID_RETURN:
77 case NRF_EVT_RADIO_SESSION_IDLE:
81 case NRF_EVT_RADIO_SESSION_CLOSED:
85 case NRF_EVT_RADIO_BLOCKED:
88 APP_ERROR_CHECK(err_code);
91 case NRF_EVT_RADIO_CANCELED:
94 APP_ERROR_CHECK(err_code);
112 res = nrf_gzll_init(NRF_GZLL_MODE_DEVICE);
114 res = nrf_gzll_set_device_channel_selection_policy(NRF_GZLL_DEVICE_CHANNEL_SELECTION_POLICY_USE_CURRENT);
116 res = nrf_gzll_set_xosc_ctl(NRF_GZLL_XOSC_CTL_MANUAL);
118 res = nrf_gzll_set_max_tx_attempts(0);
120 res = nrf_gzll_set_base_address_0(NRF_GZLL_BASE_ADDRESS_0);
124 res = nrf_gzll_enable();
130 res = nrf_gzll_set_mode(NRF_GZLL_MODE_DEVICE);
133 NRF_TIMER0->INTENSET = TIMER_INTENSET_COMPARE0_Msk;
135 NVIC_EnableIRQ(TIMER0_IRQn);
143 if (NRF_TIMER0->EVENTS_COMPARE[0] == 1)
145 NRF_TIMER0->EVENTS_COMPARE[0] = 0;
146 if (nrf_gzll_get_mode() != NRF_GZLL_MODE_SUSPEND)
148 (void)nrf_gzll_set_mode(NRF_GZLL_MODE_SUSPEND);
149 NRF_TIMER0->INTENSET = TIMER_INTENSET_COMPARE0_Msk;
154 ASSERT(nrf_gzll_get_mode() == NRF_GZLL_MODE_SUSPEND);
172 case NRF_RADIO_CALLBACK_SIGNAL_TYPE_START:
176 case NRF_RADIO_CALLBACK_SIGNAL_TYPE_RADIO:
180 case NRF_RADIO_CALLBACK_SIGNAL_TYPE_TIMER0:
194 APP_ERROR_CHECK(err_code);
196 if (err_code != NRF_SUCCESS)
200 if (err_code != NRF_SUCCESS)
202 (void)sd_radio_session_close();
214 if (tx_info.payload_received_in_ack)
216 if (nrf_gzll_fetch_packet_from_rx_fifo(pipe,
ack_payload, &ack_payload_length))
218 ASSERT(ack_payload_length == 1);
uint32_t sd_radio_init(void)
Initialize this module.
#define WDBG_TIMESLOT_LEN
Radio timeslot length (PRU)
static uint32_t m_slot_length
Radio timeslot length.
void nrf_gzll_host_rx_data_ready(uint32_t pipe, nrf_gzll_host_rx_info_t rx_info)
GZLL data packet received callback.
static uint8_t ack_payload[ACK_PAYLOAD_LENGTH]
Buffer for the ACK payload.
static void m_configure_next_event(void)
Fill in m_timeslot_request for next event.
void RADIO_IRQHandler(void)
Radio IRQ Handler.
#define ACK_PAYLOAD_LENGTH
GZLL Ack payload length.
static volatile bool m_gzll_initialized
Set to true when gzll is initialized.
#define WDBG_TIMESLOT_TIMEOUT
Radio timeslot timeout (us)
nrf_radio_signal_callback_return_param_t * m_radio_callback(uint8_t signal_type)
Radio session callback.
void nrf_gzll_disabled(void)
GZLL Disabled callback.
void nrf_gzll_device_tx_failed(uint32_t pipe, nrf_gzll_device_tx_info_t tx_info)
GZLL Transmission failed callback.
bool debug_cmd_available(void)
Call this function to check if a command is received.
static void m_on_multitimer(void)
Called when NRF_RADIO_CALLBACK_SIGNAL_TYPE_TIMER0 received.
static void m_on_start(void)
Called when NRF_RADIO_CALLBACK_SIGNAL_TYPE_START received.
static volatile bool m_cmd_received
Set to true when a command is received.
void sys_evt_dispatch(uint32_t evt_id)
SOC events handler.
static nrf_radio_request_t m_timeslot_request
Passed to the sd_radio_request function.
static nrf_radio_signal_callback_return_param_t signal_callback_return_param
Return value for the Radio session callback function.
#define WDBG_TIMESLOT_SUSPEND_GZLL
Suspend GZLL 400us before radio timeslot ends.
void nrf_gzll_device_tx_success(uint32_t pipe, nrf_gzll_device_tx_info_t tx_info)
GZLL ACK received callback.
#define NRF_GZLL_CHANNEL_TABLE_SIZE
#define WDBG_TIMESLOT_REQUEST_END
Request end 1000us before radio timeslot ends.
char get_debug_cmd(void)
Clear the m_cmd_received and return the received command.