CCxxxx Driver  0.0.1
Functions
SPI Hardware Implementation

Required MCU-to-CCxxxx functions. More...

Functions

uint8_t ccxSpiInit (void)
 Initialise the SPI hardware. More...
 
uint8_t ccxSpiShutdown (void)
 Shutdown the SPI hardware. More...
 
uint8_t ccxSpiPinChipSelectSet (uint8_t setValue)
 Set the state of the Chip Select (CS) line. More...
 
uint8_t ccxSpiPinSlaveOutRead (uint8_t *currentValue)
 Read the current state of the Slave Out (SO) line. More...
 
uint8_t ccxSpiTransaction (uint8_t address, const uint8_t *writeBytes, uint8_t writeLength, uint8_t *readBytes, uint8_t readLength)
 Start a SPI transaction to the CC1101, either read or write. More...
 
uint8_t ccxSpiDelay25us (void)
 Provide a reliable, 25 us delay. More...
 

Detailed Description

Required MCU-to-CCxxxx functions.

If porting this driver to new hardware, the user must create the necessary function definitions and implement them as described.

Function Documentation

◆ ccxSpiDelay25us()

uint8_t ccxSpiDelay25us ( void  )

Provide a reliable, 25 us delay.

Exact timing is not important, and assumed this will be implemented as a busy wait.

◆ ccxSpiInit()

uint8_t ccxSpiInit ( void  )

Initialise the SPI hardware.

This function will be called when the CC1101 module is initialised. The implementation is expected to preform any necessary configuration, including:

  • Set Chip Select (CS) line to output, initial value high. Due to the nature of the CC1101, this line is should be controlled by the driver, independently of the SPI hardware.
  • Prepare Slave In (SI), Slave Out (SO) and Clock (CLK) pins as per hardware requirements.
  • Configure the pin attached to the CC1101 GDO pin to input / interrupt. (Optional, but likely recommended depending on your implementation).

SPI Configuration

  • Clock Frequency: The clock can run at 10 MHz if 100 ns delay added between each octet. Otherwise single access should be limited to 9 MHz, and burst access 6.5 MHz.
  • Clock phase: Data centered on first rising clock edge.
  • Clock polarity: Low when idle
Note
Refer to Texas Instruments Design Note DN503 for more information on interfacing over SPI.

◆ ccxSpiPinChipSelectSet()

uint8_t ccxSpiPinChipSelectSet ( uint8_t  setValue)

Set the state of the Chip Select (CS) line.

Parameters
[in]setValueThe desired state of the CS line.
  • "1" for a high output (to not select the CC1101)
  • "0" for a low output (to select the CC1101)

◆ ccxSpiPinSlaveOutRead()

uint8_t ccxSpiPinSlaveOutRead ( uint8_t *  currentValue)

Read the current state of the Slave Out (SO) line.

Parameters
[out]currentValueThe current state of the SO line:
  • "1" the line is currently driven high by CC1101
  • "0" the line is currently driven low by CC1101

The SO line is used to indicate the readiness of the CC1101 to receive commands after the Chip Select line has been used to indicate interaction is desired. It is assumed the hardware implementation can read the state of this line when not immediately transmitting data over SPI.

◆ ccxSpiShutdown()

uint8_t ccxSpiShutdown ( void  )

Shutdown the SPI hardware.

This will be called when the CC1101 module is shutdown. Depending on the user implementation of the above driver it may never be called.

◆ ccxSpiTransaction()

uint8_t ccxSpiTransaction ( uint8_t  address,
const uint8_t *  writeBytes,
uint8_t  writeLength,
uint8_t *  readBytes,
uint8_t  readLength 
)

Start a SPI transaction to the CC1101, either read or write.

The transaction is expected to be blocking.

Parameters
[in]addressThe register address. This should be always be sent to the device as the first byte.
[in]writeBytesArray of bytes to write. Length of the array is provided as writeLength. This can be NULL.
[in]writeLengthThe length of the writeBytes array. This can be 0.
[out]readBytesArray to store read data into. Length of this array is provided as readLength. This can be NULL.
[out]readLengthLength of the array readBytes. This can be 0.

Example Transfers

The following depecits some example transfers:

writeLength == 0 and readLength == 0
Write: | address |
Read: | status |
writeLength == 1 and readLength == 0
Write: | address |
Read: | status |
writeLength == 3 and readLength == 0
Write: | address | write byte 0 | write byte 1 | write byte 2
Read: | status | status | status | status
readLength == 1 and writeLength == 0
Write: | address | -
Read: | status | read byte 0
readLength == 3 and writeLength == 0
Write: | address | - | - | -
Read: | status | read byte 0 | read byte 1 | read byte 2