COSA
An Object-Oriented Platform for Arduino Programming
|
#include <CC1101.hh>
Classes | |
union | header_t |
class | IRQPin |
union | recv_status_t |
union | status_t |
Public Member Functions | |
CC1101 (uint16_t net, uint8_t dev, Board::DigitalPin csn=Board::D10, Board::ExternalInterruptPin irq=Board::EXT0) | |
virtual bool | begin (const void *config=NULL) |
virtual bool | end () |
virtual int | send (uint8_t dest, uint8_t port, const iovec_t *vec) |
virtual int | send (uint8_t dest, uint8_t port, const void *buf, size_t len) |
virtual int | recv (uint8_t &src, uint8_t &port, void *buf, size_t len, uint32_t ms=0L) |
virtual void | powerdown () |
virtual void | wakeup_on_radio () |
virtual void | output_power_level (int8_t dBm) |
virtual int | input_power_level () |
virtual int | link_quality_indicator () |
uint8_t | channel () const |
void | channel (uint8_t channel) |
int16_t | network_address () const |
uint8_t | device_address () const |
void | address (int16_t net, uint8_t dev) |
virtual void | powerup () |
virtual bool | available () |
virtual bool | room () |
virtual int | broadcast (uint8_t port, const iovec_t *vec) |
virtual int | broadcast (uint8_t port, const void *buf, size_t len) |
virtual bool | is_broadcast () |
Static Public Attributes | |
static const size_t | DEVICE_PAYLOAD_MAX = 64 |
static const size_t | PAYLOAD_MAX = DEVICE_PAYLOAD_MAX - 4 |
static const uint8_t | BROADCAST = 0x00 |
Protected Types | |
enum | Config { IOCFG2 = 0x00, IOCFG1 = 0x01, IOCFG0 = 0x02, FIFOTH = 0x03, SYNC1 = 0x04, SYNC0 = 0x05, PKTLEN = 0x06, PKTCTR = 0x07, PKTCTRL0 = 0x08, ADDR = 0x09, CHANNR = 0x0A, FSCTRL1 = 0x0B, FSCTRL0 = 0x0C, FREQ2 = 0x0D, FREQ1 = 0x0E, FREQ0 = 0x0F, MDMCFG4 = 0x10, MDMCFG3 = 0x11, MDMCFG2 = 0x12, MDMCFG1 = 0x13, MDMCFG0 = 0x14, DEVIATN = 0x15, MCSM2 = 0x16, MCSM1 = 0x17, MCSM0 = 0x18, FOCCFG = 0x19, BSCFG = 0x1A, AGCCTRL2 = 0x1B, AGCCTRL1 = 0x1C, AGCCTRL0 = 0x1D, WOREVT1 = 0x1E, WOREVT0 = 0x1F, WORCTRL = 0x20, FREND1 = 0x21, FREND0 = 0x22, FSCAL3 = 0x23, FSCAL2 = 0x24, FSCAL1 = 0x25, FSCAL0 = 0x26, RCCTRL1 = 0x27, RCCTRL0 = 0x28, FSTEST = 0x29, PTEST = 0x2A, AGCTEST = 0x2B, TEST2 = 0x2C, TEST1 = 0x2D, TEST0 = 0x2E, CONFIG_MAX = 0x29 } |
enum | Data { PATABLE = 0x3E, TXFIFO = 0x3F, RXFIFO = 0x3F } |
enum | Status { PARTNUM = 0x30, VERSION = 0x31, FREQEST = 0x32, LQI = 0x33, RSSI = 0x34, MARCSTATE = 0x35, WORTIME1 = 0x36, WORTIME0 = 0x37, PKTSTATUS = 0x38, VCO = 0x39, TXBYTES = 0x3A, RXBYTES = 0x3B, BYTES_MASK = 0x7f, FIFO_MASK = 0x80, RCCTRL1_STATUS = 0x3C, RCCTRL0_STATUS = 0x3D, STATUS_MAX = 0x0E } |
enum | Command { SRES = 0x30, SFSTXON = 0x31, SXOFF = 0x32, SCAL = 0x33, SRX = 0x34, STX = 0x35, SIDLE = 0x36, SAFC = 0x37, SWOR = 0x38, SPWD = 0x39, SFRX = 0x3A, SFTX = 0x3B, SWORRST = 0x3C, SNOP = 0x3D } |
enum | Mode { IDLE_MODE = 0, RX_MODE, TX_MODE, FSTXON_MODE, CALIBRATION_MODE, SETTLING_MODE, RXFIFO_OVERFLOW_MODE, TXFIFO_UNDERFLOW_MODE } |
enum | State { SLEEP_STATE = 0x00, IDLE_STATE = 0x01, XOFF_STATE = 0x02, VCOON_MC_STATE = 0x03, REGON_MC_STATE = 0x04, MANCAL_STATE = 0x05, VCOON_STATE = 0x06, REGON_STATE = 0x07, STARTCAL_STATE = 0x08, BWBOOST_STATE = 0x09, FS_LOCK_STATE = 0x0A, IFADCON_STATE = 0x0B, ENDCAL_STATE = 0x0C, RX_STATE = 0x0D, RX_END_STATE = 0x0E, RX_RST_STATE = 0x0F, TXRX_SWITCH_STATE = 0x10, RXFIFO_OVERFLOW_STATE = 0x11, FSTXON_STATE = 0x12, TX_STATE = 0x13, TX_END_STATE = 0x14, RXTX_SWITCH_STATE = 0x15, TXFIFO_UNDERFLOW_STATE = 0x16 } |
Protected Member Functions | |
uint8_t | read (uint8_t reg) |
void | read (uint8_t reg, void *buf, size_t count) |
void | write (uint8_t reg, uint8_t value) |
void | write (uint8_t reg, const void *buf, size_t count) |
void | write_P (uint8_t reg, const uint8_t *buf, size_t count) |
uint8_t | read (Config reg) |
void | read (Config reg, void *buf, size_t count) |
void | write (Config reg, uint8_t value) |
void | write (Config reg, const void *buf, size_t count) |
void | write_P (Config reg, const uint8_t *buf, size_t count) |
uint8_t | read (Data reg) |
void | read (Data reg, void *buf, size_t count) |
void | write (Data reg, uint8_t value) |
void | write (Data reg, const void *buf, size_t count) |
void | write_P (Data reg, const uint8_t *buf, size_t count) |
uint8_t | read (Status reg) |
void | strobe (Command cmd) |
status_t | status () const |
status_t | read_status (uint8_t fifo=1) |
void | await (Mode mode) |
State | read_marc_state () |
Protected Attributes | |
uint8_t | m_channel |
Current channel (device dependent. More... | |
addr_t | m_addr |
Current network and device address. More... | |
volatile bool | m_avail |
Message available. May be set by ISR. More... | |
uint8_t | m_dest |
Latest message destination device address. More... | |
Static Protected Attributes | |
static const size_t | PATABLE_MAX = 8 |
Private Member Functions | |
void | set_clock (Clock rate) |
void | set_clock (uint32_t freq) |
Static Private Member Functions | |
static Clock | clock (uint32_t freq) |
static Clock | cycle (uint16_t ns) |
Private Attributes | |
Driver * | m_next |
List of drivers. More... | |
OutputPin | m_cs |
Device chip select pin. More... | |
Pulse | m_pulse |
Chip select pulse width. More... | |
uint8_t | m_spcr |
SPI/SPCR hardware control register setting. More... | |
uint8_t | m_spsr |
SPI/SPSR hardware status register. More... | |
Cosa Device Driver for Texas Instruments CC1101, Low-Power Sub-1 GHz RF Transceiver. Note that this device requires data in big endian order.
This is the pin-out for the CC1101 module which is compatible with the NRF24L01 module. CC1101 is a low voltage device (3V3) and signals require level shifter (74HC4050 or 10K resistor). Special care for MISO as this signal is multi-drop.
|
protected |
Command Strobes (Table 42, pp. 67).
Enumerator | |
---|---|
SRES |
Reset chip. |
SFSTXON |
Enable and calibrate frequency synthesizer. |
SXOFF |
Turn off crystal oscillator. |
SCAL |
Calibrate frequency synthesizer. |
SRX |
Enable RX. |
STX |
Enable TX. |
SIDLE |
Exit RX/TX. |
SAFC |
AFC adjustment of the frequency synthesizer. |
SWOR |
Start automatic Wake-on-Radio. |
SPWD |
Power down mode when CSn goes high. |
SFRX |
Flush the RX FIFO buffer. |
SFTX |
Flush the TX FIFO buffer. |
SWORRST |
Reset real time clock. |
SNOP |
No operation. |
|
protected |
Configuration Registers (Table 43, pp. 68).
Enumerator | |
---|---|
IOCFG2 |
GDO2 output pin configuration. |
IOCFG1 |
GDO1 output pin configuration. |
IOCFG0 |
GDO0 output pin configuration. |
FIFOTH |
RX FIFO and TX FIFO thresholds. |
SYNC1 |
Sync word, high byte. |
SYNC0 |
Sync word, low byte. |
PKTLEN |
Packet length. |
PKTCTR |
Packet automation control. |
PKTCTRL0 |
Packet automation control. |
ADDR |
Device address. |
CHANNR |
Channel number. |
FSCTRL1 |
Frequency synthesizer control. |
FSCTRL0 |
Frequency synthesizer control. |
FREQ2 |
Frequency control word, high byte. |
FREQ1 |
Frequency control word, middle byte. |
FREQ0 |
Frequency control word, low byte. |
MDMCFG4 |
Modem configuration. |
MDMCFG3 |
Modem configuration. |
MDMCFG2 |
Modem configuration. |
MDMCFG1 |
Modem configuration. |
MDMCFG0 |
Modem configuration. |
DEVIATN |
Modem deviation setting. |
MCSM2 |
Main Radio Cntrl State Machine config. |
MCSM1 |
Main Radio Cntrl State Machine config. |
MCSM0 |
Main Radio Cntrl State Machine config. |
FOCCFG |
Frequency Offset Compensation config. |
BSCFG |
Bit Synchronization configuration. |
AGCCTRL2 |
AGC control. |
AGCCTRL1 |
AGC control. |
AGCCTRL0 |
AGC control. |
WOREVT1 |
High byte Event 0 timeout. |
WOREVT0 |
Low byte Event 0 timeout. |
WORCTRL |
Wake On Radio control. |
FREND1 |
Front end RX configuration. |
FREND0 |
Front end TX configuration. |
FSCAL3 |
Frequency synthesizer calibration. |
FSCAL2 |
Frequency synthesizer calibration. |
FSCAL1 |
Frequency synthesizer calibration. |
FSCAL0 |
Frequency synthesizer calibration. |
RCCTRL1 |
RC oscillator configuration. |
RCCTRL0 |
RC oscillator configuration. |
FSTEST |
Frequency synthesizer cal control. |
PTEST |
Production test. |
AGCTEST |
AGC test. |
TEST2 |
Various test settings. |
TEST1 |
Various test settings. |
TEST0 |
Various test settings. |
CONFIG_MAX |
Number of configuration registers. |
|
protected |
|
protected |
Status Byte Summary (Table 23, pp. 31).
|
protected |
Main Radio Control State Machine State (pp. 93).
|
protected |
Status Registers (Table 44, pp. 69).
CC1101::CC1101 | ( | uint16_t | net, |
uint8_t | dev, | ||
Board::DigitalPin | csn = Board::D10 , |
||
Board::ExternalInterruptPin | irq = Board::EXT0 |
||
) |
Construct C1101 device driver with given network and device address. Connected to SPI bus and given chip select pin. Default pins are Arduino Nano IO Shield for CC1101 module are D10 chip select and D2/EXT0 external interrupt pin (TinyX4/Mega/Standard).
[in] | net | network address. |
[in] | dev | device address. |
[in] | csn | chip select pin (Default D2/D10/D53). |
[in] | irq | interrupt pin (Default EXT0/EXT0/EXT4). |
Definition at line 99 of file CC1101.cpp.
|
inlineinherited |
Set network and device address. Do not use the broadcast address(0). Should be used before calling begin().
[in] | net | network address. |
[in] | dev | device address. |
Definition at line 106 of file Wireless.hh.
|
inlinevirtualinherited |
Return true(1) if a message is available otherwise false(0).
Reimplemented in VWI, and NRF24L01P.
Definition at line 165 of file Wireless.hh.
|
protected |
|
virtual |
Start and configure C1101 device driver. The configuration must set GDO2 to assert on received message. This device pin is assumed to be connected the device driver interrupt pin (EXTn). Return true(1) if successful othewise false(0).
[in] | config | configuration vector (default NULL) |
Implements Wireless::Driver.
Definition at line 127 of file CC1101.cpp.
|
inlinevirtualinherited |
Broadcast message in given null terminated io vector. Returns number of bytes sent if successful otherwise a negative error code.
[in] | port | device port (or message type). |
[in] | vec | null termianted io vector. |
Definition at line 220 of file Wireless.hh.
|
inlinevirtualinherited |
Boardcast message in given buffer, with given number of bytes. Returns number of bytes sent if successful otherwise a negative error code.
[in] | port | device port (or message type). |
[in] | buf | buffer to transmit. |
[in] | len | number of bytes in buffer. |
Definition at line 235 of file Wireless.hh.
|
inlineinherited |
|
inlineinherited |
Set device transmission channel. Should be used before calling begin().
[in] | channel. |
Definition at line 117 of file Wireless.hh.
|
inlineinherited |
|
virtual |
Shutdown the device driver. Return true(1) if successful otherwise false(0).
Reimplemented from Wireless::Driver.
Definition at line 164 of file CC1101.cpp.
|
virtual |
Return estimated input power level (dBm) from latest successful message received.
Reimplemented from Wireless::Driver.
Definition at line 298 of file CC1101.cpp.
|
inlinevirtualinherited |
Return true(1) if the latest received message was a broadcast otherwise false(0).
Definition at line 262 of file Wireless.hh.
|
inlinevirtual |
Return link quality indicator from latest successful receive message. Lower level is better quality.
Reimplemented from Wireless::Driver.
|
inlineinherited |
|
virtual |
Set output power level (-30..10 dBm)
[in] | dBm. |
Reimplemented from Wireless::Driver.
Definition at line 279 of file CC1101.cpp.
|
virtual |
Set device in power down mode.
Reimplemented from Wireless::Driver.
Definition at line 265 of file CC1101.cpp.
|
inlinevirtualinherited |
Set device in power up mode.
Reimplemented in VWI, and NRF24L01P.
Definition at line 146 of file Wireless.hh.
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
|
virtual |
Receive message and store into given buffer with given maximum length. The source network address is returned in the parameter src. Returns error code(-2) if no message is available and/or a timeout occured. Returns error code(-1) if the buffer size if to small for incoming message or if the receiver fifo has overflowed. Otherwise the actual number of received bytes is returned
[out] | src | source network address. |
[out] | port | device port (or message type). |
[in] | buf | buffer to store incoming message. |
[in] | len | maximum number of bytes to receive. |
[in] | ms | maximum time out period (Default blocking(0L)). |
Implements Wireless::Driver.
Definition at line 211 of file CC1101.cpp.
|
inlinevirtualinherited |
Return true(1) if there is room to send on the device otherwise false(0).
Definition at line 176 of file Wireless.hh.
|
virtual |
Send message in given null terminated io vector. Returns number of bytes sent. Returns error code(-1) if number of bytes is greater than PAYLOAD_MAX. Return error code(-2) if fails to set transmit mode.
[in] | dest | destination network address. |
[in] | port | device port (or message type). |
[in] | vec | null termianted io vector. |
Implements Wireless::Driver.
Definition at line 173 of file CC1101.cpp.
|
virtual |
Send message in given buffer, with given number of bytes. Returns number of bytes sent. Returns error code(-1) if number of bytes is greater than PAYLOAD_MAX. Return error code(-2) if fails to set transmit mode. Note that port numbers (128 and higher are reserved for system protocols).
[in] | dest | destination network address. |
[in] | port | device port (or message type). |
[in] | buf | buffer to transmit. |
[in] | len | number of bytes in buffer. |
Reimplemented from Wireless::Driver.
Definition at line 201 of file CC1101.cpp.
|
inlineprotected |
|
protected |
Issue given command to device. Check documentation for required timing delay per command.
[in] | cmd | command. |
Definition at line 110 of file CC1101.cpp.
|
virtual |
Set device in wakeup on radio mode.
Reimplemented from Wireless::Driver.
Definition at line 272 of file CC1101.cpp.
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
|
staticinherited |
Broadcast device address.
Definition at line 58 of file Wireless.hh.
|
static |
|
protectedinherited |
Current network and device address.
Definition at line 299 of file Wireless.hh.
|
protectedinherited |
Message available. May be set by ISR.
Definition at line 300 of file Wireless.hh.
|
protectedinherited |
Current channel (device dependent.
Definition at line 298 of file Wireless.hh.
|
protectedinherited |
Latest message destination device address.
Definition at line 301 of file Wireless.hh.
|
staticprotected |
|
static |