Ken Van Hoeylandt f620255c41
New logging and more (#446)
- `TT_LOG_*` macros are replaced by `Logger` via `#include<Tactility/Logger.h>`
- Changed default timezone to Europe/Amsterdam
- Fix for logic bug in unPhone hardware
- Fix for init/deinit in DRV2605 driver
- Other fixes
- Removed optimization that broke unPhone (disabled the moving of heap-related functions to flash)
2026-01-06 22:35:39 +01:00

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(TT_UNUSED 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();
}