2019-11-17 20:47:04 +01:00
|
|
|
#include <FreeRTOS.h>
|
|
|
|
#include <task.h>
|
|
|
|
#include <libraries/log/nrf_log.h>
|
|
|
|
#include <BlinkApp/BlinkApp.h>
|
|
|
|
#include <libraries/bsp/bsp.h>
|
|
|
|
#include <legacy/nrf_drv_clock.h>
|
|
|
|
#include <libraries/timer/app_timer.h>
|
|
|
|
#include <libraries/gpiote/app_gpiote.h>
|
2019-12-05 21:19:47 +01:00
|
|
|
#include <DisplayApp/DisplayApp.h>
|
2019-11-17 20:47:04 +01:00
|
|
|
|
|
|
|
#if NRF_LOG_ENABLED
|
|
|
|
#include "Logging/NrfLogger.h"
|
|
|
|
Pinetime::Logging::NrfLogger logger;
|
|
|
|
#else
|
|
|
|
#include "Logging/DummyLogger.h"
|
|
|
|
Pinetime::Logging::DummyLogger logger;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
Pinetime::Applications::BlinkApp blinkApp;
|
2019-12-05 21:19:47 +01:00
|
|
|
Pinetime::Applications::DisplayApp displayApp;
|
2019-11-17 20:47:04 +01:00
|
|
|
TaskHandle_t systemThread;
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
void vApplicationIdleHook() {
|
|
|
|
logger.Resume();
|
|
|
|
}
|
|
|
|
|
|
|
|
void vApplicationStackOverflowHook( xTaskHandle *pxTask, signed portCHAR *pcTaskName ) {
|
|
|
|
bsp_board_led_on(3);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void bsp_event_handler(bsp_event_t event)
|
|
|
|
{
|
|
|
|
switch (event)
|
|
|
|
{
|
|
|
|
case BSP_EVENT_KEY_0:
|
|
|
|
NRF_LOG_INFO("Button pressed");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SystemTask(void *) {
|
|
|
|
APP_GPIOTE_INIT(2);
|
|
|
|
app_timer_init();
|
|
|
|
|
|
|
|
blinkApp.Start();
|
2019-12-05 21:19:47 +01:00
|
|
|
displayApp.Start();
|
2019-11-17 20:47:04 +01:00
|
|
|
|
|
|
|
while (1) {
|
|
|
|
vTaskSuspend(nullptr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(void) {
|
|
|
|
logger.Init();
|
|
|
|
nrf_drv_clock_init();
|
|
|
|
|
|
|
|
if (pdPASS != xTaskCreate(SystemTask, "MAIN", 256, nullptr, 0, &systemThread))
|
|
|
|
APP_ERROR_HANDLER(NRF_ERROR_NO_MEM);
|
|
|
|
|
|
|
|
vTaskStartScheduler();
|
|
|
|
|
|
|
|
for (;;) {
|
|
|
|
APP_ERROR_HANDLER(NRF_ERROR_FORBIDDEN);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|