CCxxxx Driver  0.0.1
All Files Functions Enumerations Enumerator Modules Pages
Macros | Enumerations | Functions
Basic CCxxxx API

Basic API to interface with the CCxxxx chip. More...

Macros

#define CCX_STATUS_LOG(_STATUS)   _CCX_STATUS_LOG(_STATUS, __FILE__, __LINE__)
 Macro called to log errors. More...
 
#define __CCX_STATUS_LOG(_STATUS, F, L)   ccxErrorLog(_STATUS, F, #L)
 Hacky middle-man to get string line number. More...
 
#define _CCX_STATUS_LOG(_STATUS, F, L)   __CCX_STATUS_LOG(_STATUS, F, L)
 Hacky middle-man to get string line number. More...
 
#define CCX_STATUS_CHECK(_STATEMENT, _STATUS)
 Convenience error handling function. Returns from current function with evaluated error code. More...
 
#define CCX_STATUS_CHECK_CLEANUP(_STATEMENT, _STATUS, _CLEANUP)
 Convenience error handling function. In the event of an error attempts cleanup. More...
 

Enumerations

enum  CcxStatus {
  CCX_OK, CCX_ERROR_API, CCX_ERROR_INTERNAL, CCX_ERROR_TIMEOUT,
  CCX_ERROR_SPI, CCX_ERROR_RX_CRC, CCX_ERROR_STATE, CCX_ERROR_FIFO,
  CCX_ERROR_ASSERT
}
 List of possible error return codes. More...
 

Functions

void ccxErrorLog (uint8_t status, char *file, char *line)
 Optional error logging function. More...
 
uint8_t ccxWriteByte (uint8_t address, uint8_t value)
 Write a single byte (octet) to the CCxxxx. More...
 
uint8_t ccxWriteBytes (uint8_t address, const uint8_t *writeBuffer, uint8_t writeBufferLength)
 Write multiple bytes (oxtets) to the CCxxxx. More...
 
uint8_t ccxStrobe (uint8_t strobeAddress)
 Send a strobe to the CCxxx. More...
 
uint8_t ccxReadByte (uint8_t address, uint8_t *readByte)
 Read a single byte from specified register. More...
 
uint8_t ccxReadBytes (uint8_t startAddress, uint8_t *readBuffer, uint8_t readBufferLength)
 Read multiple bytes beginning at the specified register. More...
 
uint8_t ccxReadStatusRegister (uint8_t address, uint8_t *readStatus)
 Read a single byte from a status register. More...
 
uint8_t ccxDelay25us (void)
 Initiate a busy, blocking wait of 25 us. More...
 
uint8_t ccxReset (void)
 Initiate a software reset of the radio. More...
 
uint8_t ccxInit (void)
 Initialise the ccx module. This must be called prior to using any other function in this library. More...
 
uint8_t ccxShutdown (void)
 Shutdown the module. Can optionally be called when finished with using the module. More...
 
uint8_t ccxRunTests (void)
 Run basic sanity tests to ensure communications between MCU and CCxxxx module are operating as expected. More...
 

Detailed Description

Basic API to interface with the CCxxxx chip.

Note: There must be a SPI port for hardware in use. See SPI Hardware Implementation for more information on the functions that must be defined.

Macro Definition Documentation

◆ __CCX_STATUS_LOG

#define __CCX_STATUS_LOG (   _STATUS,
  F,
 
)    ccxErrorLog(_STATUS, F, #L)

Hacky middle-man to get string line number.

See CCX_STATUS_LOG.

◆ _CCX_STATUS_LOG

#define _CCX_STATUS_LOG (   _STATUS,
  F,
 
)    __CCX_STATUS_LOG(_STATUS, F, L)

Hacky middle-man to get string line number.

See CCX_STATUS_LOG.

◆ CCX_STATUS_CHECK

#define CCX_STATUS_CHECK (   _STATEMENT,
  _STATUS 
)
Value:
do { \
_STATUS = (_STATEMENT); \
if ((_STATUS) != CCX_OK) \
{ \
CCX_STATUS_LOG(_STATUS); \
return _STATUS; \
} \
} while (0);
No error, operational as expected.
Definition: ccx_api.h:127

Convenience error handling function. Returns from current function with evaluated error code.

Parameters
_STATEMENTStatement to evaluate. Assumed to return a CcxStatus error code.
_STATUSLocal variable to hold CcxStatus code.

◆ CCX_STATUS_CHECK_CLEANUP

#define CCX_STATUS_CHECK_CLEANUP (   _STATEMENT,
  _STATUS,
  _CLEANUP 
)
Value:
do { \
_STATUS = (_STATEMENT); \
if ((_STATUS) != CCX_OK) \
{ \
CCX_STATUS_LOG(_STATUS); \
_CLEANUP; \
} \
} while (0);
No error, operational as expected.
Definition: ccx_api.h:127

Convenience error handling function. In the event of an error attempts cleanup.

Parameters
_STATEMENTStatement to evaluate. Assumed to return a CcxStatus error code.
_STATUSLocal variable to hold CcxStatus code.
_CLEANUPCommand to execute on error. Typically expected to be a "goto label".

◆ CCX_STATUS_LOG

#define CCX_STATUS_LOG (   _STATUS)    _CCX_STATUS_LOG(_STATUS, __FILE__, __LINE__)

Macro called to log errors.

Will provide file name and line number to user defined function ccxErrorLog.

The behaviour of this macro depends on compile time flags.

Parameters
_STATUSEncountered error from CcxStatus.

Enumeration Type Documentation

◆ CcxStatus

enum CcxStatus

List of possible error return codes.

All API functions return a CcxStatus value. Any value other than CCX_OK indicates an error occurred and function call was unsuccessful. Additional cleanup may be required by the user's application, e.g. flushing the FIFO.

Enumerator
CCX_OK 

No error, operational as expected.

CCX_ERROR_API 

Bad value passed by API.

CCX_ERROR_INTERNAL 

Internal, unexpected error detected.

CCX_ERROR_TIMEOUT 

Communications timed out.

CCX_ERROR_SPI 

SPI error.

CCX_ERROR_RX_CRC 

Received CRC was incorrect.

CCX_ERROR_STATE 

Device was in an unexpected state.

CCX_ERROR_FIFO 

One or more of the FIFOs are in error.

CCX_ERROR_ASSERT 

Sanity assert failed.

Function Documentation

◆ ccxDelay25us()

uint8_t ccxDelay25us ( void  )

Initiate a busy, blocking wait of 25 us.

Returns
A status code from CcxStatus.

◆ ccxErrorLog()

void ccxErrorLog ( uint8_t  status,
char *  file,
char *  line 
)

Optional error logging function.

If error logging is enabled, this function must be provided by the user.

Parameters
statusError encountered. Will be one of CcxStatus.
fileName of the file error was logged.
lineLine number where the error was logged.

◆ ccxInit()

uint8_t ccxInit ( void  )

Initialise the ccx module. This must be called prior to using any other function in this library.

Returns
A status code from CcxStatus.

◆ ccxReadByte()

uint8_t ccxReadByte ( uint8_t  address,
uint8_t *  readByte 
)

Read a single byte from specified register.

Parameters
[in]addressRegister address to read. See cc1100_cc2500.h.
[out]readByteThe register contents.
Returns
A status code from CcxStatus.

◆ ccxReadBytes()

uint8_t ccxReadBytes ( uint8_t  startAddress,
uint8_t *  readBuffer,
uint8_t  readBufferLength 
)

Read multiple bytes beginning at the specified register.

Parameters
[in]startAddressRegister address to start read operation on. Certain CCxxxx registers behave differently on a burst read operation. Consult the data sheet for more information. See cc1100_cc2500.h.
[out]readBufferThe buffer to be populated by the read operation.
[in]readBufferLengthThe length of readBuffer / the desired number of bytes to read.
Returns
A status code from CcxStatus.

◆ ccxReadStatusRegister()

uint8_t ccxReadStatusRegister ( uint8_t  address,
uint8_t *  readStatus 
)

Read a single byte from a status register.

Parameters
[in]addressThe status register address to read. This function will ensure the read bit and burst bit of address is set appropriately. See Registers: Status.
[out]readStatusThe contents of the status register after read is complete.
Returns
A status code from CcxStatus.

◆ ccxReset()

uint8_t ccxReset ( void  )

Initiate a software reset of the radio.

This includes the steps required for the manual power-up sequence as documented in the data sheet.

Returns
A status code from CcxStatus.

◆ ccxRunTests()

uint8_t ccxRunTests ( void  )

Run basic sanity tests to ensure communications between MCU and CCxxxx module are operating as expected.

Returns
A status code from CcxStatus. CCX_OK indicates all tests passed.

◆ ccxShutdown()

uint8_t ccxShutdown ( void  )

Shutdown the module. Can optionally be called when finished with using the module.

Returns
A status code from CcxStatus.

◆ ccxStrobe()

uint8_t ccxStrobe ( uint8_t  strobeAddress)

Send a strobe to the CCxxx.

Strobes are single byte commands.

Parameters
strobeAddressThe strobe command to send. This should be one of Registers: Strobe Command.
Returns
A status code from CcxStatus.

◆ ccxWriteByte()

uint8_t ccxWriteByte ( uint8_t  address,
uint8_t  value 
)

Write a single byte (octet) to the CCxxxx.

Parameters
addressThe register address to write to. See cc1100_cc2500.h.
valueThe byte to write to address.

◆ ccxWriteBytes()

uint8_t ccxWriteBytes ( uint8_t  address,
const uint8_t *  writeBuffer,
uint8_t  writeBufferLength 
)

Write multiple bytes (oxtets) to the CCxxxx.

Parameters
[in]addressThe register address to write to. See cc1100_cc2500.h.
[in]writeBufferA continuous array of bytes to write to the device. The behaviour of a sequential write varies depending on the address. See the CCxxxx device data sheet for more information.
[in]writeBufferLengthThe number of bytes to be written (the length of writeBuffer ).