Skip to content

Commit

Permalink
0.8.24
Browse files Browse the repository at this point in the history
* fix NRF communication for opendtufusion ethernet variant
  • Loading branch information
lumapu committed Dec 16, 2023
1 parent 222bf0e commit f191c03
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 17 deletions.
1 change: 0 additions & 1 deletion scripts/applyPatches.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,4 @@ def applyPatch(libName, patchFile):

if env['PIOENV'][:13] == "opendtufusion":
applyPatch("GxEPD2", "../patches/GxEPD2_SW_SPI.patch")
if env['PIOENV'][:22] == "opendtufusion-ethernet":
applyPatch("RF24", "../patches/RF24_Hal.patch")
3 changes: 3 additions & 0 deletions src/CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Development Changes

## 0.8.24 - 2023-12-16
* fix NRF communication for opendtufusion ethernet variant

## 0.8.23 - 2023-12-14
* heuristics fix #1269 #1270
* moved `sendInterval` in settings, **important:** *will be reseted to 15s after update to this version*
Expand Down
2 changes: 1 addition & 1 deletion src/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
//-------------------------------------
#define VERSION_MAJOR 0
#define VERSION_MINOR 8
#define VERSION_PATCH 23
#define VERSION_PATCH 24

//-------------------------------------
typedef struct {
Expand Down
1 change: 1 addition & 0 deletions src/hm/CommQueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class CommQueue {
}

uint8_t getFillState(void) {
DPRINTLN(DBG_INFO, "wr: " + String(mWrPtr) + ", rd: " + String(mRdPtr));
return abs(mRdPtr - mWrPtr);
}

Expand Down
20 changes: 9 additions & 11 deletions src/hm/hmRadio.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include "SPI.h"
#include "radio.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"
#endif

Expand All @@ -35,8 +35,8 @@ class HmRadio : public Radio {
HmRadio() {
mDtuSn = DTU_SN;
mIrqRcvd = false;
#if defined(CONFIG_IDF_TARGET_ESP32S3) && defined(ETHERNET)
mNrf24.reset(new RF24());
#if defined(CONFIG_IDF_TARGET_ESP32S3) && defined(SPI_HAL)
//mNrf24.reset(new RF24());
#else
mNrf24.reset(new RF24(CE_PIN, CS_PIN, SPI_SPEED));
#endif
Expand All @@ -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;

#ifdef ESP32
#if defined(CONFIG_IDF_TARGET_ESP32S3) && defined(ETHERNET)
mNrfHal.init(mosi, miso, sclk, cs, ce);
#if defined(CONFIG_IDF_TARGET_ESP32S3) && defined(SPI_HAL)
mNrfHal.init(mosi, miso, sclk, cs, ce, SPI_SPEED);
mNrf24.reset(new RF24(&mNrfHal));
#else
#if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
Expand All @@ -73,7 +73,7 @@ class HmRadio : public Radio {
mSpi->begin();
#endif

#if defined(CONFIG_IDF_TARGET_ESP32S3) && defined(ETHERNET)
#if defined(CONFIG_IDF_TARGET_ESP32S3) && defined(SPI_HAL)
mNrf24->begin();
#else
mNrf24->begin(mSpi.get(), ce, cs);
Expand Down Expand Up @@ -133,14 +133,12 @@ class HmRadio : public Radio {
yield();
}
// switch to next RX channel
if(++mRxChIdx >= RF_CHANNELS)
mRxChIdx = 0;
mRxChIdx = (mRxChIdx + 1) % RF_CHANNELS;
mNrf24->setChannel(mRfChLst[mRxChIdx]);
startMicros = micros();
}
// not finished but time is over
if(++mRxChIdx >= RF_CHANNELS)
mRxChIdx = 0;
mRxChIdx = (mRxChIdx + 1) % RF_CHANNELS;

return;
}
Expand Down Expand Up @@ -344,7 +342,7 @@ class HmRadio : public Radio {

std::unique_ptr<SPIClass> mSpi;
std::unique_ptr<RF24> mNrf24;
#if defined(CONFIG_IDF_TARGET_ESP32S3) && defined(ETHERNET)
#if defined(CONFIG_IDF_TARGET_ESP32S3) && defined(SPI_HAL)
nrfHal mNrfHal;
#endif
Inverter<> *mLastIv = NULL;
Expand Down
2 changes: 1 addition & 1 deletion src/hm/nrfHal.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class nrfHal: public RF24_hal, public SpiPatcherHandle {
uint8_t write(uint8_t cmd, const uint8_t* buf, uint8_t data_len, uint8_t blank_len) override {
uint8_t data[NRF_MAX_TRANSFER_SZ];
data[0] = cmd;
memset(data, 0, NRF_MAX_TRANSFER_SZ);
memset(&data[1], 0, (NRF_MAX_TRANSFER_SZ-1));
std::copy(&buf[0], &buf[data_len], &data[1]);

request_spi();
Expand Down
4 changes: 2 additions & 2 deletions src/hms/cmt2300a.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#ifndef __CMT2300A_H__
#define __CMT2300A_H__

#if defined(CONFIG_IDF_TARGET_ESP32S3) && defined(ETHERNET)
#if defined(CONFIG_IDF_TARGET_ESP32S3) && defined(SPI_HAL)
#include "cmtHal.h"
#else
#include "esp32_3wSpi.h"
Expand Down Expand Up @@ -480,7 +480,7 @@ class Cmt2300a {
return mSpi.readReg(CMT2300A_CUS_MODE_STA) & CMT2300A_MASK_CHIP_MODE_STA;
}

#if defined(CONFIG_IDF_TARGET_ESP32S3) && defined(ETHERNET)
#if defined(CONFIG_IDF_TARGET_ESP32S3) && defined(SPI_HAL)
cmtHal mSpi;
#else
esp32_3wSpi mSpi;
Expand Down
13 changes: 12 additions & 1 deletion src/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ lib_deps =
upload_protocol = esp-builtin
build_flags = ${env.build_flags}
-DETHERNET
-DSPI_HAL
-DUSE_HSPI_FOR_EPD
-DDEF_ETH_CS_PIN=42
-DDEF_ETH_SCK_PIN=39
Expand All @@ -184,13 +185,22 @@ build_flags = ${env.build_flags}
-DDEF_LED1=17
-DLED_ACTIVE_HIGH
-DARDUINO_USB_MODE=1
#-DARDUINO_USB_CDC_ON_BOOT=1
-DARDUINO_USB_CDC_ON_BOOT=1
monitor_filters =
esp32_exception_decoder, colorize

[env:opendtufusion-dev]
platform = [email protected]
board = esp32-s3-devkitc-1
lib_deps =
https://github.com/yubox-node-org/ESPAsyncWebServer
https://github.com/nrf24/RF24 @ ^1.4.8
paulstoffregen/Time @ ^1.6.1
https://github.com/bertmelis/espMqttClient#v1.5.0
bblanchon/ArduinoJson @ ^6.21.3
https://github.com/JChristensen/Timezone @ ^1.2.4
olikraus/U8g2 @ ^2.35.7
https://github.com/zinggjm/GxEPD2 @ ^1.5.2
upload_protocol = esp-builtin
build_flags = ${env.build_flags}
-DDEF_NRF_CS_PIN=37
Expand All @@ -209,5 +219,6 @@ build_flags = ${env.build_flags}
-DLED_ACTIVE_HIGH
-DARDUINO_USB_MODE=1
-DARDUINO_USB_CDC_ON_BOOT=1
-DSPI_HAL
monitor_filters =
esp32_exception_decoder, colorize

0 comments on commit f191c03

Please sign in to comment.