kw41zrf.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2017 SKF AB
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 
21 #ifndef KW41ZRF_H
22 #define KW41ZRF_H
23 
24 #include <stdint.h>
25 
26 #include "mutex.h"
27 #include "board.h"
28 #include "net/netdev.h"
29 #include "net/netdev/ieee802154.h"
30 #include "net/gnrc/nettype.h"
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
39 #define KW41ZRF_MAX_PKT_LENGTH (IEEE802154_FRAME_LEN_MAX)
40 
49 #ifndef KW41ZRF_DEFAULT_CHANNEL
50 #define KW41ZRF_DEFAULT_CHANNEL (CONFIG_IEEE802154_DEFAULT_CHANNEL)
51 #endif
52 
56 #ifndef KW41ZRF_DEFAULT_CCA_THRESHOLD
57 #define KW41ZRF_DEFAULT_CCA_THRESHOLD (-60)
58 #endif
59 
63 #ifndef KW41ZRF_DEFAULT_LQI_COMPENSATION
64 #define KW41ZRF_DEFAULT_LQI_COMPENSATION (102)
65 #endif
66 
73 #define KW41ZRF_MIN_CHANNEL (11U)
74 #define KW41ZRF_MAX_CHANNEL (26U)
75 
80 #define KW41ZRF_DEFAULT_TX_POWER (CONFIG_IEEE802154_DEFAULT_TXPOWER)
81 
85 #define KW41ZRF_OUTPUT_POWER_MAX (4)
86 
90 #define KW41ZRF_OUTPUT_POWER_MIN (-19)
91 
95 typedef void (*kw41zrf_cb_t)(void *arg);
96 
102 typedef struct {
109  uint32_t tx_warmup_time;
110  uint32_t rx_warmup_time;
111  uint32_t rf_osc_en_idle;
112  int16_t tx_power;
113  uint8_t flags;
114  uint8_t max_retrans;
118  uint8_t csma_min_be;
119  uint8_t csma_max_be;
120  uint8_t idle_seq;
121  uint8_t cca_result;
122  uint8_t csma_be;
124  uint8_t num_retrans;
125  uint32_t backoff_delay;
126  uint32_t tx_timeout;
127  uint8_t pm_blocked;
128  uint8_t recv_blocked;
132 } kw41zrf_t;
133 
141 void kw41zrf_setup(kw41zrf_t *dev, uint8_t index);
142 
152 int kw41zrf_init(kw41zrf_t *dev, kw41zrf_cb_t cb);
153 
162 int kw41zrf_reset(kw41zrf_t *dev);
163 
164 #ifdef __cplusplus
165 }
166 #endif
167 
168 #endif /* KW41ZRF_H */
169 
kw41zrf_init
int kw41zrf_init(kw41zrf_t *dev, kw41zrf_cb_t cb)
Initialize the given KW41ZRF device.
kw41zrf_setup
void kw41zrf_setup(kw41zrf_t *dev, uint8_t index)
Setup an KW41ZRF based device state.
kw41zrf_t::flags
uint8_t flags
Internal driver option flags.
Definition: kw41zrf.h:113
kw41zrf_t::tx_power
int16_t tx_power
The current tx-power setting of the device.
Definition: kw41zrf.h:112
ieee802154.h
Definitions for netdev common IEEE 802.15.4 code.
kw41zrf_t::csma_min_be
uint8_t csma_min_be
Minimum backoff exponent (macMinBe)
Definition: kw41zrf.h:118
kw41zrf_t::idle_seq
uint8_t idle_seq
state to return to after sending
Definition: kw41zrf.h:120
kw41zrf_t::num_retrans
uint8_t num_retrans
Counter used internally by send implementation.
Definition: kw41zrf.h:124
kw41zrf_t::netdev
netdev_ieee802154_t netdev
netdev parent struct
Definition: kw41zrf.h:103
kw41zrf_t::csma_max_be
uint8_t csma_max_be
Maximum backoff exponent (macMaxBe)
Definition: kw41zrf.h:119
kw41zrf_t::max_retrans
uint8_t max_retrans
Maximum number of frame retransmissions when no Ack frame is received (macMaxFrameRetries)
Definition: kw41zrf.h:114
kw41zrf_t::csma_max_backoffs
uint8_t csma_max_backoffs
Maximum number of CSMA backoffs when waiting for channel clear (macMaxCsmaBackoffs)
Definition: kw41zrf.h:116
kw41zrf_t::cca_result
uint8_t cca_result
Used for passing CCA result from ISR to user.
Definition: kw41zrf.h:121
kw41zrf_t::thread
thread_t * thread
Network driver thread, for providing feedback from IRQ handler.
Definition: kw41zrf.h:108
netdev.h
Definitions low-level network driver interface.
kw41zrf_t::tx_timeout
uint32_t tx_timeout
Used to timeout waiting for ACK during TRX.
Definition: kw41zrf.h:126
_thread
thread_t holds thread's context data.
Definition: thread.h:154
nettype.h
Protocol type definitions.
kw41zrf_t::backoff_delay
uint32_t backoff_delay
CSMA delay for the current TX operation.
Definition: kw41zrf.h:125
netdev_ieee802154_t
Extended structure to hold IEEE 802.15.4 driver state.
Definition: ieee802154.h:90
mutex.h
Mutex for thread synchronization.
kw41zrf_reset
int kw41zrf_reset(kw41zrf_t *dev)
Reset radio hardware and restore default settings.
kw41zrf_t::tx_warmup_time
uint32_t tx_warmup_time
TX warmup time, in event timer ticks.
Definition: kw41zrf.h:109
kw41zrf_t::rf_osc_en_idle
uint32_t rf_osc_en_idle
RF_OSC_EN bits setting when RF module is in standby.
Definition: kw41zrf.h:111
kw41zrf_cb_t
void(* kw41zrf_cb_t)(void *arg)
ISR callback function type.
Definition: kw41zrf.h:95
kw41zrf_t
Device descriptor for KW41ZRF radio devices.
Definition: kw41zrf.h:102
kw41zrf_t::csma_num_backoffs
uint8_t csma_num_backoffs
Counter used internally by send implementation.
Definition: kw41zrf.h:123
kw41zrf_t::recv_blocked
uint8_t recv_blocked
blocks moving to XCVSEQ_RECEIVE to prevent overwriting the RX buffer before the higher layers have co...
Definition: kw41zrf.h:128
kw41zrf_t::rx_warmup_time
uint32_t rx_warmup_time
RX warmup time, in event timer ticks.
Definition: kw41zrf.h:110
kw41zrf_t::pm_blocked
uint8_t pm_blocked
true if we have blocked a low power mode in the CPU
Definition: kw41zrf.h:127
kw41zrf_t::csma_be
uint8_t csma_be
Counter used internally by send implementation.
Definition: kw41zrf.h:122