# transceiver_cc1101

cc1101 transceiver library

Author | Matthew Schinkel - borntechi.com, copyright © 2009, all rights reserved.
Adapted-by |
Compiler | >=2.4q5

Description

    This library provides functions the TI cc1101 receiver.
                 Working baud rates are 1.2khz, 100khz and 250khz at 433.92Mhz.
                 This device will also work in the 900mhz range.
                 Max device power is 10dBi

Sources

    https://www.ccsinfo.com/forum/viewtopic.php?t=54957&postdays=0&postorder=asc&start=0

Notes

    I am not an RF genius, do your own testing and check your RF laws before
           using. Use SmartRF studio for other settings.

Dependencies

No dependency found

## Summary

### Global variables/contants

- `const byte CC1101_PATABLE = 0x3E`
- `const byte CC1101_RCCTRL0 = 0x28`
- `var byte cc1101_rx_buffer[CC1101_BUF_SIZE]`
- `const byte CC1101_FSCTRL1 = 0x0B`
- `const byte CC1101_PARTNUM = 0x30`
- `const byte CC1101_MDMCFG3 = 0x11`
- `const byte CC1101_IOCFG1 = 0x01`
- `const byte CC1101_WORCTRL = 0x20`
- `const byte CC1101_SIDLE = 0x36`
- `const byte CC1101_MDMCFG1 = 0x13`
- `const byte CC1101_RCCTRL1 = 0x27`
- `const byte CC1101_BSCFG = 0x1A`
- `const byte CC1101_MCSM2 = 0x16`
- `const byte CC1101_TEST1 = 0x2D`
- `const byte CC1101_FREQ0 = 0x0F`
- `const byte CC1101_PKTCTRL0 = 0x08`
- `const byte CC1101_FREQ2 = 0x0D`
- `const byte CC1101_FOCCFG = 0x19`
- `const byte CC1101_FREQ1 = 0x0E`
- `const byte CC1101_SPWD = 0x39`
- `var byte cc1101_tx_buffer[CC1101_BUF_SIZE]`
- `const byte CC1101_PTEST = 0x2A`
- `const byte CC1101_SAFC = 0x37`
- `const byte CC1101_DEVIATN = 0x15`
- `const byte CC1101_SYNC0 = 0x05`
- `const byte CC1101_FREND1 = 0x21`
- `const byte CC1101_FIFOTHR = 0x03`
- `const byte CC1101_FREQEST = 0x32`
- `const byte CC1101_READ_SINGLE = 0x80`
- `const byte CC1101_SFSTXON = 0x31`
- `const byte CC1101_PKTCTRL1 = 0x07`
- `const byte CC1101_WRITE_BURST = 0x40`
- `const byte CC1101_IOCFG2 = 0x00`
- `const byte CC1101_SRES = 0x30`
- `const byte CC1101_PKTLEN = 0x06`
- `const byte CC1101_FREND0 = 0x22`
- `const byte CC1101_WORTIME0 = 0x37`
- `const byte CC1101_TXBYTES = 0x3A`
- `const byte CC1101_READ_BURST = 0xC0`
- `const byte CC1101_TEST2 = 0x2C`
- `const byte CC1101_AGCCTRL1 = 0x1C`
- `var byte cc1101_has_error = 0`
- `const byte CC1101_FSTEST = 0x29`
- `const byte CC1101_FSCAL3 = 0x23`
- `const byte CC1101_MCSM1 = 0x17`
- `const byte CC1101_CHANNR = 0x0A`
- `const byte CC1101_RSSI = 0x34`
- `const byte CC1101_RXFIFO = 0x3F`
- `const byte CC1101_FSCTRL0 = 0x0C`
- `const byte CC1101_MDMCFG0 = 0x14`
- `const byte CC1101_PKTSTATUS = 0x38`
- `const byte CC1101_IOCFG0 = 0x02`
- `const byte CC1101_WORTIME1 = 0x36`
- `const byte CC1101_TEST0 = 0x2E`
- `const byte CC1101_FSCAL2 = 0x24`
- `const byte CC1101_SWORRST = 0x3C`
- `const byte CC1101_FSCAL0 = 0x26`
- `const byte CC1101_WOREVT0 = 0x1F`
- `const byte CC1101_AGCCTRL2 = 0x1B`
- `const byte CC1101_WOREVT1 = 0x1E`
- `const byte CC1101_AGCCTRL0 = 0x1D`
- `const byte CC1101_MCSM0 = 0x18`
- `const byte CC1101_VCO_VC_DAC = 0x39`
- `const byte CC1101_STX = 0x35`
- `const byte CC1101_ADDR = 0x09`
- `const byte CC1101_MDMCFG2 = 0x12`
- `const byte CC1101_SYNC1 = 0x04`
- `const byte CC1101_RXBYTES = 0x3B`
- `const byte CC1101_SXOFF = 0x32`
- `const byte CC1101_AGCTEST = 0x2B`
- `const byte CC1101_SWOR = 0x38`
- `const byte CC1101_TXFIFO = 0x3F`
- `const byte CC1101_SCAL = 0x33`
- `const byte CC1101_VERSION = 0x31`
- `const byte CC1101_LQI = 0x33`
- `const byte CC1101_FSCAL1 = 0x25`
- `const byte CC1101_SRX = 0x34`
- `const byte CC1101_MARCSTATE = 0x35`
- `const byte CC1101_SNOP = 0x3D`
- `const byte CC1101_SFTX = 0x3B`
- `const byte CC1101_MDMCFG4 = 0x10`
- `const byte CC1101_SFRX = 0x3A`

### Procedures

- `cc1101_transmit_mode()`
- `cc1101_init()`
- `cc1101_config_433_92mhz_250kbaud()`
- `cc1101_send_packet(byte in size)`
- `cc1101_receive_mode()`
- `cc1101_read_burst_register(byte in addr, byte in step)`
- `cc1101_write_register(byte in address, byte in value)`
- `cc1101_config_433_92mhz_100kbaud()`
- `cc1101_config_433_92mhz__1_2kbaud()`
- `cc1101_write_burst_reg(byte in address, byte in length)`
- `cc1101_receive_packet()`
- `cc1101_tx_10dbi()`
- `cc1101_strobe(byte in strobe)`

### Functions

- `cc1101_read_status(byte in addr) return byte`
- `cc1101_read_register(byte in address) return byte`

## API details

### Global variables/contants

- `const byte CC1101_PATABLE = 0x3E`

  No documentation found

- `const byte CC1101_RCCTRL0 = 0x28`

      RC oscillator configuration

- `var byte cc1101_rx_buffer[CC1101_BUF_SIZE]`

  No documentation found

- `const byte CC1101_FSCTRL1 = 0x0B`

      Frequency synthesizer control

- `const byte CC1101_PARTNUM = 0x30`

      int8s for simpler software.

- `const byte CC1101_MDMCFG3 = 0x11`

      Modem configuration

- `const byte CC1101_IOCFG1 = 0x01`

      GDO1 output pin configuration

- `const byte CC1101_WORCTRL = 0x20`

      Wake On Radio control

- `const byte CC1101_SIDLE = 0x36`

      MCSM0.FS_AUTOCAL = 1. If in RX state and CCA is enabled:
      Only go to TX if channel is clear.

- `const byte CC1101_MDMCFG1 = 0x13`

      Modem configuration

- `const byte CC1101_RCCTRL1 = 0x27`

      RC oscillator configuration

- `const byte CC1101_BSCFG = 0x1A`

      Bit Synchronization configuration

- `const byte CC1101_MCSM2 = 0x16`

      Main Radio Control State Machine configuration

- `const byte CC1101_TEST1 = 0x2D`

      Various test settings

- `const byte CC1101_FREQ0 = 0x0F`

      Frequency control word, low int8

- `const byte CC1101_PKTCTRL0 = 0x08`

      Packet automation control

- `const byte CC1101_FREQ2 = 0x0D`

      Frequency control word, high int8

- `const byte CC1101_FOCCFG = 0x19`

      Frequency Offset Compensation configuration

- `const byte CC1101_FREQ1 = 0x0E`

      Frequency control word, middle int8

- `const byte CC1101_SPWD = 0x39`

      Enter power down mode when CSn goes high.

- `var byte cc1101_tx_buffer[CC1101_BUF_SIZE]`

      variables

- `const byte CC1101_PTEST = 0x2A`

      Production test

- `const byte CC1101_SAFC = 0x37`

      Wake-On-Radio mode if applicable.

- `const byte CC1101_DEVIATN = 0x15`

      Modem deviation setting

- `const byte CC1101_SYNC0 = 0x05`

      Sync word, low int8

- `const byte CC1101_FREND1 = 0x21`

      Front end RX configuration

- `const byte CC1101_FIFOTHR = 0x03`

      RX FIFO and TX FIFO thresholds

- `const byte CC1101_FREQEST = 0x32`

  No documentation found

- `const byte CC1101_READ_SINGLE = 0x80`

  No documentation found

- `const byte CC1101_SFSTXON = 0x31`

      Enable and calibrate frequency synthesizer (if MCSM0.FS_AUTOCAL = 1).

- `const byte CC1101_PKTCTRL1 = 0x07`

      Packet automation control

- `const byte CC1101_WRITE_BURST = 0x40`

  No documentation found

- `const byte CC1101_IOCFG2 = 0x00`

      REGSITERS

- `const byte CC1101_SRES = 0x30`

      Commands

- `const byte CC1101_PKTLEN = 0x06`

      Packet length

- `const byte CC1101_FREND0 = 0x22`

      Front end TX configuration

- `const byte CC1101_WORTIME0 = 0x37`

  No documentation found

- `const byte CC1101_TXBYTES = 0x3A`

  No documentation found

- `const byte CC1101_READ_BURST = 0xC0`

  No documentation found

- `const byte CC1101_TEST2 = 0x2C`

      Various test settings

- `const byte CC1101_AGCCTRL1 = 0x1C`

      AGC control

- `var byte cc1101_has_error = 0`

  No documentation found

- `const byte CC1101_FSTEST = 0x29`

      Frequency synthesizer calibration control

- `const byte CC1101_FSCAL3 = 0x23`

      Frequency synthesizer calibration

- `const byte CC1101_MCSM1 = 0x17`

      Main Radio Control State Machine configuration

- `const byte CC1101_CHANNR = 0x0A`

      Channel number

- `const byte CC1101_RSSI = 0x34`

  No documentation found

- `const byte CC1101_RXFIFO = 0x3F`

  No documentation found

- `const byte CC1101_FSCTRL0 = 0x0C`

      Frequency synthesizer control

- `const byte CC1101_MDMCFG0 = 0x14`

      Modem configuration

- `const byte CC1101_PKTSTATUS = 0x38`

  No documentation found

- `const byte CC1101_IOCFG0 = 0x02`

      GDO0 output pin configuration

- `const byte CC1101_WORTIME1 = 0x36`

  No documentation found

- `const byte CC1101_TEST0 = 0x2E`

      Various test settings

- `const byte CC1101_FSCAL2 = 0x24`

      Frequency synthesizer calibration

- `const byte CC1101_SWORRST = 0x3C`

      Reset real time clock.

- `const byte CC1101_FSCAL0 = 0x26`

      Frequency synthesizer calibration

- `const byte CC1101_WOREVT0 = 0x1F`

      Low int8 Event 0 timeout

- `const byte CC1101_AGCCTRL2 = 0x1B`

      AGC control

- `const byte CC1101_WOREVT1 = 0x1E`

      High int8 Event 0 timeout

- `const byte CC1101_AGCCTRL0 = 0x1D`

      AGC control

- `const byte CC1101_MCSM0 = 0x18`

      Main Radio Control State Machine configuration

- `const byte CC1101_VCO_VC_DAC = 0x39`

  No documentation found

- `const byte CC1101_STX = 0x35`

      MCSM0.FS_AUTOCAL = 1.

- `const byte CC1101_ADDR = 0x09`

      Device address

- `const byte CC1101_MDMCFG2 = 0x12`

      Modem configuration

- `const byte CC1101_SYNC1 = 0x04`

      Sync word, high int8

- `const byte CC1101_RXBYTES = 0x3B`

  No documentation found

- `const byte CC1101_SXOFF = 0x32`

      If in RX / TX: Go to a wait state where only the synthesizer is
      Running (for quick RX / TX turnaround).

- `const byte CC1101_AGCTEST = 0x2B`

      AGC test

- `const byte CC1101_SWOR = 0x38`

      Start automatic RX polling sequence (Wake-on-Radio)

- `const byte CC1101_TXFIFO = 0x3F`

  No documentation found

- `const byte CC1101_SCAL = 0x33`

      Calibrate frequency synthesizer and turn it off

- `const byte CC1101_VERSION = 0x31`

  No documentation found

- `const byte CC1101_LQI = 0x33`

  No documentation found

- `const byte CC1101_FSCAL1 = 0x25`

      Frequency synthesizer calibration

- `const byte CC1101_SRX = 0x34`

      (Enables quick start).

- `const byte CC1101_MARCSTATE = 0x35`

  No documentation found

- `const byte CC1101_SNOP = 0x3D`

      No operation. May be used to pad strobe commands to two

- `const byte CC1101_SFTX = 0x3B`

      Flush the TX FIFO buffer.

- `const byte CC1101_MDMCFG4 = 0x10`

      Modem configuration

- `const byte CC1101_SFRX = 0x3A`

      Flush the RX FIFO buffer.

### Procedures

- `cc1101_transmit_mode()`

      Select transmit mode

- `cc1101_init()`

      Initialize

- `cc1101_config_433_92mhz_250kbaud()`

      Rf settings - 250k baud
      Smart RF Studio 7 Settings:
       Base Frequency:    433.999969 MHz
       Xtal:              26.000000  MHz
       Modulation Format: 2-FSK
       Channel Number:    0
       Data Rate:         249.939 kBaud
       Deviation:         126.953125 kHz
       Channel Spacing:   199.951172 kHz
       RF Filter BW:      650.000000 kHz
       TX Power:          0dBm
       Carrier Frequency: 433.999969 MHz
       Manchester Enable: No
       PA Ramping:        No
       Whitening:         No

- `cc1101_send_packet(byte in size)`

      Send data in cc1101_tx_buffer

- `cc1101_receive_mode()`

      Select receive mode

- `cc1101_read_burst_register(byte in addr, byte in step)`

      Read multiple from RX buffer

- `cc1101_write_register(byte in address, byte in value)`

      Register Write

- `cc1101_config_433_92mhz_100kbaud()`

      Rf settings - 100k baud

- `cc1101_config_433_92mhz__1_2kbaud()`

      Rf settings - 1.2k baud
      Values generated from SmartRF studio
      433.92MHz 1.2Kbaud, 10dB
      GFSK, dev. 5KHz, RX filter BW 58KHz

- `cc1101_write_burst_reg(byte in address, byte in length)`

      Write multiple to TX buffer

- `cc1101_receive_packet()`

      Receive packet (fills array cc1101_rx_buffer[])

- `cc1101_tx_10dbi()`

      Set TX power to 10dbi

- `cc1101_strobe(byte in strobe)`

      Send a single byte command

### Functions

- `cc1101_read_status(byte in addr) return byte`

      Read Status Byte

- `cc1101_read_register(byte in address) return byte`

      Register Read

## Related samples

Here are the list of samples which use this library:

18f4620 | 18f4620_transceiver_cc1101.jal