Loading...
Searching...
No Matches
at86rf215.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2019 2019 ML!PA Consulting GmbH
3 *
4 * This file is subject to the terms and conditions of the GNU Lesser General
5 * Public License v2.1. See the file LICENSE in the top level directory for more
6 * details.
7 */
8
23#ifndef AT86RF215_H
24#define AT86RF215_H
25
26#include <stdint.h>
27#include <stdbool.h>
28
29#include "board.h"
30#include "periph/spi.h"
31#include "periph/gpio.h"
32#include "net/netdev.h"
34#include "net/gnrc/nettype.h"
35#include "xtimer.h"
36
37#ifdef __cplusplus
38extern "C" {
39#endif
40
45
50
57typedef void (*at86rf215_batmon_cb_t)(void *arg);
58
62enum {
63 AT86RF215_FCHIP_100,
64 AT86RF215_FCHIP_200,
65 AT86RF215_FCHIP_1000,
66 AT86RF215_FCHIP_2000,
67};
68
72#define AT86RF215_MAX_PKT_LENGTH (2047)
73
84#ifdef DOXYGEN
85#define CONFIG_AT86RF215_USE_CLOCK_OUTPUT
86#endif
87
88#if defined(DOXYGEN) && !defined(CONFIG_AT86RF215_TRIM_VAL)
101#define CONFIG_AT86RF215_TRIM_VAL (0)
102#endif
103
108#ifndef CONFIG_AT86RF215_DEFAULT_CHANNEL
109#define CONFIG_AT86RF215_DEFAULT_CHANNEL (CONFIG_IEEE802154_DEFAULT_CHANNEL)
110#endif
111
112#ifndef CONFIG_AT86RF215_DEFAULT_SUBGHZ_CHANNEL
113#define CONFIG_AT86RF215_DEFAULT_SUBGHZ_CHANNEL (CONFIG_IEEE802154_DEFAULT_SUBGHZ_CHANNEL)
114#endif
121#ifndef CONFIG_AT86RF215_RPC_EN
122#define CONFIG_AT86RF215_RPC_EN (0)
123#endif
131#ifndef CONFIG_AT86RF215_BATMON_THRESHOLD
132#define CONFIG_AT86RF215_BATMON_THRESHOLD (1800)
133#endif
140#if IS_ACTIVE(CONFIG_AT86RF215_DEFAULT_LEGACY_OQPSK)
141#define CONFIG_AT86RF215_DEFAULT_PHY_MODE (IEEE802154_PHY_OQPSK)
142#elif IS_ACTIVE(CONFIG_AT86RF215_DEFAULT_MR_OQPSK)
143#define CONFIG_AT86RF215_DEFAULT_PHY_MODE (IEEE802154_PHY_MR_OQPSK)
144#elif IS_ACTIVE(CONFIG_AT86RF215_DEFAULT_MR_OFDM)
145#define CONFIG_AT86RF215_DEFAULT_PHY_MODE (IEEE802154_PHY_MR_OFDM)
146#endif
147
148#ifndef CONFIG_AT86RF215_DEFAULT_PHY_MODE
149#define CONFIG_AT86RF215_DEFAULT_PHY_MODE (IEEE802154_PHY_OQPSK)
150#endif
158#ifndef CONFIG_AT86RF215_DEFAULT_OQPSK_RATE
159#define CONFIG_AT86RF215_DEFAULT_OQPSK_RATE (0)
160#endif
167#if IS_ACTIVE(CONFIG_AT86RF215_DEFAULT_MR_OQPSK_CHIPS_100)
168#define CONFIG_AT86RF215_DEFAULT_MR_OQPSK_CHIPS (AT86RF215_FCHIP_100)
169#elif IS_ACTIVE(CONFIG_AT86RF215_DEFAULT_MR_OQPSK_CHIPS_200)
170#define CONFIG_AT86RF215_DEFAULT_MR_OQPSK_CHIPS (AT86RF215_FCHIP_200)
171#elif IS_ACTIVE(CONFIG_AT86RF215_DEFAULT_MR_OQPSK_CHIPS_1000)
172#define CONFIG_AT86RF215_DEFAULT_MR_OQPSK_CHIPS (AT86RF215_FCHIP_1000)
173#elif IS_ACTIVE(CONFIG_AT86RF215_DEFAULT_MR_OQPSK_CHIPS_2000)
174#define CONFIG_AT86RF215_DEFAULT_MR_OQPSK_CHIPS (AT86RF215_FCHIP_2000)
175#endif
176
177#ifndef CONFIG_AT86RF215_DEFAULT_MR_OQPSK_CHIPS
178#define CONFIG_AT86RF215_DEFAULT_MR_OQPSK_CHIPS (AT86RF215_FCHIP_1000)
179#endif
186#ifndef CONFIG_AT86RF215_DEFAULT_MR_OQPSK_RATE
187#define CONFIG_AT86RF215_DEFAULT_MR_OQPSK_RATE (2)
188#endif
195#ifndef CONFIG_AT86RF215_DEFAULT_MR_OFDM_OPT
196#define CONFIG_AT86RF215_DEFAULT_MR_OFDM_OPT (2)
197#endif
204#ifndef CONFIG_AT86RF215_DEFAULT_MR_OFDM_MCS
205#define CONFIG_AT86RF215_DEFAULT_MR_OFDM_MCS (2)
206#endif
213#ifndef CONFIG_AT86RF215_DEFAULT_MR_FSK_SRATE
214#define CONFIG_AT86RF215_DEFAULT_MR_FSK_SRATE FSK_SRATE_200K
215#endif
222#ifndef CONFIG_AT86RF215_DEFAULT_MR_FSK_MOD_IDX
223#define CONFIG_AT86RF215_DEFAULT_MR_FSK_MOD_IDX (64)
224#endif
231#ifndef CONFIG_AT86RF215_DEFAULT_MR_FSK_MORD
232#define CONFIG_AT86RF215_DEFAULT_MR_FSK_MORD FSK_MORD_4SFK
233#endif
240#ifndef CONFIG_AT86RF215_DEFAULT_MR_FSK_FEC
241#define CONFIG_AT86RF215_DEFAULT_MR_FSK_FEC IEEE802154_FEC_NONE
242#endif
248#ifndef CONFIG_AT86RF215_DEFAULT_TXPOWER
249#define CONFIG_AT86RF215_DEFAULT_TXPOWER (CONFIG_IEEE802154_DEFAULT_TXPOWER)
250#endif
251
268enum {
269 AT86RF215_MODE_LEGACY_OQPSK,
270 AT86RF215_MODE_MR_OQPSK,
271 AT86RF215_MODE_MR_OFDM,
272 AT86RF215_MODE_MR_FSK
273};
274
307#define AT86RF215_OPT_CSMA (0x0010)
308#define AT86RF215_OPT_PROMISCUOUS (0x0020)
309#define AT86RF215_OPT_PRELOADING (0x0040)
310#define AT86RF215_OPT_AUTOACK (0x0080)
311#define AT86RF215_OPT_ACK_REQUESTED (0x0100)
312#define AT86RF215_OPT_AGCH (0x0200)
313#define AT86RF215_OPT_TX_PENDING (0x0400)
314#define AT86RF215_OPT_CCA_PENDING (0x0800)
315#define AT86RF215_OPT_RPC (0x1000)
316#define AT86RF215_OPT_CCATX (0x2000)
323#define AT86RF215_TIMEOUT_ACK (0x0001)
324#define AT86RF215_TIMEOUT_CSMA (0x0002)
337
343typedef struct at86rf215 {
345 /* device specific fields */
353 uint16_t flags;
354 uint16_t num_chans;
355 uint16_t tx_frame_len;
356 uint8_t timeout;
357 uint8_t state;
358 uint8_t retries_max;
359 uint8_t retries;
361 uint8_t csma_retries;
362#ifdef MODULE_NETDEV_IEEE802154_MR_FSK
363 uint8_t fsk_pl;
364#endif
365 uint8_t csma_minbe;
366 uint8_t csma_maxbe;
367 int8_t csma_ed;
369
379void at86rf215_setup(at86rf215_t *dev_09, at86rf215_t *dev_24, const at86rf215_params_t *params, uint8_t index);
380
387
394
403uint16_t at86rf215_get_addr_short(const at86rf215_t *dev, uint8_t filter);
404
412void at86rf215_set_addr_short(at86rf215_t *dev, uint8_t filter, uint16_t addr);
413
423
431 void at86rf215_disable_framefilter(at86rf215_t *dev, uint8_t filter);
432
440void at86rf215_enable_framefilter(at86rf215_t *dev, uint8_t filter);
441
450
457void at86rf215_set_addr_long(at86rf215_t *dev, uint64_t addr);
458
466uint8_t at86rf215_get_chan(const at86rf215_t *dev);
467
475
484uint16_t at86rf215_get_pan(const at86rf215_t *dev, uint8_t filter);
485
493void at86rf215_set_pan(at86rf215_t *dev, uint8_t filter, uint16_t pan);
494
503
515void at86rf215_set_txpower(const at86rf215_t *dev, int16_t txpower);
516
525
533
542
550void at86rf215_set_option(at86rf215_t *dev, uint16_t option, bool state);
551
576void at86rf215_set_trim(at86rf215_t *dev, uint8_t trim);
577
587
600ssize_t at86rf215_send(at86rf215_t *dev, const void *data, size_t len);
601
613
624size_t at86rf215_tx_load(at86rf215_t *dev, const uint8_t *data,
625 size_t len, size_t offset);
626
635
642
650
662
672int at86rf215_enable_batmon(at86rf215_t *dev, unsigned voltage);
673
680
681#ifdef __cplusplus
682}
683#endif
684
685#endif /* AT86RF215_H */
spi_clk_t
Definition periph_cpu.h:352
Definitions for netdev common IEEE 802.15.4 code.
Definitions low-level network driver interface.
Low-level GPIO peripheral driver interface definitions.
int at86rf215_enable_batmon(at86rf215_t *dev, unsigned voltage)
Generate an interrupt if supply voltage drops below the configured threshold.
ssize_t at86rf215_send(at86rf215_t *dev, const void *data, size_t len)
Convenience function for simply sending data.
uint8_t at86rf215_get_chan(const at86rf215_t *dev)
Get the configured channel number of the given device.
void at86rf215_set_addr_short(at86rf215_t *dev, uint8_t filter, uint16_t addr)
Set the short address of the given device to multi address filter.
void at86rf215_reset_and_cfg(at86rf215_t *dev)
Trigger a hardware reset and configure radio with default values.
uint64_t at86rf215_get_addr_long(const at86rf215_t *dev)
Get the configured long address of the given device.
uint16_t at86rf215_get_addr_short(const at86rf215_t *dev, uint8_t filter)
Get the short address of the given device form multi address filter.
void at86rf215_set_addr_long(at86rf215_t *dev, uint64_t addr)
Set the long address of the given device.
bool at86rf215_cca(at86rf215_t *dev)
Perform one manual channel clear assessment (CCA)
int at86rf215_tx_exec(at86rf215_t *dev)
Trigger sending of data previously loaded into transmit buffer.
void at86rf215_disable_framefilter(at86rf215_t *dev, uint8_t filter)
Enables a frame filter.
void at86rf215_set_option(at86rf215_t *dev, uint16_t option, bool state)
Enable or disable driver specific options.
size_t at86rf215_tx_load(at86rf215_t *dev, const uint8_t *data, size_t len, size_t offset)
Load chunks of data into the transmit buffer of the given device.
void at86rf215_set_chan(at86rf215_t *dev, uint16_t chan)
Set the channel number of the given device.
void at86rf215_tx_abort(at86rf215_t *dev)
Abort sending of data previously loaded into transmit buffer.
int8_t at86rf215_get_ed_level(at86rf215_t *dev)
Get the latest ED level measurement.
uint16_t at86rf215_get_pan(const at86rf215_t *dev, uint8_t filter)
Get the configured PAN ID of the given device from multi address filter.
at86rf215_clko_cur_t
Definition at86rf215.h:279
at86rf215_clko_freq_t
Definition at86rf215.h:291
int16_t at86rf215_get_txpower(const at86rf215_t *dev)
Get the configured transmission power of the given device [in dBm].
void at86rf215_set_clock_output(at86rf215_t *dev, at86rf215_clko_cur_t cur, at86rf215_clko_freq_t freq)
Configure the Clock Output pin.
void at86rf215_set_pan(at86rf215_t *dev, uint8_t filter, uint16_t pan)
Set the PAN ID of the given address filter.
void at86rf215_tx_done(at86rf215_t *dev)
Signal that the transfer of the frame (and optional ACK reception) has finished.
int at86rf215_tx_prepare(at86rf215_t *dev)
Prepare for sending of data.
void(* at86rf215_batmon_cb_t)(void *arg)
Signature for the Battery monitor callback.
Definition at86rf215.h:57
void at86rf215_set_cca_threshold(at86rf215_t *dev, int8_t value)
Set the CCA threshold value.
void at86rf215_set_trim(at86rf215_t *dev, uint8_t trim)
Set crystal oscillator trim value.
struct at86rf215_params at86rf215_params_t
struct holding all params needed for device initialization
struct at86rf215 at86rf215_t
Device descriptor for AT86RF215 radio devices.
int8_t at86rf215_get_cca_threshold(const at86rf215_t *dev)
Get the CCA threshold value.
void at86rf215_enable_framefilter(at86rf215_t *dev, uint8_t filter)
Disables a frame filter.
void at86rf215_setup(at86rf215_t *dev_09, at86rf215_t *dev_24, const at86rf215_params_t *params, uint8_t index)
Setup an AT86RF215 based device state.
at86rf215_state_t
Definition at86rf215.h:258
void at86rf215_disable_batmon(at86rf215_t *dev)
Disable the Battery Monitor interrupt.
bool at86rf215_get_framefilter_enabled(at86rf215_t *dev, uint8_t filter)
Get whether a frame filter is enabled or not.
void at86rf215_set_txpower(const at86rf215_t *dev, int16_t txpower)
Set the transmission power of the given device [in dBm].
void at86rf215_reset(at86rf215_t *dev)
Trigger a hardware reset, configuration is retained.
@ AT86RF215_CLKO_2mA
2 mA
Definition at86rf215.h:280
@ AT86RF215_CLKO_4mA
4 mA
Definition at86rf215.h:281
@ AT86RF215_CLKO_8mA
8 mA
Definition at86rf215.h:283
@ AT86RF215_CLKO_6mA
6 mA
Definition at86rf215.h:282
@ AT86RF215_CLKO_26_MHz
26 MHz
Definition at86rf215.h:293
@ AT86RF215_CLKO_2_MHz
2 MHz
Definition at86rf215.h:298
@ AT86RF215_CLKO_1_MHz
1 MHz
Definition at86rf215.h:299
@ AT86RF215_CLKO_32_MHz
32 MHz
Definition at86rf215.h:294
@ AT86RF215_CLKO_16_MHz
16 MHz
Definition at86rf215.h:295
@ AT86RF215_CLKO_4_MHz
4 MHz
Definition at86rf215.h:297
@ AT86RF215_CLKO_8_MHz
8 MHz
Definition at86rf215.h:296
@ AT86RF215_CLKO_OFF
Clock Output Disabled
Definition at86rf215.h:292
@ AT86RF215_STATE_TX
sending frame
Definition at86rf215.h:262
@ AT86RF215_STATE_SLEEP
sleep mode, not listening
Definition at86rf215.h:264
@ AT86RF215_STATE_OFF
radio not configured
Definition at86rf215.h:259
@ AT86RF215_STATE_IDLE
idle state, listening
Definition at86rf215.h:260
@ AT86RF215_STATE_RX_SEND_ACK
receiving frame, sending ACK
Definition at86rf215.h:261
@ AT86RF215_STATE_TX_WAIT_ACK
sending frame, wait for ACK
Definition at86rf215.h:263
gpio_t spi_cs_t
Chip select pin type overlaps with gpio_t so it can be casted to this.
Definition spi.h:135
Protocol type definitions.
Low-level SPI peripheral driver interface definition.
Base Band Controller registers.
Radio Frontend registers.
struct holding all params needed for device initialization
Definition at86rf215.h:330
spi_t spi
SPI bus the device is connected to.
Definition at86rf215.h:331
spi_clk_t spi_clk
SPI clock speed to use.
Definition at86rf215.h:332
gpio_t reset_pin
GPIO pin connected to the reset pin.
Definition at86rf215.h:335
gpio_t int_pin
GPIO pin connected to the interrupt pin.
Definition at86rf215.h:334
spi_cs_t cs_pin
GPIO pin connected to chip select.
Definition at86rf215.h:333
Device descriptor for AT86RF215 radio devices.
Definition at86rf215.h:343
uint32_t csma_backoff_period
CSMA Backoff period.
Definition at86rf215.h:352
const at86rf215_RF_regs_t * RF
Radio Frontend Registers.
Definition at86rf215.h:348
at86rf215_params_t params
parameters for initialization
Definition at86rf215.h:346
uint8_t csma_maxbe
CSMA maximum backoff exponent.
Definition at86rf215.h:366
uint32_t ack_timeout_usec
time to wait before retransmission in µs
Definition at86rf215.h:351
uint16_t flags
Device specific flags.
Definition at86rf215.h:353
uint8_t csma_retries_max
number of retries until channel is clear
Definition at86rf215.h:360
uint8_t retries
retries left
Definition at86rf215.h:359
uint8_t csma_retries
CSMA retries left.
Definition at86rf215.h:361
int8_t csma_ed
CSMA energy detect threshold.
Definition at86rf215.h:367
xtimer_t timer
timer for ACK & CSMA timeout
Definition at86rf215.h:350
uint8_t csma_minbe
CSMA minimum backoff exponent.
Definition at86rf215.h:365
uint16_t num_chans
Number of legal channel at current modulation.
Definition at86rf215.h:354
const at86rf215_BBC_regs_t * BBC
Baseband Registers.
Definition at86rf215.h:349
uint8_t retries_max
number of retries until ACK is received
Definition at86rf215.h:358
uint16_t tx_frame_len
length of the current TX frame
Definition at86rf215.h:355
struct at86rf215 * sibling
The other radio.
Definition at86rf215.h:347
uint8_t timeout
indicates which timeout was reached
Definition at86rf215.h:356
netdev_ieee802154_t netdev
netdev parent struct
Definition at86rf215.h:344
uint8_t state
current state of the radio
Definition at86rf215.h:357
Extended structure to hold IEEE 802.15.4 driver state.
Definition ieee802154.h:100
uint16_t pan
IEEE 802.15.4 specific fields.
Definition ieee802154.h:113
int16_t txpower
tx power in dBm
Definition ieee802154.h:128
uint8_t chan
channel
Definition ieee802154.h:125
xtimer timer structure
Definition xtimer.h:97
xtimer interface definitions