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 
53 #ifndef KW2XRF_DEFAULT_CHANNEL
54 #define KW2XRF_DEFAULT_CHANNEL (CONFIG_IEEE802154_DEFAULT_CHANNEL)
55 #endif
56 
63 #define KW2XRF_MIN_CHANNEL (11U)
64 #define KW2XRF_MAX_CHANNEL (26U)
65 
70 #define KW2XRF_DEFAULT_TX_POWER (CONFIG_IEEE802154_DEFAULT_TXPOWER)
71 
75 #define KW2XDRF_OUTPUT_POWER_MAX (8)
76 
80 #define KW2XDRF_OUTPUT_POWER_MIN (-35)
81 
90 #define KW2XRF_OPT_SRC_ADDR_LONG (NETDEV_IEEE802154_SRC_MODE_LONG)
91 #define KW2XRF_OPT_RAWDUMP (NETDEV_IEEE802154_RAW)
92 #define KW2XRF_OPT_ACK_REQ (NETDEV_IEEE802154_ACK_REQ)
94 #define KW2XRF_OPT_AUTOCCA (0x0100)
95 #define KW2XRF_OPT_PROMISCUOUS (0x0200)
97 #define KW2XRF_OPT_PRELOADING (0x0400)
98 #define KW2XRF_OPT_TELL_TX_START (0x0800)
100 #define KW2XRF_OPT_TELL_TX_END (0x1000)
102 #define KW2XRF_OPT_TELL_RX_START (0x2000)
104 #define KW2XRF_OPT_TELL_RX_END (0x4000)
106 #define KW2XRF_OPT_AUTOACK (0x8000)
113 typedef struct kw2xrf_params {
114  spi_t spi;
115  spi_clk_t spi_clk;
116  gpio_t cs_pin;
117  gpio_t int_pin;
125 typedef struct {
131  thread_t *thread;
133  uint8_t buf[KW2XRF_MAX_PKT_LENGTH];
134  uint8_t state;
135  uint8_t tx_frame_len;
136  uint8_t idle_state;
137  uint8_t pending_tx;
140  int16_t tx_power;
150 void kw2xrf_setup(kw2xrf_t *dev, const kw2xrf_params_t *params);
151 
160 int kw2xrf_init(kw2xrf_t *dev, gpio_cb_t cb);
161 
167 void kw2xrf_reset_phy(kw2xrf_t *dev);
168 
169 #ifdef __cplusplus
170 }
171 #endif
172 
173 #endif /* KW2XRF_H */
174 
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:119
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:131
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