114 lines
2.5 KiB
C
114 lines
2.5 KiB
C
/*
|
|
* Copyright 2022 NXP
|
|
* All rights reserved.
|
|
*
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
*/
|
|
|
|
#include "fsl_debug_console.h"
|
|
#include "lvgl_support.h"
|
|
#include "pin_mux.h"
|
|
#include "clock_config.h"
|
|
#include "board.h"
|
|
#include "lvgl.h"
|
|
#include "gui_guider.h"
|
|
#include "events_init.h"
|
|
#include "custom.h"
|
|
|
|
/*******************************************************************************
|
|
* Definitions
|
|
******************************************************************************/
|
|
|
|
/* 1 ms per tick. */
|
|
#ifndef LVGL_TICK_MS
|
|
#define LVGL_TICK_MS 1U
|
|
#endif
|
|
|
|
/* lv_task_handler is called every 5-tick. */
|
|
#ifndef LVGL_TASK_PERIOD_TICK
|
|
#define LVGL_TASK_PERIOD_TICK 5U
|
|
#endif
|
|
|
|
/*******************************************************************************
|
|
* Variables
|
|
******************************************************************************/
|
|
|
|
lv_ui guider_ui;
|
|
static volatile uint32_t s_tick = 0U;
|
|
static volatile bool s_lvglTaskPending = false;
|
|
/*******************************************************************************
|
|
* Prototypes
|
|
******************************************************************************/
|
|
static void DEMO_SetupTick(void);
|
|
#if LV_USE_LOG
|
|
static void print_cb(const char *buf);
|
|
#endif
|
|
|
|
/*******************************************************************************
|
|
* Code
|
|
******************************************************************************/
|
|
/*!
|
|
* @brief Main function
|
|
*/
|
|
int main(void)
|
|
{
|
|
/* Init board hardware. */
|
|
/* attach main clock divide to FLEXCOMM0 (debug console) */
|
|
CLOCK_AttachClk(BOARD_DEBUG_UART_CLK_ATTACH);
|
|
|
|
BOARD_InitPins();
|
|
BOARD_BootClockFROHF96M();
|
|
BOARD_InitDebugConsole();
|
|
DEMO_SetupTick();
|
|
#if LV_USE_LOG
|
|
lv_log_register_print_cb(print_cb);
|
|
#endif
|
|
|
|
lv_port_pre_init();
|
|
lv_init();
|
|
lv_port_disp_init();
|
|
lv_port_indev_init();
|
|
|
|
setup_ui(&guider_ui);
|
|
events_init(&guider_ui);
|
|
custom_init(&guider_ui);
|
|
|
|
for (;;)
|
|
{
|
|
while (!s_lvglTaskPending)
|
|
{
|
|
}
|
|
s_lvglTaskPending = false;
|
|
|
|
lv_task_handler();
|
|
}
|
|
}
|
|
|
|
static void DEMO_SetupTick(void)
|
|
{
|
|
if (0 != SysTick_Config(SystemCoreClock / (LVGL_TICK_MS * 1000U)))
|
|
{
|
|
PRINTF("Tick initialization failed\r\n");
|
|
while (1)
|
|
;
|
|
}
|
|
}
|
|
|
|
void SysTick_Handler(void)
|
|
{
|
|
s_tick++;
|
|
lv_tick_inc(LVGL_TICK_MS);
|
|
|
|
if ((s_tick % LVGL_TASK_PERIOD_TICK) == 0U)
|
|
{
|
|
s_lvglTaskPending = true;
|
|
}
|
|
}
|
|
|
|
#if LV_USE_LOG
|
|
static void print_cb(const char *buf)
|
|
{
|
|
PRINTF("\r%s\n", buf);
|
|
}
|
|
#endif
|