ESPEASY_Plugin_ITHO icon indicating copy to clipboard operation
ESPEASY_Plugin_ITHO copied to clipboard

Using with ESP32

Open supersjimmie opened this issue 5 years ago • 4 comments

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 avatar Oct 08 '20 16:10 supersjimmie

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 avatar Oct 08 '20 16:10 supersjimmie

https://www.letscontrolit.com/forum/viewtopic.php?f=6&t=8006

supersjimmie avatar Oct 09 '20 13:10 supersjimmie

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?

jodur avatar Oct 09 '20 14:10 jodur

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.

supersjimmie avatar Oct 13 '20 08:10 supersjimmie