[beken-72xx] Move periodic heap logging to core

This commit is contained in:
Kuba Szczodrzyński
2022-09-03 21:25:39 +02:00
parent 922adfd3d4
commit 9b5013a694
3 changed files with 19 additions and 8 deletions

View File

@@ -26,15 +26,8 @@ unsigned long micros() {
return millis() * 1000;
}
static unsigned long lastHeapLog = 0;
void yield() {
#if LT_LOG_HEAP
if (millis() - lastHeapLog > 1000) {
LT_HEAP_I();
lastHeapLog = millis();
}
#endif
runPeriodicTasks();
vTaskDelay(1);
taskYIELD();
}

View File

@@ -21,6 +21,13 @@ extern bool startMainTask();
*/
extern void mainTask(const void *arg);
/**
* @brief Run periodic tasks, like printing free heap or checking millis() overflow.
*
* This is called during delaying operations, like yield() or delay().
*/
extern void runPeriodicTasks();
#define PIN_NONE (1 << 0)
#define PIN_GPIO (1 << 1)
#define PIN_IRQ (1 << 2)

View File

@@ -32,6 +32,17 @@ void mainTask(const void *arg) {
}
}
static unsigned long periodicTasks[] = {0, 0};
void runPeriodicTasks() {
#if LT_LOG_HEAP
if (millis() - periodicTasks[0] > 1000) {
LT_HEAP_I();
periodicTasks[0] = millis();
}
#endif
}
int main(void) {
// print a startup banner
LT_BANNER();