Contiki-NG
Loading...
Searching...
No Matches
at86rf215.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2023, ComLab, Jozef Stefan Institute - https://e6.ijs.si/
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of the copyright holder nor the names of its
14 * contributors may be used to endorse or promote products derived
15 * from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
20 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
21 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
28 * OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30/*---------------------------------------------------------------------------*/
31/**
32 * \file
33 * Header file for the at86rf215.c
34 * \author
35 * Grega Morano <grega.morano@ijs.si>
36 */
37/*---------------------------------------------------------------------------*/
38#ifndef AT86RF215_H_
39#define AT86RF215_H_
40
41
42/* Radio states and flags */
43typedef union {
44 struct {
45 // Corresponds to radio states
46 uint8_t RECEIVE_ON:1; // Indicates that radio is (was) in RX state - it is used manly for CSMA, so that the radio is always on except when it is set to be off with _off();
47 uint8_t PLL_LOCK:1; // Indicates when TXPREP state was reached
48 uint8_t PLL_ERR:1;
49 uint8_t PACKET_PEN:1; // Packet is pending in the radios buffer
50
51 // Corresponds to radio interrupts
52 uint8_t RX_START:1; // Indicates when frame was detected
53 uint8_t AMI:1; // Indicates when frame address matched
54 uint8_t TX_END:1; // Indicates TX operation completed
55 uint8_t CCA:1; // Indicates when CCA has ended (single Energy Detection has Completed)
56 };
57 uint8_t value;
58} at86rf215_flags_t;
59
60/* RF IRQ bits */
61typedef union {
62 struct {
63 uint8_t IRQ1_WAKEUP:1; // If radio came from SLEEP state
64 uint8_t IRQ2_TRXRDY:1; // Indicates lock of the PLL (or state change from TRCOFF to TXPREP)
65 uint8_t IRQ3_EDC:1; // End of manual measurement of Energy Detection
66 uint8_t IRQ4_BATLOW:1;
67
68 uint8_t IRQ5_TRXERR:1; // If error during TRX (PLL-unlocks)
69 uint8_t IRQ6_IQIFSF:1; // Applicable in I/Q radio mode only.
70 };
71 uint8_t value;
72} at86rf215_rf_irq_t;
73
74/* BBC IRQ bits */
75typedef union {
76 struct {
77 uint8_t IRQ1_RXFS:1; // If a valid PHY header is received
78 uint8_t IRQ2_RXFE:1; // Issued at the end of a successful frame reception (first level filtering must pass)
79 uint8_t IRQ3_RXAM:1; // If address filter is enabled and frame is extended
80 uint8_t IRQ4_RXEM:1; // If address recognised as matching
81
82 uint8_t IRQ5_TXFE:1; // When the frame is transmitted (at the end)
83 uint8_t IRQ6_AGCH:1; // used by AGC (detected SHR)
84 uint8_t IRQ7_AGCR:1; // used by AGC (end of RX)
85 uint8_t IRQ8_FBLI:1; // If the preprogramed number of octects is received in the FB
86 };
87 uint8_t value;
88} at86rf215_bbc_irq_t;
89
90/* RX frame struct */
91typedef struct {
92 //uint8_t content[AT86RF215_MAX_PAYLOAD_SIZE];
93 //uint8_t len;
94 //uint16_t crc;
95 rtimer_clock_t timestamp;
96 uint8_t lqi;
97 int8_t rssi;
98} at86rf215_rx_frame_t;
99
100/* Basic radio configuration */
101typedef struct {
102 uint16_t address;
103 uint8_t value;
104} at86rf215_radio_config_t;
105
106/*---------------------------------------------------------------------------*/
107/* NETSTACK API radio driver functions */
108/*---------------------------------------------------------------------------*/
109int at86rf215_init(void);
110int at86rf215_prepare(const void *payload, unsigned short payload_len);
111int at86rf215_transmit(unsigned short payload_len);
112int at86rf215_send(const void *payload, unsigned short payload_len);
113int at86rf215_read(void *buf, unsigned short buf_len);
114int at86rf215_receiving_packet(void);
115int at86rf215_pending_packet(void);
116int at86rf215_on(void);
117int at86rf215_off(void);
119static radio_result_t at86rf215_get_value(radio_param_t param, radio_value_t *value);
120static radio_result_t at86rf215_set_value(radio_param_t param, radio_value_t value);
121static radio_result_t at86rf215_get_object(radio_param_t param, void *dest, size_t size);
122static radio_result_t at86rf215_set_object(radio_param_t param, const void *src, size_t size);
123
124/*---------------------------------------------------------------------------*/
125/** The NETSTACK data structure for the AT86RF215 driver */
126extern const struct radio_driver at86rf215_driver;
127
128#endif /* AT86RF215_H_ */
const struct radio_driver at86rf215_driver
The NETSTACK data structure for the AT86RF215 driver.
Definition at86rf215.c:783
int at86rf215_channel_clear(void)
Definition at86rf215.c:506
enum radio_result_e radio_result_t
Radio return values when setting or getting radio parameters.
int radio_value_t
Each radio has a set of parameters that designate the current configuration and state of the radio.
Definition radio.h:88
The structure of a Contiki-NG radio device driver.
Definition radio.h:534