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 
243 #ifndef CC110X_DEFAULT_CHANNEL
244 
247 #define CC110X_DEFAULT_CHANNEL (0U)
248 #endif
249 
257 typedef enum {
258  CC110X_STATE_IDLE = 0b00000000,
273  CC110X_STATE_OFF = 0b00010000,
274  CC110X_STATE_RX_MODE = 0b00000001,
281  CC110X_STATE_TX_MODE = 0b00000010,
288  CC110X_STATE_FSTXON = 0b00000011,
289  CC110X_STATE_CALIBRATE = 0b00000100,
290  CC110X_STATE_SETTLING = 0b00000101,
294 
298 typedef enum {
309 
323 typedef struct {
324  uint8_t data[8];
326 
327 
351 typedef struct {
352  uint8_t base_freq[3];
364  uint8_t fsctrl1;
380  uint8_t mdmcfg4;
396  uint8_t mdmcfg3;
419  uint8_t deviatn;
421 
447 typedef struct {
448  uint8_t map[CC110X_MAX_CHANNELS];
450 
454 typedef struct {
465  gpio_t gdo0;
466  gpio_t gdo2;
471  uint8_t l2addr;
473 
477 typedef struct {
482  char fscal1[CC110X_MAX_CHANNELS];
483  char fscal2;
484  char fscal3;
486 
495 typedef struct __attribute__((packed)) {
496  uint8_t len;
500  uint8_t data[CC110X_MAX_FRAME_SIZE];
511  uint8_t pos;
513 
517 typedef struct {
519  uint8_t addr;
520  /* Keep above in sync with cc1xx_t members, as they must overlap! */
521  cc110x_state_t state;
522  cc110x_tx_power_t tx_power;
523  uint8_t channel;
524  /* Struct packing: addr, state, tx_power and channel add up to 32 bit */
544  uint8_t rssi_offset;
545 } cc110x_t;
546 
559 int cc110x_setup(cc110x_t *dev, const cc110x_params_t *params);
560 
585 int cc110x_apply_config(cc110x_t *dev, const cc110x_config_t *conf,
586  const cc110x_chanmap_t *chanmap, uint8_t channel);
587 
604 
623 int cc110x_set_channel(cc110x_t *dev, uint8_t channel);
624 
637 int cc110x_set_tx_power(cc110x_t *dev, cc110x_tx_power_t power);
638 
639 #ifdef __cplusplus
640 }
641 #endif
642 
643 #endif /* CC110X_H */
644 
Transmit mode.
Definition: cc110x.h:281
gpio_t gdo2
GPIO pin connected to GDO2.
Definition: cc110x.h:466
int cc110x_set_tx_power(cc110x_t *dev, cc110x_tx_power_t power)
Set the TX power to the specified value.
Listening for frames.
Definition: cc110x.h:274
cc110x_fs_calibration_t fscal
Frequency synthesizer calibration data.
Definition: cc110x.h:535
Fast TX ready.
Definition: cc110x.h:288
Waiting for transceiver to complete outgoing transmission.
Definition: cc110x.h:287
CC110x/CC1200 adaption for Network interface API.
Low-level GPIO peripheral driver interface definitions.
int cc110x_set_channel(cc110x_t *dev, uint8_t channel)
Hops to the specified channel.
char fscal3
charge pump current calibration, independent of channel
Definition: cc110x.h:484
cc110x_params_t params
Configuration of the driver.
Definition: cc110x.h:526
spi_cs_t cs
GPIO pin connected to chip select.
Definition: cc110x.h:464
uint8_t channel
Currently tuned (virtual) channel.
Definition: cc110x.h:523
uint8_t deviatn
DEVIANT configuration register that affects the amount by which the radio frequency is shifted in FSK...
Definition: cc110x.h:419
Definitions low-level network driver interface.
uint8_t rssi_offset
dBm to subtract from raw RSSI data
Definition: cc110x.h:544
PLL is settling.
Definition: cc110x.h:290
uint8_t l2addr
Layer-2 address to use or CC110X_L2ADDR_AUTO to derive it from the CPU ID.
Definition: cc110x.h:471
const cc110x_chanmap_t * channels
Pointer to the channel map to use.
Definition: cc110x.h:525
uint8_t addr
Layer 2 address of this device.
Definition: cc110x.h:519
Low-level ADC peripheral driver interface definitions.
Received packet status information for most radios.
Definition: netdev.h:257
RX FIFO overflown.
Definition: cc110x.h:291
Low-level SPI peripheral driver interface definition.
Device is calibrating.
Definition: cc110x.h:289
gpio_t spi_cs_t
Chip select pin type overlaps with gpio_t so it can be casted to this.
Definition: spi.h:126
#define CC110X_MAX_CHANNELS
Maximum number of channels supported by the driver.
Definition: cc110x.h:226
uint8_t mdmcfg3
MDMCFG3 configuration register value that affects the data rate.
Definition: cc110x.h:396
Frame received, waiting for upper layer to retrieve it.
Definition: cc110x.h:264
Structure holding all parameter for driver initialization.
Definition: cc110x.h:454
int cc110x_setup(cc110x_t *dev, const cc110x_params_t *params)
Setup the CC1100/CC1101 driver, but perform no initialization.
uint8_t len
Length of the frame in bytes.
Definition: cc110x.h:496
TX FIFO underflown.
Definition: cc110x.h:292
spi_clk_t
Available SPI clock speeds.
Definition: spi.h:173
netdev_t netdev
RIOT&#39;s interface to this driver.
Definition: cc110x.h:518
cc110x_tx_power_t tx_power
TX power of the receiver.
Definition: cc110x.h:522
Structure to hold driver state.
Definition: netdev.h:283
uint8_t pos
Index of the next cc110x_framebuf_t::data element to transfer.
Definition: cc110x.h:511
Device descriptor for CC1100/CC1101 transceivers.
Definition: cc110x.h:517
uint8_t mdmcfg4
MDMCFG4 configuration register value that affects channel filter bandwidth and the data rate...
Definition: cc110x.h:380
spi_clk_t spi_clk
SPI clock to use (max 6.5 MHz)
Definition: cc110x.h:463
cc110x_state_t state
State of the transceiver.
Definition: cc110x.h:521
Mutex for thread synchronization.
const cc110x_chanmap_t * channels
Pointer to the default channel map.
Definition: cc110x.h:461
cc110x_tx_power_t
Enumeration over the possible TX power settings the driver offers.
Definition: cc110x.h:298
Number of TX power options.
Definition: cc110x.h:307
spi_t spi
SPI bus connected to the device.
Definition: cc110x.h:462
cc1xxx_rx_info_t rx_info
RSSI and LQI of the last received frame.
Definition: cc110x.h:531
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:460
char fscal2
VCO current calibration, independent of channel.
Definition: cc110x.h:483
uint8_t fsctrl1
FSCTRL1 configuration register value that affects the intermediate frequency of the transceiver to us...
Definition: cc110x.h:364
Structure to hold mapping between virtual and physical channel numbers.
Definition: cc110x.h:447
Buffer to temporary store incoming/outgoing packet.
Definition: cc110x.h:495
#define CC110X_MAX_FRAME_SIZE
Length of a layer 2 frame.
Definition: cc110x.h:216
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.
IDLE state.
Definition: cc110x.h:258
Mutex structure.
Definition: mutex.h:37
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:543
const cc110x_patable_t * patable
Pointer to the PATABLE to use.
Definition: cc110x.h:455
int cc110x_full_calibration(cc110x_t *dev)
Perform a calibration of the frequency generator for each supported channel.
Frame received, waiting for upper layer to retrieve it.
Definition: cc110x.h:273
Protocol type definitions.
cc110x_framebuf_t buf
Temporary frame buffer.
Definition: cc110x.h:527
gpio_t gdo0
GPIO pin connected to GDO0.
Definition: cc110x.h:465
cc110x_state_t
The state of the CC1100/CC1101 transceiver.
Definition: cc110x.h:257
unsigned int spi_t
Default type for SPI devices.
Definition: spi.h:118
Configuration of the transceiver to use.
Definition: cc110x.h:351
Structure holding the calibration data of the frequency synthesizer.
Definition: cc110x.h:477
Structure that holds the PATABLE, which allows to configure the 8 available output power levels using...
Definition: cc110x.h:323
Receiving a frame just now.
Definition: cc110x.h:280