Skip to content

Commit 132c700

Browse files
author
dave
committed
Fix for ESP32 IDF V5 and above
1 parent b81ba70 commit 132c700

3 files changed

Lines changed: 9 additions & 2 deletions

File tree

library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"maintainer": true
1414
}
1515
],
16-
"version": "1.2.4",
16+
"version": "1.2.5",
1717
"license": "Apache-2.0",
1818
"frameworks": "arduino, mbed",
1919
"platforms": "*",

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55

66
name=SimpleCollections
7-
version=1.2.4
7+
version=1.2.5
88
maintainer=https://www.thecoderscorner.com
99
author=davetcc
1010
category=Other

src/SCThreadingSupport.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,19 @@ typedef volatile uint32_t position_t;
8181
typedef volatile uint32_t* position_ptr_t;
8282
typedef volatile uint32_t position_t;
8383
#define atomicInitialisationSupport()
84+
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0)
8485
inline bool casAtomic(position_ptr_t ptr, position_t expected, position_t newVal) {
8586
uint32_t exp32 = expected;
8687
uint32_t new32 = newVal;
8788
uxPortCompareSet(ptr, exp32, &new32);
8889
return new32 == expected;
8990
}
91+
#else
92+
inline bool casAtomic(position_ptr_t ptr, position_t expected, position_t newVal) {
93+
// function added in ESP-IDF v5.0
94+
return esp_cpu_compare_and_set(ptr, expected, newVal);
95+
}
96+
#endif // ESP_IDF_VERSION < 5
9097
inline uint16_t readAtomic(position_ptr_t ptr) { return *(ptr); }
9198
#else
9299
#include <Arduino.h>

0 commit comments

Comments
 (0)