Loading...
Searching...
No Matches

Functions to communicate with the CC1100/CC1101 transceiver. More...

Detailed Description

Functions to communicate with the CC1100/CC1101 transceiver.

Author
Marian Buschsieweke maria.nosp@m.n.bu.nosp@m.schsi.nosp@m.ewek.nosp@m.e@ovg.nosp@m.u.de

Definition in file cc110x_communication.h.

#include "periph/gpio.h"
#include "periph/spi.h"
#include "cc110x.h"
#include "cc110x_constants.h"
+ Include dependency graph for cc110x_communication.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

static void cc110x_acquire (cc110x_t *dev)
 Acquire the SPI interface of the transceiver.
 
static void cc110x_release (cc110x_t *dev)
 Release the SPI interface of the transceiver.
 
uint8_t cc110x_read (cc110x_t *dev, uint8_t addr, uint8_t *dest)
 Read a single configuration/status register from the transceiver.
 
uint8_t cc110x_read_reliable (cc110x_t *dev, uint8_t addr, uint8_t *dest)
 Read a single status register from the transceiver reliable.
 
uint8_t cc110x_write (cc110x_t *dev, uint8_t addr, uint8_t data)
 Write to a single configuration register on the transceiver.
 
uint8_t cc110x_burst_read (cc110x_t *dev, uint8_t addr, void *dest, size_t len)
 Burst-read a bunch of configuration registers from the transceiver.
 
uint8_t cc110x_burst_write (cc110x_t *dev, uint8_t addr, const void *src, size_t len)
 Burst-write to a bunch of configuration registers on the transceiver.
 
uint8_t cc110x_cmd (cc110x_t *dev, uint8_t cmd)
 Send a command to the transceiver.
 
uint8_t cc110x_status (cc110x_t *dev)
 Get the transceivers status byte in a reliable way.
 
int cc110x_power_on_and_acquire (cc110x_t *dev)
 Wakes up the transceiver from "Sleep" or "Crystal oscillator off" state and waits until the crystal has stabilized.
 

Function Documentation

◆ cc110x_acquire()

static void cc110x_acquire ( cc110x_t dev)
inlinestatic

Acquire the SPI interface of the transceiver.

Precondition
When first acquiring the device either after boot or after having put the device to sleep mode, use cc110x_power_on_and_acquire instead. Subsequently, this function should be used (it is faster).

Definition at line 38 of file cc110x_communication.h.

◆ cc110x_burst_read()

uint8_t cc110x_burst_read ( cc110x_t dev,
uint8_t  addr,
void *  dest,
size_t  len 
)

Burst-read a bunch of configuration registers from the transceiver.

Parameters
devDevice descriptor of the transceiver to read from
addrAddress to start reading from
destDestination buffer to store the received data to
lenNumber of bytes to read starting from addr
Returns
The received status byte
Precondition
dest points to a pre-allocated buffer of >= len bytes
addr + len <= 0x2e (CC110X_REG_TEST0)
Warning
Burst read access from status registers is impossible (==> second precondition)
The received status byte is occasionally corrupted. (See Silicon Errata from 2015 at pages 4ff.) Use cc110x_status To get the status byte in a reliable way.

◆ cc110x_burst_write()

uint8_t cc110x_burst_write ( cc110x_t dev,
uint8_t  addr,
const void *  src,
size_t  len 
)

Burst-write to a bunch of configuration registers on the transceiver.

Parameters
devDevice descriptor of the transceiver to write
addrAddress to start writing to
srcBuffer holding the configuration to write
lenNumber of registers to write to
Returns
The received status byte
Precondition
src points to len bytes of readable memory
addr + len <= 0x2e (CC110X_REG_TEST0)
Warning
Writes to status registers is impossible (==> second precondition)
The received status byte is occasionally corrupted. (See Silicon Errata from 2015 at pages 4ff.) Use cc110x_status to get the status byte in a reliable way.

◆ cc110x_cmd()

uint8_t cc110x_cmd ( cc110x_t dev,
uint8_t  cmd 
)

Send a command to the transceiver.

Parameters
devDevice descriptor of the transceiver to send the command to
cmdCommand to send
Returns
The received status byte
Warning
The received status byte is occasionally corrupted. (See Silicon Errata from 2015 at pages 4ff.) Use cc110x_status to get the status byte in a reliable way.

◆ cc110x_power_on_and_acquire()

int cc110x_power_on_and_acquire ( cc110x_t dev)

Wakes up the transceiver from "Sleep" or "Crystal oscillator off" state and waits until the crystal has stabilized.

Thus function clears the CS pin, which triggers a transition from the "Sleep" or "Crystal oscillator off" states (see Figure 13 on page 28 in the data sheet).

If the crystal was off (only in above mentioned states), the MCU must wait for the transceiver to become ready before any SPI transfer is initiated. In all other states, CS pin can be pulled low and SPI transfer can start right away (see section 10 on page 29 in the data sheet). This driver will never disable the transceivers crystal, so this function has to be called only once when the transceiver is powered on.

The transceiver will signal that it is available by pulling the MISO pin low (section 10 on page 29 in the data sheet), which does not take longer than 150 microseconds (see Table 22 on page 30 in the data sheet). Instead of messing with the SPI interface, this driver simply waits for this upper bound, as suggested in the note below Table 22 on page 30 in the data sheet.

Precondition
The device was not acquired and in low power mode
Postcondition
The device is in IDLE mode and acquired
Return values
0Success
-EIOCouldn't pull the CS pin down (cc110x_params_t::cs)

◆ cc110x_read()

uint8_t cc110x_read ( cc110x_t dev,
uint8_t  addr,
uint8_t *  dest 
)

Read a single configuration/status register from the transceiver.

Parameters
devDevice descriptor of the transceiver to read the register from
addrAddress of the register to read
destWhere to store the received register content
Returns
The received status byte
Precondition
dest points to one byte of writeable memory
Warning
Race condition: SPI access to status registers can occur while their content is changed, resulting in corrupted data being retrieved. cc110x_read_reliable provides reliable access to status registers and should be used to read the TXBYTES, RXBYTES, MARCSTATE, LQI, RSSI, WORTIME1 and WORTIME0 status registers. (See Silicon Errata from 2015 at pages 4ff.) (In IDLE state LQI and RSSI can be read safely using this function.)
The received status byte is occasionally corrupted. (See Silicon Errata from 2015 at pages 4ff.) Use cc110x_status To get the status byte in a reliable way.

◆ cc110x_read_reliable()

uint8_t cc110x_read_reliable ( cc110x_t dev,
uint8_t  addr,
uint8_t *  dest 
)

Read a single status register from the transceiver reliable.

This function has more overhead than cc110x_read, but it is the only reliable way to access frequently updated status registers.

Parameters
devDevice descriptor of the transceiver to read the register from
addrAddress of the register to read
destWhere to store the received register content
Returns
The received status byte
Precondition
dest points to one byte of writeable memory
Warning
The received status byte is occasionally corrupted. (See Silicon Errata from 2015 at pages 4ff.) Use cc110x_status To get the status byte in a reliable way.

◆ cc110x_release()

static void cc110x_release ( cc110x_t dev)
inlinestatic

Release the SPI interface of the transceiver.

Definition at line 46 of file cc110x_communication.h.

◆ cc110x_status()

uint8_t cc110x_status ( cc110x_t dev)

Get the transceivers status byte in a reliable way.

Parameters
devDevice descriptor of the transceiver to get the status from
Returns
The received status byte

◆ cc110x_write()

uint8_t cc110x_write ( cc110x_t dev,
uint8_t  addr,
uint8_t  data 
)

Write to a single configuration register on the transceiver.

Parameters
devDevice descriptor of the transceiver to write byte to
addrAddress of the register to write to
dataData to write
Returns
The received status byte
Precondition
addr <= 0x2e (CC110X_REG_TEST0)
Warning
Writing to status registers is impossible (==> precondition)
The received status byte is occasionally corrupted. (See Silicon Errata from 2015 at pages 4ff.) Use cc110x_status To get the status byte in a reliable way.