adafruit / RadioHead

A github'ified version of http://www.airspayce.com/mikem/arduino/RadioHead/
Other
186 stars 115 forks source link

Restored ESP compatibility #33

Closed dafes closed 5 years ago

dafes commented 5 years ago
ladyada commented 5 years ago

hi can you try/test this on non-ESP as well so we know it didnt break something with AVR/ARM

dafes commented 5 years ago

hi can you try/test this on non-ESP as well so we know it didnt break something with AVR/ARM

hmm you are right... looks like this now breaks the avr stuff:

error: 'ICACHE_RAM_ATTR' does not name a type

 ICACHE_RAM_ATTR void RH_CC110::isr2()

 ^

exit status 1
Error compiling for board Arduino/Genuino Uno.

I will think about an fix for this and update the PR

dafes commented 5 years ago

Added an verify for ESP8266 Buildflag

gojimmypi commented 5 years ago

perhaps something like this:

#if (RH_PLATFORM == RH_PLATFORM_ESP8266)
    // interrupt handler and related code must be in RAM on ESP8266,
    // according to issue #46.
    #define INTERRUPT_ATTR ICACHE_RAM_ATTR
#else
    #define INTERRUPT_ATTR
#endif

and use it like this:

// Read the RX data input pin, taking into account platform type and inversion.
bool INTERRUPT_ATTR RH_ASK::readRx()
{
    bool value;
#if (RH_PLATFORM == RH_PLATFORM_GENERIC_AVR8)
    value = ((RH_ASK_RX_PORT & (1<<RH_ASK_RX_PIN)) ? 1 : 0);
#else
    value = digitalRead(_rxPin);
#endif
    return value ^ _rxInverted;
}
dafes commented 5 years ago

Updated the PR to reflect the desired changes. It compiles under Arduino and works with my ESP8266