Skip to content

Commit 820a160

Browse files
committed
feat(modules): add esp-lib-utils
1 parent c86951b commit 820a160

File tree

5 files changed

+113
-0
lines changed

5 files changed

+113
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,5 @@ user.props
2828
**/**/lv_binding_micropython/*
2929
lextab.py
3030
yacctab.py
31+
32+
.vscode/

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,6 @@
7171
[submodule "modules/lv_binding_micropython"]
7272
path = modules/lv_binding_micropython
7373
url = [email protected]:esp-arduino-libs/lv_binding_micropython.git
74+
[submodule "modules/esp-lib-utils"]
75+
path = modules/esp-lib-utils
76+
url = https://github.com/esp-arduino-libs/esp-lib-utils.git

modules/esp-lib-utils

Submodule esp-lib-utils added at 0066f7c

modules/esp_utils_conf.h

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#pragma once
8+
9+
// *INDENT-OFF*
10+
11+
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
12+
///////////////////////////////////////////////// Check Configurations /////////////////////////////////////////////////
13+
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
14+
/**
15+
* These functions are used to check the function parameters, return value, etc. Disable them will reduce the code size.
16+
*
17+
*/
18+
/* Set to 1 if use `ESP_UTILS_CHECK_*()` macros */
19+
#define ESP_UTILS_CONF_ENABLE_CHECK (1) // 0/1
20+
#if ESP_UTILS_CONF_ENABLE_CHECK
21+
/* Set to 1 if print message when check failed */
22+
#define ESP_UTILS_CONF_CHECK_WITH_ERROR_LOG (1) // 0/1
23+
24+
/* Set to 1 if assert when check failed */
25+
#define ESP_UTILS_CONF_CHECK_WITH_ASSERT (0) // 0/1
26+
#endif // ESP_UTILS_CONF_ENABLE_CHECK
27+
28+
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
29+
////////////////////////////////////////////////// Log Configurations //////////////////////////////////////////////////
30+
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
31+
/**
32+
* These functions are used to print log messages. Disable them will reduce the code size.
33+
*
34+
*/
35+
/* Set to 1 if use `ESP_UTILS_LOG*()` macros */
36+
#define ESP_UTILS_CONF_ENABLE_LOG (1) // 0/1
37+
#if ESP_UTILS_CONF_ENABLE_LOG
38+
/**
39+
* Global log level, logs with a level lower than this will not be compiled. Choose one of the following:
40+
* - ESP_UTILS_LOG_LEVEL_DEBUG: Extra information which is not necessary for normal use (values, pointers, sizes, etc)
41+
* (lowest level)
42+
* - ESP_UTILS_LOG_LEVEL_INFO: Information messages which describe the normal flow of events
43+
* - ESP_UTILS_LOG_LEVEL_WARNING: Error conditions from which recovery measures have been taken
44+
* - ESP_UTILS_LOG_LEVEL_ERROR: Critical errors, software module cannot recover on its own (highest level)
45+
*
46+
*/
47+
#define ESP_UTILS_CONF_LOG_LEVEL (ESP_UTILS_LOG_LEVEL_INFO)
48+
#if ESP_UTILS_CONF_LOG_LEVEL == ESP_UTILS_LOG_LEVEL_DEBUG
49+
50+
/* Set to 1 if print trace log messages when enter/exit functions, useful for debugging */
51+
#define ESP_UTILS_CONF_ENABLE_LOG_TRACE (0)
52+
53+
#endif // ESP_UTILS_CONF_LOG_LEVEL
54+
55+
/* Log format buffer size */
56+
#define ESP_UTILS_CONF_LOG_BUFFER_SIZE (256)
57+
#endif // ESP_UTILS_CONF_ENABLE_LOG
58+
59+
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
60+
//////////////////////////////////////////////// Memory Configurations /////////////////////////////////////////////////
61+
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
62+
/**
63+
* General Memory allocation type, choose one of the following:
64+
* - ESP_UTILS_MEM_ALLOC_TYPE_STDLIB: Use the standard library memory allocation functions (malloc, free)
65+
* - ESP_UTILS_MEM_ALLOC_TYPE_ESP: Use the ESP-IDF memory allocation functions (heap_caps_aligned_alloc, heap_caps_free)
66+
* - ESP_UTILS_MEM_ALLOC_TYPE_MICROPYTHON: Use the MicroPython memory allocation functions (m_malloc, m_free)
67+
* - ESP_UTILS_MEM_ALLOC_TYPE_CUSTOM: Use custom memory allocation functions (ESP_UTILS_MEM_ALLOC_CUSTOM_MALLOC,
68+
* ESP_UTILS_MEM_ALLOC_CUSTOM_FREE)
69+
*
70+
*/
71+
#define ESP_UTILS_CONF_MEM_GEN_ALLOC_TYPE (ESP_UTILS_MEM_ALLOC_TYPE_MICROPYTHON)
72+
#if ESP_UTILS_CONF_MEM_GEN_ALLOC_TYPE == ESP_UTILS_MEM_ALLOC_TYPE_ESP
73+
74+
#define ESP_UTILS_CONF_MEM_GEN_ALLOC_ESP_ALIGN (1)
75+
#define ESP_UTILS_CONF_MEM_GEN_ALLOC_ESP_CAPS (MALLOC_CAP_DEFAULT | MALLOC_CAP_8BIT)
76+
77+
#elif ESP_UTILS_CONF_MEM_GEN_ALLOC_TYPE == ESP_UTILS_MEM_ALLOC_TYPE_CUSTOM
78+
79+
#define ESP_UTILS_CONF_MEM_GEN_ALLOC_CUSTOM_INCLUDE "stdlib.h"
80+
#define ESP_UTILS_CONF_MEM_GEN_ALLOC_CUSTOM_MALLOC malloc
81+
#define ESP_UTILS_CONF_MEM_GEN_ALLOC_CUSTOM_FREE free
82+
83+
#endif // ESP_UTILS_CONF_MEM_GEN_ALLOC_TYPE
84+
85+
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
86+
/////////////////////////////////////////////// File Version ///////////////////////////////////////////////////////////
87+
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
88+
/**
89+
* Do not change the following versions, they are used to check if the configurations in this file are compatible with
90+
* the current version of `esp_utils_conf.h` in the library. The detailed rules are as follows:
91+
*
92+
* 1. If the major version is not consistent, then the configurations in this file are incompatible with the library
93+
* and must be replaced with the file from the library.
94+
* 2. If the minor version is not consistent, this file might be missing some new configurations, which will be set to
95+
* default values. It is recommended to replace it with the file from the library.
96+
* 3. Even if the patch version is not consistent, it will not affect normal functionality.
97+
*
98+
*/
99+
#define ESP_UTILS_CONF_FILE_VERSION_MAJOR 0
100+
#define ESP_UTILS_CONF_FILE_VERSION_MINOR 1
101+
#define ESP_UTILS_CONF_FILE_VERSION_PATCH 0
102+
103+
// *INDENT-OFF*

modules/micropython.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,7 @@ include(${CMAKE_CURRENT_LIST_DIR}/lv_binding_micropython/micropython.cmake)
88
if(ESP_PLATFORM)
99
include(${CMAKE_CURRENT_LIST_DIR}/esp_memory/micropython.cmake)
1010
endif()
11+
12+
if(ESP_PLATFORM)
13+
include(${CMAKE_CURRENT_LIST_DIR}/esp-lib-utils/micropython.cmake)
14+
endif()

0 commit comments

Comments
 (0)