1517#define RH_VERSION_MAJOR 1
1518#define RH_VERSION_MINOR 136
1521#define RH_PLATFORM_ARDUINO 1
1522#define RH_PLATFORM_MSP430 2
1523#define RH_PLATFORM_STM32 3
1524#define RH_PLATFORM_GENERIC_AVR8 4
1525#define RH_PLATFORM_UNO32 5
1526#define RH_PLATFORM_UNIX 6
1527#define RH_PLATFORM_STM32STD 7
1528#define RH_PLATFORM_STM32F4_HAL 8
1529#define RH_PLATFORM_RASPI 9
1530#define RH_PLATFORM_NRF51 10
1531#define RH_PLATFORM_ESP8266 11
1532#define RH_PLATFORM_STM32F2 12
1533#define RH_PLATFORM_CHIPKIT_CORE 13
1534#define RH_PLATFORM_ESP32 14
1535#define RH_PLATFORM_NRF52 15
1536#define RH_PLATFORM_MONGOOSE_OS 16
1537#define RH_PLATFORM_ATTINY 17
1539#define RH_PLATFORM_ATTINY_MEGA 18
1540#define RH_PLATFORM_STM32L0 19
1541#define RH_PLATFORM_RASPI_PICO 20
1546 #if (defined(MPIDE) && MPIDE>=150 && defined(ARDUINO))
1548 #define RH_PLATFORM RH_PLATFORM_CHIPKIT_CORE
1549 #elif defined(MPIDE)
1551 #define RH_PLATFORM RH_PLATFORM_UNO32
1552 #elif defined(NRF51) || defined(NRF52)
1553 #define RH_PLATFORM RH_PLATFORM_NRF51
1554 #elif defined(NRF52)
1555 #define RH_PLATFORM RH_PLATFORM_NRF52
1556 #elif defined(ESP8266)
1557 #define RH_PLATFORM RH_PLATFORM_ESP8266
1558 #elif defined(ESP32)
1559 #define RH_PLATFORM RH_PLATFORM_ESP32
1560 #elif defined(STM32L0) || defined(ARDUINO_ARCH_STM32L0)
1561 #define RH_PLATFORM RH_PLATFORM_STM32L0
1563 #define RH_PLATFORM RH_PLATFORM_MONGOOSE_OS
1564#elif defined(MEGATINYCORE) || defined(ARDUINO_attinyxy2) || defined(ARDUINO_attinyxy4) || defined(ARDUINO_attinyxy6) || defined(ARDUINO_attinyxy7)
1565 #define RH_PLATFORM RH_PLATFORM_ATTINY_MEGA
1566 #elif defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny85__) || defined(__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtinyX4__) || defined(__AVR_ATtinyX5__) || defined(__AVR_ATtiny2313__) || defined(__AVR_ATtiny4313__) || defined(__AVR_ATtinyX313__) || defined(ARDUINO_attiny)
1567 #define RH_PLATFORM RH_PLATFORM_ATTINY
1568 #elif defined(ARDUINO)
1569 #define RH_PLATFORM RH_PLATFORM_ARDUINO
1570 #elif defined(__MSP430G2452__) || defined(__MSP430G2553__)
1571 #define RH_PLATFORM RH_PLATFORM_MSP430
1572 #elif defined(MCU_STM32F103RE)
1573 #define RH_PLATFORM RH_PLATFORM_STM32
1574 #elif defined(STM32F2XX)
1575 #define RH_PLATFORM RH_PLATFORM_STM32F2
1576 #elif defined(USE_STDPERIPH_DRIVER)
1577 #define RH_PLATFORM RH_PLATFORM_STM32STD
1578 #elif defined(RASPBERRY_PI)
1579 #define RH_PLATFORM RH_PLATFORM_RASPI
1580 #elif defined(__unix__)
1581 #define RH_PLATFORM RH_PLATFORM_UNIX
1582 #elif defined(__APPLE__)
1583 #define RH_PLATFORM RH_PLATFORM_UNIX
1586 #error Platform not defined!
1592#if (RH_PLATFORM == RH_PLATFORM_ARDUINO)
1594 #if (ARDUINO >= 100)
1595 #include <Arduino.h>
1600 #define RH_HAVE_HARDWARE_SPI
1601 #define RH_HAVE_SERIAL
1602 #if defined(ARDUINO_ARCH_STM32F4)
1606 #define Serial Serial2
1607 #elif defined(ARDUINO_ARCH_RP2040)
1609 #define RH_ASK_PICO_ALARM_IRQ TIMER_IRQ_1
1610 #define RH_ASK_PICO_ALARM_NUM 1
1611 #elif defined(ARDUINO_LORA_E5_MINI)
1615#elif (RH_PLATFORM == RH_PLATFORM_ATTINY)
1616 #include <Arduino.h>
1618#elif (RH_PLATFORM == RH_PLATFORM_ATTINY_MEGA)
1620 #define RH_HAVE_HARDWARE_SPI
1621 #define RH_HAVE_SERIAL
1625 #if defined(MILLIS_USE_TIMERB0) && defined(TCB1)
1626 #define RH_ATTINY_MEGA_ASK_TIMER TCB1
1627 #define RH_ATTINY_MEGA_ASK_TIMER_VECTOR TCB1_INT_vect
1629 #define RH_ATTINY_MEGA_ASK_TIMER TCB0
1630 #define RH_ATTINY_MEGA_ASK_TIMER_VECTOR TCB0_INT_vect
1633#elif (RH_PLATFORM == RH_PLATFORM_ESP8266)
1634 #include <Arduino.h>
1636 #define RH_HAVE_HARDWARE_SPI
1637 #define RH_HAVE_SERIAL
1638 #define RH_MISSING_SPIUSINGINTERRUPT
1640#elif (RH_PLATFORM == RH_PLATFORM_ESP32)
1641 #include <Arduino.h>
1643 #define RH_HAVE_HARDWARE_SPI
1644 #define RH_HAVE_SERIAL
1645 #define RH_MISSING_SPIUSINGINTERRUPT
1660#elif (RH_PLATFORM == RH_PLATFORM_MONGOOSE_OS)
1662 #include <mgos_adc.h>
1663 #include <mgos_pwm.h>
1664 #include <MGOSCompat/HardwareSerial.h>
1665 #include <MGOSCompat/HardwareSPI.h>
1666 #include <MGOSCompat/MGOS.h>
1668 #define RH_HAVE_HARDWARE_SPI
1671 #if defined(RH_SERIAL_PORT)
1672 #if RH_SERIAL_PORT == 0
1673 #define Serial Serial0
1674 #elif RH_SERIAL_PORT == 1
1675 #define Serial Serial1
1676 #elif RH_SERIAL_PORT == 2
1677 #define Serial Serial2
1680 #warning "RH_SERIAL_PORT not defined. Therefore serial port 0 selected"
1681 #define Serial Serial0
1683 #define RH_HAVE_SERIAL
1685#elif (RH_PLATFORM == RH_PLATFORM_MSP430)
1686 #include "legacymsp430.h"
1687 #include "Energia.h"
1689 #define RH_HAVE_HARDWARE_SPI
1690 #define RH_HAVE_SERIAL
1692#elif (RH_PLATFORM == RH_PLATFORM_UNO32 || RH_PLATFORM == RH_PLATFORM_CHIPKIT_CORE)
1693 #include <WProgram.h>
1696 #define RH_HAVE_HARDWARE_SPI
1697 #define memcpy_P memcpy
1698 #define RH_HAVE_SERIAL
1700#elif (RH_PLATFORM == RH_PLATFORM_STM32)
1701 #include <STM32ArduinoCompat/wirish.h>
1704 #include <STM32ArduinoCompat/HardwareSPI.h>
1705 #define RH_HAVE_HARDWARE_SPI
1707 #define MAPLE_TIMER 1
1709 #define memcpy_P memcpy
1710 #define Serial SerialUSB
1711 #define RH_HAVE_SERIAL
1713#elif (RH_PLATFORM == RH_PLATFORM_STM32L0)
1714 #include <Arduino.h>
1717 #ifndef RH_EXCLUDE_STM32L0_INCLUDES
1719 #include <stm32l0_gpio.h>
1720 #include <stm32l0_exti.h>
1721 #include <stm32l0_rtc.h>
1723 #define RH_HAVE_HARDWARE_SPI
1724 #define RH_HAVE_SERIAL
1726#elif (RH_PLATFORM == RH_PLATFORM_STM32F2)
1727 #include <stm32f2xx.h>
1728 #include <application.h>
1730 #define RH_HAVE_SERIAL
1731 #define RH_HAVE_HARDWARE_SPI
1733#elif (RH_PLATFORM == RH_PLATFORM_STM32STD)
1734 #include <stm32f4xx.h>
1739 #include <HardwareSPI.h>
1740 #define RH_HAVE_HARDWARE_SPI
1741 #define Serial SerialUSB
1742 #define RH_HAVE_SERIAL
1744#elif (RH_PLATFORM == RH_PLATFORM_GENERIC_AVR8)
1746 #include <avr/interrupt.h>
1747 #include <util/delay.h>
1749 #include <stdbool.h>
1750 #define RH_HAVE_HARDWARE_SPI
1755#elif (RH_PLATFORM == RH_PLATFORM_STM32F4_HAL)
1756 #include <ArduinoWorkarounds.h>
1757 #include <stm32f4xx.h>
1761 #define RH_HAVE_HARDWARE_SPI
1763#elif (RH_PLATFORM == RH_PLATFORM_RASPI)
1764 #define RH_HAVE_HARDWARE_SPI
1765 #define RH_HAVE_SERIAL
1769 #if (__has_include (<pigpio.h>))
1770 #include <RHutil_pigpio/RasPi.h>
1772 #include <RHutil/RasPi.h>
1778#elif (RH_PLATFORM == RH_PLATFORM_NRF51)
1779 #define RH_HAVE_SERIAL
1781 #include <Arduino.h>
1783#elif (RH_PLATFORM == RH_PLATFORM_NRF52)
1785 #define RH_HAVE_HARDWARE_SPI
1786 #define RH_HAVE_SERIAL
1788 #include <Arduino.h>
1790#elif (RH_PLATFORM == RH_PLATFORM_UNIX)
1792 #include <RHutil/simulator.h>
1793 #define RH_HAVE_SERIAL
1794#include <netinet/in.h>
1797 #error Platform unknown!
1802#if (RH_PLATFORM == RH_PLATFORM_ARDUINO)
1803 #if defined(__arm__)
1804 #include <RHutil/atomic.h>
1806 #include <util/atomic.h>
1808 #if defined(ARDUINO_ARCH_MBED_RP2040) || defined(ARDUINO_UNOR4_MINIMA) || defined(ARDUINO_UNOR4_WIFI)
1810 #define ATOMIC_BLOCK_START {
1811 #define ATOMIC_BLOCK_END }
1814 #define ATOMIC_BLOCK_START ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
1815 #define ATOMIC_BLOCK_END }
1817#elif (RH_PLATFORM == RH_PLATFORM_CHIPKIT_CORE)
1819 #define ATOMIC_BLOCK_START unsigned int __status = disableInterrupts(); {
1820 #define ATOMIC_BLOCK_END } restoreInterrupts(__status);
1821#elif (RH_PLATFORM == RH_PLATFORM_UNO32)
1823 #include <peripheral/int.h>
1824 #define ATOMIC_BLOCK_START unsigned int __status = INTDisableInterrupts(); {
1825 #define ATOMIC_BLOCK_END } INTRestoreInterrupts(__status);
1826#elif (RH_PLATFORM == RH_PLATFORM_STM32L0)
1827 #define ATOMIC_BLOCK_START uint32_t primask = __get_PRIMASK(); __disable_irq(); {
1828 #define ATOMIC_BLOCK_END } __set_PRIMASK(primask);
1829#elif (RH_PLATFORM == RH_PLATFORM_STM32F2)
1830 #define ATOMIC_BLOCK_START { int __prev = HAL_disable_irq();
1831 #define ATOMIC_BLOCK_END HAL_enable_irq(__prev); }
1832#elif (RH_PLATFORM == RH_PLATFORM_ESP8266)
1834 #define ATOMIC_BLOCK_START { uint32_t __savedPS = xt_rsil(15);
1835 #define ATOMIC_BLOCK_END xt_wsr_ps(__savedPS);}
1836#elif (RH_PLATFORM == RH_PLATFORM_ESP32)
1845 #include "freertos/atomic.h"
1846 #define ATOMIC_BLOCK_START ATOMIC_ENTER_CRITICAL()
1847 #define ATOMIC_BLOCK_END ATOMIC_EXIT_CRITICAL()
1850 #define ATOMIC_BLOCK_START
1851 #define ATOMIC_BLOCK_END
1858#if (RH_PLATFORM == RH_PLATFORM_ARDUINO && ARDUINO >= 155) || (defined(TEENSYDUINO) && defined(__MK20DX128__))
1859 #define YIELD yield();
1860#elif (RH_PLATFORM == RH_PLATFORM_ESP8266)
1862 #define YIELD yield();
1863#elif (RH_PLATFORM == RH_PLATFORM_STM32L0)
1864 #define YIELD yield();
1865#elif (RH_PLATFORM == RH_PLATFORM_MONGOOSE_OS)
1870 void mgosYield(
void);
1872 #define YIELD mgosYield()
1873#elif (RH_PLATFORM == RH_PLATFORM_ESP32)
1875 #define YIELD yield();
1883#ifndef NOT_AN_INTERRUPT
1884 #define NOT_AN_INTERRUPT -1
1886#ifndef digitalPinToInterrupt
1887 #if (RH_PLATFORM == RH_PLATFORM_ARDUINO) && !defined(__arm__)
1889 #if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
1892 #define digitalPinToInterrupt(p) ((p) == 2 ? 0 : ((p) == 3 ? 1 : ((p) >= 18 && (p) <= 21 ? 23 - (p) : NOT_AN_INTERRUPT)))
1894 #elif defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__)
1897 #define digitalPinToInterrupt(p) ((p) == 10 ? 0 : ((p) == 11 ? 1 : ((p) == 2 ? 2 : NOT_AN_INTERRUPT)))
1899 #elif defined(__AVR_ATmega32U4__)
1902 #define digitalPinToInterrupt(p) ((p) == 0 ? 2 : ((p) == 1 ? 3 : ((p) == 2 ? 1 : ((p) == 3 ? 0 : ((p) == 7 ? 4 : NOT_AN_INTERRUPT)))))
1908 #define digitalPinToInterrupt(p) ((p) == 2 ? 0 : ((p) == 3 ? 1 : NOT_AN_INTERRUPT))
1912 #elif (RH_PLATFORM == RH_PLATFORM_UNO32) || (RH_PLATFORM == RH_PLATFORM_CHIPKIT_CORE)
1914 #define digitalPinToInterrupt(p) ((p) == 38 ? 0 : ((p) == 2 ? 1 : ((p) == 7 ? 2 : ((p) == 8 ? 3 : ((p) == 735 ? 4 : NOT_AN_INTERRUPT)))))
1916 #elif (RH_PLATFORM == RH_PLATFORM_ESP32)
1917 #define digitalPinToInterrupt(p) (((p) < 40) ? (p) : -1)
1919 #elif (RH_PLATFORM == RH_PLATFORM_ESP8266)
1920 #define digitalPinToInterrupt(p) (((p) < EXTERNAL_NUM_INTERRUPTS)? (p) : NOT_AN_INTERRUPT)
1925 #define digitalPinToInterrupt(p) (p)
1930#if (RH_PLATFORM == RH_PLATFORM_ARDUINO) && defined (__arm__) && (defined(ARDUINO_ARCH_SAMD) || defined(ARDUINO_SAM_DUE)) || defined(ARDUINO_ARCH_STM32L0)
1931 #define RH_ATTACHINTERRUPT_TAKES_PIN_NUMBER
1937#if (RH_PLATFORM != RH_PLATFORM_ESP32)
1944#if (RH_PLATFORM == RH_PLATFORM_ESP8266)
1948 #define RH_INTERRUPT_ATTR IRAM_ATTR
1950#elif (RH_PLATFORM == RH_PLATFORM_ESP32)
1951 #define RH_INTERRUPT_ATTR IRAM_ATTR
1953 #define RH_INTERRUPT_ATTR
1963#if RH_PLATFORM != RH_PLATFORM_UNIX && !defined(htons)
1966 #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
1968 #define htons(x) ( ((x)<<8) | (((x)>>8)&0xFF) )
1969 #define ntohs(x) htons(x)
1970 #define htonl(x) ( ((x)<<24 & 0xFF000000UL) | \
1971 ((x)<< 8 & 0x00FF0000UL) | \
1972 ((x)>> 8 & 0x0000FF00UL) | \
1973 ((x)>>24 & 0x000000FFUL) )
1974 #define ntohl(x) htonl(x)
1976 #elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
1978 #define htons(x) (x)
1979 #define ntohs(x) (x)
1980 #define htonl(x) (x)
1981 #define ntohl(x) (x)
1984 #error "RadioHead.h: Dont know how to define htons and friends for this processor"
1990 #include <pthread.h>
1991 #define RH_DECLARE_MUTEX(X) pthread_mutex_t X;
1992 #define RH_MUTEX_INIT(X) pthread_mutex_init(&X, NULL)
1993 #define RH_MUTEX_LOCK(X) pthread_mutex_lock(&X)
1994 #define RH_MUTEX_UNLOCK(X) pthread_mutex_unlock(&X)
1996 #define RH_DECLARE_MUTEX(X)
1997 #define RH_MUTEX_INIT(X)
1998 #define RH_MUTEX_LOCK(X)
1999 #define RH_MUTEX_UNLOCK(X)
2003#define RH_BROADCAST_ADDRESS 0xff
2006#define RH_INVALID_PIN 0xff