Contiki-NG
Loading...
Searching...
No Matches
at86rf215.c File Reference

AT86RF215 driver for Contiki-NG, version 0.1. More...

#include "contiki.h"
#include "dev/radio.h"
#include "net/netstack.h"
#include "net/mac/tsch/tsch.h"
#include "at86rf215.h"
#include "at86rf215-arch.h"
#include "at86rf215-conf.h"
#include "at86rf215-registermap.h"
#include "at86rf215-def.h"
#include "sys/log.h"

Go to the source code of this file.

Macros

#define RG_RFn_STATE   RG_RF24_STATE
 Current drivers support only one BBC (RF band) at a time.
 

Functions

static void set_auto_ack (uint8_t enable)
 
static void set_frequency (uint16_t freq, uint8_t decimal)
 Set frequency via fine resolution obtion.
 
static uint8_t regRead (uint16_t address)
 Read a single register (16-bit) from the AT86RF215 Implementation of the so called single access mode.
 
static void regWrite (uint16_t address, uint8_t data)
 Write a single register (16-bit) to the AT86RF215.
 
static uint8_t bitRead (uint16_t address, uint8_t mask, uint8_t offset)
 Read one ore multiple bits from the radio's register.
 
static void bitWrite (uint16_t address, uint8_t mask, uint8_t offset, uint8_t value)
 Write one ore multiple bits to the radio's register.
 
static void burstRead (uint16_t address, uint8_t *data, uint16_t len)
 Read a burst of data from the AT86RF215 registers.
 
static void burstWrite (uint16_t address, uint8_t *data, uint16_t len)
 Write a burst of data to the AT86RF215 registers.
 
static void frameRead (uint8_t *frame, uint16_t *frame_len)
 Custom fuction to read a packet frame from the radio's memory.
 
static void frameWrite (uint8_t *frame, uint16_t frame_len)
 Custom fuction to write a packet frame to the radio's memory.
 
int at86rf215_channel_clear (void)
 
void at86rf215_isr (void)
 Interrupt service routine for the AT86RF215.
 
 PROCESS_THREAD (at86rf215_process, ev, data)
 Contiki-NG process for the AT86RF215 driver.
 

Variables

static at86rf215_rx_frame_t rx_frame
 Contiki-NG requires that the driver stores the values of last RSSI, LQI and timestamp -> we are using at86rf215_rx_frame_t for that.
 
static uint8_t current_channel = IEEE802154_DEFAULT_CHANNEL
 It is easier to store the current channel in a global variable than to read it from the radio register every time it is needed.
 
static volatile at86rf215_flags_t flags
 The radio driver uses the following flags to keep track of the current state of the radio and IRQ events.
 
static uint8_t radio_send_on_cca = 0
 Radio configuration parameters according to the Contiki-NG radio API.
 
const struct radio_driver at86rf215_driver
 The NETSTACK data structure for the AT86RF215 driver.
 

Detailed Description

AT86RF215 driver for Contiki-NG, version 0.1.

Author
Grega Morano grega.nosp@m..mor.nosp@m.ano@i.nosp@m.js.s.nosp@m.i

Drivers for AT86RF215 radio, supporting only one BBC (RF core) at a time. Currently only 2.4 GHz O-QPSK modulation tested. Drivers designed to support TSCH, but CSMA works as well. Radio config can be done in at86rf215-conf.h

Definition in file at86rf215.c.

Macro Definition Documentation

◆ RG_RFn_STATE

#define RG_RFn_STATE   RG_RF24_STATE

Current drivers support only one BBC (RF band) at a time.

Regarding the defined frequency band, the following macros are used to select the corresponding registers.

Note: The driver is not tested for the Sub-GHz band yet!

Definition at line 71 of file at86rf215.c.

Function Documentation

◆ at86rf215_channel_clear()

int at86rf215_channel_clear ( void )

Contiki-NG CSMA mode calls the channel clear function to sense if there is an ACK in the air (besides calling receiving_packet and pending_packet) So instead of receiving an ACK, with this function (implemented from the reference manual) what we do is we put the radio to TXPREP and disable BBC to avoid packet detection to be able to measure Energy Detection value. TODO: ... So at this point, we just return 1 --> chanel not busy

For TSCH, this implementation is usefull, but the CCA in TSCH is disabled by default (TSCH_CCA_ENABLED) ...

Definition at line 506 of file at86rf215.c.

◆ at86rf215_isr()

void at86rf215_isr ( void )

Interrupt service routine for the AT86RF215.

Interrupt routine.

This function is called by the GPIO interrupt handler. The interrupt can be triggered by the radio (RF) or the baseband part (BBC). Depending on the predefined frequency band, correct register addresses are used to read the interrupt states. The states are then used to set the corresponding flags. To clear the IRQ line, all 4 interrupts registers must be read.

Definition at line 811 of file at86rf215.c.

References flags, process_poll(), regRead(), RTIMER_NOW, and rx_frame.

◆ bitRead()

static uint8_t bitRead ( uint16_t address,
uint8_t mask,
uint8_t offset )
static

Read one ore multiple bits from the radio's register.

For params (addr, mask, offset) --> u can use SR_ defines in registermap.h

Definition at line 1218 of file at86rf215.c.

References regRead().

◆ bitWrite()

static void bitWrite ( uint16_t address,
uint8_t mask,
uint8_t offset,
uint8_t value )
static

Write one ore multiple bits to the radio's register.

The previous content of the registers is not overwritten.

For (addr, mask, offset) --> u can use SR_ defines in registermap.h

Definition at line 1230 of file at86rf215.c.

References regRead(), and regWrite().

Referenced by set_auto_ack().

◆ burstRead()

static void burstRead ( uint16_t address,
uint8_t * data,
uint16_t len )
static

Read a burst of data from the AT86RF215 registers.

Implementation of so called block access mode.

Definition at line 1240 of file at86rf215.c.

References at86rf215_arch_spi_deselect(), at86rf215_arch_spi_select(), and at86rf215_arch_spi_txrx().

Referenced by frameRead().

◆ burstWrite()

static void burstWrite ( uint16_t address,
uint8_t * data,
uint16_t len )
static

Write a burst of data to the AT86RF215 registers.

Implementation of so called block access mode.

Definition at line 1259 of file at86rf215.c.

References at86rf215_arch_spi_deselect(), at86rf215_arch_spi_select(), and at86rf215_arch_spi_txrx().

Referenced by frameWrite().

◆ PROCESS_THREAD()

PROCESS_THREAD ( at86rf215_process ,
ev ,
data  )

Contiki-NG process for the AT86RF215 driver.

The process is started by the at86rf215_init() function and waits idle for an event. The event is triggered at the at86rf215_isr() function when the radio has received a packet. In pool mode, the upper layer has to poll the driver for new packets and therefore this process is not used.

Definition at line 870 of file at86rf215.c.

References flags, mac_driver::input, packetbuf_clear(), packetbuf_dataptr(), packetbuf_set_datalen(), PACKETBUF_SIZE, PROCESS_BEGIN, PROCESS_END, PROCESS_YIELD_UNTIL, and rx_frame.

◆ set_auto_ack()

static void set_auto_ack ( uint8_t enable)
static

Auto ACK is sent if the frame passes all third level filtering rules, therefore frame filtering must be enabled beforehand.

Definition at line 927 of file at86rf215.c.

References bitWrite(), and regWrite().

◆ set_frequency()

void set_frequency ( uint16_t freq,
uint8_t decimal )
inlinestatic

Set frequency via fine resolution obtion.

param freq is valid in range of 2400 to 2482 MHz. param decimal is valid in range of 0 to 9.

NOTE: This implementation is valid only for 2.4 GHz band!

To set the requency to 2440.5 MHz, set: freq = 2440 and decimal = 5. f = 2366 MHz + (26 MHz * N) / 2^16

Definition at line 1153 of file at86rf215.c.

References regWrite().