Functions to communicate with the CC1100/CC1101 transceiver.
More...
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.
Go to the source code of this file.
static int | cc110x_acquire (cc110x_t *dev) |
| Acquire the SPI interface of the transceiver and configure it. More...
|
|
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. More...
|
|
uint8_t | cc110x_read_reliable (cc110x_t *dev, uint8_t addr, uint8_t *dest) |
| Read a single status register from the transceiver reliable. More...
|
|
uint8_t | cc110x_write (cc110x_t *dev, uint8_t addr, uint8_t data) |
| Write to a single configuration register on the transceiver. More...
|
|
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. More...
|
|
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. More...
|
|
uint8_t | cc110x_cmd (cc110x_t *dev, uint8_t cmd) |
| Send a command to the transceiver. More...
|
|
uint8_t | cc110x_status (cc110x_t *dev) |
| Get the transceivers status byte in a reliable way. More...
|
|
int | cc110x_power_on (cc110x_t *dev) |
| Wakes up the transceiver from "Sleep" or "Crystal oscillator off" state and waits until the crystal has stabilized. More...
|
|
◆ cc110x_acquire()
static int cc110x_acquire |
( |
cc110x_t * |
dev | ) |
|
|
inlinestatic |
Acquire the SPI interface of the transceiver and configure it.
- Return values
-
SPI_OK | Success |
SPI_NOMODE | SPI mode 0 not supported by MCU |
SPI_NOCLK | SPI clock given in cc110x_params_t is not supported |
- Precondition
- cc110x_power_on has be called before calling this function. (Only needed once when the driver initializes.)
Definition at line 41 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
-
dev | Device descriptor of the transceiver to read from |
addr | Address to start reading from |
dest | Destination buffer to store the received data to |
len | Number 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
-
dev | Device descriptor of the transceiver to write |
addr | Address to start writing to |
src | Buffer holding the configuration to write |
len | Number 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
-
dev | Device descriptor of the transceiver to send the command to |
cmd | Command 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()
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.
- Return values
-
◆ 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
-
dev | Device descriptor of the transceiver to read the register from |
addr | Address of the register to read |
dest | Where 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
-
dev | Device descriptor of the transceiver to read the register from |
addr | Address of the register to read |
dest | Where 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_status()
Get the transceivers status byte in a reliable way.
- Parameters
-
dev | Device 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
-
dev | Device descriptor of the transceiver to write byte to |
addr | Address of the register to write to |
data | Data 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.