[beken-72xx] Move periodic heap logging to core
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user