cc110x.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2013 INRIA
3  * 2014 Freie Universität Berlin
4  * 2015 Kaspar Schleiser <kaspar@schleiser.de>
5  * 2018,2019 Otto-von-Guericke-Universität Magdeburg
6  *
7  * This file is subject to the terms and conditions of the GNU Lesser General
8  * Public License v2.1. See the file LICENSE in the top level directory for more
9  * details.
10  */
11 
194 #ifndef CC110X_H
195 #define CC110X_H
196 
197 #include <stdint.h>
198 
199 #include "cc1xxx_common.h"
200 #include "mutex.h"
201 #include "net/gnrc/nettype.h"
202 #include "net/netdev.h"
203 #include "periph/adc.h"
204 #include "periph/gpio.h"
205 #include "periph/spi.h"
206 
207 #ifdef __cplusplus
208 extern "C" {
209 #endif
210 
216 #define CC110X_MAX_FRAME_SIZE 0xFF
217 
221 #define CC110X_MAX_PAYLOAD_SIZE (CC110X_MAX_FRAME_SIZE - CC1XXX_HEADER_SIZE)
222 
226 #define CC110X_MAX_CHANNELS 8
227 
232 #define CC110X_L2ADDR_AUTO 0x00
233 
237 #ifdef MODULE_GNRC_SIXLOWPAN
238 #define CC110X_DEFAULT_PROTOCOL (GNRC_NETTYPE_SIXLOWPAN)
239 #else
240 #define CC110X_DEFAULT_PROTOCOL (GNRC_NETTYPE_UNDEF)
241 #endif
242 
251 #ifndef CONFIG_CC110X_DEFAULT_CHANNEL
252 #define CONFIG_CC110X_DEFAULT_CHANNEL (0U)
253 #endif
254 
263 typedef enum {
300 
304 typedef enum {
315 
329 typedef struct {
330  uint8_t data[8];
332 
333 
357 typedef struct {
358  uint8_t base_freq[3];
370  uint8_t fsctrl1;
386  uint8_t mdmcfg4;
402  uint8_t mdmcfg3;
425  uint8_t deviatn;
427 
453 typedef struct {
454  uint8_t map[CC110X_MAX_CHANNELS];
456 
460 typedef struct {
471  gpio_t gdo0;
472  gpio_t gdo2;
477  uint8_t l2addr;
479 
483 typedef struct {
488  char fscal1[CC110X_MAX_CHANNELS];
489  char fscal2;
490  char fscal3;
492 
501 typedef struct __attribute__((packed)) {
502  uint8_t len;
506  uint8_t data[CC110X_MAX_FRAME_SIZE];
517  uint8_t pos;
519 
523 typedef struct {
525  uint8_t addr;
526  /* Keep above in sync with cc1xx_t members, as they must overlap! */
529  uint8_t channel;
530  /* Struct packing: addr, state, tx_power and channel add up to 32 bit */
550  uint8_t rssi_offset;
551 } cc110x_t;
552 
565 int cc110x_setup(cc110x_t *dev, const cc110x_params_t *params);
566 
591 int cc110x_apply_config(cc110x_t *dev, const cc110x_config_t *conf,
592  const cc110x_chanmap_t *chanmap, uint8_t channel);
593 
610 
629 int cc110x_set_channel(cc110x_t *dev, uint8_t channel);
630 
644 
645 #ifdef __cplusplus
646 }
647 #endif
648 
649 #endif /* CC110X_H */
650 
cc110x_t::tx_power
cc110x_tx_power_t tx_power
TX power of the receiver.
Definition: cc110x.h:528
cc110x_tx_power_t
cc110x_tx_power_t
Enumeration over the possible TX power settings the driver offers.
Definition: cc110x.h:304
cc110x_config_t::mdmcfg3
uint8_t mdmcfg3
MDMCFG3 configuration register value that affects the data rate.
Definition: cc110x.h:402
CC110X_STATE_CALIBRATE
@ CC110X_STATE_CALIBRATE
Device is calibrating.
Definition: cc110x.h:295
CC110X_MAX_FRAME_SIZE
#define CC110X_MAX_FRAME_SIZE
Length of a layer 2 frame.
Definition: cc110x.h:216
cc110x_params_t::l2addr
uint8_t l2addr
Layer-2 address to use or CC110X_L2ADDR_AUTO to derive it from the CPU ID.
Definition: cc110x.h:477
cc110x_fs_calibration_t::fscal2
char fscal2
VCO current calibration, independent of channel.
Definition: cc110x.h:489
cc110x_params_t::channels
const cc110x_chanmap_t * channels
Pointer to the default channel map.
Definition: cc110x.h:467
cc110x_fs_calibration_t
Structure holding the calibration data of the frequency synthesizer.
Definition: cc110x.h:483
CC110X_TX_POWER_PLUS_10_DBM
@ CC110X_TX_POWER_PLUS_10_DBM
10 dBm
Definition: cc110x.h:312
CC110X_TX_POWER_PLUS_5_DBM
@ CC110X_TX_POWER_PLUS_5_DBM
5 dBm
Definition: cc110x.h:310
spi.h
Low-level SPI peripheral driver interface definition.
cc110x_t::netdev
netdev_t netdev
RIOT's interface to this driver.
Definition: cc110x.h:524
cc110x_t::isr_signal
mutex_t isr_signal
Use mutex to block during TX and unblock from ISR when ISR needs to be handled from thread-context.
Definition: cc110x.h:549
CC110X_STATE_FRAME_READY
@ CC110X_STATE_FRAME_READY
Frame received, waiting for upper layer to retrieve it.
Definition: cc110x.h:270
CC110X_TX_POWER_NUMOF
@ CC110X_TX_POWER_NUMOF
Number of TX power options.
Definition: cc110x.h:313
cc110x_framebuf_t::len
uint8_t len
Length of the frame in bytes.
Definition: cc110x.h:502
cc110x_params_t::config
const cc110x_config_t * config
Pointer to the configuration of the base frequency, data rate and channel bandwidth; or NULL to keep ...
Definition: cc110x.h:466
adc.h
Low-level ADC peripheral driver interface definitions.
CC110X_STATE_RECEIVING
@ CC110X_STATE_RECEIVING
Receiving a frame just now.
Definition: cc110x.h:286
CC110X_STATE_OFF
@ CC110X_STATE_OFF
Frame received, waiting for upper layer to retrieve it.
Definition: cc110x.h:279
cc110x_params_t
Structure holding all parameter for driver initialization.
Definition: cc110x.h:460
cc110x_t::fscal
cc110x_fs_calibration_t fscal
Frequency synthesizer calibration data.
Definition: cc110x.h:541
cc110x_t::buf
cc110x_framebuf_t buf
Temporary frame buffer.
Definition: cc110x.h:533
cc110x_config_t
Configuration of the transceiver to use.
Definition: cc110x.h:357
cc110x_set_channel
int cc110x_set_channel(cc110x_t *dev, uint8_t channel)
Hops to the specified channel.
cc110x_params_t::spi_clk
spi_clk_t spi_clk
SPI clock to use (max 6.5 MHz)
Definition: cc110x.h:469
CC110X_STATE_TXFIFO_UNDERFLOW
@ CC110X_STATE_TXFIFO_UNDERFLOW
TX FIFO underflown.
Definition: cc110x.h:298
CC110X_STATE_TX_MODE
@ CC110X_STATE_TX_MODE
Transmit mode.
Definition: cc110x.h:287
cc1xxx_common.h
CC110x/CC1200 adaption for Network interface API.
spi_cs_t
gpio_t spi_cs_t
Chip select pin type overlaps with gpio_t so it can be casted to this.
Definition: spi.h:126
CC110X_MAX_CHANNELS
#define CC110X_MAX_CHANNELS
Maximum number of channels supported by the driver.
Definition: cc110x.h:226
cc110x_t::channel
uint8_t channel
Currently tuned (virtual) channel.
Definition: cc110x.h:529
cc110x_t::state
cc110x_state_t state
State of the transceiver.
Definition: cc110x.h:527
cc110x_set_tx_power
int cc110x_set_tx_power(cc110x_t *dev, cc110x_tx_power_t power)
Set the TX power to the specified value.
cc110x_framebuf_t
Buffer to temporary store incoming/outgoing packet.
Definition: cc110x.h:501
CC110X_STATE_IDLE
@ CC110X_STATE_IDLE
IDLE state.
Definition: cc110x.h:264
CC110X_STATE_FSTXON
@ CC110X_STATE_FSTXON
Fast TX ready.
Definition: cc110x.h:294
CC110X_TX_POWER_PLUS_7_DBM
@ CC110X_TX_POWER_PLUS_7_DBM
7 dBm
Definition: cc110x.h:311
spi_clk_t
spi_clk_t
Available SPI clock speeds.
Definition: spi.h:173
cc110x_framebuf_t::pos
uint8_t pos
Index of the next cc110x_framebuf_t::data element to transfer.
Definition: cc110x.h:517
CC110X_STATE_RX_MODE
@ CC110X_STATE_RX_MODE
Listening for frames.
Definition: cc110x.h:280
netdev.h
Definitions low-level network driver interface.
cc110x_config_t::fsctrl1
uint8_t fsctrl1
FSCTRL1 configuration register value that affects the intermediate frequency of the transceiver to us...
Definition: cc110x.h:370
CC110X_TX_POWER_MINUS_10_DBM
@ CC110X_TX_POWER_MINUS_10_DBM
-10 dBm
Definition: cc110x.h:308
cc110x_t::rx_info
cc1xxx_rx_info_t rx_info
RSSI and LQI of the last received frame.
Definition: cc110x.h:537
nettype.h
Protocol type definitions.
cc110x_apply_config
int cc110x_apply_config(cc110x_t *dev, const cc110x_config_t *conf, const cc110x_chanmap_t *chanmap, uint8_t channel)
Apply the given configuration and the given channel map and performs a recalibration.
cc110x_t::params
cc110x_params_t params
Configuration of the driver.
Definition: cc110x.h:532
CC110X_TX_POWER_MINUS_30_DBM
@ CC110X_TX_POWER_MINUS_30_DBM
-30 dBm
Definition: cc110x.h:305
cc110x_t::channels
const cc110x_chanmap_t * channels
Pointer to the channel map to use.
Definition: cc110x.h:531
cc110x_t::rssi_offset
uint8_t rssi_offset
dBm to subtract from raw RSSI data
Definition: cc110x.h:550
CC110X_TX_POWER_0_DBM
@ CC110X_TX_POWER_0_DBM
0 dBm
Definition: cc110x.h:309
CC110X_STATE_SETTLING
@ CC110X_STATE_SETTLING
PLL is settling.
Definition: cc110x.h:296
netdev
Structure to hold driver state.
Definition: netdev.h:302
cc110x_config_t::deviatn
uint8_t deviatn
DEVIANT configuration register that affects the amount by which the radio frequency is shifted in FSK...
Definition: cc110x.h:425
cc110x_patable_t
Structure that holds the PATABLE, which allows to configure the 8 available output power levels using...
Definition: cc110x.h:329
CC110X_TX_POWER_MINUS_15_DBM
@ CC110X_TX_POWER_MINUS_15_DBM
-15 dBm
Definition: cc110x.h:307
cc110x_params_t::spi
spi_t spi
SPI bus connected to the device.
Definition: cc110x.h:468
cc110x_setup
int cc110x_setup(cc110x_t *dev, const cc110x_params_t *params)
Setup the CC1100/CC1101 driver, but perform no initialization.
mutex.h
Mutex for thread synchronization.
cc110x_params_t::gdo2
gpio_t gdo2
GPIO pin connected to GDO2.
Definition: cc110x.h:472
gpio.h
Low-level GPIO peripheral driver interface definitions.
cc110x_chanmap_t
Structure to hold mapping between virtual and physical channel numbers.
Definition: cc110x.h:453
CC110X_TX_POWER_MINUS_20_DBM
@ CC110X_TX_POWER_MINUS_20_DBM
-20 dBm
Definition: cc110x.h:306
cc110x_params_t::patable
const cc110x_patable_t * patable
Pointer to the PATABLE to use.
Definition: cc110x.h:461
cc110x_fs_calibration_t::fscal3
char fscal3
charge pump current calibration, independent of channel
Definition: cc110x.h:490
cc110x_t::addr
uint8_t addr
Layer 2 address of this device.
Definition: cc110x.h:525
cc110x_state_t
cc110x_state_t
The state of the CC1100/CC1101 transceiver.
Definition: cc110x.h:263
cc110x_params_t::cs
spi_cs_t cs
GPIO pin connected to chip select.
Definition: cc110x.h:470
CC110X_STATE_TX_COMPLETING
@ CC110X_STATE_TX_COMPLETING
Waiting for transceiver to complete outgoing transmission.
Definition: cc110x.h:293
CC110X_STATE_RXFIFO_OVERFLOW
@ CC110X_STATE_RXFIFO_OVERFLOW
RX FIFO overflown.
Definition: cc110x.h:297
can_frame::data
uint8_t data[CAN_MAX_DLEN]
Frame data.
Definition: can.h:95
cc110x_config_t::mdmcfg4
uint8_t mdmcfg4
MDMCFG4 configuration register value that affects channel filter bandwidth and the data rate.
Definition: cc110x.h:386
cc110x_full_calibration
int cc110x_full_calibration(cc110x_t *dev)
Perform a calibration of the frequency generator for each supported channel.
cc110x_params_t::gdo0
gpio_t gdo0
GPIO pin connected to GDO0.
Definition: cc110x.h:471
netdev_radio_rx_info
Received frame status information for most radios.
Definition: netdev.h:258
mutex_t
Mutex structure.
Definition: mutex.h:120
cc110x_t
Device descriptor for CC1100/CC1101 transceivers.
Definition: cc110x.h:523
spi_t
unsigned int spi_t
Default type for SPI devices.
Definition: spi.h:118