|
15 | 15 | #endif |
16 | 16 | #endif |
17 | 17 |
|
18 | | -#if defined(ARDUINO_ARCH_AVR) |
19 | | - #include <util/atomic.h> |
20 | | - #define RB_ATOMIC_START ATOMIC_BLOCK(ATOMIC_RESTORESTATE) { |
21 | | - #define RB_ATOMIC_END } |
22 | 18 |
|
| 19 | +#ifdef ARDUINO |
23 | 20 |
|
24 | | -#elif defined(ARDUINO_ARCH_ESP8266) |
25 | | - #ifndef __STRINGIFY |
26 | | - #define __STRINGIFY(a) #a |
27 | | - #endif |
| 21 | + #if defined(ARDUINO_ARCH_AVR) |
| 22 | + #include <util/atomic.h> |
| 23 | + #define RB_ATOMIC_START ATOMIC_BLOCK(ATOMIC_RESTORESTATE) { |
| 24 | + #define RB_ATOMIC_END } |
28 | 25 |
|
29 | | - #ifndef xt_rsil |
30 | | - #define xt_rsil(level) (__extension__({uint32_t state; __asm__ __volatile__("rsil %0," __STRINGIFY(level) : "=a" (state)); state;})) |
31 | | - #endif |
32 | 26 |
|
33 | | - #ifndef xt_wsr_ps |
34 | | - #define xt_wsr_ps(state) __asm__ __volatile__("wsr %0,ps; isync" :: "a" (state) : "memory") |
| 27 | + #elif defined(ARDUINO_ARCH_ESP8266) |
| 28 | + #ifndef __STRINGIFY |
| 29 | + #define __STRINGIFY(a) #a |
| 30 | + #endif |
| 31 | + |
| 32 | + #ifndef xt_rsil |
| 33 | + #define xt_rsil(level) (__extension__({uint32_t state; __asm__ __volatile__("rsil %0," __STRINGIFY(level) : "=a" (state)); state;})) |
| 34 | + #endif |
| 35 | + |
| 36 | + #ifndef xt_wsr_ps |
| 37 | + #define xt_wsr_ps(state) __asm__ __volatile__("wsr %0,ps; isync" :: "a" (state) : "memory") |
| 38 | + #endif |
| 39 | + |
| 40 | + #define RB_ATOMIC_START do { uint32_t _savedIS = xt_rsil(15) ; |
| 41 | + #define RB_ATOMIC_END xt_wsr_ps(_savedIS) ;} while(0); |
| 42 | + |
| 43 | + #else |
| 44 | + #define RB_ATOMIC_START { |
| 45 | + #define RB_ATOMIC_END } |
| 46 | + #warning “This library only fully supports AVR and ESP8266 Boards.” |
| 47 | + #warning "Operations on the buffer in ISRs are not safe!" |
35 | 48 | #endif |
36 | 49 |
|
37 | | - #define RB_ATOMIC_START do { uint32_t _savedIS = xt_rsil(15) ; |
38 | | - #define RB_ATOMIC_END xt_wsr_ps(_savedIS) ;} while(0); |
39 | 50 | #else |
40 | | - #error “This library only supports AVR and ESP8266 Boards.” |
| 51 | + #define RB_ATOMIC_START { |
| 52 | + #define RB_ATOMIC_END } |
| 53 | + #warning "Operations on the buffer in ISRs are not safe!" |
| 54 | + #warning "Impliment RB_ATOMIC_START and RB_ATOMIC_END macros for safe ISR operation!" |
41 | 55 | #endif |
42 | 56 |
|
43 | 57 |
|
| 58 | + |
44 | 59 | typedef struct RingBuf RingBuf; |
45 | 60 |
|
46 | 61 | typedef struct RingBuf |
|
0 commit comments