#include <CC2500.h>
Public Member Functions | |
CC2500 (unsigned char pinCS=10, unsigned char pinSCK=13, unsigned char pinMOSI=11, unsigned char pinMISO=12) | |
~CC2500 () | |
void | init () |
void | reset () |
unsigned char | sendByte (unsigned char data) |
unsigned char | sendCommand (unsigned char command, unsigned char data) |
unsigned char | sendStrobeCommand (unsigned char command) |
unsigned char | sendBurstCommand (unsigned char command, unsigned char *data, unsigned char length) |
Protected Member Functions | |
unsigned char | spiTransfer (volatile unsigned char data) |
Private Attributes | |
unsigned char | m_pinCS |
unsigned char | m_pinSCK |
unsigned char | m_pinMOSI |
unsigned char | m_pinMISO |
This class implements basic functions to communicate with the CC2500 and is tailored specifically for the Philips LivingColors.
Used documentation from http://focus.ti.com/docs/prod/folders/print/cc2500.html :
CC2500::CC2500 | ( | unsigned char | pinCS = 10 , |
|
unsigned char | pinSCK = 13 , |
|||
unsigned char | pinMOSI = 11 , |
|||
unsigned char | pinMISO = 12 | |||
) |
Constructor.
[in] | pinCS | Pin number of slave select, default is 10. |
[in] | pinSCK | Pin number of clock, default is 13 (Arduino standard). |
[in] | pinMOSI | Pin number of master output slave input, default is 11 (Arduino standard). |
[in] | pinMISO | Pin number of master input slave output, default is 12 (Arduino standard). |
CC2500::~CC2500 | ( | ) |
Destructor.
void CC2500::init | ( | ) |
Initializes the CC2500 by setting the pin modes and disabling the device (slave select is set to high). Also sets up the arduino SPI control register (SPCR).
void CC2500::reset | ( | ) |
unsigned char CC2500::sendByte | ( | unsigned char | data | ) |
Sends a byte of data to the CC2500 using SPI. The received byte is returned.
[in] | data | Byte of data to send. |
unsigned char CC2500::sendCommand | ( | unsigned char | command, | |
unsigned char | data | |||
) |
Sends a command and a byte of data to the CC2500 using SPI. Can be used to (1) write to a configuration register, (2) read a configuration register (by writing dummy data), (3) writing to patable memory if single access writes are used. Burst bit may be set, but burst access is not allowed!
See datasheet, chapters 10 & 32 for more information.
[in] | command | Command to send, can be register/patable memory, can be write or read. |
[in] | data | Data to send, can be dummy data when read command is issued. |
unsigned char CC2500::sendStrobeCommand | ( | unsigned char | command | ) |
Sends a strobe command to the CC2500 using SPI. For a strobe command no data is necessary.
See datasheet, chapter 32 for more information.
[in] | command | Strobe command to send. |
unsigned char CC2500::sendBurstCommand | ( | unsigned char | command, | |
unsigned char * | data, | |||
unsigned char | length | |||
) |
Sends a burst command to the CC2500 using SPI. The burst bit (0x40) in the command must be set!
[in] | command | Burst command to send. |
[in] | data | Data bytes to send, will be filled with received bytes. |
[in] | length | Number of data bytes to send. |
unsigned char CC2500::spiTransfer | ( | volatile unsigned char | data | ) | [protected] |
Transfers a byte of data using the Arduino SPI registers.
[in] | data | Byte of data to send. |
unsigned char CC2500::m_pinCS [private] |
Number of the slave select (CS) pin.
unsigned char CC2500::m_pinSCK [private] |
Number of the clock (SCK) pin.
unsigned char CC2500::m_pinMOSI [private] |
Number of the master output, slave input (MOSI) pin.
unsigned char CC2500::m_pinMISO [private] |
Number of the master input, slave output (MISO) pin.