kw2xrf.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 Phytec Messtechnik GmbH
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
23 #ifndef KW2XRF_H
24 #define KW2XRF_H
25 
26 #include <stdint.h>
27 
28 #include "board.h"
29 #include "periph/spi.h"
30 #include "periph/gpio.h"
31 #include "net/netdev.h"
32 #include "net/netdev/ieee802154.h"
33 #include "net/gnrc/nettype.h"
34 #include "thread.h"
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
43 #define KW2XRF_MAX_PKT_LENGTH (IEEE802154_FRAME_LEN_MAX)
44 
48 #define KW2XRF_DEFAULT_PANID (IEEE802154_DEFAULT_PANID)
49 
55 #ifndef KW2XRF_DEFAULT_CHANNEL
56 #define KW2XRF_DEFAULT_CHANNEL (IEEE802154_DEFAULT_CHANNEL)
57 #endif
58 
65 #define KW2XRF_MIN_CHANNEL (11U)
66 #define KW2XRF_MAX_CHANNEL (26U)
67 
72 #define KW2XRF_DEFAULT_TX_POWER (IEEE802154_DEFAULT_TXPOWER)
73 
77 #define KW2XDRF_OUTPUT_POWER_MAX (8)
78 
82 #define KW2XDRF_OUTPUT_POWER_MIN (-35)
83 
92 #define KW2XRF_OPT_SRC_ADDR_LONG (NETDEV_IEEE802154_SRC_MODE_LONG)
93 #define KW2XRF_OPT_RAWDUMP (NETDEV_IEEE802154_RAW)
94 #define KW2XRF_OPT_ACK_REQ (NETDEV_IEEE802154_ACK_REQ)
96 #define KW2XRF_OPT_AUTOCCA (0x0100)
97 #define KW2XRF_OPT_PROMISCUOUS (0x0200)
99 #define KW2XRF_OPT_PRELOADING (0x0400)
100 #define KW2XRF_OPT_TELL_TX_START (0x0800)
102 #define KW2XRF_OPT_TELL_TX_END (0x1000)
104 #define KW2XRF_OPT_TELL_RX_START (0x2000)
106 #define KW2XRF_OPT_TELL_RX_END (0x4000)
108 #define KW2XRF_OPT_AUTOACK (0x8000)
115 typedef struct kw2xrf_params {
116  spi_t spi;
117  spi_clk_t spi_clk;
118  gpio_t cs_pin;
119  gpio_t int_pin;
127 typedef struct {
133  thread_t *thread;
135  uint8_t buf[KW2XRF_MAX_PKT_LENGTH];
136  uint8_t state;
137  uint8_t tx_frame_len;
138  uint8_t idle_state;
139  uint8_t pending_tx;
142  int16_t tx_power;
152 void kw2xrf_setup(kw2xrf_t *dev, const kw2xrf_params_t *params);
153 
162 int kw2xrf_init(kw2xrf_t *dev, gpio_cb_t cb);
163 
169 void kw2xrf_reset_phy(kw2xrf_t *dev);
170 
171 #ifdef __cplusplus
172 }
173 #endif
174 
175 #endif /* KW2XRF_H */
176 
Definitions low-level network driver interface.
Low-level GPIO peripheral driver interface definitions.
void kw2xrf_reset_phy(kw2xrf_t *dev)
Configure radio with default values.
thread_t holds thread&#39;s context data.
Definition: thread.h:178
Low-level SPI peripheral driver interface definition.
Struct holding all params needed for device initialization.
Definition: kw2xrf.h:121
Threading API.
int kw2xrf_init(kw2xrf_t *dev, gpio_cb_t cb)
Initialize the given KW2XRF device.
Structure to hold driver state.
Definition: netdev.h:275
Definitions for netdev common IEEE 802.15.4 code.
void kw2xrf_setup(kw2xrf_t *dev, const kw2xrf_params_t *params)
Setup an KW2XRF based device state.
Extended structure to hold IEEE 802.15.4 driver state.
#define KW2XRF_MAX_PKT_LENGTH
Maximum packet length.
Definition: kw2xrf.h:43
Device descriptor for KW2XRF radio devices.
Definition: kw2xrf.h:133
struct kw2xrf_params kw2xrf_params_t
Struct holding all params needed for device initialization.
Protocol type definitions.
unsigned int spi_t
Default type for SPI devices.
Definition: spi.h:105
void(* gpio_cb_t)(void *arg)
Signature of event callback functions triggered from interrupts.
Definition: gpio.h:124