Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
LSatan authored Jul 13, 2021
1 parent 9f4d125 commit b8c6af4
Show file tree
Hide file tree
Showing 12 changed files with 137 additions and 19 deletions.
99 changes: 90 additions & 9 deletions ELECHOUSE_CC1101_SRC_DRV.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,26 @@ cc1101 Driver for RC Switch. Mod by Little Satan. With permission to modify and
#define READ_SINGLE 0x80 //read single
#define READ_BURST 0xC0 //read burst
#define BYTES_IN_RXFIFO 0x7F //byte number in RXfifo
#define max_modul 6

byte modulation = 2;
byte frend0;
byte chan = 0;
int pa = 12;
byte last_pa;
byte SCK_PIN = 13;
byte MISO_PIN = 12;
byte MOSI_PIN = 11;
byte SS_PIN = 10;
byte SCK_PIN;
byte MISO_PIN;
byte MOSI_PIN;
byte SS_PIN;
byte GDO0;
byte GDO2;
byte SCK_PIN_M[max_modul];
byte MISO_PIN_M[max_modul];
byte MOSI_PIN_M[max_modul];
byte SS_PIN_M[max_modul];
byte GDO0_M[max_modul];
byte GDO2_M[max_modul];
byte gdo_set=0;
bool spi = 0;
bool ccmode = 0;
float MHz = 433.92;
Expand Down Expand Up @@ -101,18 +109,27 @@ void ELECHOUSE_CC1101::SpiEnd(void)
// disable SPI
SPI.endTransaction();
SPI.end();
digitalWrite(SCK_PIN, LOW);
}
/****************************************************************
*FUNCTION NAME: GDO_Set()
*FUNCTION : set GDO0,GDO2 pin
*FUNCTION : set GDO0,GDO2 pin for serial pinmode.
*INPUT : none
*OUTPUT : none
****************************************************************/
void ELECHOUSE_CC1101::GDO_Set (void)
{
pinMode(GDO0, INPUT);
pinMode(GDO2, OUTPUT);
pinMode(GDO0, OUTPUT);
pinMode(GDO2, INPUT);
}
/****************************************************************
*FUNCTION NAME: GDO_Set()
*FUNCTION : set GDO0 for internal transmission mode.
*INPUT : none
*OUTPUT : none
****************************************************************/
void ELECHOUSE_CC1101::GDO0_Set (void)
{
pinMode(GDO0, INPUT);
}
/****************************************************************
*FUNCTION NAME:Reset
Expand Down Expand Up @@ -297,6 +314,19 @@ void ELECHOUSE_CC1101::setSpiPin(byte sck, byte miso, byte mosi, byte ss){
SS_PIN = ss;
}
/****************************************************************
*FUNCTION NAME:COSTUM SPI
*FUNCTION :set costum spi pins.
*INPUT :none
*OUTPUT :none
****************************************************************/
void ELECHOUSE_CC1101::addSpiPin(byte sck, byte miso, byte mosi, byte ss, byte modul){
spi = 1;
SCK_PIN_M[modul] = sck;
MISO_PIN_M[modul] = miso;
MOSI_PIN_M[modul] = mosi;
SS_PIN_M[modul] = ss;
}
/****************************************************************
*FUNCTION NAME:GDO Pin settings
*FUNCTION :set GDO Pins
*INPUT :none
Expand All @@ -308,6 +338,58 @@ GDO2 = gdo2;
GDO_Set();
}
/****************************************************************
*FUNCTION NAME:GDO0 Pin setting
*FUNCTION :set GDO0 Pin
*INPUT :none
*OUTPUT :none
****************************************************************/
void ELECHOUSE_CC1101::setGDO0(byte gdo0){
GDO0 = gdo0;
GDO0_Set();
}
/****************************************************************
*FUNCTION NAME:GDO Pin settings
*FUNCTION :add GDO Pins
*INPUT :none
*OUTPUT :none
****************************************************************/
void ELECHOUSE_CC1101::addGDO(byte gdo0, byte gdo2, byte modul){
GDO0_M[modul] = gdo0;
GDO2_M[modul] = gdo2;
gdo_set=2;
GDO_Set();
}
/****************************************************************
*FUNCTION NAME:add GDO0 Pin
*FUNCTION :add GDO0 Pin
*INPUT :none
*OUTPUT :none
****************************************************************/
void ELECHOUSE_CC1101::addGDO0(byte gdo0, byte modul){
GDO0_M[modul] = gdo0;
gdo_set=1;
GDO0_Set();
}
/****************************************************************
*FUNCTION NAME:set Modul
*FUNCTION :change modul
*INPUT :none
*OUTPUT :none
****************************************************************/
void ELECHOUSE_CC1101::setModul(byte modul){
SCK_PIN = SCK_PIN_M[modul];
MISO_PIN = MISO_PIN_M[modul];
MOSI_PIN = MOSI_PIN_M[modul];
SS_PIN = SS_PIN_M[modul];
if (gdo_set==1){
GDO0 = GDO0_M[modul];
}
else if (gdo_set==2){
GDO0 = GDO0_M[modul];
GDO2 = GDO2_M[modul];
}
}
/****************************************************************
*FUNCTION NAME:CCMode
*FUNCTION :Format of RX and TX data
*INPUT :none
Expand Down Expand Up @@ -1073,7 +1155,6 @@ void ELECHOUSE_CC1101::setSidle(void)
{
SpiStrobe(CC1101_SIDLE);
trxstate=0;

}
/****************************************************************
*FUNCTION NAME:goSleep
Expand Down
6 changes: 6 additions & 0 deletions ELECHOUSE_CC1101_SRC_DRV.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ class ELECHOUSE_CC1101
void SpiStart(void);
void SpiEnd(void);
void GDO_Set (void);
void GDO0_Set (void);
void Reset (void);
void setSpi(void);
void RegConfigSettings(void);
Expand All @@ -130,7 +131,12 @@ class ELECHOUSE_CC1101
void Init(void);
byte SpiReadStatus(byte addr);
void setSpiPin(byte sck, byte miso, byte mosi, byte ss);
void addSpiPin(byte sck, byte miso, byte mosi, byte ss, byte modul);
void setGDO(byte gdo0, byte gdo2);
void setGDO0(byte gdo0);
void addGDO(byte gdo0, byte gdo2, byte modul);
void addGDO0(byte gdo0, byte modul);
void setModul(byte modul);
void setCCMode(bool s);
void setModulation(byte m);
void setPA(int p);
Expand Down
30 changes: 28 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# SmartRC-CC1101-Driver-Lib_V2.5.6
# SmartRC-CC1101-Driver-Lib_V2.5.7

![GitHub (Pre-)Release Date](https://img.shields.io/github/release-date-pre/LSatan/SmartRC-CC1101-Driver-Lib)

Note: Find out about the laws in your country.
Use at your own risk.

Attention! in version 2.5.7 there are changes for the internal transfer functions regarding the gdo pin assignment!

---------------------------------------------
Announcements / other
---------------------------------------------
Expand Down Expand Up @@ -93,14 +95,29 @@ ELECHOUSE_cc1101.SetRx(MHZ); //Sets receive on and changes the frequency.

ELECHOUSE_cc1101.setRxBW(RXBW); //Set Receive filter bandwidth

ELECHOUSE_cc1101.setGDO(GDO0, GDO2); //Put the Gdo pins. For libraries that address the gdo pins directly.
ELECHOUSE_cc1101.setGDO(GDO0, GDO2); //Set Gdo0 (tx) and Gdo2 (rx) for serial transmission function.


ELECHOUSE_cc1101.setSpiPin(SCK, MISO, MOSI, CSN); //custom SPI pins. Set your own Spi Pins.Or to switch between multiple cc1101. Must be set before init and before changing the cc1101.

ELECHOUSE_cc1101.setChannel(chnl); //Set Channel from 0 to 255. default = 0(basic frequency).

ELECHOUSE_cc1101.setClb(fband, cal1, cal2); //Optionally enter Offset Callibration. Requirements: Sketch Calibrate_frequency.ino below [CC1101-Debug-Service-Tool](https://github.com/LSatan/CC1101-Debug-Service-Tool/tree/master/Calibrate_frequency).A SDR receiver and SDR software.

New in V2.5.7

ELECHOUSE_cc1101.setGDO0(GDO0); //Sets Gdo0 for internal transfer function.

ELECHOUSE_cc1101.addGDO0(GDO0, Modul); //Adds Gdo0 for internal transfer function (multiple cc1101).

ELECHOUSE_cc1101.addGDO(GDO0, GDO2, Modul); //Adds Gdo0 (tx) and Gdo2 (rx) for serial transmission function (multiple cc1101).

ELECHOUSE_cc1101.addSpiPin(SCK, MISO, MOSI, CSN, Modul); //Adds Spi Pins for multiple cc1101.

ELECHOUSE_cc1101.setModul(Modul); //Switches between modules. from 0 to 5. So a maximum of 6.


The new features are not final and can be changed at any time.

All can also be used in a loop and are applied directly.

Expand Down Expand Up @@ -134,6 +151,15 @@ https://www.paypal.me/LittleSatan666

Thank You!

---------------------------------------------
Changelog: SmartRC-CC1101-Driver-Lib_V2.5.7
---------------------------------------------
13.07.2021

Driver Library :Fixed a bug when initalizing multiple cc1101

Driver Library :new commandos for easy handling of multiple cc1101

---------------------------------------------
Changelog: SmartRC-CC1101-Driver-Lib_V2.5.6
---------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ gdo0 = 6; // for Arduino! GDO0 on pin 6.
}

ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101!
ELECHOUSE_cc1101.setGDO(gdo0,0); // set lib internal gdo pins (gdo0,gdo2). Gdo2 not use for this example.
ELECHOUSE_cc1101.setGDO0(gdo0); // set lib internal gdo pin (gdo0). Gdo2 not use for this example.
ELECHOUSE_cc1101.setCCMode(1); // set config for internal transmission mode.
ELECHOUSE_cc1101.setModulation(0); // set modulation mode. 0 = 2-FSK, 1 = GFSK, 2 = ASK/OOK, 3 = 4-FSK, 4 = MSK.
ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ gdo0 = 6; // for Arduino! GDO0 on pin 6.
}

ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101!
ELECHOUSE_cc1101.setGDO(gdo0,0); // set lib internal gdo pins (gdo0,gdo2). Gdo2 not use for this example.
ELECHOUSE_cc1101.setGDO0(gdo0); // set lib internal gdo pin (gdo0). Gdo2 not use for this example.
ELECHOUSE_cc1101.setCCMode(1); // set config for internal transmission mode.
ELECHOUSE_cc1101.setModulation(0); // set modulation mode. 0 = 2-FSK, 1 = GFSK, 2 = ASK/OOK, 3 = 4-FSK, 4 = MSK.
ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ gdo0 = 6; // for Arduino! GDO0 on pin 6.
}

ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101!
ELECHOUSE_cc1101.setGDO(gdo0,0); // set lib internal gdo pins (gdo0,gdo2). Gdo2 not use for this example.
ELECHOUSE_cc1101.setGDO0(gdo0); // set lib internal gdo pin (gdo0). Gdo2 not use for this example.
ELECHOUSE_cc1101.setCCMode(1); // set config for internal transmission mode.
ELECHOUSE_cc1101.setModulation(0); // set modulation mode. 0 = 2-FSK, 1 = GFSK, 2 = ASK/OOK, 3 = 4-FSK, 4 = MSK.
ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ gdo0 = 6; // for Arduino! GDO0 on pin 6.
}

ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101!
ELECHOUSE_cc1101.setGDO(gdo0,0); // set lib internal gdo pins (gdo0,gdo2). Gdo2 not use for this example.
ELECHOUSE_cc1101.setGDO0(gdo0); // set lib internal gdo pin (gdo0). Gdo2 not use for this example.
ELECHOUSE_cc1101.setCCMode(1); // set config for internal transmission mode.
ELECHOUSE_cc1101.setModulation(0); // set modulation mode. 0 = 2-FSK, 1 = GFSK, 2 = ASK/OOK, 3 = 4-FSK, 4 = MSK.
ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ gdo0 = 6; // for Arduino! GDO0 on pin 6.
}

ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101!
ELECHOUSE_cc1101.setGDO(gdo0,0); // set lib internal gdo pins (gdo0,gdo2). Gdo2 not use for this example.
ELECHOUSE_cc1101.setGDO0(gdo0); // set lib internal gdo pin (gdo0). Gdo2 not use for this example.
ELECHOUSE_cc1101.setCCMode(1); // set config for internal transmission mode.
ELECHOUSE_cc1101.setModulation(0); // set modulation mode. 0 = 2-FSK, 1 = GFSK, 2 = ASK/OOK, 3 = 4-FSK, 4 = MSK.
ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ gdo0 = 6; // for Arduino! GDO0 on pin 6.
}

ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101!
ELECHOUSE_cc1101.setGDO(gdo0,0); // set lib internal gdo pins (gdo0,gdo2). Gdo2 not use for this example.
ELECHOUSE_cc1101.setGDO0(gdo0); // set lib internal gdo pin (gdo0). Gdo2 not use for this example.
ELECHOUSE_cc1101.setCCMode(1); // set config for internal transmission mode.
ELECHOUSE_cc1101.setModulation(0); // set modulation mode. 0 = 2-FSK, 1 = GFSK, 2 = ASK/OOK, 3 = 4-FSK, 4 = MSK.
ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet.
Expand Down
5 changes: 5 additions & 0 deletions keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ SpiWriteBurstReg KEYWORD2
SpiReadReg KEYWORD2
SpiReadBurstReg KEYWORD2
setSpiPin KEYWORD2
addSpiPin KEYWORD2
setGDO KEYWORD2
setGDO0 KEYWORD2
addGDO KEYWORD2
addGDO0 KEYWORD2
setModul KEYWORD2
setCCMode KEYWORD2
setModulation KEYWORD2
setPA KEYWORD2
Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"type": "git",
"url": "https://github.com/LSatan/SmartRC-CC1101-Driver-Lib"
},
"version": "2.5.6",
"version": "2.5.7",
"frameworks": [
"arduino"
],
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=SmartRC-CC1101-Driver-Lib
version=2.5.6
version=2.5.7
author=LSatan
maintainer=LSatan <[email protected]>
sentence=Driver for cc1101.
Expand Down

0 comments on commit b8c6af4

Please sign in to comment.