mirror of
https://github.com/p2r3/bareiron.git
synced 2025-10-02 07:35:08 +02:00
make esp task yielding more consistent and reduce overhead
This commit is contained in:
@@ -5,6 +5,24 @@
|
||||
|
||||
#include "globals.h"
|
||||
|
||||
#ifdef ESP_PLATFORM
|
||||
#include "esp_task_wdt.h"
|
||||
#include "esp_timer.h"
|
||||
|
||||
// Time between vTaskDelay calls in microseconds
|
||||
#define TASK_YIELD_INTERVAL 1000 * 1000
|
||||
// How many ticks to delay for on each yield
|
||||
#define TASK_YIELD_TICKS 1
|
||||
|
||||
int64_t last_yield = 0;
|
||||
void task_yield () {
|
||||
int64_t time_now = esp_timer_get_time();
|
||||
if (time_now - last_yield < TASK_YIELD_INTERVAL) return;
|
||||
vTaskDelay(TASK_YIELD_TICKS);
|
||||
last_yield = time_now;
|
||||
}
|
||||
#endif
|
||||
|
||||
ssize_t recv_count;
|
||||
uint8_t recv_buffer[256] = {0};
|
||||
|
||||
|
Reference in New Issue
Block a user