mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-21 10:26:06 +03:00
Allow constexpr evalution to occur. optimistic_yield is always called with a literal parameter value.
This commit is contained in:
parent
3d7423bdde
commit
3767791fbc
@ -204,7 +204,24 @@ void setup(void);
|
|||||||
void loop(void);
|
void loop(void);
|
||||||
|
|
||||||
void yield(void);
|
void yield(void);
|
||||||
void optimistic_yield(uint32_t interval_us);
|
|
||||||
|
#ifndef F_CPU
|
||||||
|
// single function needed from SDK user_interface.h
|
||||||
|
extern "C" uint8 system_get_cpu_freq(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void __optimistic_yield(uint32_t intvl_cycles);
|
||||||
|
|
||||||
|
void inline optimistic_yield(uint32_t interval_us) __attribute__((always_inline));
|
||||||
|
void inline optimistic_yield(uint32_t interval_us) {
|
||||||
|
__optimistic_yield(interval_us *
|
||||||
|
#if defined(F_CPU)
|
||||||
|
clockCyclesPerMicrosecond()
|
||||||
|
#else
|
||||||
|
getCpuFreqMHz()
|
||||||
|
#endif
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#define _PORT_GPIO16 1
|
#define _PORT_GPIO16 1
|
||||||
#define digitalPinToPort(pin) (((pin)==16)?(_PORT_GPIO16):(0))
|
#define digitalPinToPort(pin) (((pin)==16)?(_PORT_GPIO16):(0))
|
||||||
|
@ -57,7 +57,7 @@ cont_t* g_pcont __attribute__((section(".noinit")));
|
|||||||
/* Event queue used by the main (arduino) task */
|
/* Event queue used by the main (arduino) task */
|
||||||
static os_event_t s_loop_queue[LOOP_QUEUE_SIZE];
|
static os_event_t s_loop_queue[LOOP_QUEUE_SIZE];
|
||||||
|
|
||||||
/* Used to implement optimistic_yield */
|
/* Used to implement __optimistic_yield */
|
||||||
static uint32_t s_cycles_since_yield_start;
|
static uint32_t s_cycles_since_yield_start;
|
||||||
|
|
||||||
/* For ets_intr_lock_nest / ets_intr_unlock_nest
|
/* For ets_intr_lock_nest / ets_intr_unlock_nest
|
||||||
@ -125,10 +125,9 @@ extern "C" void __yield() {
|
|||||||
|
|
||||||
extern "C" void yield(void) __attribute__ ((weak, alias("__yield")));
|
extern "C" void yield(void) __attribute__ ((weak, alias("__yield")));
|
||||||
|
|
||||||
extern "C" void optimistic_yield(uint32_t interval_us) {
|
extern "C" void __optimistic_yield(uint32_t intvl_cycles) {
|
||||||
const uint32_t interval_cycles = interval_us * ESP.getCpuFreqMHz();
|
if ((ESP.getCycleCount() - s_cycles_since_yield_start) > intvl_cycles &&
|
||||||
if (can_yield() &&
|
can_yield())
|
||||||
(ESP.getCycleCount() - s_cycles_since_yield_start) > interval_cycles)
|
|
||||||
{
|
{
|
||||||
yield();
|
yield();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user