129 lines
2.5 KiB
C
129 lines
2.5 KiB
C
/*
|
|
* Copyright 2020 NXP
|
|
* All rights reserved.
|
|
*
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
*/
|
|
|
|
#include "FreeRTOS.h"
|
|
#include "task.h"
|
|
|
|
#include "fsl_debug_console.h"
|
|
#include "lvgl_support.h"
|
|
#include "pin_mux.h"
|
|
#include "clock_config.h"
|
|
#include "board.h"
|
|
#include "lvgl.h"
|
|
#include "demos/lv_demos.h"
|
|
|
|
#include "fsl_dma.h"
|
|
/*******************************************************************************
|
|
* Definitions
|
|
******************************************************************************/
|
|
#define EXAMPLE_LPSPI_MASTER_DMA_BASEADDR DMA0
|
|
|
|
static volatile bool s_lvgl_initialized = false;
|
|
|
|
/*******************************************************************************
|
|
* Prototypes
|
|
******************************************************************************/
|
|
#if LV_USE_LOG
|
|
static void print_cb(const char *buf)
|
|
{
|
|
PRINTF("\r%s\n", buf);
|
|
}
|
|
#endif
|
|
|
|
static void AppTask(void *param)
|
|
{
|
|
#if LV_USE_LOG
|
|
lv_log_register_print_cb(print_cb);
|
|
#endif
|
|
|
|
PRINTF("lvgl widgets demo started\r\n");
|
|
|
|
lv_port_pre_init();
|
|
lv_init();
|
|
lv_port_disp_init();
|
|
lv_port_indev_init();
|
|
|
|
s_lvgl_initialized = true;
|
|
|
|
lv_demo_widgets();
|
|
|
|
for (;;)
|
|
{
|
|
lv_task_handler();
|
|
vTaskDelay(5);
|
|
}
|
|
}
|
|
|
|
/*******************************************************************************
|
|
* Code
|
|
******************************************************************************/
|
|
/*!
|
|
* @brief Main function
|
|
*/
|
|
int main(void)
|
|
{
|
|
BaseType_t stat;
|
|
|
|
/* Init board hardware. */
|
|
/* attach main clock divide to FLEXCOMM0 (debug console) */
|
|
CLOCK_AttachClk(BOARD_DEBUG_UART_CLK_ATTACH);
|
|
|
|
BOARD_InitPins();
|
|
BOARD_BootClockFROHF96M();
|
|
BOARD_InitDebugConsole();
|
|
DMA_Init(EXAMPLE_LPSPI_MASTER_DMA_BASEADDR);
|
|
|
|
stat = xTaskCreate(AppTask, "lvgl", configMINIMAL_STACK_SIZE + 800, NULL, tskIDLE_PRIORITY + 2, NULL);
|
|
|
|
if (pdPASS != stat)
|
|
{
|
|
PRINTF("Failed to create lvgl task");
|
|
while (1)
|
|
;
|
|
}
|
|
|
|
vTaskStartScheduler();
|
|
|
|
for (;;)
|
|
{
|
|
} /* should never get here */
|
|
}
|
|
|
|
/*!
|
|
* @brief Malloc failed hook.
|
|
*/
|
|
void vApplicationMallocFailedHook(void)
|
|
{
|
|
PRINTF("Malloc failed. Increase the heap size.");
|
|
|
|
for (;;)
|
|
;
|
|
}
|
|
|
|
/*!
|
|
* @brief FreeRTOS tick hook.
|
|
*/
|
|
void vApplicationTickHook(void)
|
|
{
|
|
if (s_lvgl_initialized)
|
|
{
|
|
lv_tick_inc(1);
|
|
}
|
|
}
|
|
|
|
/*!
|
|
* @brief Stack overflow hook.
|
|
*/
|
|
void vApplicationStackOverflowHook(TaskHandle_t xTask, char *pcTaskName)
|
|
{
|
|
(void)pcTaskName;
|
|
(void)xTask;
|
|
|
|
for (;;)
|
|
;
|
|
}
|