Verified Commit 6b956ce0 authored by Rahix's avatar Rahix
Browse files

chore(epicardium): Move hw-init into hardware.c



Signed-off-by: Rahix's avatarRahix <rahix@rahix.de>
parent e9fbd11d
#include <stdio.h>
#include <stdlib.h>
#include <ff.h>
#include "max32665.h"
#include "uart.h"
#include "cdcacm.h"
#include "gpio.h"
#include "card10.h"
#include "pmic.h"
#include "leds.h"
#include "api/dispatcher.h"
#include "modules/modules.h"
#include "modules/log.h"
#include "modules/stream.h"
#include "modules/filesystem.h"
#include "api/interrupt-sender.h"
#include "gfx.h"
#include "display.h"
#include "card10-version.h"
#include "FreeRTOS.h"
#include "task.h"
#include <stdlib.h>
TaskHandle_t dispatcher_task_id;
void vBleTask(void *pvParameters);
......@@ -34,41 +16,9 @@ int main(void)
LOG_INFO("startup", "Epicardium startup ...");
LOG_INFO("startup", "Version " CARD10_VERSION);
LOG_INFO("startup", "Initializing hardware ...");
hardware_early_init();
#ifdef CARD10_DEBUG_CORE1
LOG_WARN("startup", "Core 1 Debugger Mode");
static const gpio_cfg_t swclk = {
PORT_0,
PIN_7,
GPIO_FUNC_ALT3,
GPIO_PAD_NONE,
};
static const gpio_cfg_t swdio = {
PORT_0,
PIN_6,
GPIO_FUNC_ALT3,
GPIO_PAD_NONE,
};
GPIO_Config(&swclk);
GPIO_Config(&swdio);
#endif /* CARD10_DEBUG_CORE1 */
/* TODO: Move this to its own function */
SCB->SCR |= SCB_SCR_SEVONPEND_Msk;
if (cdcacm_init() < 0) {
LOG_ERR("startup", "USB-Serial unavailable");
}
fatfs_init();
api_interrupt_init();
stream_init();
LOG_INFO("startup", "Initializing dispatcher ...");
api_dispatcher_init();
LOG_INFO("startup", "Initializing tasks ...");
/* Serial */
......@@ -123,10 +73,6 @@ int main(void)
abort();
}
/* light sensor */
LOG_INFO("startup", "starting light sensor ...");
epic_light_sensor_run();
/* Lifecycle */
if (xTaskCreate(
vLifecycleTask,
......
#include "epicardium.h"
#include "api/dispatcher.h"
#include "api/interrupt-sender.h"
#include "cdcacm.h"
#include "modules/filesystem.h"
#include "modules/log.h"
#include "modules/modules.h"
#include "modules/stream.h"
#include "card10.h"
......@@ -10,6 +18,60 @@
int hardware_early_init(void)
{
card10_init();
#ifdef CARD10_DEBUG_CORE1
/*
* The SAO pins can be reconfigured for SWCLK2 and SWDIO2 which allows
* debugging core 1. This feature can optionally be enabled at
* compile-time.
*/
LOG_WARN("init", "Core 1 Debugger Mode");
static const gpio_cfg_t swclk = {
PORT_0,
PIN_7,
GPIO_FUNC_ALT3,
GPIO_PAD_NONE,
};
static const gpio_cfg_t swdio = {
PORT_0,
PIN_6,
GPIO_FUNC_ALT3,
GPIO_PAD_NONE,
};
GPIO_Config(&swclk);
GPIO_Config(&swdio);
#endif /* CARD10_DEBUG_CORE1 */
/*
* Enable SEV-ON-PEND which is needed for proper working of the FreeRTOS
* tickless idle sleep in Epicardium.
*/
SCB->SCR |= SCB_SCR_SEVONPEND_Msk;
/*
* USB-Serial
*/
if (cdcacm_init() < 0) {
LOG_ERR("init", "USB-Serial unavailable");
}
/*
* Flash & FatFS
*/
fatfs_init();
/*
* API Dispatcher & API Interrupts
*/
api_interrupt_init();
api_dispatcher_init();
/*
* Sensor streams
*/
stream_init();
return 0;
}
......@@ -23,6 +85,10 @@ int hardware_early_init(void)
*/
int hardware_init(void)
{
/* Light Sensor */
LOG_INFO("init", "Starting light sensor ...");
epic_light_sensor_run();
return 0;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment