Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 6 of 6

Thread: Porting Elechouse CC1101 Lib

  1. #1
    Junior Member
    Join Date
    Mar 2015
    Posts
    7

    Porting Elechouse CC1101 Lib

    Hello.

    I would like to use a CC1101 Wireless Module with my Teensy 3.1.
    I found a Library here at Elechouse.

    First of all i changed
    Code:
    #include <WProgram.h>
    into
    Code:
    #if defined(ARDUINO) && ARDUINO >= 100
    #include "Arduino.h"
    #else
    #include "WProgram.h"
    #endif
    in the ELECHOUSE_CC1101.h File.

    After that, i changed the Pin Definitions according to my schematic :
    Code:
    //*************************************** pins **************************************************//
    #define SCK_PIN   14
    #define MISO_PIN  12
    #define MOSI_PIN  11
    #define SS_PIN    10
    #define GDO0	6
    #define GDO2	9
    //************************************* class **************************************************//


    Unfortunately, my Breakout Board gives me no access to the GDO2 Pin....

    Can some of you give me an advice how to get the CC1101 Library to work ? What do i have to change in the Elechouse Lib ? Or maybe there is a better CC1101 Lib for Teensy ?

    Any advice will be appreciated.
    Greetings,

    Christian

  2. #2
    Junior Member
    Join Date
    Mar 2015
    Posts
    7
    I just managed it, to compile... But i can not receive anything.
    Well, i can not figure out if the problem is at RX-Teensy or TX-Teensy...

    Here is the code i modified so far :

    CC1101.ino
    Code:
     
     #include <SPI.h>
     #include "ELECHOUSE_CC1101.h"
     
     #define rx
     
    
    
    
    #ifdef tx
    #define size 61
    byte TX_buffer[size]={0};
    byte i;
    
    void setup()
    {
      
      
      
      Serial.begin(9600);
      ELECHOUSE_cc1101.Init();
      for(i=0;i<size;i++)
      {
         TX_buffer[i]=i;
      }
    }
    
    void loop()
    {
      ELECHOUSE_cc1101.SendData(TX_buffer,size);
      delay(1);
    }
    #endif
    
    #ifdef rx
     void setup()
    {
      Serial.begin(9600);
      ELECHOUSE_cc1101.Init();
      ELECHOUSE_cc1101.SetReceive();
    }
    
    byte RX_buffer[61]={0};
    byte size,i,flag;
    
    void loop()
    {
      if(ELECHOUSE_cc1101.CheckReceiveFlag())
      {
        size=ELECHOUSE_cc1101.ReceiveData(RX_buffer);
        for(i=0;i<size;i++)
        {
          Serial.print(RX_buffer[i],DEC);
          Serial.print(' ',BYTE);
        }
        Serial.println("");
        ELECHOUSE_cc1101.SetReceive();
      }
      Serial.println("test");
    }
    
    #endif

    ELECHOUSE_CC1101.cpp

    Code:
    #include "ELECHOUSE_CC1101.h"
    #include <Arduino.h>
    #include <SPI.h>
    
    /****************************************************************/
    #define 	WRITE_BURST     	0x40						//write burst
    #define 	READ_SINGLE     	0x80						//read single
    #define 	READ_BURST      	0xC0						//read burst
    #define 	BYTES_IN_RXFIFO     0x7F  						//byte number in RXfifo
    
    #define         ChipSelect_Pin 6
    #define         GDNull_Pin 16
    /****************************************************************/
    byte PaTabel[8] = {0x60 ,0x60 ,0x60 ,0x60 ,0x60 ,0x60 ,0x60 ,0x60};
    
    /****************************************************************
    *FUNCTION NAME:SpiInit
    *FUNCTION     :spi communication initialization
    *INPUT        :none
    *OUTPUT       :none
    ****************************************************************/
    void ELECHOUSE_CC1101::SpiInit(void)
    {
      // Pin initialisieren
      pinMode(ChipSelect_Pin, OUTPUT);
      
        //SPI initialisieren
      SPI.begin();
      // Clock-Signal auf Pin 14 mappen
      SPI.setSCK(14);
      
      
    }
    /****************************************************************
    *FUNCTION NAME:SpiTransfer
    *FUNCTION     :spi transfer
    *INPUT        :value: data to send
    *OUTPUT       :data to receive
    ****************************************************************/
    byte ELECHOUSE_CC1101::SpiTransfer(byte value)
    {
      SPI.transfer(value);
      return SPI.transfer(0);
    }
    
    /****************************************************************
    *FUNCTION NAME: GDO_Set()
    *FUNCTION     : set GDO0,GDO2 pin
    *INPUT        : none
    *OUTPUT       : none
    ****************************************************************/
    void ELECHOUSE_CC1101::GDO_Set (void)
    {
    	 pinMode(GDNull_Pin, INPUT);
    	
    }
    
    /****************************************************************
    *FUNCTION NAME:Reset
    *FUNCTION     :CC1101 reset //details refer datasheet of CC1101/CC1100//
    *INPUT        :none
    *OUTPUT       :none
    ****************************************************************/
    void ELECHOUSE_CC1101::Reset (void)
    {
    	digitalWrite(ChipSelect_Pin, LOW);
    	delay(1);
    	digitalWrite(ChipSelect_Pin, HIGH);
    	delay(1);
    	digitalWrite(ChipSelect_Pin, LOW);
    	delay(1);
    	SpiTransfer(CC1101_SRES);
    	delay(1);
    	digitalWrite(ChipSelect_Pin, HIGH);
    }
    
    /****************************************************************
    *FUNCTION NAME:Init
    *FUNCTION     :CC1101 initialization
    *INPUT        :none
    *OUTPUT       :none
    ****************************************************************/
    void ELECHOUSE_CC1101::Init(void)
    {
    	SpiInit();										//spi initialization
    	GDO_Set();										//GDO set
    	digitalWrite(ChipSelect_Pin, HIGH);
    	Reset();										//CC1101 reset
    	RegConfigSettings();							//CC1101 register config
    	SpiWriteBurstReg(CC1101_PATABLE,PaTabel,8);		//CC1101 PATABLE config
    }
    
    
    /****************************************************************
    *FUNCTION NAME:SpiWriteReg
    *FUNCTION     :CC1101 write data to register
    *INPUT        :addr: register address; value: register value
    *OUTPUT       :none
    ****************************************************************/
    void ELECHOUSE_CC1101::SpiWriteReg(byte addr, byte value)
    {
            SPI.beginTransaction(SPISettings(4000000, MSBFIRST, SPI_MODE0));
    	digitalWrite(ChipSelect_Pin, LOW);
    	SpiTransfer(addr);
    	SpiTransfer(value);
    	digitalWrite(ChipSelect_Pin, HIGH);
            SPI.endTransaction();
    }
    
    /****************************************************************
    *FUNCTION NAME:SpiWriteBurstReg
    *FUNCTION     :CC1101 write burst data to register
    *INPUT        :addr: register address; buffer:register value array; num:number to write
    *OUTPUT       :none
    ****************************************************************/
    void ELECHOUSE_CC1101::SpiWriteBurstReg(byte addr, byte *buffer, byte num)
    {
    	byte i, temp;
    
    	temp = addr | WRITE_BURST;
        SPI.beginTransaction(SPISettings(4000000, MSBFIRST, SPI_MODE0));
        digitalWrite(ChipSelect_Pin, LOW);
        delay(1);
        SpiTransfer(temp);
        for (i = 0; i < num; i++)
     	{
            SpiTransfer(buffer[i]);
        }
        digitalWrite(ChipSelect_Pin, HIGH);
          SPI.endTransaction();
    }
    
    /****************************************************************
    *FUNCTION NAME:SpiStrobe
    *FUNCTION     :CC1101 Strobe
    *INPUT        :strobe: command; //refer define in CC1101.h//
    *OUTPUT       :none
    ****************************************************************/
    void ELECHOUSE_CC1101::SpiStrobe(byte strobe)
    {
    	SPI.beginTransaction(SPISettings(4000000, MSBFIRST, SPI_MODE0));
            digitalWrite(ChipSelect_Pin, LOW);
    	delay(1);
    	SpiTransfer(strobe);
    	digitalWrite(ChipSelect_Pin, HIGH);
            SPI.endTransaction();
    }
    
    /****************************************************************
    *FUNCTION NAME:SpiReadReg
    *FUNCTION     :CC1101 read data from register
    *INPUT        :addr: register address
    *OUTPUT       :register value
    ****************************************************************/
    byte ELECHOUSE_CC1101::SpiReadReg(byte addr) 
    {
    	byte temp, value;
    
        temp = addr|READ_SINGLE;
    	SPI.beginTransaction(SPISettings(4000000, MSBFIRST, SPI_MODE0));
            digitalWrite(ChipSelect_Pin, LOW);
    	delay(1);
    	SpiTransfer(temp);
    	value=SpiTransfer(0);
    	digitalWrite(ChipSelect_Pin, HIGH);
            SPI.endTransaction();
    
    	return value;
    }
    
    /****************************************************************
    *FUNCTION NAME:SpiReadBurstReg
    *FUNCTION     :CC1101 read burst data from register
    *INPUT        :addr: register address; buffer:array to store register value; num: number to read
    *OUTPUT       :none
    ****************************************************************/
    void ELECHOUSE_CC1101::SpiReadBurstReg(byte addr, byte *buffer, byte num)
    {
    	byte i,temp;
    
    	temp = addr | READ_BURST;
    	SPI.beginTransaction(SPISettings(4000000, MSBFIRST, SPI_MODE0));
            digitalWrite(ChipSelect_Pin, LOW);
    	delay(1);
    	SpiTransfer(temp);
    	for(i=0;i<num;i++)
    	{
    		buffer[i]=SpiTransfer(0);
    	}
    	digitalWrite(ChipSelect_Pin, HIGH);
            SPI.endTransaction();
    }
    
    /****************************************************************
    *FUNCTION NAME:SpiReadStatus
    *FUNCTION     :CC1101 read status register
    *INPUT        :addr: register address
    *OUTPUT       :status value
    ****************************************************************/
    byte ELECHOUSE_CC1101::SpiReadStatus(byte addr) 
    {
    	byte value,temp;
    
    	temp = addr | READ_BURST;
    	SPI.beginTransaction(SPISettings(4000000, MSBFIRST, SPI_MODE0));
            digitalWrite(ChipSelect_Pin, LOW);
    	delay(1);
    	SpiTransfer(temp);
    	value=SpiTransfer(0);
    	digitalWrite(ChipSelect_Pin, HIGH);
            SPI.endTransaction();
    
    	return value;
    }
    
    /****************************************************************
    *FUNCTION NAME:RegConfigSettings
    *FUNCTION     :CC1101 register config //details refer datasheet of CC1101/CC1100//
    *INPUT        :none
    *OUTPUT       :none
    ****************************************************************/
    void ELECHOUSE_CC1101::RegConfigSettings(void) 
    {
        //SpiWriteReg(CC1101_FSCTRL1,  0x08);
        SpiWriteReg(CC1101_FSCTRL0,  0x00);
       // SpiWriteReg(CC1101_FREQ2,    0x10);
       // SpiWriteReg(CC1101_FREQ1,    0xA7);
       // SpiWriteReg(CC1101_FREQ0,    0x62);
       // SpiWriteReg(CC1101_MDMCFG4,  0x5B);
      //  SpiWriteReg(CC1101_MDMCFG3,  0xF8);
      //  SpiWriteReg(CC1101_MDMCFG2,  0x03);
        SpiWriteReg(CC1101_MDMCFG1,  0x22);
        SpiWriteReg(CC1101_MDMCFG0,  0xF8);
        SpiWriteReg(CC1101_CHANNR,   0x00);
       // SpiWriteReg(CC1101_DEVIATN,  0x47);
        SpiWriteReg(CC1101_FREND1,   0xB6);
        SpiWriteReg(CC1101_FREND0,   0x10);
        SpiWriteReg(CC1101_MCSM0 ,   0x18);
        //SpiWriteReg(CC1101_FOCCFG,   0x1D);
        SpiWriteReg(CC1101_BSCFG,    0x1C);
        SpiWriteReg(CC1101_AGCCTRL2, 0xC7);
    	SpiWriteReg(CC1101_AGCCTRL1, 0x00);
        SpiWriteReg(CC1101_AGCCTRL0, 0xB2);
        //SpiWriteReg(CC1101_FSCAL3,   0xEA);
    	SpiWriteReg(CC1101_FSCAL2,   0x2A);
    	SpiWriteReg(CC1101_FSCAL1,   0x00);
        //SpiWriteReg(CC1101_FSCAL0,   0x11);
        SpiWriteReg(CC1101_FSTEST,   0x59);
        SpiWriteReg(CC1101_TEST2,    0x81);
        SpiWriteReg(CC1101_TEST1,    0x35);
        SpiWriteReg(CC1101_TEST0,    0x09);
        SpiWriteReg(CC1101_IOCFG2,   0x0B); 	//serial clock.synchronous to the data in synchronous serial mode
        SpiWriteReg(CC1101_IOCFG0,   0x06);  	//asserts when sync word has been sent/received, and de-asserts at the end of the packet 
        SpiWriteReg(CC1101_PKTCTRL1, 0x04);		//two status bytes will be appended to the payload of the packet,including RSSI LQI and CRC OK
    											//No address check
        SpiWriteReg(CC1101_PKTCTRL0, 0x05);		//whitening off;CRC Enable��variable length packets, packet length configured by the first byte after sync word
        SpiWriteReg(CC1101_ADDR,     0x00);		//address used for packet filtration.
        SpiWriteReg(CC1101_PKTLEN,   0x3D); 	//61 bytes max length
        
        //Abweichungen
        SpiWriteReg(CC1101_FSCTRL1,  0x06);
        SpiWriteReg(0x03,0x47);
        SpiWriteReg(CC1101_FREQ2,    0x21);
        SpiWriteReg(CC1101_FREQ1,    0x62);
        SpiWriteReg(CC1101_FREQ0,    0x76);
        SpiWriteReg(CC1101_MDMCFG4,  0xF5);
        SpiWriteReg(CC1101_MDMCFG3,  0x83);
        SpiWriteReg(CC1101_MDMCFG2,  0x13);
        SpiWriteReg(CC1101_DEVIATN,  0x15);
        SpiWriteReg(CC1101_FOCCFG,   0x16);
        SpiWriteReg(0x20,   0xFB);
        SpiWriteReg(CC1101_FSCAL3,   0xE9);
        SpiWriteReg(CC1101_FSCAL0,   0x1F);
         SpiWriteReg(CC1101_TEST2,    0x81);
    }
    
    /****************************************************************
    *FUNCTION NAME:SendData
    *FUNCTION     :use CC1101 send data
    *INPUT        :txBuffer: data array to send; size: number of data to send, no more than 61
    *OUTPUT       :none
    ****************************************************************/
    void ELECHOUSE_CC1101::SendData(byte *txBuffer,byte size)
    {
    	SpiWriteReg(CC1101_TXFIFO,size);
    	SpiWriteBurstReg(CC1101_TXFIFO,txBuffer,size);			//write data to send
    	SpiStrobe(CC1101_STX);									//start send	
        while (!digitalRead(GDNull_Pin));								// Wait for GDO0 to be set -> sync transmitted  
        while (digitalRead(GDNull_Pin));								// Wait for GDO0 to be cleared -> end of packet
    	SpiStrobe(CC1101_SFTX);									//flush TXfifo
    }
    
    /****************************************************************
    *FUNCTION NAME:SetReceive
    *FUNCTION     :set CC1101 to receive state
    *INPUT        :none
    *OUTPUT       :none
    ****************************************************************/
    void ELECHOUSE_CC1101::SetReceive(void)
    {
    	SpiStrobe(CC1101_SRX);
    }
    
    /****************************************************************
    *FUNCTION NAME:CheckReceiveFlag
    *FUNCTION     :check receive data or not
    *INPUT        :none
    *OUTPUT       :flag: 0 no data; 1 receive data 
    ****************************************************************/
    byte ELECHOUSE_CC1101::CheckReceiveFlag(void)
    {
    	if(digitalRead(GDNull_Pin))			//receive data
    	{
    		while (digitalRead(GDNull_Pin));
    		return 1;
    	}
    	else							// no data
    	{
    		return 0;
    	}
    }
    
    
    /****************************************************************
    *FUNCTION NAME:ReceiveData
    *FUNCTION     :read data received from RXfifo
    *INPUT        :rxBuffer: buffer to store data
    *OUTPUT       :size of data received
    ****************************************************************/
    byte ELECHOUSE_CC1101::ReceiveData(byte *rxBuffer)
    {
    	byte size;
    	byte status[2];
    
    	if(SpiReadStatus(CC1101_RXBYTES) & BYTES_IN_RXFIFO)
    	{
    		size=SpiReadReg(CC1101_RXFIFO);
    		SpiReadBurstReg(CC1101_RXFIFO,rxBuffer,size);
    		SpiReadBurstReg(CC1101_RXFIFO,status,2);
    		SpiStrobe(CC1101_SFRX);
    		return size;
    	}
    	else
    	{
    		SpiStrobe(CC1101_SFRX);
    		return 0;
    	}
    	
    }
    
    ELECHOUSE_CC1101 ELECHOUSE_cc1101;

    ELECHOUSE_CC1101.h

    Code:
    #ifndef ELECHOUSE_CC1101_h
    #define ELECHOUSE_CC1101_h
    
    #include "Arduino.h"
    //***************************************CC1101 define**************************************************//
    // CC1101 CONFIG REGSITER
    #define CC1101_IOCFG2       0x00        // GDO2 output pin configuration
    #define CC1101_IOCFG1       0x01        // GDO1 output pin configuration
    #define CC1101_IOCFG0       0x02        // GDO0 output pin configuration
    #define CC1101_FIFOTHR      0x03        // RX FIFO and TX FIFO thresholds
    #define CC1101_SYNC1        0x04        // Sync word, high INT8U
    #define CC1101_SYNC0        0x05        // Sync word, low INT8U
    #define CC1101_PKTLEN       0x06        // Packet length
    #define CC1101_PKTCTRL1     0x07        // Packet automation control
    #define CC1101_PKTCTRL0     0x08        // Packet automation control
    #define CC1101_ADDR         0x09        // Device address
    #define CC1101_CHANNR       0x0A        // Channel number
    #define CC1101_FSCTRL1      0x0B        // Frequency synthesizer control
    #define CC1101_FSCTRL0      0x0C        // Frequency synthesizer control
    #define CC1101_FREQ2        0x0D        // Frequency control word, high INT8U
    #define CC1101_FREQ1        0x0E        // Frequency control word, middle INT8U
    #define CC1101_FREQ0        0x0F        // Frequency control word, low INT8U
    #define CC1101_MDMCFG4      0x10        // Modem configuration
    #define CC1101_MDMCFG3      0x11        // Modem configuration
    #define CC1101_MDMCFG2      0x12        // Modem configuration
    #define CC1101_MDMCFG1      0x13        // Modem configuration
    #define CC1101_MDMCFG0      0x14        // Modem configuration
    #define CC1101_DEVIATN      0x15        // Modem deviation setting
    #define CC1101_MCSM2        0x16        // Main Radio Control State Machine configuration
    #define CC1101_MCSM1        0x17        // Main Radio Control State Machine configuration
    #define CC1101_MCSM0        0x18        // Main Radio Control State Machine configuration
    #define CC1101_FOCCFG       0x19        // Frequency Offset Compensation configuration
    #define CC1101_BSCFG        0x1A        // Bit Synchronization configuration
    #define CC1101_AGCCTRL2     0x1B        // AGC control
    #define CC1101_AGCCTRL1     0x1C        // AGC control
    #define CC1101_AGCCTRL0     0x1D        // AGC control
    #define CC1101_WOREVT1      0x1E        // High INT8U Event 0 timeout
    #define CC1101_WOREVT0      0x1F        // Low INT8U Event 0 timeout
    #define CC1101_WORCTRL      0x20        // Wake On Radio control
    #define CC1101_FREND1       0x21        // Front end RX configuration
    #define CC1101_FREND0       0x22        // Front end TX configuration
    #define CC1101_FSCAL3       0x23        // Frequency synthesizer calibration
    #define CC1101_FSCAL2       0x24        // Frequency synthesizer calibration
    #define CC1101_FSCAL1       0x25        // Frequency synthesizer calibration
    #define CC1101_FSCAL0       0x26        // Frequency synthesizer calibration
    #define CC1101_RCCTRL1      0x27        // RC oscillator configuration
    #define CC1101_RCCTRL0      0x28        // RC oscillator configuration
    #define CC1101_FSTEST       0x29        // Frequency synthesizer calibration control
    #define CC1101_PTEST        0x2A        // Production test
    #define CC1101_AGCTEST      0x2B        // AGC test
    #define CC1101_TEST2        0x2C        // Various test settings
    #define CC1101_TEST1        0x2D        // Various test settings
    #define CC1101_TEST0        0x2E        // Various test settings
    
    //CC1101 Strobe commands
    #define CC1101_SRES         0x30        // Reset chip.
    #define CC1101_SFSTXON      0x31        // Enable and calibrate frequency synthesizer (if MCSM0.FS_AUTOCAL=1).
                                            // If in RX/TX: Go to a wait state where only the synthesizer is
                                            // running (for quick RX / TX turnaround).
    #define CC1101_SXOFF        0x32        // Turn off crystal oscillator.
    #define CC1101_SCAL         0x33        // Calibrate frequency synthesizer and turn it off
                                            // (enables quick start).
    #define CC1101_SRX          0x34        // Enable RX. Perform calibration first if coming from IDLE and
                                            // MCSM0.FS_AUTOCAL=1.
    #define CC1101_STX          0x35        // In IDLE state: Enable TX. Perform calibration first if
                                            // MCSM0.FS_AUTOCAL=1. If in RX state and CCA is enabled:
                                            // Only go to TX if channel is clear.
    #define CC1101_SIDLE        0x36        // Exit RX / TX, turn off frequency synthesizer and exit
                                            // Wake-On-Radio mode if applicable.
    #define CC1101_SAFC         0x37        // Perform AFC adjustment of the frequency synthesizer
    #define CC1101_SWOR         0x38        // Start automatic RX polling sequence (Wake-on-Radio)
    #define CC1101_SPWD         0x39        // Enter power down mode when CSn goes high.
    #define CC1101_SFRX         0x3A        // Flush the RX FIFO buffer.
    #define CC1101_SFTX         0x3B        // Flush the TX FIFO buffer.
    #define CC1101_SWORRST      0x3C        // Reset real time clock.
    #define CC1101_SNOP         0x3D        // No operation. May be used to pad strobe commands to two
                                            // INT8Us for simpler software.
    //CC1101 STATUS REGSITER
    #define CC1101_PARTNUM      0x30
    #define CC1101_VERSION      0x31
    #define CC1101_FREQEST      0x32
    #define CC1101_LQI          0x33
    #define CC1101_RSSI         0x34
    #define CC1101_MARCSTATE    0x35
    #define CC1101_WORTIME1     0x36
    #define CC1101_WORTIME0     0x37
    #define CC1101_PKTSTATUS    0x38
    #define CC1101_VCO_VC_DAC   0x39
    #define CC1101_TXBYTES      0x3A
    #define CC1101_RXBYTES      0x3B
    
    //CC1101 PATABLE,TXFIFO,RXFIFO
    #define CC1101_PATABLE      0x3E
    #define CC1101_TXFIFO       0x3F
    #define CC1101_RXFIFO       0x3F
    
    
    //************************************* class **************************************************//
    class ELECHOUSE_CC1101
    {
    	private:
    		void SpiInit(void);
    		byte SpiTransfer(byte value);
    		void GDO_Set (void);
    		void Reset (void);
    		void SpiWriteReg(byte addr, byte value);
    		void SpiWriteBurstReg(byte addr, byte *buffer, byte num);
    		void SpiStrobe(byte strobe);
    		byte SpiReadReg(byte addr);
    		void SpiReadBurstReg(byte addr, byte *buffer, byte num);
    		byte SpiReadStatus(byte addr);
    		void RegConfigSettings(void);
    	public:
    		void Init(void);
    		void SendData(byte *txBuffer, byte size);
    		void SetReceive(void);
    		byte CheckReceiveFlag(void);
    		byte ReceiveData(byte *rxBuffer);
    };
    
    extern ELECHOUSE_CC1101 ELECHOUSE_cc1101;
    
    #endif


    Maybe some of you can spot a mistake ? Been working 3 days on CC1101 with no luck -.-

  3. #3
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    22,077
    Use SPI.setCLK() before SPI.begin().

  4. #4
    Junior Member
    Join Date
    Mar 2015
    Posts
    7
    Thanks Paul, after using that a can see some SPI communication on my scope. So i can be sure now, it is not a wiring or hardware issue.

    I've got me a Arduino Leonardo and a level shifter from a friend to test.
    Using that Board, the library from Elechouse seems to be working. At least i see a peak on 868 Mhz and it disappears after powering off the circuit :



    So the mistake must be in the software differences between the Arduino Leonardo and the architecture of my Teensy 3.1.

    So i want to ask... Can some of you spot any differences in the way....
    Code:
    /*
    	ELECHOUSE_CC1101.cpp - CC1101 module library
    	Copyright (c) 2010 Michael.
      	Author: Michael, <www.elechouse.com>
      	Version: November 12, 2010
    
    	This library is designed to use CC1101/CC1100 module on Arduino platform.
    	CC1101/CC1100 module is an useful wireless module.Using the functions of the 
    	library, you can easily send and receive data by the CC1101/CC1100 module. 
    	Just have fun!
    	For the details, please refer to the datasheet of CC1100/CC1101.
    */
    #include <ELECHOUSE_CC1101.h>
    #include <WProgram.h>
    
    /****************************************************************/
    #define 	WRITE_BURST     	0x40						//write burst
    #define 	READ_SINGLE     	0x80						//read single
    #define 	READ_BURST      	0xC0						//read burst
    #define 	BYTES_IN_RXFIFO     0x7F  						//byte number in RXfifo
    
    /****************************************************************/
    byte PaTabel[8] = {0x60 ,0x60 ,0x60 ,0x60 ,0x60 ,0x60 ,0x60 ,0x60};
    
    /****************************************************************
    *FUNCTION NAME:SpiInit
    *FUNCTION     :spi communication initialization
    *INPUT        :none
    *OUTPUT       :none
    ****************************************************************/
    void ELECHOUSE_CC1101::SpiInit(void)
    {
      // initialize the SPI pins
      pinMode(SCK_PIN, OUTPUT);
      pinMode(MOSI_PIN, OUTPUT);
      pinMode(MISO_PIN, INPUT);
      pinMode(SS_PIN, OUTPUT);
    
      // enable SPI Master, MSB, SPI mode 0, FOSC/4
      SpiMode(0);
    }
    /****************************************************************
    *FUNCTION NAME:SpiMode
    *FUNCTION     :set spi mode
    *INPUT        :        config               mode
    			   (0<<CPOL) | (0 << CPHA)		 0
    			   (0<<CPOL) | (1 << CPHA)		 1
    			   (1<<CPOL) | (0 << CPHA)		 2
    			   (1<<CPOL) | (1 << CPHA)		 3
    *OUTPUT       :none
    ****************************************************************/
    void ELECHOUSE_CC1101::SpiMode(byte config)
    {
      byte tmp;
    
      // enable SPI master with configuration byte specified
      SPCR = 0;
      SPCR = (config & 0x7F) | (1<<SPE) | (1<<MSTR);
      tmp = SPSR;
      tmp = SPDR;
    }
    
    /****************************************************************
    *FUNCTION NAME:SpiTransfer
    *FUNCTION     :spi transfer
    *INPUT        :value: data to send
    *OUTPUT       :data to receive
    ****************************************************************/
    byte ELECHOUSE_CC1101::SpiTransfer(byte value)
    {
      SPDR = value;
      while (!(SPSR & (1<<SPIF))) ;
      return SPDR;
    }
    
    /****************************************************************
    *FUNCTION NAME: GDO_Set()
    *FUNCTION     : set GDO0,GDO2 pin
    *INPUT        : none
    *OUTPUT       : none
    ****************************************************************/
    void ELECHOUSE_CC1101::GDO_Set (void)
    {
    	pinMode(GDO0, INPUT);
    	pinMode(GDO2, INPUT);
    }
    
    /****************************************************************
    *FUNCTION NAME:Reset
    *FUNCTION     :CC1101 reset //details refer datasheet of CC1101/CC1100//
    *INPUT        :none
    *OUTPUT       :none
    ****************************************************************/
    void ELECHOUSE_CC1101::Reset (void)
    {
    	digitalWrite(SS_PIN, LOW);
    	delay(1);
    	digitalWrite(SS_PIN, HIGH);
    	delay(1);
    	digitalWrite(SS_PIN, LOW);
    	while(digitalRead(MISO_PIN));
    	SpiTransfer(CC1101_SRES);
    	while(digitalRead(MISO_PIN));
    	digitalWrite(SS_PIN, HIGH);
    }
    
    /****************************************************************
    *FUNCTION NAME:Init
    *FUNCTION     :CC1101 initialization
    *INPUT        :none
    *OUTPUT       :none
    ****************************************************************/
    void ELECHOUSE_CC1101::Init(void)
    {
    	SpiInit();										//spi initialization
    	GDO_Set();										//GDO set
    	digitalWrite(SS_PIN, HIGH);
    	digitalWrite(SCK_PIN, HIGH);
    	digitalWrite(MOSI_PIN, LOW);
    	Reset();										//CC1101 reset
    	RegConfigSettings();							//CC1101 register config
    	SpiWriteBurstReg(CC1101_PATABLE,PaTabel,8);		//CC1101 PATABLE config
    }
    
    
    /****************************************************************
    *FUNCTION NAME:SpiWriteReg
    *FUNCTION     :CC1101 write data to register
    *INPUT        :addr: register address; value: register value
    *OUTPUT       :none
    ****************************************************************/
    void ELECHOUSE_CC1101::SpiWriteReg(byte addr, byte value)
    {
    	digitalWrite(SS_PIN, LOW);
    	while(digitalRead(MISO_PIN));
    	SpiTransfer(addr);
    	SpiTransfer(value);
    	digitalWrite(SS_PIN, HIGH);
    }
    
    /****************************************************************
    *FUNCTION NAME:SpiWriteBurstReg
    *FUNCTION     :CC1101 write burst data to register
    *INPUT        :addr: register address; buffer:register value array; num:number to write
    *OUTPUT       :none
    ****************************************************************/
    void ELECHOUSE_CC1101::SpiWriteBurstReg(byte addr, byte *buffer, byte num)
    {
    	byte i, temp;
    
    	temp = addr | WRITE_BURST;
        digitalWrite(SS_PIN, LOW);
        while(digitalRead(MISO_PIN));
        SpiTransfer(temp);
        for (i = 0; i < num; i++)
     	{
            SpiTransfer(buffer[i]);
        }
        digitalWrite(SS_PIN, HIGH);
    }
    
    /****************************************************************
    *FUNCTION NAME:SpiStrobe
    *FUNCTION     :CC1101 Strobe
    *INPUT        :strobe: command; //refer define in CC1101.h//
    *OUTPUT       :none
    ****************************************************************/
    void ELECHOUSE_CC1101::SpiStrobe(byte strobe)
    {
    	digitalWrite(SS_PIN, LOW);
    	while(digitalRead(MISO_PIN));
    	SpiTransfer(strobe);
    	digitalWrite(SS_PIN, HIGH);
    }
    
    /****************************************************************
    *FUNCTION NAME:SpiReadReg
    *FUNCTION     :CC1101 read data from register
    *INPUT        :addr: register address
    *OUTPUT       :register value
    ****************************************************************/
    byte ELECHOUSE_CC1101::SpiReadReg(byte addr) 
    {
    	byte temp, value;
    
        temp = addr|READ_SINGLE;
    	digitalWrite(SS_PIN, LOW);
    	while(digitalRead(MISO_PIN));
    	SpiTransfer(temp);
    	value=SpiTransfer(0);
    	digitalWrite(SS_PIN, HIGH);
    
    	return value;
    }
    
    /****************************************************************
    *FUNCTION NAME:SpiReadBurstReg
    *FUNCTION     :CC1101 read burst data from register
    *INPUT        :addr: register address; buffer:array to store register value; num: number to read
    *OUTPUT       :none
    ****************************************************************/
    void ELECHOUSE_CC1101::SpiReadBurstReg(byte addr, byte *buffer, byte num)
    {
    	byte i,temp;
    
    	temp = addr | READ_BURST;
    	digitalWrite(SS_PIN, LOW);
    	while(digitalRead(MISO_PIN));
    	SpiTransfer(temp);
    	for(i=0;i<num;i++)
    	{
    		buffer[i]=SpiTransfer(0);
    	}
    	digitalWrite(SS_PIN, HIGH);
    }
    
    /****************************************************************
    *FUNCTION NAME:SpiReadStatus
    *FUNCTION     :CC1101 read status register
    *INPUT        :addr: register address
    *OUTPUT       :status value
    ****************************************************************/
    byte ELECHOUSE_CC1101::SpiReadStatus(byte addr) 
    {
    	byte value,temp;
    
    	temp = addr | READ_BURST;
    	digitalWrite(SS_PIN, LOW);
    	while(digitalRead(MISO_PIN));
    	SpiTransfer(temp);
    	value=SpiTransfer(0);
    	digitalWrite(SS_PIN, HIGH);
    
    	return value;
    }
    
    /****************************************************************
    *FUNCTION NAME:RegConfigSettings
    *FUNCTION     :CC1101 register config //details refer datasheet of CC1101/CC1100//
    *INPUT        :none
    *OUTPUT       :none
    ****************************************************************/
    void ELECHOUSE_CC1101::RegConfigSettings(void) 
    {
        SpiWriteReg(CC1101_FSCTRL1,  0x08);
        SpiWriteReg(CC1101_FSCTRL0,  0x00);
        SpiWriteReg(CC1101_FREQ2,    0x10);
        SpiWriteReg(CC1101_FREQ1,    0xA7);
        SpiWriteReg(CC1101_FREQ0,    0x62);
        SpiWriteReg(CC1101_MDMCFG4,  0x5B);
        SpiWriteReg(CC1101_MDMCFG3,  0xF8);
        SpiWriteReg(CC1101_MDMCFG2,  0x03);
        SpiWriteReg(CC1101_MDMCFG1,  0x22);
        SpiWriteReg(CC1101_MDMCFG0,  0xF8);
        SpiWriteReg(CC1101_CHANNR,   0x00);
        SpiWriteReg(CC1101_DEVIATN,  0x47);
        SpiWriteReg(CC1101_FREND1,   0xB6);
        SpiWriteReg(CC1101_FREND0,   0x10);
        SpiWriteReg(CC1101_MCSM0 ,   0x18);
        SpiWriteReg(CC1101_FOCCFG,   0x1D);
        SpiWriteReg(CC1101_BSCFG,    0x1C);
        SpiWriteReg(CC1101_AGCCTRL2, 0xC7);
    	SpiWriteReg(CC1101_AGCCTRL1, 0x00);
        SpiWriteReg(CC1101_AGCCTRL0, 0xB2);
        SpiWriteReg(CC1101_FSCAL3,   0xEA);
    	SpiWriteReg(CC1101_FSCAL2,   0x2A);
    	SpiWriteReg(CC1101_FSCAL1,   0x00);
        SpiWriteReg(CC1101_FSCAL0,   0x11);
        SpiWriteReg(CC1101_FSTEST,   0x59);
        SpiWriteReg(CC1101_TEST2,    0x81);
        SpiWriteReg(CC1101_TEST1,    0x35);
        SpiWriteReg(CC1101_TEST0,    0x09);
        SpiWriteReg(CC1101_IOCFG2,   0x0B); 	//serial clock.synchronous to the data in synchronous serial mode
        SpiWriteReg(CC1101_IOCFG0,   0x06);  	//asserts when sync word has been sent/received, and de-asserts at the end of the packet 
        SpiWriteReg(CC1101_PKTCTRL1, 0x04);		//two status bytes will be appended to the payload of the packet,including RSSI LQI and CRC OK
    											//No address check
        SpiWriteReg(CC1101_PKTCTRL0, 0x05);		//whitening off;CRC Enable£»variable length packets, packet length configured by the first byte after sync word
        SpiWriteReg(CC1101_ADDR,     0x00);		//address used for packet filtration.
        SpiWriteReg(CC1101_PKTLEN,   0x3D); 	//61 bytes max length
    }
    
    /****************************************************************
    *FUNCTION NAME:SendData
    *FUNCTION     :use CC1101 send data
    *INPUT        :txBuffer: data array to send; size: number of data to send, no more than 61
    *OUTPUT       :none
    ****************************************************************/
    void ELECHOUSE_CC1101::SendData(byte *txBuffer,byte size)
    {
    	SpiWriteReg(CC1101_TXFIFO,size);
    	SpiWriteBurstReg(CC1101_TXFIFO,txBuffer,size);			//write data to send
    	SpiStrobe(CC1101_STX);									//start send	
        while (!digitalRead(GDO0));								// Wait for GDO0 to be set -> sync transmitted  
        while (digitalRead(GDO0));								// Wait for GDO0 to be cleared -> end of packet
    	SpiStrobe(CC1101_SFTX);									//flush TXfifo
    }
    
    /****************************************************************
    *FUNCTION NAME:SetReceive
    *FUNCTION     :set CC1101 to receive state
    *INPUT        :none
    *OUTPUT       :none
    ****************************************************************/
    void ELECHOUSE_CC1101::SetReceive(void)
    {
    	SpiStrobe(CC1101_SRX);
    }
    
    /****************************************************************
    *FUNCTION NAME:CheckReceiveFlag
    *FUNCTION     :check receive data or not
    *INPUT        :none
    *OUTPUT       :flag: 0 no data; 1 receive data 
    ****************************************************************/
    byte ELECHOUSE_CC1101::CheckReceiveFlag(void)
    {
    	if(digitalRead(GDO0))			//receive data
    	{
    		while (digitalRead(GDO0));
    		return 1;
    	}
    	else							// no data
    	{
    		return 0;
    	}
    }
    
    
    /****************************************************************
    *FUNCTION NAME:ReceiveData
    *FUNCTION     :read data received from RXfifo
    *INPUT        :rxBuffer: buffer to store data
    *OUTPUT       :size of data received
    ****************************************************************/
    byte ELECHOUSE_CC1101::ReceiveData(byte *rxBuffer)
    {
    	byte size;
    	byte status[2];
    
    	if(SpiReadStatus(CC1101_RXBYTES) & BYTES_IN_RXFIFO)
    	{
    		size=SpiReadReg(CC1101_RXFIFO);
    		SpiReadBurstReg(CC1101_RXFIFO,rxBuffer,size);
    		SpiReadBurstReg(CC1101_RXFIFO,status,2);
    		SpiStrobe(CC1101_SFRX);
    		return size;
    	}
    	else
    	{
    		SpiStrobe(CC1101_SFRX);
    		return 0;
    	}
    	
    }
    
    ELECHOUSE_CC1101 ELECHOUSE_cc1101;
    this Code does magic on the Arduino Leonardo and...
    Code:
    #include "ELECHOUSE_CC1101.h"
    #include <Arduino.h>
    #include <SPI.h>
    
    /****************************************************************/
    #define 	WRITE_BURST     	0x40						//write burst
    #define 	READ_SINGLE     	0x80						//read single
    #define 	READ_BURST      	0xC0						//read burst
    #define 	BYTES_IN_RXFIFO     0x7F  						//byte number in RXfifo
    
    #define         ChipSelect_Pin 6
    #define         GDNull_Pin 16
    /****************************************************************/
    byte PaTabel[8] = {0x60 ,0x60 ,0x60 ,0x60 ,0x60 ,0x60 ,0x60 ,0x60};
    
    /****************************************************************
    *FUNCTION NAME:SpiInit
    *FUNCTION     :spi communication initialization
    *INPUT        :none
    *OUTPUT       :none
    ****************************************************************/
    void ELECHOUSE_CC1101::SpiInit(void)
    {
      // Pin initialisieren
      pinMode(ChipSelect_Pin, OUTPUT);
      
       // Clock-Signal auf Pin 14 mappen
      SPI.setSCK(14);
      
        //SPI initialisieren
      SPI.begin();
     
      
      
    }
    /****************************************************************
    *FUNCTION NAME:SpiTransfer
    *FUNCTION     :spi transfer
    *INPUT        :value: data to send
    *OUTPUT       :data to receive
    ****************************************************************/
    byte ELECHOUSE_CC1101::SpiTransfer(byte value)
    {
      SPI.transfer(value);
      return SPI.transfer(0);
    }
    
    /****************************************************************
    *FUNCTION NAME: GDO_Set()
    *FUNCTION     : set GDO0,GDO2 pin
    *INPUT        : none
    *OUTPUT       : none
    ****************************************************************/
    void ELECHOUSE_CC1101::GDO_Set (void)
    {
    	 pinMode(GDNull_Pin, INPUT);
    	
    }
    
    /****************************************************************
    *FUNCTION NAME:Reset
    *FUNCTION     :CC1101 reset //details refer datasheet of CC1101/CC1100//
    *INPUT        :none
    *OUTPUT       :none
    ****************************************************************/
    void ELECHOUSE_CC1101::Reset (void)
    {
    	digitalWrite(ChipSelect_Pin, LOW);
    	delay(1);
    	digitalWrite(ChipSelect_Pin, HIGH);
            delay(1);
    	digitalWrite(ChipSelect_Pin, LOW);
    	while(digitalRead(12));
    	SpiTransfer(CC1101_SRES);
    	while(digitalRead(12));
    	digitalWrite(ChipSelect_Pin, HIGH);
    }
    
    /****************************************************************
    *FUNCTION NAME:Init
    *FUNCTION     :CC1101 initialization
    *INPUT        :none
    *OUTPUT       :none
    ****************************************************************/
    void ELECHOUSE_CC1101::Init(void)
    {
    	SpiInit();										//spi initialization
    	GDO_Set();										//GDO set
    	digitalWrite(ChipSelect_Pin, HIGH);
            digitalWrite(14, HIGH);
    	digitalWrite(11, LOW);
    	Reset();										//CC1101 reset
    	RegConfigSettings();							//CC1101 register config
    	SpiWriteBurstReg(CC1101_PATABLE,PaTabel,8);		//CC1101 PATABLE config
    }
    
    
    /****************************************************************
    *FUNCTION NAME:SpiWriteReg
    *FUNCTION     :CC1101 write data to register
    *INPUT        :addr: register address; value: register value
    *OUTPUT       :none
    ****************************************************************/
    void ELECHOUSE_CC1101::SpiWriteReg(byte addr, byte value)
    {
            SPI.beginTransaction(SPISettings(1000000, MSBFIRST, SPI_MODE0));
    	digitalWrite(ChipSelect_Pin, LOW);
            while(digitalRead(12));
    	SpiTransfer(addr);
    	SpiTransfer(value);
    	digitalWrite(ChipSelect_Pin, HIGH);
            SPI.endTransaction();
    }
    
    /****************************************************************
    *FUNCTION NAME:SpiWriteBurstReg
    *FUNCTION     :CC1101 write burst data to register
    *INPUT        :addr: register address; buffer:register value array; num:number to write
    *OUTPUT       :none
    ****************************************************************/
    void ELECHOUSE_CC1101::SpiWriteBurstReg(byte addr, byte *buffer, byte num)
    {
    	byte i, temp;
    
    	temp = addr | WRITE_BURST;
        SPI.beginTransaction(SPISettings(1000000, MSBFIRST, SPI_MODE0));
        digitalWrite(ChipSelect_Pin, LOW);
        while(digitalRead(12));
        SpiTransfer(temp);
        for (i = 0; i < num; i++)
     	{
            SpiTransfer(buffer[i]);
        }
        digitalWrite(ChipSelect_Pin, HIGH);
          SPI.endTransaction();
    }
    
    /****************************************************************
    *FUNCTION NAME:SpiStrobe
    *FUNCTION     :CC1101 Strobe
    *INPUT        :strobe: command; //refer define in CC1101.h//
    *OUTPUT       :none
    ****************************************************************/
    void ELECHOUSE_CC1101::SpiStrobe(byte strobe)
    {
    	SPI.beginTransaction(SPISettings(1000000, MSBFIRST, SPI_MODE0));
            digitalWrite(ChipSelect_Pin, LOW);
    	while(digitalRead(12));
    	SpiTransfer(strobe);
    	digitalWrite(ChipSelect_Pin, HIGH);
            SPI.endTransaction();
    }
    
    /****************************************************************
    *FUNCTION NAME:SpiReadReg
    *FUNCTION     :CC1101 read data from register
    *INPUT        :addr: register address
    *OUTPUT       :register value
    ****************************************************************/
    byte ELECHOUSE_CC1101::SpiReadReg(byte addr) 
    {
    	byte temp, value;
    
        temp = addr|READ_SINGLE;
    	SPI.beginTransaction(SPISettings(1000000, MSBFIRST, SPI_MODE0));
            digitalWrite(ChipSelect_Pin, LOW);
    	while(digitalRead(12));
    	SpiTransfer(temp);
    	value=SpiTransfer(0);
    	digitalWrite(ChipSelect_Pin, HIGH);
            SPI.endTransaction();
    
    	return value;
    }
    
    /****************************************************************
    *FUNCTION NAME:SpiReadBurstReg
    *FUNCTION     :CC1101 read burst data from register
    *INPUT        :addr: register address; buffer:array to store register value; num: number to read
    *OUTPUT       :none
    ****************************************************************/
    void ELECHOUSE_CC1101::SpiReadBurstReg(byte addr, byte *buffer, byte num)
    {
    	byte i,temp;
    
    	temp = addr | READ_BURST;
    	SPI.beginTransaction(SPISettings(1000000, MSBFIRST, SPI_MODE0));
            digitalWrite(ChipSelect_Pin, LOW);
    	while(digitalRead(12));
    	SpiTransfer(temp);
    	for(i=0;i<num;i++)
    	{
    		buffer[i]=SpiTransfer(0);
    	}
    	digitalWrite(ChipSelect_Pin, HIGH);
            SPI.endTransaction();
    }
    
    /****************************************************************
    *FUNCTION NAME:SpiReadStatus
    *FUNCTION     :CC1101 read status register
    *INPUT        :addr: register address
    *OUTPUT       :status value
    ****************************************************************/
    byte ELECHOUSE_CC1101::SpiReadStatus(byte addr) 
    {
    	byte value,temp;
    
    	temp = addr | READ_BURST;
    	SPI.beginTransaction(SPISettings(1000000, MSBFIRST, SPI_MODE0));
            digitalWrite(ChipSelect_Pin, LOW);
    	while(digitalRead(12));
    	SpiTransfer(temp);
    	value=SpiTransfer(0);
    	digitalWrite(ChipSelect_Pin, HIGH);
            SPI.endTransaction();
    
    	return value;
    }
    
    /****************************************************************
    *FUNCTION NAME:RegConfigSettings
    *FUNCTION     :CC1101 register config //details refer datasheet of CC1101/CC1100//
    *INPUT        :none
    *OUTPUT       :none
    ****************************************************************/
    void ELECHOUSE_CC1101::RegConfigSettings(void) 
    {
      
      //Abweichungen
        SpiWriteReg(CC1101_FSCTRL1,  0x08);
        
            SpiWriteReg(CC1101_FREQ2,    0x10);
             
        SpiWriteReg(CC1101_FREQ1,    0xA7);
    
        SpiWriteReg(CC1101_FREQ0,    0x62);
         
        SpiWriteReg(CC1101_MDMCFG4,  0x5B);
        
        SpiWriteReg(CC1101_MDMCFG3,  0xF8);
     
        SpiWriteReg(CC1101_MDMCFG2,  0x03);
           
       SpiWriteReg(CC1101_DEVIATN,  0x47);
          
       SpiWriteReg(CC1101_FOCCFG,   0x1D);
          
         SpiWriteReg(CC1101_FSCAL3,   0xEA);
            
            SpiWriteReg(CC1101_FSCAL0,   0x11);
      
        SpiWriteReg(CC1101_FSCTRL0,  0x00);
    
        SpiWriteReg(CC1101_MDMCFG1,  0x22);
        SpiWriteReg(CC1101_MDMCFG0,  0xF8);
        SpiWriteReg(CC1101_CHANNR,   0x00);
       
        SpiWriteReg(CC1101_FREND1,   0xB6);
        SpiWriteReg(CC1101_FREND0,   0x10);
        SpiWriteReg(CC1101_MCSM0 ,   0x18);
       
        SpiWriteReg(CC1101_BSCFG,    0x1C);
        SpiWriteReg(CC1101_AGCCTRL2, 0xC7);
    	SpiWriteReg(CC1101_AGCCTRL1, 0x00);
        SpiWriteReg(CC1101_AGCCTRL0, 0xB2);
      
    	SpiWriteReg(CC1101_FSCAL2,   0x2A);
    	SpiWriteReg(CC1101_FSCAL1,   0x00);
    
        SpiWriteReg(CC1101_FSTEST,   0x59);
        SpiWriteReg(CC1101_TEST2,    0x81);
        SpiWriteReg(CC1101_TEST1,    0x35);
        SpiWriteReg(CC1101_TEST0,    0x09);
        SpiWriteReg(CC1101_IOCFG2,   0x0B); 	//serial clock.synchronous to the data in synchronous serial mode
        SpiWriteReg(CC1101_IOCFG0,   0x06);  	//asserts when sync word has been sent/received, and de-asserts at the end of the packet 
        SpiWriteReg(CC1101_PKTCTRL1, 0x04);		//two status bytes will be appended to the payload of the packet,including RSSI LQI and CRC OK
    											//No address check
        SpiWriteReg(CC1101_PKTCTRL0, 0x05);		//whitening off;CRC Enable��variable length packets, packet length configured by the first byte after sync word
        SpiWriteReg(CC1101_ADDR,     0x00);		//address used for packet filtration.
        SpiWriteReg(CC1101_PKTLEN,   0x3D); 	//61 bytes max length
        
        //Abweichungen
      /*  SpiWriteReg(CC1101_FSCTRL1,  0x06);
        SpiWriteReg(0x03,0x47);
        SpiWriteReg(CC1101_FREQ2,    0x21);
        SpiWriteReg(CC1101_FREQ1,    0x62);
        SpiWriteReg(CC1101_FREQ0,    0x76);
        SpiWriteReg(CC1101_MDMCFG4,  0xF5);
        SpiWriteReg(CC1101_MDMCFG3,  0x83);
        SpiWriteReg(CC1101_MDMCFG2,  0x13);
        SpiWriteReg(CC1101_DEVIATN,  0x15);
        SpiWriteReg(CC1101_FOCCFG,   0x16);
        SpiWriteReg(0x20,   0xFB);
        SpiWriteReg(CC1101_FSCAL3,   0xE9);
        SpiWriteReg(CC1101_FSCAL0,   0x1F);
         SpiWriteReg(CC1101_TEST2,    0x81);*/
    }
    
    /****************************************************************
    *FUNCTION NAME:SendData
    *FUNCTION     :use CC1101 send data
    *INPUT        :txBuffer: data array to send; size: number of data to send, no more than 61
    *OUTPUT       :none
    ****************************************************************/
    void ELECHOUSE_CC1101::SendData(byte *txBuffer,byte size)
    {
    	SpiWriteReg(CC1101_TXFIFO,size);
    	SpiWriteBurstReg(CC1101_TXFIFO,txBuffer,size);			//write data to send
    	SpiStrobe(CC1101_STX);									//start send	
        while (!digitalRead(GDNull_Pin));								// Wait for GDO0 to be set -> sync transmitted  
        while (digitalRead(GDNull_Pin));	
     //  delay(1);							// Wait for GDO0 to be cleared -> end of packet
    	SpiStrobe(CC1101_SFTX);									//flush TXfifo
    }
    
    /****************************************************************
    *FUNCTION NAME:SetReceive
    *FUNCTION     :set CC1101 to receive state
    *INPUT        :none
    *OUTPUT       :none
    ****************************************************************/
    void ELECHOUSE_CC1101::SetReceive(void)
    {
    	SpiStrobe(CC1101_SRX);
    }
    
    /****************************************************************
    *FUNCTION NAME:CheckReceiveFlag
    *FUNCTION     :check receive data or not
    *INPUT        :none
    *OUTPUT       :flag: 0 no data; 1 receive data 
    ****************************************************************/
    byte ELECHOUSE_CC1101::CheckReceiveFlag(void)
    {
    	if(digitalRead(GDNull_Pin))			//receive data
    	{
    		while (digitalRead(GDNull_Pin));
    		return 1;
    	}
    	else							// no data
    	{
    		return 0;
    	}
    }
    
    
    /****************************************************************
    *FUNCTION NAME:ReceiveData
    *FUNCTION     :read data received from RXfifo
    *INPUT        :rxBuffer: buffer to store data
    *OUTPUT       :size of data received
    ****************************************************************/
    byte ELECHOUSE_CC1101::ReceiveData(byte *rxBuffer)
    {
    	byte size;
    	byte status[2];
    
    	if(SpiReadStatus(CC1101_RXBYTES) & BYTES_IN_RXFIFO)
    	{
    		size=SpiReadReg(CC1101_RXFIFO);
    		SpiReadBurstReg(CC1101_RXFIFO,rxBuffer,size);
    		SpiReadBurstReg(CC1101_RXFIFO,status,2);
    		SpiStrobe(CC1101_SFRX);
    		return size;
    	}
    	else
    	{
    		SpiStrobe(CC1101_SFRX);
    		return 0;
    	}
    	
    }
    
    ELECHOUSE_CC1101 ELECHOUSE_cc1101;
    this Code should do the SAME magic on the Teensy ?


    Greeting from germany,

    Christian

  5. #5
    Junior Member
    Join Date
    Oct 2015
    Posts
    1
    ¿Did you have any success with this ?

    Because I am in the same situation.

  6. #6
    Junior Member
    Join Date
    Jan 2017
    Posts
    1
    Hi

    Great work and thanjs it has helped me no end.

    I am struggling with GDO0, no matter which pin I assign as GDNull_Pin in the cpp, and connect the GDO0 pin to it the code stalls in the SendData function after the first SpiStrobe(CC1101_STX) function call. The while loops are waiting for GDO0 to be set and I guess it never happens. I get a burst of data in GQRX at the expected frequncy then it freezes.

    I'm using a teensy 3.2 and powering the CC1101 from the 3.3v of the teensy...

    Any help would be greatly appreciated.

    Cheers
    Rob
    Last edited by rfullagar; 01-31-2017 at 02:57 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •