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 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
42 #define KW2XRF_MAX_PKT_LENGTH (IEEE802154_FRAME_LEN_MAX)
43 
47 #define KW2XRF_DEFAULT_PANID (IEEE802154_DEFAULT_PANID)
48 
54 #ifndef KW2XRF_DEFAULT_CHANNEL
55 #define KW2XRF_DEFAULT_CHANNEL (IEEE802154_DEFAULT_CHANNEL)
56 #endif
57 
64 #define KW2XRF_MIN_CHANNEL (11U)
65 #define KW2XRF_MAX_CHANNEL (26U)
66 
71 #define KW2XRF_DEFAULT_TX_POWER (IEEE802154_DEFAULT_TXPOWER)
72 
76 #define KW2XDRF_OUTPUT_POWER_MAX (8)
77 
81 #define KW2XDRF_OUTPUT_POWER_MIN (-35)
82 
91 #define KW2XRF_OPT_SRC_ADDR_LONG (NETDEV_IEEE802154_SRC_MODE_LONG)
92 #define KW2XRF_OPT_RAWDUMP (NETDEV_IEEE802154_RAW)
93 #define KW2XRF_OPT_ACK_REQ (NETDEV_IEEE802154_ACK_REQ)
95 #define KW2XRF_OPT_AUTOCCA (0x0100)
96 #define KW2XRF_OPT_PROMISCUOUS (0x0200)
98 #define KW2XRF_OPT_PRELOADING (0x0400)
99 #define KW2XRF_OPT_TELL_TX_START (0x0800)
101 #define KW2XRF_OPT_TELL_TX_END (0x1000)
103 #define KW2XRF_OPT_TELL_RX_START (0x2000)
105 #define KW2XRF_OPT_TELL_RX_END (0x4000)
107 #define KW2XRF_OPT_AUTOACK (0x8000)
114 typedef struct kw2xrf_params {
115  spi_t spi;
116  spi_clk_t spi_clk;
117  gpio_t cs_pin;
118  gpio_t int_pin;
126 typedef struct {
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.
Low-level SPI peripheral driver interface definition.
Struct holding all params needed for device initialization.
Definition: kw2xrf.h:120
int kw2xrf_init(kw2xrf_t *dev, gpio_cb_t cb)
Initialize the given KW2XRF device.
Structure to hold driver state.
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:42
Device descriptor for KW2XRF radio devices.
Definition: kw2xrf.h:132
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