File tree 2 files changed +22
-6
lines changed
2 files changed +22
-6
lines changed Original file line number Diff line number Diff line change @@ -204,7 +204,24 @@ void setup(void);
204
204
void loop (void );
205
205
206
206
void yield (void );
207
- void optimistic_yield (uint32_t interval_us);
207
+
208
+ #ifndef F_CPU
209
+ // single function needed from SDK user_interface.h
210
+ extern " C" uint8 system_get_cpu_freq (void );
211
+ #endif
212
+
213
+ void __optimistic_yield (uint32_t intvl_cycles);
214
+
215
+ void inline optimistic_yield (uint32_t interval_us) __attribute__((always_inline));
216
+ void inline optimistic_yield (uint32_t interval_us) {
217
+ __optimistic_yield (interval_us *
218
+ #if defined(F_CPU)
219
+ clockCyclesPerMicrosecond ()
220
+ #else
221
+ getCpuFreqMHz ()
222
+ #endif
223
+ );
224
+ }
208
225
209
226
#define _PORT_GPIO16 1
210
227
#define digitalPinToPort (pin ) (((pin)==16 )?(_PORT_GPIO16):(0 ))
Original file line number Diff line number Diff line change @@ -57,7 +57,7 @@ cont_t* g_pcont __attribute__((section(".noinit")));
57
57
/* Event queue used by the main (arduino) task */
58
58
static os_event_t s_loop_queue[LOOP_QUEUE_SIZE];
59
59
60
- /* Used to implement optimistic_yield */
60
+ /* Used to implement __optimistic_yield */
61
61
static uint32_t s_cycles_since_yield_start;
62
62
63
63
/* For ets_intr_lock_nest / ets_intr_unlock_nest
@@ -125,10 +125,9 @@ extern "C" void __yield() {
125
125
126
126
extern " C" void yield (void ) __attribute__ ((weak, alias(" __yield" )));
127
127
128
- extern " C" void optimistic_yield (uint32_t interval_us) {
129
- const uint32_t interval_cycles = interval_us * ESP.getCpuFreqMHz ();
130
- if (can_yield () &&
131
- (ESP.getCycleCount () - s_cycles_since_yield_start) > interval_cycles)
128
+ extern " C" void __optimistic_yield (uint32_t intvl_cycles) {
129
+ if ((ESP.getCycleCount () - s_cycles_since_yield_start) > intvl_cycles &&
130
+ can_yield ())
132
131
{
133
132
yield ();
134
133
}
You can’t perform that action at this time.
0 commit comments