|
| 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* |
0 commit comments