[CC1101] Changed pin mapping

This commit is contained in:
jgromes 2019-12-27 13:16:31 +01:00
parent 606e317958
commit 540867365c
8 changed files with 46 additions and 33 deletions

View file

@ -17,10 +17,11 @@
#include <RadioLib.h> #include <RadioLib.h>
// CC1101 has the following connections: // CC1101 has the following connections:
// NSS pin: 10 // CS pin: 10
// GDO0 pin: 2 // GDO0 pin: 2
// GDO2 pin: 3 // RST pin: unused
CC1101 cc = new Module(10, 2, 3); // GDO2 pin: 3 (optional)
CC1101 cc = new Module(10, 2, RADIOLIB_PIN_UNUSED, 3);
// or using RadioShield // or using RadioShield
// https://github.com/jgromes/RadioShield // https://github.com/jgromes/RadioShield

View file

@ -15,10 +15,11 @@
#include <RadioLib.h> #include <RadioLib.h>
// CC1101 has the following connections: // CC1101 has the following connections:
// NSS pin: 10 // CS pin: 10
// GDO0 pin: 2 // GDO0 pin: 2
// GDO2 pin: 3 // RST pin: unused
CC1101 cc = new Module(10, 2, 3); // GDO2 pin: 3 (optional)
CC1101 cc = new Module(10, 2, RADIOLIB_PIN_UNUSED, 3);
// or using RadioShield // or using RadioShield
// https://github.com/jgromes/RadioShield // https://github.com/jgromes/RadioShield

View file

@ -20,10 +20,11 @@
#include <RadioLib.h> #include <RadioLib.h>
// CC1101 has the following connections: // CC1101 has the following connections:
// NSS pin: 10 // CS pin: 10
// GDO0 pin: 2 // GDO0 pin: 2
// GDO2 pin: 3 // RST pin: unused
CC1101 cc = new Module(10, 2, 3); // GDO2 pin: 3 (optional)
CC1101 cc = new Module(10, 2, RADIOLIB_PIN_UNUSED, 3);
// or using RadioShield // or using RadioShield
// https://github.com/jgromes/RadioShield // https://github.com/jgromes/RadioShield

View file

@ -19,16 +19,18 @@
#include <RadioLib.h> #include <RadioLib.h>
// CC1101 has the following connections: // CC1101 has the following connections:
// NSS pin: 10 // CS pin: 10
// GDO0 pin: 2 // GDO0 pin: 2
// GDO2 pin: 3 // RST pin: unused
CC1101 cc1 = new Module(10, 2, 3); // GDO2 pin: 3 (optional)
CC1101 cc1 = new Module(10, 2, RADIOLIB_PIN_UNUSED, 3);
// second CC1101 has different connections: // second CC1101 has different connections:
// NSS pin: 9 // CS pin: 9
// GDO0 pin: 4 // GDO0 pin: 4
// GDO2 pin: 5 // RST pin: unused
CC1101 cc2 = new Module(9, 4, 5); // GDO2 pin: 5 (optional)
CC1101 cc2 = new Module(9, 4, RADIOLIB_PIN_UNUSED, 53);
// or using RadioShield // or using RadioShield
// https://github.com/jgromes/RadioShield // https://github.com/jgromes/RadioShield

View file

@ -15,10 +15,11 @@
#include <RadioLib.h> #include <RadioLib.h>
// CC1101 has the following connections: // CC1101 has the following connections:
// NSS pin: 10 // CS pin: 10
// GDO0 pin: 2 // GDO0 pin: 2
// GDO2 pin: 3 // RST pin: unused
CC1101 cc = new Module(10, 2, 3); // GDO2 pin: 3 (optional)
CC1101 cc1 = new Module(10, 2, RADIOLIB_PIN_UNUSED, 3);
// or using RadioShield // or using RadioShield
// https://github.com/jgromes/RadioShield // https://github.com/jgromes/RadioShield

View file

@ -15,10 +15,11 @@
#include <RadioLib.h> #include <RadioLib.h>
// CC1101 has the following connections: // CC1101 has the following connections:
// NSS pin: 10 // CS pin: 10
// GDO0 pin: 2 // GDO0 pin: 2
// GDO2 pin: 3 // RST pin: unused
CC1101 cc = new Module(10, 2, 3); // GDO2 pin: 3 (optional)
CC1101 cc1 = new Module(10, 2, RADIOLIB_PIN_UNUSED, 3);
// or using RadioShield // or using RadioShield
// https://github.com/jgromes/RadioShield // https://github.com/jgromes/RadioShield

View file

@ -16,10 +16,11 @@
#include <RadioLib.h> #include <RadioLib.h>
// CC1101 has the following connections: // CC1101 has the following connections:
// NSS pin: 10 // CS pin: 10
// GDO0 pin: 2 // GDO0 pin: 2
// GDO2 pin: 3 // RST pin: unused
CC1101 cc = new Module(10, 2, 3); // GDO2 pin: 3 (optional)
CC1101 cc1 = new Module(10, 2, RADIOLIB_PIN_UNUSED, 3);
// or using RadioShield // or using RadioShield
// https://github.com/jgromes/RadioShield // https://github.com/jgromes/RadioShield

View file

@ -13,7 +13,8 @@ int16_t CC1101::begin(float freq, float br, float rxBw, float freqDev, int8_t po
// set module properties // set module properties
_mod->SPIreadCommand = CC1101_CMD_READ; _mod->SPIreadCommand = CC1101_CMD_READ;
_mod->SPIwriteCommand = CC1101_CMD_WRITE; _mod->SPIwriteCommand = CC1101_CMD_WRITE;
_mod->init(RADIOLIB_USE_SPI, RADIOLIB_INT_0); _mod->init(RADIOLIB_USE_SPI);
Module::pinMode(_mod->getIrq(), INPUT);
// try to find the CC1101 chip // try to find the CC1101 chip
uint8_t i = 0; uint8_t i = 0;
@ -110,10 +111,10 @@ int16_t CC1101::transmit(uint8_t* data, size_t len, uint8_t addr) {
} }
// wait for transmission start // wait for transmission start
while(!digitalRead(_mod->getInt0())); while(!digitalRead(_mod->getIrq()));
// wait for transmission end // wait for transmission end
while(digitalRead(_mod->getInt0())); while(digitalRead(_mod->getIrq()));
// set mode to standby // set mode to standby
standby(); standby();
@ -132,10 +133,10 @@ int16_t CC1101::receive(uint8_t* data, size_t len) {
} }
// wait for sync word // wait for sync word
while(!digitalRead(_mod->getInt0())); while(!digitalRead(_mod->getIrq()));
// wait for packet end // wait for packet end
while(digitalRead(_mod->getInt0())); while(digitalRead(_mod->getIrq()));
// read packet data // read packet data
return(readData(data, len)); return(readData(data, len));
@ -187,11 +188,15 @@ int16_t CC1101::packetMode() {
} }
void CC1101::setGdo0Action(void (*func)(void), uint8_t dir) { void CC1101::setGdo0Action(void (*func)(void), uint8_t dir) {
attachInterrupt(digitalPinToInterrupt(_mod->getInt0()), func, dir); attachInterrupt(digitalPinToInterrupt(_mod->getIrq()), func, dir);
} }
void CC1101::setGdo2Action(void (*func)(void), uint8_t dir) { void CC1101::setGdo2Action(void (*func)(void), uint8_t dir) {
attachInterrupt(digitalPinToInterrupt(_mod->getInt1()), func, dir); if(_mod->getGpio() != RADIOLIB_PIN_UNUSED) {
return;
}
Module::pinMode(_mod->getGpio(), INPUT);
attachInterrupt(digitalPinToInterrupt(_mod->getGpio()), func, dir);
} }
int16_t CC1101::startTransmit(uint8_t* data, size_t len, uint8_t addr) { int16_t CC1101::startTransmit(uint8_t* data, size_t len, uint8_t addr) {
@ -808,9 +813,9 @@ void CC1101::SPIwriteRegisterBurst(uint8_t reg, uint8_t* data, size_t len) {
} }
void CC1101::SPIsendCommand(uint8_t cmd) { void CC1101::SPIsendCommand(uint8_t cmd) {
digitalWrite(_mod->getCs(), LOW); Module::digitalWrite(_mod->getCs(), LOW);
SPI.beginTransaction(SPISettings(2000000, MSBFIRST, SPI_MODE0)); SPI.beginTransaction(SPISettings(2000000, MSBFIRST, SPI_MODE0));
SPI.transfer(cmd); SPI.transfer(cmd);
SPI.endTransaction(); SPI.endTransaction();
digitalWrite(_mod->getCs(), HIGH); Module::digitalWrite(_mod->getCs(), HIGH);
} }