cc110x.h
3.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/*
* Copyright (C) 2014 Freie Universität Berlin
* 2015 Kaspar Schleiser <kaspar@schleiser.de>
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @defgroup drivers_cc110x CC1100/CC1101 radio driver
* @ingroup drivers_netdev
* @brief Driver for TI CC1100/CC1101 radios
* @{
* @file
* @brief Public interface for cc110x driver
* @author Kaspar Schleiser <kaspar@schleiser.de>
*/
#ifndef CC110X_H
#define CC110X_H
#ifdef __cplusplus
extern "C" {
#endif
#include "periph/spi.h"
#include "periph/gpio.h"
#include "cc110x-internal.h"
#include "net/gnrc/nettype.h"
/**
* @brief Struct for holding cc110x IO parameters
*/
typedef struct cc110x_params {
spi_t spi; /**< what */
gpio_t cs; /**< does */
gpio_t gdo0; /**< this */
gpio_t gdo1; /**< look */
gpio_t gdo2; /**< like */
} cc110x_params_t;
/**
* @brief Forward declaration
*/
typedef struct cc110x cc110x_t;
/**
* @brief Struct for holding cc110x device state
*/
struct cc110x {
cc110x_params_t params; /**< cc110x IO configuration */
cc110x_statistic_t cc110x_statistic; /**< Statistic values for
debugging */
uint8_t radio_state; /**< Radio state */
uint8_t radio_channel; /**< current Radio channel */
uint8_t radio_address; /**< current Radio address */
cc110x_pkt_buf_t pkt_buf; /**< RX/TX buffer */
void (*isr_cb)(cc110x_t *dev, void* arg); /**< isr callback */
void *isr_cb_arg; /**< isr callback argument */
#ifdef MODULE_GNRC_NETIF
gnrc_nettype_t proto; /**< protocol the radio expects */
#endif
};
/**
* @brief Setup cc110x device parameters
*
* @param[in] dev device struct to set up
* @param[in] params struct holding parameters
*
* @return always succeeds
*/
int cc110x_setup(cc110x_t *dev, const cc110x_params_t *params);
/**
* @brief Set cc110x channel number
*
* @param[in] dev device to work on
* @param[in] channr guess what
*
* @return nr of set channel on success
* @return -1 on error
*/
int16_t cc110x_set_channel(cc110x_t *dev, uint8_t channr);
/**
* @brief Send raw cc110x packet
*
* @param[in] dev Device to send on
* @param[in] packet ptr to packet to be sent
*
* @return size of packet on success
* @return <0 on error
*/
int cc110x_send(cc110x_t *dev, cc110x_pkt_t *packet);
/**
* @brief Set cc110x radio address
*
* @param[in] dev device to query
*
* @return nr of currently set address
*/
uint8_t cc110x_get_address(cc110x_t *dev);
/**
* @brief Set cc110x radio address
*
* @param[in] dev device to work on
* @param[in] address new address
*
* @return address set on success
* @return 0 on error
*/
uint8_t cc110x_set_address(cc110x_t *dev, uint8_t address);
/**
* @brief Set cc110x monitor mode setting
*
* @param[in] dev device to work on
* @param[in] mode mode to set (0 or 1)
*/
void cc110x_set_monitor(cc110x_t *dev, uint8_t mode);
#ifdef __cplusplus
}
#endif
#endif /* CC110X_H */
/** @} */