|
@ -10,7 +10,7 @@ |
|
|
#include "SPI.h" |
|
|
#include "SPI.h" |
|
|
#include "radio.h" |
|
|
#include "radio.h" |
|
|
#include "../config/config.h" |
|
|
#include "../config/config.h" |
|
|
#if defined(CONFIG_IDF_TARGET_ESP32S3) && defined(ETHERNET) |
|
|
#if defined(CONFIG_IDF_TARGET_ESP32S3) && defined(SPI_HAL) |
|
|
#include "nrfHal.h" |
|
|
#include "nrfHal.h" |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
@ -35,8 +35,8 @@ class HmRadio : public Radio { |
|
|
HmRadio() { |
|
|
HmRadio() { |
|
|
mDtuSn = DTU_SN; |
|
|
mDtuSn = DTU_SN; |
|
|
mIrqRcvd = false; |
|
|
mIrqRcvd = false; |
|
|
#if defined(CONFIG_IDF_TARGET_ESP32S3) && defined(ETHERNET) |
|
|
#if defined(CONFIG_IDF_TARGET_ESP32S3) && defined(SPI_HAL) |
|
|
mNrf24.reset(new RF24()); |
|
|
//mNrf24.reset(new RF24());
|
|
|
#else |
|
|
#else |
|
|
mNrf24.reset(new RF24(CE_PIN, CS_PIN, SPI_SPEED)); |
|
|
mNrf24.reset(new RF24(CE_PIN, CS_PIN, SPI_SPEED)); |
|
|
#endif |
|
|
#endif |
|
@ -56,8 +56,8 @@ class HmRadio : public Radio { |
|
|
DTU_RADIO_ID = ((uint64_t)(((mDtuSn >> 24) & 0xFF) | ((mDtuSn >> 8) & 0xFF00) | ((mDtuSn << 8) & 0xFF0000) | ((mDtuSn << 24) & 0xFF000000)) << 8) | 0x01; |
|
|
DTU_RADIO_ID = ((uint64_t)(((mDtuSn >> 24) & 0xFF) | ((mDtuSn >> 8) & 0xFF00) | ((mDtuSn << 8) & 0xFF0000) | ((mDtuSn << 24) & 0xFF000000)) << 8) | 0x01; |
|
|
|
|
|
|
|
|
#ifdef ESP32 |
|
|
#ifdef ESP32 |
|
|
#if defined(CONFIG_IDF_TARGET_ESP32S3) && defined(ETHERNET) |
|
|
#if defined(CONFIG_IDF_TARGET_ESP32S3) && defined(SPI_HAL) |
|
|
mNrfHal.init(mosi, miso, sclk, cs, ce); |
|
|
mNrfHal.init(mosi, miso, sclk, cs, ce, SPI_SPEED); |
|
|
mNrf24.reset(new RF24(&mNrfHal)); |
|
|
mNrf24.reset(new RF24(&mNrfHal)); |
|
|
#else |
|
|
#else |
|
|
#if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3 |
|
|
#if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3 |
|
@ -73,7 +73,7 @@ class HmRadio : public Radio { |
|
|
mSpi->begin(); |
|
|
mSpi->begin(); |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
#if defined(CONFIG_IDF_TARGET_ESP32S3) && defined(ETHERNET) |
|
|
#if defined(CONFIG_IDF_TARGET_ESP32S3) && defined(SPI_HAL) |
|
|
mNrf24->begin(); |
|
|
mNrf24->begin(); |
|
|
#else |
|
|
#else |
|
|
mNrf24->begin(mSpi.get(), ce, cs); |
|
|
mNrf24->begin(mSpi.get(), ce, cs); |
|
@ -133,14 +133,12 @@ class HmRadio : public Radio { |
|
|
yield(); |
|
|
yield(); |
|
|
} |
|
|
} |
|
|
// switch to next RX channel
|
|
|
// switch to next RX channel
|
|
|
if(++mRxChIdx >= RF_CHANNELS) |
|
|
mRxChIdx = (mRxChIdx + 1) % RF_CHANNELS; |
|
|
mRxChIdx = 0; |
|
|
|
|
|
mNrf24->setChannel(mRfChLst[mRxChIdx]); |
|
|
mNrf24->setChannel(mRfChLst[mRxChIdx]); |
|
|
startMicros = micros(); |
|
|
startMicros = micros(); |
|
|
} |
|
|
} |
|
|
// not finished but time is over
|
|
|
// not finished but time is over
|
|
|
if(++mRxChIdx >= RF_CHANNELS) |
|
|
mRxChIdx = (mRxChIdx + 1) % RF_CHANNELS; |
|
|
mRxChIdx = 0; |
|
|
|
|
|
|
|
|
|
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
@ -344,7 +342,7 @@ class HmRadio : public Radio { |
|
|
|
|
|
|
|
|
std::unique_ptr<SPIClass> mSpi; |
|
|
std::unique_ptr<SPIClass> mSpi; |
|
|
std::unique_ptr<RF24> mNrf24; |
|
|
std::unique_ptr<RF24> mNrf24; |
|
|
#if defined(CONFIG_IDF_TARGET_ESP32S3) && defined(ETHERNET) |
|
|
#if defined(CONFIG_IDF_TARGET_ESP32S3) && defined(SPI_HAL) |
|
|
nrfHal mNrfHal; |
|
|
nrfHal mNrfHal; |
|
|
#endif |
|
|
#endif |
|
|
Inverter<> *mLastIv = NULL; |
|
|
Inverter<> *mLastIv = NULL; |
|
|