Newer
Older
#include "Heart.h"
#include "gfx.h"
#include "display.h"
TaskHandle_t dispatcher_task_id;
/*
* API dispatcher task. This task will sleep until an API call is issued and
* then wake up to dispatch it.
*/
LOG_DEBUG("dispatcher", "Ready.");
if (api_dispatcher_poll()) {
api_dispatcher_exec();
}
ulTaskNotifyTake(pdTRUE, portMAX_DELAY);
LOG_INFO("startup", "Epicardium startup ...");
LOG_INFO("startup", "Version " CARD10_VERSION);
gfx_copy_region_raw(
&display_screen, 0, 0, 160, 80, 2, (const void *)(Heart)
);
gfx_update(&display_screen);
/* TODO: Move this to its own function */
SCB->SCR |= SCB_SCR_SEVONPEND_Msk;
if (cdcacm_init() < 0) {
LOG_ERR("startup", "USB-Serial unavailable");
}
LOG_INFO("startup", "Initializing tasks ...");
vSerialTask,
(const char *)"Serial",
configMINIMAL_STACK_SIZE,
NULL,
tskIDLE_PRIORITY + 1,
NULL) != pdPASS) {
LOG_CRIT("startup", "Failed to create %s task!", "Serial");
/* PMIC */
if (xTaskCreate(
vPmicTask,
(const char *)"PMIC",
configMINIMAL_STACK_SIZE,
NULL,
tskIDLE_PRIORITY + 1,
NULL) != pdPASS) {
LOG_CRIT("startup", "Failed to create %s task!", "PMIC");
vApiDispatcher,
(const char *)"API Dispatcher",
NULL,
tskIDLE_PRIORITY + 2,
&dispatcher_task_id) != pdPASS) {
LOG_CRIT(
"startup",
"Failed to create %s task!",
"API Dispatcher"
);
vBleTask,
(const char *)"BLE",
configMINIMAL_STACK_SIZE * 10,
NULL,
tskIDLE_PRIORITY + 1,
NULL) != pdPASS) {
LOG_CRIT("startup", "Failed to create %s task!", "BLE");
LOG_INFO("startup", "Initializing dispatcher ...");
/* light sensor */
LOG_INFO("startup", "starting light sensor ...");
epic_light_sensor_run();
/*
* See if there's a l0dable.elf to run. If not, run pycardium.
* This is temporary until epicardium gets a l0dable API from pycardium.
*/
const char *l0dable = "l0dable.elf";
if (f_stat(l0dable, NULL) == FR_OK) {
LOG_INFO("startup", "Running %s ...", l0dable);
struct l0dable_info info;
int res = l0der_load_path(l0dable, &info);
if (res != 0) {
LOG_ERR("startup", "l0der failed: %d\n", res);
} else {
core1_start(info.isr_vector);
}
LOG_INFO("startup", "Starting pycardium on core1 ...");
core1_start((void *)0x10080000);
LOG_INFO("startup", "Starting FreeRTOS ...");
LOG_CRIT("startup", "FreeRTOS did not start due to unknown error!");
abort();