Zephyr API Documentation  2.7.0-rc2
A Scalable Open Source RTOS
ieee802154_radio.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2016 Intel Corporation.
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
12#ifndef ZEPHYR_INCLUDE_NET_IEEE802154_RADIO_H_
13#define ZEPHYR_INCLUDE_NET_IEEE802154_RADIO_H_
14
15#include <device.h>
16#include <net/net_if.h>
17#include <net/net_pkt.h>
18#include <net/ieee802154.h>
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
45};
46
48 IEEE802154_HW_FCS = BIT(0), /* Frame Check-Sum supported */
49 IEEE802154_HW_PROMISC = BIT(1), /* Promiscuous mode supported */
50 IEEE802154_HW_FILTER = BIT(2), /* Filter PAN ID, long/short addr */
51 IEEE802154_HW_CSMA = BIT(3), /* CSMA-CA supported */
52 IEEE802154_HW_2_4_GHZ = BIT(4), /* 2.4Ghz radio supported */
53 IEEE802154_HW_TX_RX_ACK = BIT(5), /* Handles ACK request on TX */
54 IEEE802154_HW_SUB_GHZ = BIT(6), /* Sub-GHz radio supported */
55 IEEE802154_HW_ENERGY_SCAN = BIT(7), /* Energy scan supported */
56 IEEE802154_HW_TXTIME = BIT(8), /* TX at specified time supported */
57 IEEE802154_HW_SLEEP_TO_TX = BIT(9), /* TX directly from sleep supported */
58 IEEE802154_HW_TX_SEC = BIT(10), /* TX security hadling supported */
59 IEEE802154_HW_RXTIME = BIT(11), /* RX at specified time supported */
60};
61
68};
69
71 IEEE802154_EVENT_TX_STARTED, /* Data transmission started */
72 IEEE802154_EVENT_RX_FAILED, /* Data reception failed */
73 IEEE802154_EVENT_SLEEP, /* Sleep pending */
74};
75
77 IEEE802154_RX_FAIL_NOT_RECEIVED, /* Nothing received */
78 IEEE802154_RX_FAIL_INVALID_FCS, /* Frame had invalid checksum */
79 IEEE802154_RX_FAIL_ADDR_FILTERED, /* Address did not match */
80 IEEE802154_RX_FAIL_OTHER /* General reason */
81};
82
83typedef void (*energy_scan_done_cb_t)(const struct device *dev,
84 int16_t max_ed);
85
86typedef void (*ieee802154_event_cb_t)(const struct device *dev,
87 enum ieee802154_event evt,
88 void *event_params);
89
92 union {
93 uint8_t *ieee_addr;
94 uint16_t short_addr;
95 uint16_t pan_id;
96 };
97/* @endcond */
98};
99
106};
107
112
115
118
121
124};
125
131
136};
137
148
154
157
160
165
168
171
208
211
216
222};
223
227 union {
229 struct {
233
235 struct {
238 bool enabled;
240
243
246
249
262
265
267 struct {
272
275
278
280 struct {
281 const uint8_t *data;
293 };
294};
295
307 struct net_if_api iface_api;
308
310 enum ieee802154_hw_caps (*get_capabilities)(const struct device *dev);
311
313 int (*cca)(const struct device *dev);
314
316 int (*set_channel)(const struct device *dev, uint16_t channel);
317
319 int (*filter)(const struct device *dev,
320 bool set,
321 enum ieee802154_filter_type type,
322 const struct ieee802154_filter *filter);
323
325 int (*set_txpower)(const struct device *dev, int16_t dbm);
326
328 int (*tx)(const struct device *dev, enum ieee802154_tx_mode mode,
329 struct net_pkt *pkt, struct net_buf *frag);
330
332 int (*start)(const struct device *dev);
333
335 int (*stop)(const struct device *dev);
336
338 int (*configure)(const struct device *dev,
339 enum ieee802154_config_type type,
340 const struct ieee802154_config *config);
341
344
349 int (*ed_scan)(const struct device *dev,
350 uint16_t duration,
351 energy_scan_done_cb_t done_cb);
352
354 uint64_t (*get_time)(const struct device *dev);
355
361 uint8_t (*get_sch_acc)(const struct device *dev);
362};
363
364/* Make sure that the network interface API is properly setup inside
365 * IEEE 802154 radio API struct (it is the first one).
366 */
367BUILD_ASSERT(offsetof(struct ieee802154_radio_api, iface_api) == 0);
368
369#define IEEE802154_AR_FLAG_SET (0x20)
370
381static inline bool ieee802154_is_ar_flag_set(struct net_buf *frag)
382{
383 return (*frag->data & IEEE802154_AR_FLAG_SET);
384}
385
398 struct net_pkt *pkt);
399
405#ifndef CONFIG_IEEE802154_RAW_MODE
406void ieee802154_init(struct net_if *iface);
407#else
408#define ieee802154_init(_iface_)
409#endif /* CONFIG_IEEE802154_RAW_MODE */
410
411#ifdef __cplusplus
412}
413#endif
414
419#endif /* ZEPHYR_INCLUDE_NET_IEEE802154_RADIO_H_ */
void
Definition: eswifi_shell.c:15
ieee802154_rx_fail_reason
Definition: ieee802154_radio.h:76
ieee802154_channel
IEEE 802.15.4 Channel assignments.
Definition: ieee802154_radio.h:40
ieee802154_event
Definition: ieee802154_radio.h:70
ieee802154_config_type
Definition: ieee802154_radio.h:139
enum net_verdict ieee802154_radio_handle_ack(struct net_if *iface, struct net_pkt *pkt)
Radio driver ACK handling function that hw drivers should use.
void(* ieee802154_event_cb_t)(const struct device *dev, enum ieee802154_event evt, void *event_params)
Definition: ieee802154_radio.h:86
#define IEEE802154_AR_FLAG_SET
Definition: ieee802154_radio.h:369
void(* energy_scan_done_cb_t)(const struct device *dev, int16_t max_ed)
Definition: ieee802154_radio.h:83
ieee802154_filter_type
Definition: ieee802154_radio.h:62
ieee802154_tx_mode
Definition: ieee802154_radio.h:109
ieee802154_fpb_mode
Definition: ieee802154_radio.h:127
void ieee802154_init(struct net_if *iface)
Initialize L2 stack for a given interface.
static bool ieee802154_is_ar_flag_set(struct net_buf *frag)
Check if AR flag is set on the frame inside given net_pkt.
Definition: ieee802154_radio.h:381
ieee802154_hw_caps
Definition: ieee802154_radio.h:47
@ IEEE802154_RX_FAIL_INVALID_FCS
Definition: ieee802154_radio.h:78
@ IEEE802154_RX_FAIL_OTHER
Definition: ieee802154_radio.h:80
@ IEEE802154_RX_FAIL_ADDR_FILTERED
Definition: ieee802154_radio.h:79
@ IEEE802154_RX_FAIL_NOT_RECEIVED
Definition: ieee802154_radio.h:77
@ IEEE802154_2_4_GHZ_CHANNEL_MAX
Definition: ieee802154_radio.h:44
@ IEEE802154_SUB_GHZ_CHANNEL_MIN
Definition: ieee802154_radio.h:41
@ IEEE802154_2_4_GHZ_CHANNEL_MIN
Definition: ieee802154_radio.h:43
@ IEEE802154_SUB_GHZ_CHANNEL_MAX
Definition: ieee802154_radio.h:42
@ IEEE802154_EVENT_TX_STARTED
Definition: ieee802154_radio.h:71
@ IEEE802154_EVENT_RX_FAILED
Definition: ieee802154_radio.h:72
@ IEEE802154_EVENT_SLEEP
Definition: ieee802154_radio.h:73
@ IEEE802154_CONFIG_AUTO_ACK_FPB
Definition: ieee802154_radio.h:147
@ IEEE802154_CONFIG_PROMISCUOUS
Definition: ieee802154_radio.h:159
@ IEEE802154_CONFIG_ENH_ACK_HEADER_IE
Definition: ieee802154_radio.h:221
@ IEEE802154_CONFIG_MAC_KEYS
Definition: ieee802154_radio.h:167
@ IEEE802154_CONFIG_EVENT_HANDLER
Definition: ieee802154_radio.h:164
@ IEEE802154_CONFIG_CSL_PERIOD
Definition: ieee802154_radio.h:210
@ IEEE802154_CONFIG_CSL_RX_TIME
Definition: ieee802154_radio.h:215
@ IEEE802154_CONFIG_FRAME_COUNTER
Definition: ieee802154_radio.h:170
@ IEEE802154_CONFIG_PAN_COORDINATOR
Definition: ieee802154_radio.h:156
@ IEEE802154_CONFIG_ACK_FPB
Definition: ieee802154_radio.h:153
@ IEEE802154_CONFIG_RX_SLOT
Definition: ieee802154_radio.h:207
@ IEEE802154_FILTER_TYPE_SHORT_ADDR
Definition: ieee802154_radio.h:64
@ IEEE802154_FILTER_TYPE_IEEE_ADDR
Definition: ieee802154_radio.h:63
@ IEEE802154_FILTER_TYPE_PAN_ID
Definition: ieee802154_radio.h:65
@ IEEE802154_FILTER_TYPE_SRC_SHORT_ADDR
Definition: ieee802154_radio.h:67
@ IEEE802154_FILTER_TYPE_SRC_IEEE_ADDR
Definition: ieee802154_radio.h:66
@ IEEE802154_TX_MODE_CCA
Definition: ieee802154_radio.h:114
@ IEEE802154_TX_MODE_TXTIME_CCA
Definition: ieee802154_radio.h:123
@ IEEE802154_TX_MODE_CSMA_CA
Definition: ieee802154_radio.h:117
@ IEEE802154_TX_MODE_DIRECT
Definition: ieee802154_radio.h:111
@ IEEE802154_TX_MODE_TXTIME
Definition: ieee802154_radio.h:120
@ IEEE802154_FPB_ADDR_MATCH_THREAD
Definition: ieee802154_radio.h:130
@ IEEE802154_FPB_ADDR_MATCH_ZIGBEE
Definition: ieee802154_radio.h:135
@ IEEE802154_HW_FCS
Definition: ieee802154_radio.h:48
@ IEEE802154_HW_ENERGY_SCAN
Definition: ieee802154_radio.h:55
@ IEEE802154_HW_CSMA
Definition: ieee802154_radio.h:51
@ IEEE802154_HW_SLEEP_TO_TX
Definition: ieee802154_radio.h:57
@ IEEE802154_HW_TXTIME
Definition: ieee802154_radio.h:56
@ IEEE802154_HW_PROMISC
Definition: ieee802154_radio.h:49
@ IEEE802154_HW_RXTIME
Definition: ieee802154_radio.h:59
@ IEEE802154_HW_TX_SEC
Definition: ieee802154_radio.h:58
@ IEEE802154_HW_SUB_GHZ
Definition: ieee802154_radio.h:54
@ IEEE802154_HW_TX_RX_ACK
Definition: ieee802154_radio.h:53
@ IEEE802154_HW_2_4_GHZ
Definition: ieee802154_radio.h:52
@ IEEE802154_HW_FILTER
Definition: ieee802154_radio.h:50
net_verdict
Net Verdict.
Definition: net_core.h:97
#define BIT(n)
Unsigned integer with bit position n set (signed in assembly language).
Definition: util_macro.h:44
IEEE 802.15.4 L2 stack public header.
Public API for network interface.
Network packet buffer descriptor API.
__UINT32_TYPE__ uint32_t
Definition: stdint.h:60
__UINT64_TYPE__ uint64_t
Definition: stdint.h:61
__UINT8_TYPE__ uint8_t
Definition: stdint.h:58
__UINT16_TYPE__ uint16_t
Definition: stdint.h:59
__INT16_TYPE__ int16_t
Definition: stdint.h:43
Runtime device structure (in ROM) per driver instance.
Definition: device.h:367
Definition: ieee802154_radio.h:225
const uint8_t * ext_addr
Definition: ieee802154_radio.h:291
bool pan_coordinator
Definition: ieee802154_radio.h:242
uint32_t csl_rx_time
Definition: ieee802154_radio.h:277
ieee802154_event_cb_t event_handler
Definition: ieee802154_radio.h:248
uint32_t frame_counter
Definition: ieee802154_radio.h:264
const uint8_t * data
Definition: ieee802154_radio.h:281
struct ieee802154_config::@152::@156 rx_slot
uint32_t duration
Definition: ieee802154_radio.h:270
struct ieee802154_config::@152::@157 ack_ie
uint32_t csl_period
Definition: ieee802154_radio.h:274
bool extended
Definition: ieee802154_radio.h:237
struct ieee802154_config::@152::@155 ack_fpb
uint8_t * addr
Definition: ieee802154_radio.h:236
uint8_t channel
Definition: ieee802154_radio.h:268
struct ieee802154_key * mac_keys
Definition: ieee802154_radio.h:261
uint16_t short_addr
Definition: ieee802154_radio.h:283
uint16_t data_len
Definition: ieee802154_radio.h:282
bool promiscuous
Definition: ieee802154_radio.h:245
enum ieee802154_fpb_mode mode
Definition: ieee802154_radio.h:231
uint32_t start
Definition: ieee802154_radio.h:269
bool enabled
Definition: ieee802154_radio.h:230
struct ieee802154_config::@152::@154 auto_ack_fpb
Definition: ieee802154_radio.h:90
Definition: ieee802154_radio.h:100
uint8_t * key_value
Definition: ieee802154_radio.h:101
uint32_t key_frame_counter
Definition: ieee802154_radio.h:102
bool frame_counter_per_key
Definition: ieee802154_radio.h:103
uint8_t key_id_mode
Definition: ieee802154_radio.h:104
uint8_t key_index
Definition: ieee802154_radio.h:105
IEEE 802.15.4 radio interface API.
Definition: ieee802154_radio.h:300
int(* ed_scan)(const struct device *dev, uint16_t duration, energy_scan_done_cb_t done_cb)
Definition: ieee802154_radio.h:349
enum ieee802154_hw_caps(* get_capabilities)(const struct device *dev)
Definition: ieee802154_radio.h:310
int(* start)(const struct device *dev)
Definition: ieee802154_radio.h:332
int(* cca)(const struct device *dev)
Definition: ieee802154_radio.h:313
int(* tx)(const struct device *dev, enum ieee802154_tx_mode mode, struct net_pkt *pkt, struct net_buf *frag)
Definition: ieee802154_radio.h:328
int(* stop)(const struct device *dev)
Definition: ieee802154_radio.h:335
int(* configure)(const struct device *dev, enum ieee802154_config_type type, const struct ieee802154_config *config)
Definition: ieee802154_radio.h:338
int(* set_channel)(const struct device *dev, uint16_t channel)
Definition: ieee802154_radio.h:316
int(* filter)(const struct device *dev, bool set, enum ieee802154_filter_type type, const struct ieee802154_filter *filter)
Definition: ieee802154_radio.h:319
struct net_if_api iface_api
Definition: ieee802154_radio.h:307
uint16_t(* get_subg_channel_count)(const struct device *dev)
Definition: ieee802154_radio.h:343
uint8_t(* get_sch_acc)(const struct device *dev)
Definition: ieee802154_radio.h:361
int(* set_txpower)(const struct device *dev, int16_t dbm)
Definition: ieee802154_radio.h:325
uint64_t(* get_time)(const struct device *dev)
Definition: ieee802154_radio.h:354
Network buffer representation.
Definition: buf.h:919
uint8_t * data
Definition: buf.h:944
Network Interface structure.
Definition: net_if.h:468
Network packet.
Definition: net_pkt.h:62