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 
50 #ifndef KW2XRF_DEFAULT_CHANNEL
51 #define KW2XRF_DEFAULT_CHANNEL (IEEE802154_DEFAULT_CHANNEL)
52 #endif
53 
60 #define KW2XRF_MIN_CHANNEL (11U)
61 #define KW2XRF_MAX_CHANNEL (26U)
62 
67 #define KW2XRF_DEFAULT_TX_POWER (IEEE802154_DEFAULT_TXPOWER)
68 
72 #define KW2XDRF_OUTPUT_POWER_MAX (8)
73 
77 #define KW2XDRF_OUTPUT_POWER_MIN (-35)
78 
87 #define KW2XRF_OPT_SRC_ADDR_LONG (NETDEV_IEEE802154_SRC_MODE_LONG)
88 #define KW2XRF_OPT_RAWDUMP (NETDEV_IEEE802154_RAW)
89 #define KW2XRF_OPT_ACK_REQ (NETDEV_IEEE802154_ACK_REQ)
91 #define KW2XRF_OPT_AUTOCCA (0x0100)
92 #define KW2XRF_OPT_PROMISCUOUS (0x0200)
94 #define KW2XRF_OPT_PRELOADING (0x0400)
95 #define KW2XRF_OPT_TELL_TX_START (0x0800)
97 #define KW2XRF_OPT_TELL_TX_END (0x1000)
99 #define KW2XRF_OPT_TELL_RX_START (0x2000)
101 #define KW2XRF_OPT_TELL_RX_END (0x4000)
103 #define KW2XRF_OPT_AUTOACK (0x8000)
110 typedef struct kw2xrf_params {
111  spi_t spi;
112  spi_clk_t spi_clk;
113  gpio_t cs_pin;
114  gpio_t int_pin;
122 typedef struct {
128  thread_t *thread;
130  uint8_t buf[KW2XRF_MAX_PKT_LENGTH];
131  uint8_t state;
132  uint8_t tx_frame_len;
133  uint8_t idle_state;
134  uint8_t pending_tx;
137  int16_t tx_power;
147 void kw2xrf_setup(kw2xrf_t *dev, const kw2xrf_params_t *params);
148 
157 int kw2xrf_init(kw2xrf_t *dev, gpio_cb_t cb);
158 
164 void kw2xrf_reset_phy(kw2xrf_t *dev);
165 
166 #ifdef __cplusplus
167 }
168 #endif
169 
170 #endif /* KW2XRF_H */
171 
Low-level GPIO peripheral driver interface definitions.
Definitions low-level network driver interface.
void kw2xrf_reset_phy(kw2xrf_t *dev)
Configure radio with default values.
thread_t holds thread&#39;s context data.
Definition: thread.h:144
Low-level SPI peripheral driver interface definition.
Struct holding all params needed for device initialization.
Definition: kw2xrf.h:116
int kw2xrf_init(kw2xrf_t *dev, gpio_cb_t cb)
Initialize the given KW2XRF device.
spi_clk_t
Available SPI clock speeds.
Definition: spi.h:173
Structure to hold driver state.
Definition: netdev.h:283
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.
Definition: ieee802154.h:89
#define KW2XRF_MAX_PKT_LENGTH
Maximum packet length.
Definition: kw2xrf.h:43
Device descriptor for KW2XRF radio devices.
Definition: kw2xrf.h:128
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:118
void(* gpio_cb_t)(void *arg)
Signature of event callback functions triggered from interrupts.
Definition: gpio.h:141