1
0
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:
p2r3
2025-08-20 15:21:02 +03:00
parent 5f3dcc56f9
commit 8936eb32db
6 changed files with 36 additions and 23 deletions

View File

@@ -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};