1559#define RH_VERSION_MAJOR 1
1560#define RH_VERSION_MINOR 143
1563#define RH_PLATFORM_ARDUINO 1
1564#define RH_PLATFORM_MSP430 2
1565#define RH_PLATFORM_STM32 3
1566#define RH_PLATFORM_GENERIC_AVR8 4
1567#define RH_PLATFORM_UNO32 5
1568#define RH_PLATFORM_UNIX 6
1569#define RH_PLATFORM_STM32STD 7
1570#define RH_PLATFORM_STM32F4_HAL 8
1571#define RH_PLATFORM_RASPI 9
1572#define RH_PLATFORM_NRF51 10
1573#define RH_PLATFORM_ESP8266 11
1574#define RH_PLATFORM_STM32F2 12
1575#define RH_PLATFORM_CHIPKIT_CORE 13
1576#define RH_PLATFORM_ESP32 14
1577#define RH_PLATFORM_NRF52 15
1578#define RH_PLATFORM_MONGOOSE_OS 16
1579#define RH_PLATFORM_ATTINY 17
1581#define RH_PLATFORM_ATTINY_MEGA 18
1582#define RH_PLATFORM_STM32L0 19
1583#define RH_PLATFORM_RASPI_PICO 20
1588 #if (defined(MPIDE) && MPIDE>=150 && defined(ARDUINO))
1590 #define RH_PLATFORM RH_PLATFORM_CHIPKIT_CORE
1591 #elif defined(MPIDE)
1593 #define RH_PLATFORM RH_PLATFORM_UNO32
1594 #elif defined(NRF51) || defined(NRF52)
1595 #define RH_PLATFORM RH_PLATFORM_NRF51
1596 #elif defined(NRF52)
1597 #define RH_PLATFORM RH_PLATFORM_NRF52
1598 #elif defined(ESP8266)
1599 #define RH_PLATFORM RH_PLATFORM_ESP8266
1600 #elif defined(ESP32)
1601 #define RH_PLATFORM RH_PLATFORM_ESP32
1602 #elif defined(STM32L0) || defined(ARDUINO_ARCH_STM32L0)
1603 #define RH_PLATFORM RH_PLATFORM_STM32L0
1605 #define RH_PLATFORM RH_PLATFORM_MONGOOSE_OS
1606#elif defined(MEGATINYCORE) || defined(ARDUINO_attinyxy2) || defined(ARDUINO_attinyxy4) || defined(ARDUINO_attinyxy6) || defined(ARDUINO_attinyxy7)
1607 #define RH_PLATFORM RH_PLATFORM_ATTINY_MEGA
1608 #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)
1609 #define RH_PLATFORM RH_PLATFORM_ATTINY
1610 #elif defined(ARDUINO)
1611 #define RH_PLATFORM RH_PLATFORM_ARDUINO
1612 #elif defined(__MSP430G2452__) || defined(__MSP430G2553__)
1613 #define RH_PLATFORM RH_PLATFORM_MSP430
1614 #elif defined(MCU_STM32F103RE)
1615 #define RH_PLATFORM RH_PLATFORM_STM32
1616 #elif defined(STM32F2XX)
1617 #define RH_PLATFORM RH_PLATFORM_STM32F2
1618 #elif defined(USE_STDPERIPH_DRIVER)
1619 #define RH_PLATFORM RH_PLATFORM_STM32STD
1620 #elif defined(RASPBERRY_PI)
1621 #define RH_PLATFORM RH_PLATFORM_RASPI
1622 #elif defined(__unix__)
1623 #define RH_PLATFORM RH_PLATFORM_UNIX
1624 #elif defined(__APPLE__)
1625 #define RH_PLATFORM RH_PLATFORM_UNIX
1628 #error Platform not defined!
1634#if (RH_PLATFORM == RH_PLATFORM_ARDUINO)
1635 #if (ARDUINO >= 100)
1636 #include <Arduino.h>
1641 #define RH_HAVE_HARDWARE_SPI
1642 #define RH_HAVE_SERIAL
1644 #if defined(ARDUINO_ARCH_STM32F4)
1648 #define Serial Serial2
1650 #elif defined(ARDUINO_ARCH_RP2040)
1651 #if defined(PICO_RP2350)
1653 #define RH_ASK_PICO_ALARM_IRQ TIMER0_IRQ_1
1656 #define RH_ASK_PICO_ALARM_IRQ TIMER_IRQ_1
1658 #define RH_ASK_PICO_ALARM_NUM 1
1660 #elif defined(ARDUINO_LORA_E5_MINI)
1664#elif defined(CubeCell_Board) || defined(CubeCell_Board_V2) || defined(CubeCell_Capsule) || defined(CubeCell_Module) || defined(CubeCell_Module_V2) || defined(CubeCell_BoardPlus) || defined(CubeCell_GPS) || defined(CubeCell_ModulePlus) || defined(CubeCell_HalfAA) || defined(CubeCell_BoardP)
1665 #define RH_CUBE_CELL_BOARD
1666 #define RH_MISSING_SPIUSINGINTERRUPT
1667 #include <board-config.h>
1671#elif (RH_PLATFORM == RH_PLATFORM_ATTINY)
1672 #include <Arduino.h>
1674#elif (RH_PLATFORM == RH_PLATFORM_ATTINY_MEGA)
1676 #define RH_HAVE_HARDWARE_SPI
1677 #define RH_HAVE_SERIAL
1681 #if defined(MILLIS_USE_TIMERB0) && defined(TCB1)
1682 #define RH_ATTINY_MEGA_ASK_TIMER TCB1
1683 #define RH_ATTINY_MEGA_ASK_TIMER_VECTOR TCB1_INT_vect
1685 #define RH_ATTINY_MEGA_ASK_TIMER TCB0
1686 #define RH_ATTINY_MEGA_ASK_TIMER_VECTOR TCB0_INT_vect
1689#elif (RH_PLATFORM == RH_PLATFORM_ESP8266)
1690 #include <Arduino.h>
1692 #define RH_HAVE_HARDWARE_SPI
1693 #define RH_HAVE_SERIAL
1694 #define RH_MISSING_SPIUSINGINTERRUPT
1696#elif (RH_PLATFORM == RH_PLATFORM_ESP32)
1697 #include <Arduino.h>
1699 #define RH_HAVE_HARDWARE_SPI
1700 #define RH_HAVE_SERIAL
1701 #define RH_MISSING_SPIUSINGINTERRUPT
1716#elif (RH_PLATFORM == RH_PLATFORM_MONGOOSE_OS)
1718 #include <mgos_adc.h>
1719 #include <mgos_pwm.h>
1720 #include <MGOSCompat/HardwareSerial.h>
1721 #include <MGOSCompat/HardwareSPI.h>
1722 #include <MGOSCompat/MGOS.h>
1724 #define RH_HAVE_HARDWARE_SPI
1727 #if defined(RH_SERIAL_PORT)
1728 #if RH_SERIAL_PORT == 0
1729 #define Serial Serial0
1730 #elif RH_SERIAL_PORT == 1
1731 #define Serial Serial1
1732 #elif RH_SERIAL_PORT == 2
1733 #define Serial Serial2
1736 #warning "RH_SERIAL_PORT not defined. Therefore serial port 0 selected"
1737 #define Serial Serial0
1739 #define RH_HAVE_SERIAL
1741#elif (RH_PLATFORM == RH_PLATFORM_MSP430)
1742 #include "legacymsp430.h"
1743 #include "Energia.h"
1745 #define RH_HAVE_HARDWARE_SPI
1746 #define RH_HAVE_SERIAL
1748#elif (RH_PLATFORM == RH_PLATFORM_UNO32 || RH_PLATFORM == RH_PLATFORM_CHIPKIT_CORE)
1749 #include <WProgram.h>
1752 #define RH_HAVE_HARDWARE_SPI
1753 #define memcpy_P memcpy
1754 #define RH_HAVE_SERIAL
1756#elif (RH_PLATFORM == RH_PLATFORM_STM32)
1757 #include <STM32ArduinoCompat/wirish.h>
1760 #include <STM32ArduinoCompat/HardwareSPI.h>
1761 #define RH_HAVE_HARDWARE_SPI
1763 #define MAPLE_TIMER 1
1765 #define memcpy_P memcpy
1766 #define Serial SerialUSB
1767 #define RH_HAVE_SERIAL
1769#elif (RH_PLATFORM == RH_PLATFORM_STM32L0)
1770 #include <Arduino.h>
1773 #ifndef RH_EXCLUDE_STM32L0_INCLUDES
1775 #include <stm32l0_gpio.h>
1776 #include <stm32l0_exti.h>
1777 #include <stm32l0_rtc.h>
1779 #define RH_HAVE_HARDWARE_SPI
1780 #define RH_HAVE_SERIAL
1782#elif (RH_PLATFORM == RH_PLATFORM_STM32F2)
1783 #include <stm32f2xx.h>
1784 #include <application.h>
1786 #define RH_HAVE_SERIAL
1787 #define RH_HAVE_HARDWARE_SPI
1789#elif (RH_PLATFORM == RH_PLATFORM_STM32STD)
1790 #include <stm32f4xx.h>
1795 #include <HardwareSPI.h>
1796 #define RH_HAVE_HARDWARE_SPI
1797 #define Serial SerialUSB
1798 #define RH_HAVE_SERIAL
1800#elif (RH_PLATFORM == RH_PLATFORM_GENERIC_AVR8)
1802 #include <avr/interrupt.h>
1803 #include <util/delay.h>
1805 #include <stdbool.h>
1806 #define RH_HAVE_HARDWARE_SPI
1811#elif (RH_PLATFORM == RH_PLATFORM_STM32F4_HAL)
1812 #include <ArduinoWorkarounds.h>
1813 #include <stm32f4xx.h>
1817 #define RH_HAVE_HARDWARE_SPI
1819#elif (RH_PLATFORM == RH_PLATFORM_RASPI)
1820 #define RH_HAVE_HARDWARE_SPI
1821 #define RH_HAVE_SERIAL
1825 #if (__has_include (<pigpio.h>))
1826 #include <RHutil_pigpio/RasPi.h>
1828 #include <RHutil/RasPi.h>
1834#elif (RH_PLATFORM == RH_PLATFORM_NRF51)
1835 #define RH_HAVE_SERIAL
1837 #include <Arduino.h>
1839#elif (RH_PLATFORM == RH_PLATFORM_NRF52)
1841 #define RH_HAVE_HARDWARE_SPI
1842 #define RH_HAVE_SERIAL
1843 #define RH_HAVE_SPI_ATTACH_INTERRUPT
1845 #include <Arduino.h>
1847#elif (RH_PLATFORM == RH_PLATFORM_UNIX)
1849 #include <RHutil/simulator.h>
1850 #define RH_HAVE_SERIAL
1851#include <netinet/in.h>
1854 #error Platform unknown!
1859#if (RH_PLATFORM == RH_PLATFORM_ARDUINO)
1860 #if defined(RH_CUBE_CELL_BOARD)
1862 #elif defined(__arm__)
1863 #include <RHutil/atomic.h>
1865 #include <util/atomic.h>
1868 #if defined(ARDUINO_ARCH_MBED_RP2040) || defined(ARDUINO_UNOR4_MINIMA) || defined(ARDUINO_UNOR4_WIFI) || defined(RH_CUBE_CELL_BOARD)
1870 #define ATOMIC_BLOCK_START {
1871 #define ATOMIC_BLOCK_END }
1874 #define ATOMIC_BLOCK_START ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
1875 #define ATOMIC_BLOCK_END }
1877#elif (RH_PLATFORM == RH_PLATFORM_CHIPKIT_CORE)
1879 #define ATOMIC_BLOCK_START unsigned int __status = disableInterrupts(); {
1880 #define ATOMIC_BLOCK_END } restoreInterrupts(__status);
1881#elif (RH_PLATFORM == RH_PLATFORM_UNO32)
1883 #include <peripheral/int.h>
1884 #define ATOMIC_BLOCK_START unsigned int __status = INTDisableInterrupts(); {
1885 #define ATOMIC_BLOCK_END } INTRestoreInterrupts(__status);
1886#elif (RH_PLATFORM == RH_PLATFORM_STM32L0)
1887 #define ATOMIC_BLOCK_START uint32_t primask = __get_PRIMASK(); __disable_irq(); {
1888 #define ATOMIC_BLOCK_END } __set_PRIMASK(primask);
1889#elif (RH_PLATFORM == RH_PLATFORM_STM32F2)
1890 #define ATOMIC_BLOCK_START { int __prev = HAL_disable_irq();
1891 #define ATOMIC_BLOCK_END HAL_enable_irq(__prev); }
1892#elif (RH_PLATFORM == RH_PLATFORM_ESP8266)
1894 #define ATOMIC_BLOCK_START { uint32_t __savedPS = xt_rsil(15);
1895 #define ATOMIC_BLOCK_END xt_wsr_ps(__savedPS);}
1896#elif (RH_PLATFORM == RH_PLATFORM_ESP32)
1905 #include "freertos/atomic.h"
1906 #define ATOMIC_BLOCK_START ATOMIC_ENTER_CRITICAL()
1907 #define ATOMIC_BLOCK_END ATOMIC_EXIT_CRITICAL()
1910 #define ATOMIC_BLOCK_START
1911 #define ATOMIC_BLOCK_END
1918#if (RH_PLATFORM == RH_PLATFORM_ARDUINO) && defined(RH_CUBE_CELL_BOARD)
1920#elif (RH_PLATFORM == RH_PLATFORM_ARDUINO && ARDUINO >= 155) || (defined(TEENSYDUINO) && defined(__MK20DX128__))
1921 #define YIELD yield();
1922#elif (RH_PLATFORM == RH_PLATFORM_ESP8266)
1924 #define YIELD yield();
1925#elif (RH_PLATFORM == RH_PLATFORM_STM32L0)
1926 #define YIELD yield();
1927#elif (RH_PLATFORM == RH_PLATFORM_MONGOOSE_OS)
1932 void mgosYield(
void);
1934 #define YIELD mgosYield()
1935#elif (RH_PLATFORM == RH_PLATFORM_ESP32)
1937 #define YIELD yield();
1945#ifndef NOT_AN_INTERRUPT
1946 #define NOT_AN_INTERRUPT -1
1948#ifndef digitalPinToInterrupt
1949 #if (RH_PLATFORM == RH_PLATFORM_ARDUINO) && !defined(__arm__)
1951 #if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
1954 #define digitalPinToInterrupt(p) ((p) == 2 ? 0 : ((p) == 3 ? 1 : ((p) >= 18 && (p) <= 21 ? 23 - (p) : NOT_AN_INTERRUPT)))
1956 #elif defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__)
1959 #define digitalPinToInterrupt(p) ((p) == 10 ? 0 : ((p) == 11 ? 1 : ((p) == 2 ? 2 : NOT_AN_INTERRUPT)))
1961 #elif defined(__AVR_ATmega32U4__)
1964 #define digitalPinToInterrupt(p) ((p) == 0 ? 2 : ((p) == 1 ? 3 : ((p) == 2 ? 1 : ((p) == 3 ? 0 : ((p) == 7 ? 4 : NOT_AN_INTERRUPT)))))
1970 #define digitalPinToInterrupt(p) ((p) == 2 ? 0 : ((p) == 3 ? 1 : NOT_AN_INTERRUPT))
1974 #elif (RH_PLATFORM == RH_PLATFORM_UNO32) || (RH_PLATFORM == RH_PLATFORM_CHIPKIT_CORE)
1976 #define digitalPinToInterrupt(p) ((p) == 38 ? 0 : ((p) == 2 ? 1 : ((p) == 7 ? 2 : ((p) == 8 ? 3 : ((p) == 735 ? 4 : NOT_AN_INTERRUPT)))))
1978 #elif (RH_PLATFORM == RH_PLATFORM_ESP32)
1979 #define digitalPinToInterrupt(p) (((p) < 40) ? (p) : -1)
1981 #elif (RH_PLATFORM == RH_PLATFORM_ESP8266)
1982 #define digitalPinToInterrupt(p) (((p) < EXTERNAL_NUM_INTERRUPTS)? (p) : NOT_AN_INTERRUPT)
1987 #define digitalPinToInterrupt(p) (p)
1992#if (RH_PLATFORM == RH_PLATFORM_ARDUINO) && defined (__arm__) && (defined(ARDUINO_ARCH_SAMD) || defined(ARDUINO_SAM_DUE)) || defined(ARDUINO_ARCH_STM32L0)
1993 #define RH_ATTACHINTERRUPT_TAKES_PIN_NUMBER
1999#if (RH_PLATFORM != RH_PLATFORM_ESP32)
2006#if (RH_PLATFORM == RH_PLATFORM_ESP8266)
2010 #define RH_INTERRUPT_ATTR IRAM_ATTR
2012#elif (RH_PLATFORM == RH_PLATFORM_ESP32)
2013 #define RH_INTERRUPT_ATTR IRAM_ATTR
2015 #define RH_INTERRUPT_ATTR
2025#if RH_PLATFORM != RH_PLATFORM_UNIX && !defined(htons)
2028 #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
2030 #define htons(x) ( ((x)<<8) | (((x)>>8)&0xFF) )
2031 #define ntohs(x) htons(x)
2032 #define htonl(x) ( ((x)<<24 & 0xFF000000UL) | \
2033 ((x)<< 8 & 0x00FF0000UL) | \
2034 ((x)>> 8 & 0x0000FF00UL) | \
2035 ((x)>>24 & 0x000000FFUL) )
2036 #define ntohl(x) htonl(x)
2038 #elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
2040 #define htons(x) (x)
2041 #define ntohs(x) (x)
2042 #define htonl(x) (x)
2043 #define ntohl(x) (x)
2046 #error "RadioHead.h: Dont know how to define htons and friends for this processor"
2052 #include <pthread.h>
2053 #define RH_DECLARE_MUTEX(X) pthread_mutex_t X;
2054 #define RH_MUTEX_INIT(X) pthread_mutex_init(&X, NULL)
2055 #define RH_MUTEX_LOCK(X) pthread_mutex_lock(&X)
2056 #define RH_MUTEX_UNLOCK(X) pthread_mutex_unlock(&X)
2058 #define RH_DECLARE_MUTEX(X)
2059 #define RH_MUTEX_INIT(X)
2060 #define RH_MUTEX_LOCK(X)
2061 #define RH_MUTEX_UNLOCK(X)
2065#define RH_BROADCAST_ADDRESS 0xff
2068#define RH_INVALID_PIN 0xff