Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using with ESP32 #13

Open
supersjimmie opened this issue Oct 8, 2020 · 4 comments
Open

Using with ESP32 #13

supersjimmie opened this issue Oct 8, 2020 · 4 comments

Comments

@supersjimmie
Copy link

I found which changes are needed to get this working on the ESP32 version of ESPEASY, and thought you would like to know too.

First you need to enable SPI in the GUI as HSPI, so with pins 14/12/13.

Then I use a fix for SS:
In the CC1101.cpp, rename every SS to mySS and add the following on top of the file:
#define mySS 15
This makes the code use pin 15 as the SS(CS) pin according to the default HSPI layout.

Next, remove (or comment out) the following line:
SPI.begin();
Otherwise boot will hang due to beginning SPI twice.

Then a WDT reset will occur after a couple of received packets.
This can be solved by some changes in the _P145_Itho.ino file.

Add this to the beginning of the void PLUGIN_145_ITHOinterrupt():
detachInterrupt(Plugin_145_IRQ_pin);
To disable new interrupts while handling a previous packet.

Re-enable the interrupts again after finishing the processing of a packet by adding this to the end of the void PLUGIN_145_ITHOcheck():
attachInterrupt(Plugin_145_IRQ_pin, PLUGIN_145_ITHOinterrupt, RISING);

@supersjimmie
Copy link
Author

supersjimmie commented Oct 8, 2020

I addition, when a lot of packets come in, a WDT reset can still occur.
From what I found, you cannot use SPI.tranfer from an ISR on the ESP32..
A quick fix is to disconnect the GDO2 line as soon as you do'n really need it anymore.
(only use it to find your own remote ID, unfortunately there is no more status update from your other remotes after you disconnect GDO2.

@supersjimmie
Copy link
Author

@jodur
Copy link
Owner

jodur commented Oct 9, 2020

I just read you comments. I is already 3 years ago that i created the plugin based on your initial work , so in meantime i didn't do any maintenance on this plugin. For 3/4 months ago i switched to ESPHome and created a project for this also on github. I am aware that there are some problems with the interrupt handling. Someone mentioned that the Ticker library causes problems on the ESP8286. I already saw a solution where they set a flag in the ISR and check that flag in the PLUGIN_TEN_PER_SECOND, if true then call the code that is now in the ISR.

Call schema:
intterupt -> Start Ticker
Ticker -> Set Flag
TEN_PER_SECOND ->Check Flag -> If True Call code that now is called by Ticker and reset Flag

The Ticker is also an other interrupt and should possible also be declared as :
void PLUGIN_145_ITHOcheck() ICACHE_RAM_ATTR; for a ESP8266 because of stack issues

I remember reading somewere that ICACHE_RAM_ATTR attributes could cause problems on a ESP32.
In this way al the code that is called in a interrupt is only a set Flag operation, and all other code is called outside the ISR.
Currently i don't have any time to setup a test environment to play with it, but you could try this and let me know?

@supersjimmie
Copy link
Author

Currently working on a fix at the above mentioned letcontrlit forum.

  • Remove the ticker,
  • Set a var in the interrupt function,
  • Check (and reset) that var in the FIFTY_PER_SECOND after fetching the received packet.

When I am satisfied AND have some more spare time, I will probably put it on github.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants