mirror of
https://github.com/ByteWelder/Tactility.git
synced 2026-02-18 19:03:16 +00:00
* **New Features** * Time and delay utilities added (ticks, ms, µs); SD card now uses an expansion-header CS pin; HTTP downloads warn when run on the GUI task and yield to avoid blocking. * **Bug Fixes / Reliability** * Many hard-crash paths converted to guarded checks to reduce abrupt termination and improve stability. * **Tests** * Unit tests added to validate time and delay accuracy. * **Chores** * License header and build/macro updates.
61 lines
1.4 KiB
C++
61 lines
1.4 KiB
C++
#include "Main.h"
|
|
#include <Tactility/Thread.h>
|
|
#include <Tactility/TactilityCore.h>
|
|
|
|
#include "FreeRTOS.h"
|
|
#include "task.h"
|
|
|
|
static const auto LOGGER = tt::Logger("FreeRTOS");
|
|
|
|
namespace simulator {
|
|
|
|
MainFunction mainFunction = nullptr;
|
|
|
|
void setMain(MainFunction newMainFunction) {
|
|
mainFunction = newMainFunction;
|
|
}
|
|
|
|
static void freertosMainTask(void* parameter) {
|
|
LOGGER.info("starting app_main()");
|
|
assert(simulator::mainFunction);
|
|
mainFunction();
|
|
LOGGER.info("returned from app_main()");
|
|
vTaskDelete(nullptr);
|
|
}
|
|
|
|
void freertosMain() {
|
|
BaseType_t task_result = xTaskCreate(
|
|
freertosMainTask,
|
|
"main",
|
|
8192,
|
|
nullptr,
|
|
static_cast<UBaseType_t>(tt::Thread::Priority::Normal),
|
|
nullptr
|
|
);
|
|
|
|
assert(task_result == pdTRUE);
|
|
|
|
// Blocks forever
|
|
vTaskStartScheduler();
|
|
}
|
|
|
|
} // namespace
|
|
|
|
/**
|
|
* Assert implementation as defined in the FreeRTOSConfig.h
|
|
* It allows you to set breakpoints and debug asserts.
|
|
*/
|
|
void vAssertCalled(unsigned long line, const char* const file) {
|
|
volatile uint32_t set_to_nonzero_in_debugger_to_continue = 0;
|
|
LOGGER.error("Assert triggered at {}:{}", file, line);
|
|
taskENTER_CRITICAL();
|
|
{
|
|
// Step out by attaching a debugger and setting set_to_nonzero_in_debugger_to_continue
|
|
while (set_to_nonzero_in_debugger_to_continue == 0) {
|
|
// NO-OP
|
|
}
|
|
}
|
|
taskEXIT_CRITICAL();
|
|
}
|
|
|