Contiki-NG
Loading...
Searching...
No Matches
nrf-ieee-driver-nrf54l15.c
1/*
2 * Copyright (c) 2026, RISE Research Institutes of Sweden AB
3 * All rights reserved.
4 *
5 * Author: Joakim Eriksson <joakim.eriksson@ri.se>
6 *
7 * SPDX-License-Identifier: BSD-3-Clause
8 *
9 * IEEE 802.15.4 radio driver for nRF54L15 using Nordic's nrf_802154 library.
10 * This file wraps the nrf_802154 API into Contiki-NG's radio_driver interface.
11 */
12
13#include "contiki.h"
14#include "dev/radio.h"
15#include "net/netstack.h"
16#include "net/packetbuf.h"
17#include "net/linkaddr.h"
19#include "sys/energest.h"
20#include "nrf_802154.h"
21#include "nrf_802154_config.h"
22#include "nrf.h"
23
24#include <string.h>
25#include <stdbool.h>
26
27/* Log configuration */
28#include "sys/log.h"
29#define LOG_MODULE "nrf54l15-radio"
30#define LOG_LEVEL LOG_CONF_LEVEL_RADIO
31
32/*---------------------------------------------------------------------------*/
33/* IEEE 802.15.4 constants */
34#define MAX_PAYLOAD_LEN 125 /* 127 - FCS(2) */
35#define ACK_LEN 5
36#define FRAME_ACK_REQUEST_BIT 0x20
37
38/* Default radio parameters */
39#define DEFAULT_CHANNEL 26
40#define DEFAULT_TX_POWER 0 /* dBm */
41
42/* Use the radio timer's microsecond clock so timeouts match the nRF 802154
43 * platform backend on nRF54L15. The generic rtimer backend still uses a
44 * different tick scale on this port. */
45#define TX_DONE_TIMEOUT_US 250000ULL
46#define TX_ABORT_TIMEOUT_US 10000ULL
47#define CCA_DONE_TIMEOUT_US 50000ULL
48
49/*---------------------------------------------------------------------------*/
50/* TX buffer: [PHR byte (length)] [PSDU ...] -- nrf_802154 expects raw format */
51static uint8_t tx_buf[1 + MAX_PAYLOAD_LEN + 2]; /* +2 for FCS space */
52static volatile uint8_t tx_buf_len;
53
54/* RX state */
55/* Stage as many software RX buffers as the driver advertises so that bursts
56 * of received frames are not dropped while the upper layer drains them
57 * outside of ISR context. */
58#define RX_BUF_COUNT NRF_802154_RX_BUFFERS
59static uint8_t *rx_bufs[RX_BUF_COUNT];
60static int8_t rx_rssi[RX_BUF_COUNT];
61static uint8_t rx_lqi[RX_BUF_COUNT];
62static volatile uint8_t rx_head; /* next slot to write into */
63static volatile uint8_t rx_tail; /* next slot to read from */
64
65/* TX completion state */
66static volatile bool tx_done;
67static volatile bool tx_success;
68static volatile nrf_802154_tx_error_t tx_error;
69
70/* CCA completion state */
71static volatile bool cca_done;
72static volatile bool cca_free;
73
74/* Error counters -- incremented in ISR, logged in process context */
75static volatile uint32_t rx_fail_count;
76static volatile uint32_t tx_fail_count;
77
78/* Current radio parameters */
79static uint8_t current_channel = DEFAULT_CHANNEL;
80static int8_t current_tx_power = DEFAULT_TX_POWER;
81static bool radio_is_on;
82
83/*---------------------------------------------------------------------------*/
84PROCESS(nrf54l15_radio_process, "nRF54L15 radio driver");
85/*---------------------------------------------------------------------------*/
86static const char *
87tx_error_name(nrf_802154_tx_error_t error)
88{
89 switch(error) {
90 case NRF_802154_TX_ERROR_NONE:
91 return "none";
92 case NRF_802154_TX_ERROR_BUSY_CHANNEL:
93 return "busy_channel";
94 case NRF_802154_TX_ERROR_INVALID_ACK:
95 return "invalid_ack";
96 case NRF_802154_TX_ERROR_NO_MEM:
97 return "no_mem";
98 case NRF_802154_TX_ERROR_TIMESLOT_ENDED:
99 return "timeslot_ended";
100 case NRF_802154_TX_ERROR_NO_ACK:
101 return "no_ack";
102 case NRF_802154_TX_ERROR_ABORTED:
103 return "aborted";
104 case NRF_802154_TX_ERROR_TIMESLOT_DENIED:
105 return "timeslot_denied";
106 case NRF_802154_TX_ERROR_KEY_ID_INVALID:
107 return "key_id_invalid";
108 case NRF_802154_TX_ERROR_FRAME_COUNTER_ERROR:
109 return "frame_counter_error";
110 case NRF_802154_TX_ERROR_TIMESTAMP_ENCODING_ERROR:
111 return "timestamp_encoding_error";
112 case NRF_802154_TX_ERROR_INVALID_REQUEST:
113 return "invalid_request";
114 default:
115 return "unknown";
116 }
117}
118/*---------------------------------------------------------------------------*/
119static bool
120wait_for_flag(volatile bool *flag, uint64_t timeout_us)
121{
122 uint64_t deadline = nrf_802154_time_get() + timeout_us;
123
124 while(!*flag && nrf_802154_time_get() < deadline) {
125 __WFE();
126 }
127
128 return *flag;
129}
130/*---------------------------------------------------------------------------*/
131static void
132recover_to_receive_state(void)
133{
134 if(!radio_is_on) {
135 return;
136 }
137
138 if(nrf_802154_sleep()) {
139 (void)wait_for_flag(&tx_done, TX_ABORT_TIMEOUT_US);
140 }
141
142 if(!nrf_802154_receive()) {
143 LOG_WARN("Failed to restore receive state\n");
144 }
145}
146/*---------------------------------------------------------------------------*/
147static int
148init(void)
149{
150 LOG_INFO("Initializing nrf_802154 radio driver\n");
151
152 nrf_802154_init();
153
154 /* Set default channel and TX power. */
155 nrf_802154_channel_set(current_channel);
156 nrf_802154_tx_power_set(current_tx_power);
157
158 /* Enable auto-ACK. */
159 nrf_802154_auto_ack_set(true);
160 nrf_802154_rx_on_when_idle_set(true);
161
162 /* Set PAN ID from Contiki-NG configuration. */
163 uint8_t pan_id[2] = {
164 (uint8_t)(IEEE802154_PANID & 0xFF),
165 (uint8_t)(IEEE802154_PANID >> 8)
166 };
167 nrf_802154_pan_id_set(pan_id);
168
169 /* Set short address. */
170 uint8_t short_addr[2] = {
171 (uint8_t)(linkaddr_node_addr.u8[LINKADDR_SIZE - 2]),
172 (uint8_t)(linkaddr_node_addr.u8[LINKADDR_SIZE - 1])
173 };
174 nrf_802154_short_address_set(short_addr);
175
176 /* Set extended address (8 bytes, little-endian). */
177 uint8_t ext_addr[8];
178 for(int i = 0; i < 8; i++) {
179 if(i < LINKADDR_SIZE) {
180 ext_addr[i] = linkaddr_node_addr.u8[LINKADDR_SIZE - 1 - i];
181 } else {
182 ext_addr[i] = 0;
183 }
184 }
185 nrf_802154_extended_address_set(ext_addr);
186
187 /* Initialize RX buffer pointers. */
188 rx_head = 0;
189 rx_tail = 0;
190
191 radio_is_on = false;
192
193 /* Start the radio process. */
194 process_start(&nrf54l15_radio_process, NULL);
195
196 LOG_INFO("Radio initialized, channel %u, PAN 0x%04x\n",
197 current_channel, IEEE802154_PANID);
198
199 return 1;
200}
201/*---------------------------------------------------------------------------*/
202static int
203on(void)
204{
205 if(!radio_is_on) {
206 LOG_DBG("Radio ON\n");
207 ENERGEST_ON(ENERGEST_TYPE_LISTEN);
208 if(!nrf_802154_receive()) {
209 ENERGEST_OFF(ENERGEST_TYPE_LISTEN);
210 LOG_WARN("Failed to enter receive state\n");
211 return 0;
212 }
213 LOG_DBG("receive() returned, ticks=%lu\n", (unsigned long)clock_time());
214 radio_is_on = true;
215 }
216 return 1;
217}
218/*---------------------------------------------------------------------------*/
219static int
220off(void)
221{
222 if(radio_is_on) {
223 LOG_DBG("Radio OFF\n");
224 nrf_802154_sleep();
225 ENERGEST_OFF(ENERGEST_TYPE_LISTEN);
226 radio_is_on = false;
227 }
228 return 1;
229}
230/*---------------------------------------------------------------------------*/
231static int
232prepare(const void *payload, unsigned short payload_len)
233{
234 if(payload_len > MAX_PAYLOAD_LEN) {
235 LOG_WARN("TX payload too long: %u\n", payload_len);
236 return 1;
237 }
238
239 /* PHR byte = payload length + FCS length (2 bytes). */
240 tx_buf[0] = payload_len + 2;
241 memcpy(&tx_buf[1], payload, payload_len);
242 tx_buf_len = payload_len;
243
244 return 0;
245}
246/*---------------------------------------------------------------------------*/
247static int
248transmit(unsigned short transmit_len)
249{
250 nrf_802154_transmit_metadata_t metadata = {
251 .frame_props = NRF_802154_TRANSMITTED_FRAME_PROPS_DEFAULT_INIT,
252 .cca = false,
253 .tx_power = { .use_metadata_value = false },
254 .tx_channel = { .use_metadata_value = false },
255 .tx_timestamp_encode = false,
256 };
257
258 /* Ensure the radio is in RX state — nrf_802154 requires this before TX. */
259 if(!radio_is_on) {
260 on();
261 }
262
263 LOG_DBG("TX %u bytes, ch=%u\n", tx_buf[0], nrf_802154_channel_get());
264
265 tx_done = false;
266 tx_success = false;
267 tx_error = NRF_802154_TX_ERROR_NONE;
268
269 ENERGEST_SWITCH(ENERGEST_TYPE_LISTEN, ENERGEST_TYPE_TRANSMIT);
270
271 /* nrf_802154_transmit_raw() returns nrf_802154_tx_error_t (uint8_t):
272 * NRF_802154_TX_ERROR_NONE (0) = accepted, non-zero = error */
273 nrf_802154_tx_error_t tx_err = nrf_802154_transmit_raw(tx_buf, &metadata);
274
275 LOG_DBG("TX result=%u\n", tx_err);
276
277 if(tx_err != NRF_802154_TX_ERROR_NONE) {
278 LOG_WARN("TX request rejected: %s (%u)\n", tx_error_name(tx_err), tx_err);
279 ENERGEST_SWITCH(ENERGEST_TYPE_TRANSMIT, ENERGEST_TYPE_LISTEN);
280
281 if(tx_err == NRF_802154_TX_ERROR_BUSY_CHANNEL) {
282 recover_to_receive_state();
283 return RADIO_TX_COLLISION;
284 }
285
286 if(tx_err == NRF_802154_TX_ERROR_INVALID_ACK ||
287 tx_err == NRF_802154_TX_ERROR_NO_ACK) {
288 return RADIO_TX_NOACK;
289 }
290
291 return RADIO_TX_ERR;
292 }
293
294 /* Wait for TX completion callback with timeout. */
295 if(!wait_for_flag(&tx_done, TX_DONE_TIMEOUT_US)) {
296 /* The frame was accepted for transmission, but the 802.15.4 stack never
297 * reported a final verdict. This is not safe to translate to NOACK:
298 * higher layers would poison link metrics and may leave the DAG on a
299 * completion-path bug. */
300 LOG_WARN("TX timeout\n");
301 ENERGEST_SWITCH(ENERGEST_TYPE_TRANSMIT, ENERGEST_TYPE_LISTEN);
302 tx_error = NRF_802154_TX_ERROR_ABORTED;
303 return RADIO_TX_ERR;
304 }
305
306 ENERGEST_SWITCH(ENERGEST_TYPE_TRANSMIT, ENERGEST_TYPE_LISTEN);
307
308 if(tx_success) {
309 LOG_DBG("TX OK %u bytes on ch %u\n", tx_buf[0], current_channel);
310 return RADIO_TX_OK;
311 }
312
313 if(tx_error == NRF_802154_TX_ERROR_NO_ACK) {
314 LOG_WARN("TX failed: no ACK\n");
315 return RADIO_TX_NOACK;
316 }
317
318 if(tx_error == NRF_802154_TX_ERROR_INVALID_ACK) {
319 LOG_WARN("TX failed: invalid ACK\n");
320 return RADIO_TX_NOACK;
321 }
322
323 if(tx_error == NRF_802154_TX_ERROR_BUSY_CHANNEL) {
324 LOG_WARN("TX failed: busy channel\n");
325 return RADIO_TX_COLLISION;
326 }
327
328 LOG_WARN("TX failed: %s (%u)\n", tx_error_name(tx_error), tx_error);
329 return RADIO_TX_ERR;
330}
331/*---------------------------------------------------------------------------*/
332static int
333send(const void *payload, unsigned short payload_len)
334{
335 prepare(payload, payload_len);
336 return transmit(payload_len);
337}
338/*---------------------------------------------------------------------------*/
339static int
340radio_read(void *buf, unsigned short buf_len)
341{
342 if(rx_tail == rx_head) {
343 return 0; /* No pending frames */
344 }
345
346 uint8_t idx = rx_tail % RX_BUF_COUNT;
347 uint8_t *p_data = rx_bufs[idx];
348
349 if(p_data == NULL) {
350 rx_tail++;
351 return 0;
352 }
353
354 /* p_data[0] = PHR (length including FCS).
355 * Actual payload length = PHR - FCS(2). */
356 uint8_t frame_len = p_data[0];
357 uint8_t payload_len = frame_len - 2; /* Subtract FCS */
358
359 if(payload_len > buf_len) {
360 payload_len = buf_len;
361 }
362
363 memcpy(buf, &p_data[1], payload_len);
364
365 /* Store RSSI and LQI in packetbuf attributes. */
366 packetbuf_set_attr(PACKETBUF_ATTR_RSSI, rx_rssi[idx]);
367 packetbuf_set_attr(PACKETBUF_ATTR_LINK_QUALITY, rx_lqi[idx]);
368
369 /* Free the buffer back to the nrf_802154 driver. */
370 nrf_802154_buffer_free_raw(p_data);
371 rx_bufs[idx] = NULL;
372 rx_tail++;
373
374 LOG_DBG("RX %u bytes, RSSI %d, LQI %u\n", payload_len,
375 rx_rssi[idx], rx_lqi[idx]);
376
377 return payload_len;
378}
379/*---------------------------------------------------------------------------*/
380static int
381channel_clear(void)
382{
383 LOG_DBG("CCA\n");
384
385 if(!radio_is_on) {
386 on();
387 }
388
389 cca_done = false;
390 cca_free = false;
391
392 if(!nrf_802154_cca()) {
393 LOG_WARN("CCA could not start\n");
394 return 0;
395 }
396
397 /* Wait for CCA completion callback with timeout. */
398 if(!wait_for_flag(&cca_done, CCA_DONE_TIMEOUT_US)) {
399 LOG_WARN("CCA timeout\n");
400 recover_to_receive_state();
401 return 0;
402 }
403
404 return cca_free ? 1 : 0;
405}
406/*---------------------------------------------------------------------------*/
407static int
408receiving_packet(void)
409{
410 /* We cannot easily detect "mid-frame reception" from the nrf_802154 API.
411 * Return 0 -- Contiki-NG treats this as "not currently receiving". */
412 return 0;
413}
414/*---------------------------------------------------------------------------*/
415static int
416pending_packet(void)
417{
418 return (rx_head != rx_tail) ? 1 : 0;
419}
420/*---------------------------------------------------------------------------*/
421static radio_result_t
422get_value(radio_param_t param, radio_value_t *value)
423{
424 switch(param) {
426 *value = radio_is_on ? RADIO_POWER_MODE_ON : RADIO_POWER_MODE_OFF;
427 return RADIO_RESULT_OK;
428
430 *value = (radio_value_t)nrf_802154_channel_get();
431 return RADIO_RESULT_OK;
432
435
438
440 *value = 0;
441 return RADIO_RESULT_OK;
442
444 *value = 0;
445 return RADIO_RESULT_OK;
446
448 *value = (radio_value_t)nrf_802154_tx_power_get();
449 return RADIO_RESULT_OK;
450
453
454 case RADIO_PARAM_RSSI:
455 *value = (radio_value_t)nrf_802154_rssi_last_get();
456 return RADIO_RESULT_OK;
457
459 *value = 11;
460 return RADIO_RESULT_OK;
461
463 *value = 26;
464 return RADIO_RESULT_OK;
465
467 *value = -20;
468 return RADIO_RESULT_OK;
469
471 *value = 8;
472 return RADIO_RESULT_OK;
473
474 case RADIO_CONST_MAX_PAYLOAD_LEN:
475 *value = MAX_PAYLOAD_LEN;
476 return RADIO_RESULT_OK;
477
478 default:
480 }
481}
482/*---------------------------------------------------------------------------*/
483static radio_result_t
484set_value(radio_param_t param, radio_value_t value)
485{
486 switch(param) {
488 if(value == RADIO_POWER_MODE_ON) {
489 on();
490 } else {
491 off();
492 }
493 return RADIO_RESULT_OK;
494
496 if(value < 11 || value > 26) {
498 }
499 current_channel = (uint8_t)value;
500 nrf_802154_channel_set(current_channel);
501 return RADIO_RESULT_OK;
502
504 current_tx_power = (int8_t)value;
505 nrf_802154_tx_power_set(current_tx_power);
506 return RADIO_RESULT_OK;
507
509 return RADIO_RESULT_OK;
510
512 return RADIO_RESULT_OK;
513
514 default:
516 }
517}
518/*---------------------------------------------------------------------------*/
519static radio_result_t
520get_object(radio_param_t param, void *dest, size_t size)
521{
523}
524/*---------------------------------------------------------------------------*/
525static radio_result_t
526set_object(radio_param_t param, const void *src, size_t size)
527{
528 switch(param) {
530 if(size != 8) {
532 }
533 /* Convert to little-endian for nrf_802154. */
534 uint8_t ext_addr[8];
535 const uint8_t *addr = (const uint8_t *)src;
536 for(int i = 0; i < 8; i++) {
537 ext_addr[i] = addr[7 - i];
538 }
539 nrf_802154_extended_address_set(ext_addr);
540 return RADIO_RESULT_OK;
541 }
542 case RADIO_PARAM_PAN_ID: {
543 if(size != 2) {
545 }
546 nrf_802154_pan_id_set((const uint8_t *)src);
547 return RADIO_RESULT_OK;
548 }
550 if(size != 2) {
552 }
553 nrf_802154_short_address_set((const uint8_t *)src);
554 return RADIO_RESULT_OK;
555 }
556 default:
558 }
559}
560/*---------------------------------------------------------------------------*/
561/* nrf_802154 callbacks below are invoked from ISR context. */
562void
563nrf_802154_received_timestamp_raw(uint8_t *p_data, int8_t power,
564 uint8_t lqi, uint64_t time)
565{
566 uint8_t idx = rx_head % RX_BUF_COUNT;
567
568 if(((rx_head - rx_tail) & 0xFF) >= RX_BUF_COUNT) {
569 /* RX buffer full -- drop the oldest frame. */
570 if(rx_bufs[rx_tail % RX_BUF_COUNT] != NULL) {
571 nrf_802154_buffer_free_raw(rx_bufs[rx_tail % RX_BUF_COUNT]);
572 rx_bufs[rx_tail % RX_BUF_COUNT] = NULL;
573 }
574 rx_tail++;
575 idx = rx_head % RX_BUF_COUNT;
576 }
577
578 rx_bufs[idx] = p_data;
579 rx_rssi[idx] = power;
580 rx_lqi[idx] = lqi;
581 rx_head++;
582
583 /* Signal the Contiki-NG process to deliver the frame. */
584 process_poll(&nrf54l15_radio_process);
585}
586/*---------------------------------------------------------------------------*/
587void
588nrf_802154_receive_failed(nrf_802154_rx_error_t error, uint32_t id)
589{
590 (void)error;
591 (void)id;
592 rx_fail_count++;
593 process_poll(&nrf54l15_radio_process);
594}
595/*---------------------------------------------------------------------------*/
596void
597nrf_802154_transmitted_raw(uint8_t *p_frame,
598 const nrf_802154_transmit_done_metadata_t *p_metadata)
599{
600 bool ack_requested = false;
601
602 if(p_frame != NULL) {
603 /* p_frame[0] is PHR, p_frame[1] is FCF byte 0. */
604 ack_requested = (p_frame[1] & FRAME_ACK_REQUEST_BIT) != 0;
605 }
606
607 if(p_metadata->data.transmitted.p_ack != NULL) {
608 uint8_t *ack = p_metadata->data.transmitted.p_ack;
609 uint8_t ack_len = p_metadata->data.transmitted.length;
610
611 (void)ack_len;
612
613 /* Free the ACK buffer back to nrf_802154. */
614 nrf_802154_buffer_free_raw(ack);
615 tx_success = true;
616 } else if(ack_requested) {
617 tx_error = NRF_802154_TX_ERROR_NO_ACK;
618 tx_success = false;
619 } else {
620 tx_success = true;
621 }
622
623 tx_done = true;
624 __SEV();
625}
626/*---------------------------------------------------------------------------*/
627void
628nrf_802154_transmit_failed(uint8_t *p_frame,
629 nrf_802154_tx_error_t error,
630 const nrf_802154_transmit_done_metadata_t *p_metadata)
631{
632 (void)p_frame;
633 (void)p_metadata;
634
635 tx_fail_count++;
636 tx_error = error;
637 tx_success = false;
638 tx_done = true;
639 __SEV();
640}
641/*---------------------------------------------------------------------------*/
642void
643nrf_802154_cca_done(bool channel_free)
644{
645 cca_free = channel_free;
646 cca_done = true;
647 __SEV();
648}
649/*---------------------------------------------------------------------------*/
650void
651nrf_802154_cca_failed(nrf_802154_cca_error_t error)
652{
653 (void)error;
654 cca_free = false;
655 cca_done = true;
656 __SEV();
657}
658/*---------------------------------------------------------------------------*/
659void
660nrf_802154_energy_detected(const nrf_802154_energy_detected_t *p_result)
661{
662 (void)p_result;
663}
664/*---------------------------------------------------------------------------*/
665void
666nrf_802154_energy_detection_failed(nrf_802154_ed_error_t error)
667{
668 (void)error;
669}
670/*---------------------------------------------------------------------------*/
671/* Contiki-NG process for async RX delivery. */
672PROCESS_THREAD(nrf54l15_radio_process, ev, data)
673{
675
676 while(1) {
677 PROCESS_YIELD_UNTIL(ev == PROCESS_EVENT_POLL);
678
679 /* Log any errors that occurred in ISR context. */
680 if(rx_fail_count > 0) {
681 if(rx_fail_count > 16) {
682 LOG_WARN("RX failed %" PRIu32 " times\n", rx_fail_count);
683 }
684 rx_fail_count = 0;
685 }
686 if(tx_fail_count > 0) {
687 LOG_WARN("TX failed %" PRIu32 " times\n", tx_fail_count);
688 tx_fail_count = 0;
689 }
690
691 /* Deliver all pending received frames to the MAC layer. */
692 while(pending_packet()) {
694 int len = radio_read(packetbuf_dataptr(), PACKETBUF_SIZE);
695 if(len > 0) {
697 NETSTACK_MAC.input();
698 }
699 }
700 }
701
702 PROCESS_END();
703}
704/*---------------------------------------------------------------------------*/
705const struct radio_driver nrf_ieee_driver = {
706 init,
707 prepare,
708 transmit,
709 send,
710 radio_read,
714 on,
715 off,
716 get_value,
717 set_value,
720};
Header file for the energy estimation mechanism.
802.15.4 frame creation and parsing functions
clock_time_t clock_time(void)
Get the current clock time.
Definition clock.c:118
linkaddr_t linkaddr_node_addr
The link-layer address of the node.
Definition linkaddr.c:48
void packetbuf_set_datalen(uint16_t len)
Set the length of the data in the packetbuf.
Definition packetbuf.c:136
void * packetbuf_dataptr(void)
Get a pointer to the data in the packetbuf.
Definition packetbuf.c:143
#define PACKETBUF_SIZE
The size of the packetbuf, in bytes.
Definition packetbuf.h:67
void packetbuf_clear(void)
Clear and reset the packetbuf.
Definition packetbuf.c:75
#define PROCESS(name, strname)
Declare a process.
Definition process.h:309
#define PROCESS_BEGIN()
Define the beginning of a process.
Definition process.h:122
#define PROCESS_END()
Define the end of a process.
Definition process.h:133
void process_start(struct process *p, process_data_t data)
Start a process.
Definition process.c:121
#define PROCESS_THREAD(name, ev, data)
Define the body of a process.
Definition process.h:275
#define PROCESS_YIELD_UNTIL(c)
Yield the currently running process until a condition occurs.
Definition process.h:180
void process_poll(struct process *p)
Request a process to be polled.
Definition process.c:366
enum radio_result_e radio_result_t
Radio return values when setting or getting radio parameters.
int radio_value_t
Each radio has a set of parameters that designate the current configuration and state of the radio.
Definition radio.h:88
@ RADIO_RESULT_NOT_SUPPORTED
The parameter is not supported.
Definition radio.h:481
@ RADIO_RESULT_INVALID_VALUE
The value argument was incorrect.
Definition radio.h:482
@ RADIO_RESULT_OK
The parameter was set/read successfully.
Definition radio.h:480
@ RADIO_PARAM_POWER_MODE
When getting the value of this parameter, the radio driver should indicate whether the radio is on or...
Definition radio.h:119
@ RADIO_PARAM_RSSI
Received signal strength indicator in dBm.
Definition radio.h:218
@ RADIO_PARAM_RX_MODE
Radio receiver mode determines if the radio has address filter (RADIO_RX_MODE_ADDRESS_FILTER) and aut...
Definition radio.h:173
@ RADIO_PARAM_CHANNEL
Channel used for radio communication.
Definition radio.h:134
@ RADIO_PARAM_TXPOWER
Transmission power in dBm.
Definition radio.h:192
@ RADIO_PARAM_64BIT_ADDR
Long (64 bits) address for the radio, which is used by the address filter.
Definition radio.h:263
@ RADIO_CONST_CHANNEL_MAX
The highest radio channel number.
Definition radio.h:316
@ RADIO_PARAM_PAN_ID
The personal area network identifier (PAN ID), which is used by the h/w frame filtering functionality...
Definition radio.h:150
@ RADIO_PARAM_CCA_THRESHOLD
Clear channel assessment threshold in dBm.
Definition radio.h:205
@ RADIO_CONST_TXPOWER_MIN
The minimum transmission power in dBm.
Definition radio.h:321
@ RADIO_CONST_CHANNEL_MIN
The lowest radio channel number.
Definition radio.h:311
@ RADIO_CONST_TXPOWER_MAX
The maximum transmission power in dBm.
Definition radio.h:326
@ RADIO_PARAM_16BIT_ADDR
The short address (16 bits) for the radio, which is used by the h/w filter.
Definition radio.h:166
@ RADIO_PARAM_TX_MODE
Radio transmission mode determines if the radio has send on CCA (RADIO_TX_MODE_SEND_ON_CCA) enabled o...
Definition radio.h:180
@ RADIO_POWER_MODE_OFF
Radio powered off and in the lowest possible power consumption state.
Definition radio.h:395
@ RADIO_POWER_MODE_ON
Radio powered on and able to receive frames.
Definition radio.h:400
@ RADIO_TX_NOACK
A unicast frame was sent OK but an ACK was not received.
Definition radio.h:516
@ RADIO_TX_COLLISION
TX failed due to a collision.
Definition radio.h:511
@ RADIO_TX_ERR
An error occurred during transmission.
Definition radio.h:506
@ RADIO_TX_OK
TX was successful and where an ACK was requested one was received.
Definition radio.h:498
Header file for the link-layer address representation.
Header file for the logging system.
Include file for the Contiki low-layer network stack (NETSTACK)
Header file for the Packet buffer (packetbuf) management.
Header file for the radio API.
void(* input)(void)
Callback for getting notified of incoming packet.
Definition mac.h:78
The structure of a Contiki-NG radio device driver.
Definition radio.h:534
radio_result_t(* get_object)(radio_param_t param, void *dest, size_t size)
Get a radio parameter object.
Definition radio.h:770
int(* prepare)(const void *payload, unsigned short payload_len)
Prepare the radio with a packet to be sent.
Definition radio.h:580
radio_result_t(* set_value)(radio_param_t param, radio_value_t value)
Set a radio parameter value.
Definition radio.h:756
int(* off)(void)
Turn the radio off.
Definition radio.h:729
int(* init)(void)
Initialise the radio hardware.
Definition radio.h:555
int(* send)(const void *payload, unsigned short payload_len)
Prepare & transmit a packet.
Definition radio.h:631
int(* receiving_packet)(void)
Check if the radio driver is currently receiving a packet.
Definition radio.h:684
radio_result_t(* set_object)(radio_param_t param, const void *src, size_t size)
Set a radio parameter object.
Definition radio.h:787
int(* on)(void)
Turn the radio on.
Definition radio.h:711
int(* transmit)(unsigned short transmit_len)
Send the packet that has previously been prepared.
Definition radio.h:619
int(* pending_packet)(void)
Check if a packet has been received and is available in the radio driver's buffers.
Definition radio.h:697
radio_result_t(* get_value)(radio_param_t param, radio_value_t *value)
Get a radio parameter value.
Definition radio.h:741
int(* channel_clear)(void)
Perform a Clear-Channel Assessment (CCA) to find out if there is a packet in the air or not.
Definition radio.h:672
static uip_ds6_addr_t * addr
Pointer to a nbr cache entry.
Definition uip-nd6.c:107