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 Jan 22, 2021
1 parent f860157 commit 0152d79
Show file tree
Hide file tree
Showing 40 changed files with 321 additions and 52 deletions.
63 changes: 59 additions & 4 deletions ELECHOUSE_CC1101_SRC_DRV.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ byte pc0WDATA;
byte pc0PktForm;
byte pc0CRC_EN;
byte pc0LenConf;
byte trxstate;
byte trxstate = 0;
byte clb1[2]= {24,28};
byte clb2[2]= {31,38};
byte clb3[2]= {65,76};
Expand Down Expand Up @@ -527,6 +527,29 @@ clb4[1]=e;
}
}
/****************************************************************
*FUNCTION NAME:getCC1101
*FUNCTION :Test Spi connection and return 1 when true.
*INPUT :none
*OUTPUT :none
****************************************************************/
bool ELECHOUSE_CC1101::getCC1101(void){
setSpi();
if (SpiReadStatus(0x31)>0){
return 1;
}else{
return 0;
}
}
/****************************************************************
*FUNCTION NAME:getMode
*FUNCTION :Return the Mode. Sidle = 0, TX = 1, Rx = 2.
*INPUT :none
*OUTPUT :none
****************************************************************/
byte ELECHOUSE_CC1101::getMode(void){
return trxstate;
}
/****************************************************************
*FUNCTION NAME:Set Sync_Word
*FUNCTION :Sync Word
*INPUT :none
Expand Down Expand Up @@ -948,10 +971,12 @@ void ELECHOUSE_CC1101::RegConfigSettings(void)
****************************************************************/
void ELECHOUSE_CC1101::SetTx(void)
{
if(trxstate!=1){
SpiStrobe(CC1101_SIDLE);
SpiStrobe(CC1101_STX); //start send
trxstate=1;
}
}
/****************************************************************
*FUNCTION NAME:SetRx
*FUNCTION :set CC1101 to receive state
Expand All @@ -960,9 +985,11 @@ void ELECHOUSE_CC1101::SetTx(void)
****************************************************************/
void ELECHOUSE_CC1101::SetRx(void)
{
if(trxstate!=2){
SpiStrobe(CC1101_SRX); //start receive
trxstate=2;
}
}
/****************************************************************
*FUNCTION NAME:SetTx
*FUNCTION :set CC1101 send data and change frequency
Expand All @@ -972,10 +999,12 @@ void ELECHOUSE_CC1101::SetRx(void)
void ELECHOUSE_CC1101::SetTx(float mhz)
{
setMHZ(mhz);
if(trxstate!=1){
SpiStrobe(CC1101_SIDLE);
SpiStrobe(CC1101_STX); //start send
trxstate=1;
}
}
/****************************************************************
*FUNCTION NAME:SetRx
*FUNCTION :set CC1101 to receive state and change frequency
Expand All @@ -985,9 +1014,11 @@ void ELECHOUSE_CC1101::SetTx(float mhz)
void ELECHOUSE_CC1101::SetRx(float mhz)
{
setMHZ(mhz);
if(trxstate!=2){
SpiStrobe(CC1101_SRX); //start receive
trxstate=2;
}
}
/****************************************************************
*FUNCTION NAME:RSSI Level
*FUNCTION :Calculating the RSSI Level
Expand Down Expand Up @@ -1022,7 +1053,31 @@ return lqi;
****************************************************************/
void ELECHOUSE_CC1101::setSres(void)
{
SpiStrobe(CC1101_SRES); //reset cc1101
SpiStrobe(CC1101_SRES);
trxstate=0;
}
/****************************************************************
*FUNCTION NAME:setSidle
*FUNCTION :set Rx / TX Off
*INPUT :none
*OUTPUT :none
****************************************************************/
void ELECHOUSE_CC1101::setSidle(void)
{
SpiStrobe(CC1101_SIDLE);
trxstate=0;

}
/****************************************************************
*FUNCTION NAME:goSleep
*FUNCTION :set cc1101 Sleep on
*INPUT :none
*OUTPUT :none
****************************************************************/
void ELECHOUSE_CC1101::goSleep(void){
trxstate=0;
SpiStrobe(0x36);//Exit RX / TX, turn off frequency synthesizer and exit
SpiStrobe(0x39);//Enter power down mode when CSn goes high.
}
/****************************************************************
*FUNCTION NAME:Char direct SendData
Expand Down Expand Up @@ -1107,7 +1162,7 @@ return 0;
*OUTPUT :flag: 0 no data; 1 receive data
****************************************************************/
bool ELECHOUSE_CC1101::CheckRxFifo(int t){
if(trxstate!=2){SetRx();}
SetRx();
if(SpiReadStatus(CC1101_RXBYTES) & BYTES_IN_RXFIFO){
delay(t);
return 1;
Expand All @@ -1123,7 +1178,7 @@ return 0;
****************************************************************/
byte ELECHOUSE_CC1101::CheckReceiveFlag(void)
{
if(trxstate!=2){SetRx();}
SetRx();
if(digitalRead(GDO0)) //receive data
{
while (digitalRead(GDO0));
Expand Down
4 changes: 4 additions & 0 deletions ELECHOUSE_CC1101_SRC_DRV.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ class ELECHOUSE_CC1101
int getRssi(void);
byte getLqi(void);
void setSres(void);
void setSidle(void);
void goSleep(void);
void SendData(byte *txBuffer, byte size);
void SendData(char *txchar);
void SendData(byte *txBuffer, byte size, int t);
Expand All @@ -160,6 +162,8 @@ class ELECHOUSE_CC1101
byte SpiReadReg(byte addr);
void SpiReadBurstReg(byte addr, byte *buffer, byte num);
void setClb(byte b, byte s, byte e);
bool getCC1101(void);
byte getMode(void);
void setSyncWord(byte sh, byte sl);
void setAddr(byte v);
void setWhiteData(bool v);
Expand Down
19 changes: 18 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SmartRC-CC1101-Driver-Lib_V2.5.2
# SmartRC-CC1101-Driver-Lib_V2.5.3

Note: Find out about the laws in your country.
Use at your own risk.
Expand Down Expand Up @@ -132,6 +132,23 @@ https://www.paypal.me/LittleSatan666

Thank You!

---------------------------------------------
Changelog: SmartRC-CC1101-Driver-Lib_V2.5.3
---------------------------------------------
22.01.2021

Driver Library :Putting rx tx has no effect if they are already in mode. Prevents unnecessary double-initaliesing.

Driver Library :new command added: ELECHOUSE_cc1101.goSleep(); //Enter power down mode. For wakeup set RX or TX.

Driver Library :new command added: ELECHOUSE_cc1101.getMode(); //Return the Mode. Sidle = 0, TX = 1, Rx = 2.

Driver Library :new command added: ELECHOUSE_cc1101.setSidle(); //Set Rx / Tx Off.

Driver Library :new command added: ELECHOUSE_cc1101.getCC1101(); //Test Spi connection and return 1 when true.

Examples :RcSwitch Repeater_cc1101.ino has been shortened.

---------------------------------------------
Changelog: SmartRC-CC1101-Driver-Lib_V2.5.2
---------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
void setup(){

Serial.begin(9600);
if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.
Serial.println("Connection OK");
}else{
Serial.println("Connection Error");
}

ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101!
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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@
void setup(){

Serial.begin(9600);

if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.
Serial.println("Connection OK");
}else{
Serial.println("Connection Error");
}

ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101!
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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ char *transmitt_char = "Hello World";
void setup() {

Serial.begin(9600);

if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.
Serial.println("Connection OK");
}else{
Serial.println("Connection Error");
}

ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101!
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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ char *transmitt_char = "Hello World";
void setup() {

Serial.begin(9600);

if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.
Serial.println("Connection OK");
}else{
Serial.println("Connection Error");
}

ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101!
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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ byte buffer[n] = "";
void setup() {

Serial.begin(9600);

if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.
Serial.println("Connection OK");
}else{
Serial.println("Connection Error");
}

ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101!
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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ byte buffer[n] = "";
void setup() {

Serial.begin(9600);

if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.
Serial.println("Connection OK");
}else{
Serial.println("Connection Error");
}

ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101!
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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ gdo0 = 6; // for Arduino! GDO0 on pin 6.
#endif

Serial.begin(9600);

if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.
Serial.println("Connection OK");
}else{
Serial.println("Connection Error");
}

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.setCCMode(1); // set config for internal transmission mode.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ gdo0 = 6; // for Arduino! GDO0 on pin 6.
#endif

Serial.begin(9600);

if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.
Serial.println("Connection OK");
}else{
Serial.println("Connection Error");
}

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.setCCMode(1); // set config for internal transmission mode.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ gdo0 = 6; // for Arduino! GDO0 on pin 6.
#endif

Serial.begin(9600);

if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.
Serial.println("Connection OK");
}else{
Serial.println("Connection Error");
}

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.setCCMode(1); // set config for internal transmission mode.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ gdo0 = 6; // for Arduino! GDO0 on pin 6.
#endif

Serial.begin(9600);

if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.
Serial.println("Connection OK");
}else{
Serial.println("Connection Error");
}

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.setCCMode(1); // set config for internal transmission mode.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ gdo0 = 6; // for Arduino! GDO0 on pin 6.
#endif

Serial.begin(9600);

if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.
Serial.println("Connection OK");
}else{
Serial.println("Connection Error");
}

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.setCCMode(1); // set config for internal transmission mode.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ gdo0 = 6; // for Arduino! GDO0 on pin 6.
#endif

Serial.begin(9600);

if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.
Serial.println("Connection OK");
}else{
Serial.println("Connection Error");
}

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.setCCMode(1); // set config for internal transmission mode.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ RECEIVER_PIN = 4; TRANSMITTER_PIN = 5; // for esp8266! Receiver on pin 4 = D2.
RECEIVER_PIN = 0; TRANSMITTER_PIN = 6; // for Arduino! Receiver on interrupt 0 => that is pin #2. Transmit on pin 6.
#endif

if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.
Serial.println("Connection OK");
}else{
Serial.println("Connection Error");
}

//CC1101 Settings: (Settings with "//" are optional!)
ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101!
//ELECHOUSE_cc1101.setRxBW(812.50); // Set the Receive Bandwidth in kHz. Value from 58.03 to 812.50. Default is 812.50 kHz.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ RECEIVER_PIN = 4; TRANSMITTER_PIN = 5; // for esp8266! Receiver on pin 4 = D2.
RECEIVER_PIN = 0; TRANSMITTER_PIN = 6; // for Arduino! Receiver on interrupt 0 => that is pin #2. Transmit on pin 6.
#endif

if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.
Serial.println("Connection OK");
}else{
Serial.println("Connection Error");
}

//CC1101 Settings: (Settings with "//" are optional!)
ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101!
//ELECHOUSE_cc1101.setRxBW(812.50); // Set the Receive Bandwidth in kHz. Value from 58.03 to 812.50. Default is 812.50 kHz.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ TRANSMITTER_PIN = 5; // for esp8266! Transmit on pin 5 = D1.
TRANSMITTER_PIN = 6; // for Arduino! Transmit on pin 6.
#endif

if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.
Serial.println("Connection OK");
}else{
Serial.println("Connection Error");
}

//CC1101 Settings: (Settings with "//" are optional!)
ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101!
//ELECHOUSE_cc1101.setRxBW(812.50); // Set the Receive Bandwidth in kHz. Value from 58.03 to 812.50. Default is 812.50 kHz.
Expand Down
Loading

0 comments on commit 0152d79

Please sign in to comment.