2018-03-25 08:27:48 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2018 Jan Van Winkel <jan.van_winkel@dxplore.eu>
|
2020-09-23 05:50:18 +08:00
|
|
|
* Copyright (c) 2020 Intel Corporation
|
2018-03-25 08:27:48 +08:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "lvgl_mem.h"
|
|
|
|
#include <zephyr.h>
|
|
|
|
#include <init.h>
|
2020-09-23 05:50:18 +08:00
|
|
|
#include <sys/sys_heap.h>
|
2018-03-25 08:27:48 +08:00
|
|
|
|
2020-09-23 05:50:18 +08:00
|
|
|
|
|
|
|
#define HEAP_BYTES (CONFIG_LVGL_MEM_POOL_MAX_SIZE * \
|
|
|
|
CONFIG_LVGL_MEM_POOL_NUMBER_BLOCKS)
|
|
|
|
|
|
|
|
static char lvgl_heap_mem[HEAP_BYTES];
|
|
|
|
static struct sys_heap lvgl_heap;
|
2018-03-25 08:27:48 +08:00
|
|
|
|
|
|
|
void *lvgl_malloc(size_t size)
|
|
|
|
{
|
2020-09-23 05:50:18 +08:00
|
|
|
return sys_heap_alloc(&lvgl_heap, size);
|
2018-03-25 08:27:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void lvgl_free(void *ptr)
|
|
|
|
{
|
2020-09-23 05:50:18 +08:00
|
|
|
sys_heap_free(&lvgl_heap, ptr);
|
2018-03-25 08:27:48 +08:00
|
|
|
}
|
|
|
|
|
2020-09-23 05:50:18 +08:00
|
|
|
static int lvgl_heap_init(const struct device *unused)
|
2018-03-25 08:27:48 +08:00
|
|
|
{
|
2020-09-23 05:50:18 +08:00
|
|
|
sys_heap_init(&lvgl_heap, &lvgl_heap_mem[0], HEAP_BYTES);
|
2018-03-25 08:27:48 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-09-23 05:50:18 +08:00
|
|
|
SYS_INIT(lvgl_heap_init, APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);
|