LSatan / SmartRC-CC1101-Driver-Lib

This driver library can be used for many libraries that use a simple RF ASK module, with the advantages of the cc1101 module. It offers many direct setting options as in SmartRF Studio and calculates settings such as MHz directly.
Other
440 stars 98 forks source link

How to use multiple cc1101 correctly? (one sending, one receiving) #107

Open dracobucio opened 2 years ago

dracobucio commented 2 years ago

I know this topic has been discussed before and the author will try to add an example later in the next update. However, I have tried to use the new features to send and receive, I found that I need to use a double initialization to be able to use 2 cc1101 modules with a teensy 4.0, using V2.5.7. This is my code:

void configure(){ ELECHOUSE_cc1101.Init(); ELECHOUSE_cc1101.setCCMode(1); ELECHOUSE_cc1101.setModulation(0); ELECHOUSE_cc1101.setMHZ(433.92); ELECHOUSE_cc1101.setDeviation(47.60); ELECHOUSE_cc1101.setChannel(0); ELECHOUSE_cc1101.setChsp(199.95); ELECHOUSE_cc1101.setRxBW(812.50); ELECHOUSE_cc1101.setDRate(99.97); ELECHOUSE_cc1101.setPA(10); ELECHOUSE_cc1101.setSyncMode(2); ELECHOUSE_cc1101.setSyncWord(211, 145); ELECHOUSE_cc1101.setAdrChk(0); ELECHOUSE_cc1101.setAddr(0); ELECHOUSE_cc1101.setWhiteData(0); ELECHOUSE_cc1101.setPktFormat(0); ELECHOUSE_cc1101.setLengthConfig(1); ELECHOUSE_cc1101.setPacketLength(0); ELECHOUSE_cc1101.setCrc(1); ELECHOUSE_cc1101.setCRC_AF(0); ELECHOUSE_cc1101.setDcFilterOff(0); ELECHOUSE_cc1101.setManchester(0); ELECHOUSE_cc1101.setFEC(0); ELECHOUSE_cc1101.setPRE(0); ELECHOUSE_cc1101.setPQT(0); ELECHOUSE_cc1101.setAppendStatus(0); }

void setup(){ Serial.begin(19200); ELECHOUSE_cc1101.addSpiPin(13, 12, 11, 10, 0); ELECHOUSE_cc1101.addGDO0(2, 0); ELECHOUSE_cc1101.addSpiPin(13, 12, 11, 9, 1); ELECHOUSE_cc1101.addGDO0(3, 1); ELECHOUSE_cc1101.setModul(0); configure();
ELECHOUSE_cc1101.setModul(1); configure();
}

If just using this initialization in the setup function doesn't work, I must add an initialization again to make it work inside the loop function:

if (conf == false){ ELECHOUSE_cc1101.setModul(0); configure(); ELECHOUSE_cc1101.setModul(1); configure(); conf = true; }

how to correctly use multiple cc1101 switching with the SPI without losing communication? An example of a cc1101 as a transmitter and another as a receiver on the same board would be greatly appreciated.

THANKS! :)

IndieMash commented 2 weeks ago

Hi, I'm probably to late for this but did you manage to figure this out? If you did, it would be much appreciated if you shared your script. The developer has been saying he will upload an example script for a while now.