lv_mem: add LV_MEM_ADR to set wotk memory address externally

This commit is contained in:
Gabor Kiss-Vamosi
2019-01-28 06:08:51 +01:00
parent 28414505bc
commit eca9245382
3 changed files with 29 additions and 4 deletions

View File

@@ -22,6 +22,9 @@
#ifndef LV_MEM_ATTR
#define LV_MEM_ATTR /*Complier prefix for big array declaration*/
#endif
#ifndef LV_MEM_ADR
#define LV_MEM_ADR 0 /*Set an address for memory pool instead of allocation it as an array. Can be in external SRAM too.*/
#endif
#ifndef LV_MEM_AUTO_DEFRAG
#define LV_MEM_AUTO_DEFRAG 1 /*Automatically defrag on free*/
#endif
@@ -48,6 +51,7 @@
#ifndef LV_VER_RES
#define LV_VER_RES (320)
#endif
/* Dot Per Inch: used to initialize default sizes. E.g. a button with width = LV_DPI / 2 -> half inch wide
* (Not so important, you can adjust it to modify default sizes and spaces)*/
#ifndef LV_DPI
@@ -164,6 +168,15 @@
#ifndef LV_TXT_BREAK_CHARS
#define LV_TXT_BREAK_CHARS " ,.;:-_" /*Can break texts on these chars*/
#endif
#ifndef LV_TXT_LINE_BREAK_LONG_LEN
#define LV_TXT_LINE_BREAK_LONG_LEN 12 /* If a character is at least this long, will break wherever "prettiest" */
#endif
#ifndef LV_TXT_LINE_BREAK_LONG_PRE_MIN_LEN
#define LV_TXT_LINE_BREAK_LONG_PRE_MIN_LEN 3 /* Minimum number of characters of a word to put on a line before a break */
#endif
#ifndef LV_TXT_LINE_BREAK_LONG_POST_MIN_LEN
#define LV_TXT_LINE_BREAK_LONG_POST_MIN_LEN 1 /* Minimum number of characters of a word to put on a line after a break */
#endif
/*Feature usage*/
#ifndef USE_LV_ANIMATION
@@ -454,7 +467,7 @@
#define USE_LV_LMETER 1
#endif
/*Gauge (dependencies:bar, lmeter)*/
/*Gauge (dependencies:lv_bar, lv_lmeter)*/
#ifndef USE_LV_GAUGE
#define USE_LV_GAUGE 1
#endif
@@ -507,7 +520,7 @@
#define USE_LV_CALENDAR 1
#endif
/*Preload (dependencies: arc)*/
/*Preload (dependencies: lv_arc)*/
#ifndef USE_LV_PRELOAD
#define USE_LV_PRELOAD 1
#endif
@@ -523,6 +536,10 @@
#endif
#endif
/*Canvas (dependencies: lv_img)*/
#ifndef USE_LV_CANVAS
#define USE_LV_CANVAS 1
#endif
/*************************
* User input objects
*************************/
@@ -605,7 +622,7 @@
/*************************
* Non-user section
*************************/
#ifdef _MSC_VER /* Disable warnings for Visual Studio*/
#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS) /* Disable warnings for Visual Studio*/
#ifndef _CRT_SECURE_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS
#endif

View File

@@ -21,6 +21,7 @@
#if LV_MEM_CUSTOM == 0
#define LV_MEM_SIZE (64U * 1024U) /*Size memory used by `lv_mem_alloc` in bytes (>= 2kB)*/
#define LV_MEM_ATTR /*Complier prefix for big array declaration*/
#define LV_MEM_ADR 0 /*Set an address for memory pool instead of allocation it as an array. Can be in external SRAM too.*/
#define LV_MEM_AUTO_DEFRAG 1 /*Automatically defrag on free*/
#else /*LV_MEM_CUSTOM*/
#define LV_MEM_CUSTOM_INCLUDE <stdlib.h> /*Header for the dynamic memory function*/

View File

@@ -63,7 +63,6 @@ static void ent_trunc(lv_mem_ent_t * e, uint32_t size);
* STATIC VARIABLES
**********************/
#if LV_MEM_CUSTOM == 0
static LV_MEM_ATTR MEM_UNIT work_mem_int[LV_MEM_SIZE / sizeof(MEM_UNIT)]; /*Work memory for allocations*/
static uint8_t * work_mem;
#endif
@@ -83,7 +82,15 @@ static uint32_t zero_mem; /*Give the address of this variable if 0 byte sh
void lv_mem_init(void)
{
#if LV_MEM_CUSTOM == 0
#if LV_MEM_ADR == 0
/*Allocate a large array to store the dynamically allocated data*/
static LV_MEM_ATTR MEM_UNIT work_mem_int[LV_MEM_SIZE / sizeof(MEM_UNIT)];
work_mem = (uint8_t *) work_mem_int;
#else
work_mem = (uint8_t *) LV_MEM_ADR;
#endif
lv_mem_ent_t * full = (lv_mem_ent_t *)work_mem;
full->header.used = 0;
/*The total mem size id reduced by the first header and the close patterns */