Loading...
Searching...
No Matches
cc110x.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2013 INRIA
3 * SPDX-FileCopyrightText: 2014 Freie Universität Berlin
4 * SPDX-FileCopyrightText: 2015 Kaspar Schleiser <kaspar@schleiser.de>
5 * SPDX-FileCopyrightText: 2018-2019 Otto-von-Guericke-Universität Magdeburg
6 * SPDX-License-Identifier: LGPL-2.1-only
7 */
8
9#pragma once
10
192
193#include <stdint.h>
194
195#include "cc1xxx_common.h"
196#include "mutex.h"
197#include "net/gnrc/nettype.h"
198#include "net/netdev.h"
199#include "periph/adc.h"
200#include "periph/gpio.h"
201#include "periph/spi.h"
202
203#ifdef __cplusplus
204extern "C" {
205#endif
206
212#define CC110X_MAX_FRAME_SIZE 0xFF
213
217#define CC110X_MAX_PAYLOAD_SIZE (CC110X_MAX_FRAME_SIZE - CC1XXX_HEADER_SIZE)
218
222#define CC110X_MAX_CHANNELS 8
223
227#ifdef MODULE_GNRC_SIXLOWPAN
228#define CC110X_DEFAULT_PROTOCOL (GNRC_NETTYPE_SIXLOWPAN)
229#else
230#define CC110X_DEFAULT_PROTOCOL (GNRC_NETTYPE_UNDEF)
231#endif
232
242#ifndef CONFIG_CC110X_DEFAULT_CHANNEL
243#define CONFIG_CC110X_DEFAULT_CHANNEL (0U)
244#endif
246
291
306
320typedef struct {
321 uint8_t data[8];
323
347typedef struct {
348 uint8_t base_freq[3];
360 uint8_t fsctrl1;
376 uint8_t mdmcfg4;
392 uint8_t mdmcfg3;
415 uint8_t deviatn;
417
443typedef struct {
446
464
477
486typedef struct __attribute__((packed)) {
487 uint8_t len;
502 uint8_t pos;
504
508typedef struct {
510 uint8_t addr;
511 /* Keep above in sync with cc1xx_t members, as they must overlap! */
514 uint8_t channel;
515 /* Struct packing: addr, state, tx_power and channel add up to 32 bit */
535 uint8_t rssi_offset;
536} cc110x_t;
537
552int cc110x_setup(cc110x_t *dev, const cc110x_params_t *params, uint8_t index);
553
579 const cc110x_chanmap_t *chanmap, uint8_t channel);
580
597
616int cc110x_set_channel(cc110x_t *dev, uint8_t channel);
617
631
639
646
647#ifdef __cplusplus
648}
649#endif
650
Low-level ADC peripheral driver interface definitions.
spi_clk_t
Definition periph_cpu.h:348
CC110x/CC1200 adaption for Network interface API.
Definitions low-level network driver interface.
Low-level GPIO peripheral driver interface definitions.
cc110x_state_t
The state of the CC1100/CC1101 transceiver.
Definition cc110x.h:254
int cc110x_set_channel(cc110x_t *dev, uint8_t channel)
Hops to the specified channel.
int cc110x_full_calibration(cc110x_t *dev)
Perform a calibration of the frequency generator for each supported channel.
cc110x_tx_power_t
Enumeration over the possible TX power settings the driver offers.
Definition cc110x.h:295
#define CC110X_MAX_CHANNELS
Maximum number of channels supported by the driver.
Definition cc110x.h:222
#define CC110X_MAX_FRAME_SIZE
Length of a layer 2 frame.
Definition cc110x.h:212
int cc110x_set_tx_power(cc110x_t *dev, cc110x_tx_power_t power)
Set the TX power to the specified value.
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.
void cc110x_sleep(cc110x_t *dev)
Sets the transceiver into SLEEP mode.
int cc110x_setup(cc110x_t *dev, const cc110x_params_t *params, uint8_t index)
Setup the CC1100/CC1101 driver, but perform no initialization.
int cc110x_wakeup(cc110x_t *dev)
Wakes the transceiver from SLEEP mode and enters RX mode.
@ CC110X_STATE_CALIBRATE
Device is calibrating.
Definition cc110x.h:286
@ CC110X_STATE_RECEIVING
Receiving a frame just now.
Definition cc110x.h:277
@ CC110X_STATE_OFF
Devices is powered down.
Definition cc110x.h:270
@ CC110X_STATE_RXFIFO_OVERFLOW
RX FIFO overflown.
Definition cc110x.h:288
@ CC110X_STATE_FRAME_READY
Frame received, waiting for upper layer to retrieve it.
Definition cc110x.h:261
@ CC110X_STATE_FSTXON
Fast TX ready.
Definition cc110x.h:285
@ CC110X_STATE_SETTLING
PLL is settling.
Definition cc110x.h:287
@ CC110X_STATE_TX_COMPLETING
Waiting for transceiver to complete outgoing transmission.
Definition cc110x.h:284
@ CC110X_STATE_RX_MODE
Listening for frames.
Definition cc110x.h:271
@ CC110X_STATE_TX_MODE
Transmit mode.
Definition cc110x.h:278
@ CC110X_STATE_IDLE
IDLE state.
Definition cc110x.h:255
@ CC110X_STATE_TXFIFO_UNDERFLOW
TX FIFO underflown.
Definition cc110x.h:289
@ CC110X_TX_POWER_MINUS_30_DBM
-30 dBm
Definition cc110x.h:296
@ CC110X_TX_POWER_MINUS_10_DBM
-10 dBm
Definition cc110x.h:299
@ CC110X_TX_POWER_MINUS_15_DBM
-15 dBm
Definition cc110x.h:298
@ CC110X_TX_POWER_PLUS_5_DBM
5 dBm
Definition cc110x.h:301
@ CC110X_TX_POWER_0_DBM
0 dBm
Definition cc110x.h:300
@ CC110X_TX_POWER_NUMOF
Number of TX power options.
Definition cc110x.h:304
@ CC110X_TX_POWER_MINUS_20_DBM
-20 dBm
Definition cc110x.h:297
@ CC110X_TX_POWER_PLUS_7_DBM
7 dBm
Definition cc110x.h:302
@ CC110X_TX_POWER_PLUS_10_DBM
10 dBm
Definition cc110x.h:303
struct netdev_radio_rx_info cc1xxx_rx_info_t
Statistics for one received frame.
struct netdev netdev_t
Forward declaration for netdev struct.
Definition netdev.h:285
gpio_t spi_cs_t
Chip select pin type overlaps with gpio_t so it can be casted to this.
Definition spi.h:157
Mutex for thread synchronization.
Protocol type definitions.
Low-level SPI peripheral driver interface definition.
Structure to hold mapping between virtual and physical channel numbers.
Definition cc110x.h:443
uint8_t map[CC110X_MAX_CHANNELS]
"Physical" channel numbers
Definition cc110x.h:444
Configuration of the transceiver to use.
Definition cc110x.h:347
uint8_t base_freq[3]
Base frequency to use.
Definition cc110x.h:348
uint8_t mdmcfg4
MDMCFG4 configuration register value that affects channel filter bandwidth and the data rate.
Definition cc110x.h:376
uint8_t deviatn
DEVIANT configuration register that affects the amount by which the radio frequency is shifted in FSK...
Definition cc110x.h:415
uint8_t fsctrl1
FSCTRL1 configuration register value that affects the intermediate frequency of the transceiver to us...
Definition cc110x.h:360
uint8_t mdmcfg3
MDMCFG3 configuration register value that affects the data rate.
Definition cc110x.h:392
Buffer to temporary store incoming/outgoing packet.
Definition cc110x.h:486
uint8_t pos
Index of the next cc110x_framebuf_t::data element to transfer.
Definition cc110x.h:502
uint8_t len
Length of the frame in bytes.
Definition cc110x.h:487
uint8_t data[CC110X_MAX_FRAME_SIZE]
The payload data of the frame.
Definition cc110x.h:491
Structure holding the calibration data of the frequency synthesizer.
Definition cc110x.h:468
char fscal2
VCO current calibration, independent of channel.
Definition cc110x.h:474
char fscal1[CC110X_MAX_CHANNELS]
VCO capacitance calibration, which depends on the frequency and, thus, has to be stored for each chan...
Definition cc110x.h:473
char fscal3
charge pump current calibration, independent of channel
Definition cc110x.h:475
Structure holding all parameter for driver initialization.
Definition cc110x.h:450
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:456
const cc110x_chanmap_t * channels
Pointer to the default channel map.
Definition cc110x.h:457
spi_t spi
SPI bus connected to the device.
Definition cc110x.h:458
const cc110x_patable_t * patable
Pointer to the PATABLE to use.
Definition cc110x.h:451
gpio_t gdo2
GPIO pin connected to GDO2.
Definition cc110x.h:462
spi_clk_t spi_clk
SPI clock to use (max 6.5 MHz)
Definition cc110x.h:459
spi_cs_t cs
GPIO pin connected to chip select.
Definition cc110x.h:460
gpio_t gdo0
GPIO pin connected to GDO0.
Definition cc110x.h:461
Structure that holds the PATABLE, which allows to configure the 8 available output power levels using...
Definition cc110x.h:320
uint8_t data[8]
Magic number to store in the configuration register.
Definition cc110x.h:321
Device descriptor for CC1100/CC1101 transceivers.
Definition cc110x.h:508
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:534
cc110x_state_t state
State of the transceiver.
Definition cc110x.h:512
const cc110x_chanmap_t * channels
Pointer to the channel map to use.
Definition cc110x.h:516
netdev_t netdev
RIOT's interface to this driver.
Definition cc110x.h:509
cc1xxx_rx_info_t rx_info
RSSI and LQI of the last received frame.
Definition cc110x.h:522
cc110x_tx_power_t tx_power
TX power of the receiver.
Definition cc110x.h:513
uint8_t channel
Currently tuned (virtual) channel.
Definition cc110x.h:514
uint8_t addr
Layer 2 address of this device.
Definition cc110x.h:510
cc110x_fs_calibration_t fscal
Frequency synthesizer calibration data.
Definition cc110x.h:526
cc110x_framebuf_t buf
Temporary frame buffer.
Definition cc110x.h:518
uint8_t rssi_offset
dBm to subtract from raw RSSI data
Definition cc110x.h:535
cc110x_params_t params
Configuration of the driver.
Definition cc110x.h:517
Mutex structure.
Definition mutex.h:36