CCxxxx Driver
0.0.1
|
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... | |
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.
#define __CCX_STATUS_LOG | ( | _STATUS, | |
F, | |||
L | |||
) | ccxErrorLog(_STATUS, F, #L) |
Hacky middle-man to get string line number.
See CCX_STATUS_LOG.
#define _CCX_STATUS_LOG | ( | _STATUS, | |
F, | |||
L | |||
) | __CCX_STATUS_LOG(_STATUS, F, L) |
Hacky middle-man to get string line number.
See CCX_STATUS_LOG.
#define CCX_STATUS_CHECK | ( | _STATEMENT, | |
_STATUS | |||
) |
Convenience error handling function. Returns from current function with evaluated error code.
#define CCX_STATUS_CHECK_CLEANUP | ( | _STATEMENT, | |
_STATUS, | |||
_CLEANUP | |||
) |
Convenience error handling function. In the event of an error attempts cleanup.
#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.
_STATUS | Encountered error from 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.
uint8_t ccxDelay25us | ( | void | ) |
Initiate a busy, blocking wait of 25 us.
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.
status | Error encountered. Will be one of CcxStatus. |
file | Name of the file error was logged. |
line | Line number where the error was logged. |
uint8_t ccxInit | ( | void | ) |
Initialise the ccx module. This must be called prior to using any other function in this library.
uint8_t ccxReadByte | ( | uint8_t | address, |
uint8_t * | readByte | ||
) |
Read a single byte from specified register.
[in] | address | Register address to read. See cc1100_cc2500.h. |
[out] | readByte | The register contents. |
uint8_t ccxReadBytes | ( | uint8_t | startAddress, |
uint8_t * | readBuffer, | ||
uint8_t | readBufferLength | ||
) |
Read multiple bytes beginning at the specified register.
[in] | startAddress | Register 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] | readBuffer | The buffer to be populated by the read operation. |
[in] | readBufferLength | The length of readBuffer / the desired number of bytes to read. |
uint8_t ccxReadStatusRegister | ( | uint8_t | address, |
uint8_t * | readStatus | ||
) |
Read a single byte from a status register.
[in] | address | The status register address to read. This function will ensure the read bit and burst bit of address is set appropriately. See Registers: Status. |
[out] | readStatus | The contents of the status register after read is complete. |
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.
uint8_t ccxRunTests | ( | void | ) |
Run basic sanity tests to ensure communications between MCU and CCxxxx module are operating as expected.
CCX_OK
indicates all tests passed. uint8_t ccxShutdown | ( | void | ) |
Shutdown the module. Can optionally be called when finished with using the module.
uint8_t ccxStrobe | ( | uint8_t | strobeAddress | ) |
Send a strobe to the CCxxx.
Strobes are single byte commands.
strobeAddress | The strobe command to send. This should be one of Registers: Strobe Command. |
uint8_t ccxWriteByte | ( | uint8_t | address, |
uint8_t | value | ||
) |
Write a single byte (octet) to the CCxxxx.
address | The register address to write to. See cc1100_cc2500.h. |
value | The byte to write to address . |
uint8_t ccxWriteBytes | ( | uint8_t | address, |
const uint8_t * | writeBuffer, | ||
uint8_t | writeBufferLength | ||
) |
Write multiple bytes (oxtets) to the CCxxxx.
[in] | address | The register address to write to. See cc1100_cc2500.h. |
[in] | writeBuffer | A 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] | writeBufferLength | The number of bytes to be written (the length of writeBuffer ). |