summaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorJF <jf@codingfield.com>2019-11-17 20:47:04 +0100
committerJF <jf@codingfield.com>2019-11-17 20:47:04 +0100
commit2ea27e0cdac91cd4743d9f12496bb3f911d9efa9 (patch)
treeae6488be1be14c2b83aff6e69a6e622088fb093a /src/main.cpp
Initial commit
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp76
1 files changed, 76 insertions, 0 deletions
diff --git a/src/main.cpp b/src/main.cpp
new file mode 100644
index 00000000..9ce22d36
--- /dev/null
+++ b/src/main.cpp
@@ -0,0 +1,76 @@
+#include <FreeRTOS.h>
+#include <task.h>
+#include <libraries/log/nrf_log.h>
+#include <BlinkApp/BlinkApp.h>
+#include <boards.h>
+#include <libraries/bsp/bsp.h>
+#include <legacy/nrf_drv_clock.h>
+#include <libraries/timer/app_timer.h>
+#include <libraries/gpiote/app_gpiote.h>
+
+
+#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;
+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();
+
+ bsp_board_init(BSP_INIT_LEDS|BSP_INIT_BUTTONS);
+ bsp_init(BSP_INIT_LEDS | BSP_INIT_BUTTONS, bsp_event_handler);
+
+ blinkApp.Start();
+
+ 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);
+ }
+}
+
+
+