@@ -144,7 +144,11 @@ namespace _IRrecv { // Namespace extension
144
144
#if defined(ESP32)
145
145
portMUX_TYPE mux = portMUX_INITIALIZER_UNLOCKED;
146
146
#endif // ESP32
147
+ #if __cplusplus >= 202002L
148
+ atomic<irparams_t > params;
149
+ #else
147
150
volatile irparams_t params;
151
+ #endif
148
152
irparams_t *params_save; // A copy of the interrupt state while decoding.
149
153
} // namespace _IRrecv
150
154
@@ -437,7 +441,13 @@ void IRrecv::resume(void) {
437
441
// / i.e. In kStopState.
438
442
// / @param[in] src Pointer to an irparams_t structure to copy from.
439
443
// / @param[out] dst Pointer to an irparams_t structure to copy to.
440
- void IRrecv::copyIrParams (volatile irparams_t *src, irparams_t *dst) {
444
+ void IRrecv::copyIrParams (
445
+ #if __cplusplus >= 202002L
446
+ atomic<irparams_t > *src
447
+ #else
448
+ volatile irparams_t *src
449
+ #endif
450
+ , irparams_t *dst) {
441
451
// Typecast src and dst addresses to (char *)
442
452
char *csrc = (char *)src; // NOLINT(readability/casting)
443
453
char *cdst = (char *)dst; // NOLINT(readability/casting)
@@ -1449,7 +1459,12 @@ bool IRrecv::decodeHash(decode_results *results) {
1449
1459
// / @return A match_result_t structure containing the success (or not), the
1450
1460
// / data value, and how many buffer entries were used.
1451
1461
match_result_t IRrecv::matchData (
1452
- volatile uint16_t *data_ptr, const uint16_t nbits, const uint16_t onemark,
1462
+ #if __cplusplus >= 202002L
1463
+ atomic<uint16_t > *data_ptr
1464
+ #else
1465
+ volatile uint16_t *data_ptr
1466
+ #endif
1467
+ , const uint16_t nbits, const uint16_t onemark,
1453
1468
const uint32_t onespace, const uint16_t zeromark, const uint32_t zerospace,
1454
1469
const uint8_t tolerance, const int16_t excess, const bool MSBfirst,
1455
1470
const bool expectlastspace) {
@@ -1509,7 +1524,13 @@ match_result_t IRrecv::matchData(
1509
1524
// / true is Most Significant Bit First Order, false is Least Significant First
1510
1525
// / @param[in] expectlastspace Do we expect a space at the end of the message?
1511
1526
// / @return If successful, how many buffer entries were used. Otherwise 0.
1512
- uint16_t IRrecv::matchBytes (volatile uint16_t *data_ptr, uint8_t *result_ptr,
1527
+ uint16_t IRrecv::matchBytes (
1528
+ #if __cplusplus >= 202002L
1529
+ atomic<uint16_t > *data_ptr
1530
+ #else
1531
+ volatile uint16_t *data_ptr
1532
+ #endif
1533
+ , uint8_t *result_ptr,
1513
1534
const uint16_t remaining, const uint16_t nbytes,
1514
1535
const uint16_t onemark, const uint32_t onespace,
1515
1536
const uint16_t zeromark, const uint32_t zerospace,
@@ -1561,7 +1582,12 @@ uint16_t IRrecv::matchBytes(volatile uint16_t *data_ptr, uint8_t *result_ptr,
1561
1582
// / @param[in] MSBfirst Bit order to save the data in. (Def: true)
1562
1583
// / true is Most Significant Bit First Order, false is Least Significant First
1563
1584
// / @return If successful, how many buffer entries were used. Otherwise 0.
1564
- uint16_t IRrecv::_matchGeneric (volatile uint16_t *data_ptr,
1585
+ uint16_t IRrecv::_matchGeneric (
1586
+ #if __cplusplus >= 202002L
1587
+ atomic<uint16_t > *data_ptr,
1588
+ #else
1589
+ volatile uint16_t *data_ptr,
1590
+ #endif
1565
1591
uint64_t *result_bits_ptr,
1566
1592
uint8_t *result_bytes_ptr,
1567
1593
const bool use_bits,
@@ -1663,7 +1689,12 @@ uint16_t IRrecv::_matchGeneric(volatile uint16_t *data_ptr,
1663
1689
// / @param[in] MSBfirst Bit order to save the data in. (Def: true)
1664
1690
// / true is Most Significant Bit First Order, false is Least Significant First
1665
1691
// / @return If successful, how many buffer entries were used. Otherwise 0.
1666
- uint16_t IRrecv::matchGeneric (volatile uint16_t *data_ptr,
1692
+ uint16_t IRrecv::matchGeneric (
1693
+ #if __cplusplus >= 202002L
1694
+ atomic<uint16_t > *data_ptr,
1695
+ #else
1696
+ volatile uint16_t *data_ptr,
1697
+ #endif
1667
1698
uint64_t *result_ptr,
1668
1699
const uint16_t remaining,
1669
1700
const uint16_t nbits,
@@ -1710,7 +1741,12 @@ uint16_t IRrecv::matchGeneric(volatile uint16_t *data_ptr,
1710
1741
// / @param[in] MSBfirst Bit order to save the data in. (Def: true)
1711
1742
// / true is Most Significant Bit First Order, false is Least Significant First
1712
1743
// / @return If successful, how many buffer entries were used. Otherwise 0.
1713
- uint16_t IRrecv::matchGeneric (volatile uint16_t *data_ptr,
1744
+ uint16_t IRrecv::matchGeneric (
1745
+ #if __cplusplus >= 202002L
1746
+ atomic<uint16_t > *data_ptr,
1747
+ #else
1748
+ volatile uint16_t *data_ptr,
1749
+ #endif
1714
1750
uint8_t *result_ptr,
1715
1751
const uint16_t remaining,
1716
1752
const uint16_t nbits,
@@ -1757,7 +1793,12 @@ uint16_t IRrecv::matchGeneric(volatile uint16_t *data_ptr,
1757
1793
// / @return If successful, how many buffer entries were used. Otherwise 0.
1758
1794
// / @note Parameters one + zero add up to the total time for a bit.
1759
1795
// / e.g. mark(one) + space(zero) is a `1`, mark(zero) + space(one) is a `0`.
1760
- uint16_t IRrecv::matchGenericConstBitTime (volatile uint16_t *data_ptr,
1796
+ uint16_t IRrecv::matchGenericConstBitTime (
1797
+ #if __cplusplus >= 202002L
1798
+ atomic<uint16_t > *data_ptr,
1799
+ #else
1800
+ volatile uint16_t *data_ptr,
1801
+ #endif
1761
1802
uint64_t *result_ptr,
1762
1803
const uint16_t remaining,
1763
1804
const uint16_t nbits,
@@ -1844,7 +1885,12 @@ uint16_t IRrecv::matchGenericConstBitTime(volatile uint16_t *data_ptr,
1844
1885
// / @return If successful, how many buffer entries were used. Otherwise 0.
1845
1886
// / @see https://en.wikipedia.org/wiki/Manchester_code
1846
1887
// / @see http://ww1.microchip.com/downloads/en/AppNotes/Atmel-9164-Manchester-Coding-Basics_Application-Note.pdf
1847
- uint16_t IRrecv::matchManchester (volatile const uint16_t *data_ptr,
1888
+ uint16_t IRrecv::matchManchester (
1889
+ #if __cplusplus >= 202002L
1890
+ atomic<const uint16_t > *data_ptr,
1891
+ #else
1892
+ volatile const uint16_t *data_ptr,
1893
+ #endif
1848
1894
uint64_t *result_ptr,
1849
1895
const uint16_t remaining,
1850
1896
const uint16_t nbits,
@@ -1951,7 +1997,12 @@ uint16_t IRrecv::matchManchester(volatile const uint16_t *data_ptr,
1951
1997
// / @see https://en.wikipedia.org/wiki/Manchester_code
1952
1998
// / @see http://ww1.microchip.com/downloads/en/AppNotes/Atmel-9164-Manchester-Coding-Basics_Application-Note.pdf
1953
1999
// / @todo Clean up and optimise this. It is just "get it working code" atm.
1954
- uint16_t IRrecv::matchManchesterData (volatile const uint16_t *data_ptr,
2000
+ uint16_t IRrecv::matchManchesterData (
2001
+ #if __cplusplus >= 202002L
2002
+ atomic<const uint16_t > *data_ptr,
2003
+ #else
2004
+ volatile const uint16_t *data_ptr,
2005
+ #endif
1955
2006
uint64_t *result_ptr,
1956
2007
const uint16_t remaining,
1957
2008
const uint16_t nbits,
@@ -2072,7 +2123,12 @@ uint16_t IRrecv::matchManchesterData(volatile const uint16_t *data_ptr,
2072
2123
2073
2124
#if UNIT_TEST
2074
2125
// / Unit test helper to get access to the params structure.
2075
- volatile irparams_t *IRrecv::_getParamsPtr (void ) {
2126
+ #if __cplusplus >= 202002L
2127
+ atomic<irparams_t >
2128
+ #else
2129
+ volatile irparams_t
2130
+ #endif
2131
+ *IRrecv::_getParamsPtr (void ) {
2076
2132
return ¶ms;
2077
2133
}
2078
2134
#endif // UNIT_TEST
0 commit comments