From 17d0169e5099a773140df1ffa5a3320143910c7c Mon Sep 17 00:00:00 2001 From: Liam <30486941+liamHowatt@users.noreply.github.com> Date: Wed, 6 Nov 2024 16:52:51 +0100 Subject: [PATCH] chore(NemaGFX): add missing header, correct the docs, provided HAL is optional (#7174) --- docs/details/integration/chip/stm32.rst | 2 +- .../integration/driver/display/st_ltdc.rst | 4 ++-- .../integration/renderers/nema_gfx.rst | 23 +++++++++--------- lv_conf_template.h | 9 +++++-- scripts/lv_conf_internal_gen.py | 3 +++ ...gfx_hal.c => lv_draw_nema_gfx_stm32_hal.c} | 8 ++++--- src/lv_conf_internal.h | 24 +++++++++++++++---- 7 files changed, 48 insertions(+), 25 deletions(-) rename src/draw/nema_gfx/{lv_draw_nema_gfx_hal.c => lv_draw_nema_gfx_stm32_hal.c} (97%) diff --git a/docs/details/integration/chip/stm32.rst b/docs/details/integration/chip/stm32.rst index 1068474cd..d63e2b8e3 100644 --- a/docs/details/integration/chip/stm32.rst +++ b/docs/details/integration/chip/stm32.rst @@ -292,4 +292,4 @@ If ``LV_USE_DRAW_DMA2D_INTERRUPT`` is enabled then you are required to call :cpp:expr:`lv_draw_dma2d_transfer_complete_interrupt_handler` whenever the DMA2D "transfer complete" global interrupt is received. -If your STM device has a Nema GPU, you can use the :ref:`Nema GFX renderer ` instead. +If your STM device has a NeoChrom GPU, you can use the :ref:`Nema GFX renderer ` instead. diff --git a/docs/details/integration/driver/display/st_ltdc.rst b/docs/details/integration/driver/display/st_ltdc.rst index a83527ec2..95c6b23f3 100644 --- a/docs/details/integration/driver/display/st_ltdc.rst +++ b/docs/details/integration/driver/display/st_ltdc.rst @@ -95,8 +95,8 @@ See the :ref:`DMA2D support `. .. admonition:: Further Reading - You may be interested in enabling the :ref:`Nema GFX renderer ` - if your STM32 has a GPU which is supported by Nema GFX. + You may be interested in enabling the :ref:`Nema GFX renderer ` + if your STM32 has a NeoChrom GPU. `lv_port_riverdi_stm32u5 `__ is a way to quick way to get started with LTDC on LVGL. diff --git a/docs/details/integration/renderers/nema_gfx.rst b/docs/details/integration/renderers/nema_gfx.rst index 9b53ab8f5..62a3d2520 100644 --- a/docs/details/integration/renderers/nema_gfx.rst +++ b/docs/details/integration/renderers/nema_gfx.rst @@ -1,12 +1,12 @@ -.. _stm32_nema_gfx: +.. _nema_gfx: -=================================== -NemaGFX Acceleration (AKA NeoChrom) -=================================== +==================== +NemaGFX Acceleration +==================== -Some of the more powerful STM32 MCUs such as the -STM32U5 feature a 2.5D GPU which can natively draw most -LVGL primitives. +NemaGFX is a high-level graphics API supported +by many embedded 2.5D GPUs. LVGL can use it to +natively render LVGL graphics. Get Started with the Riverdi STM32U5 5-inch Display *************************************************** @@ -48,11 +48,10 @@ At the time of writing, :c:macro:`LV_USE_OS` support is experimental and not yet working in `lv_port_riverdi_stm32u5 `__ -"src/draw/nema_gfx/lv_draw_nema_gfx_hal.c" implements the HAL functionality -required by Nema to allocate memory and lock resources (in this implementation, -no locking is done). It may conflict with existing definitions -if you have an existing Nema HAL implementation. You may -simply be able to remove yours. +NemaGFX requires a simple HAL implementation to allocate memory and optionally +lock resources. You may use a custom HAL implementation for your platform or use one of the +provided implementations by setting :c:macro:`LV_USE_NEMA_HAL` to a value other than +:c:macro:`LV_NEMA_HAL_CUSTOM`. TSC Images ********** diff --git a/lv_conf_template.h b/lv_conf_template.h index bb2adeb82..8cf8f4631 100644 --- a/lv_conf_template.h +++ b/lv_conf_template.h @@ -210,11 +210,16 @@ #define LV_USE_NEMA_GFX 0 #if LV_USE_NEMA_GFX - #define LV_NEMA_GFX_HAL_INCLUDE + /** Select which NemaGFX HAL to use. Possible options: + * - LV_NEMA_HAL_CUSTOM + * - LV_NEMA_HAL_STM32 */ + #define LV_USE_NEMA_HAL LV_NEMA_HAL_CUSTOM + #if LV_USE_NEMA_HAL == LV_NEMA_HAL_STM32 + #define LV_NEMA_STM32_HAL_INCLUDE + #endif /*Enable Vector Graphics Operations. Available only if NemaVG library is present*/ #define LV_USE_NEMA_VG 0 - #if LV_USE_NEMA_VG /*Define application's resolution used for VG related buffer allocation */ #define LV_NEMA_GFX_MAX_RESX 800 diff --git a/scripts/lv_conf_internal_gen.py b/scripts/lv_conf_internal_gen.py index b20876485..a3a0da8be 100755 --- a/scripts/lv_conf_internal_gen.py +++ b/scripts/lv_conf_internal_gen.py @@ -51,6 +51,9 @@ fout.write( #define LV_DRAW_SW_ASM_HELIUM 2 #define LV_DRAW_SW_ASM_CUSTOM 255 +#define LV_NEMA_HAL_CUSTOM 0 +#define LV_NEMA_HAL_STM32 1 + /** Handle special Kconfig options. */ #ifndef LV_KCONFIG_IGNORE #include "lv_conf_kconfig.h" diff --git a/src/draw/nema_gfx/lv_draw_nema_gfx_hal.c b/src/draw/nema_gfx/lv_draw_nema_gfx_stm32_hal.c similarity index 97% rename from src/draw/nema_gfx/lv_draw_nema_gfx_hal.c rename to src/draw/nema_gfx/lv_draw_nema_gfx_stm32_hal.c index c82d938b2..7b5b6f67a 100644 --- a/src/draw/nema_gfx/lv_draw_nema_gfx_hal.c +++ b/src/draw/nema_gfx/lv_draw_nema_gfx_stm32_hal.c @@ -12,18 +12,19 @@ #include "../../lv_conf_internal.h" #if LV_USE_NEMA_GFX +#if LV_USE_NEMA_HAL == LV_NEMA_HAL_STM32 + #include "../../misc/lv_types.h" #include "../../misc/lv_assert.h" #include "../../stdlib/lv_string.h" -#include "config.h" #include #include #include #include -#include LV_NEMA_GFX_HAL_INCLUDE +#include LV_NEMA_STM32_HAL_INCLUDE #include @@ -63,7 +64,6 @@ extern GPU2D_HandleTypeDef hgpu2d; * STATIC VARIABLES **********************/ -LOCATION_PRAGMA_NOLOAD("Nemagfx_Memory_Pool_Buffer") static uint8_t nemagfx_pool_mem[NEMAGFX_MEM_POOL_SIZE]; /* NemaGFX memory pool */ static nema_ringbuffer_t ring_buffer_str; @@ -260,4 +260,6 @@ void platform_invalidate_cache(void) * STATIC FUNCTIONS **********************/ +#endif /* LV_USE_NEMA_HAL == LV_NEMA_HAL_STM32 */ + #endif /* LV_USE_NEMA_GFX */ diff --git a/src/lv_conf_internal.h b/src/lv_conf_internal.h index 1b22549c1..7da9d0a42 100644 --- a/src/lv_conf_internal.h +++ b/src/lv_conf_internal.h @@ -29,6 +29,9 @@ #define LV_DRAW_SW_ASM_HELIUM 2 #define LV_DRAW_SW_ASM_CUSTOM 255 +#define LV_NEMA_HAL_CUSTOM 0 +#define LV_NEMA_HAL_STM32 1 + /** Handle special Kconfig options. */ #ifndef LV_KCONFIG_IGNORE #include "lv_conf_kconfig.h" @@ -593,11 +596,23 @@ #endif #if LV_USE_NEMA_GFX - #ifndef LV_NEMA_GFX_HAL_INCLUDE - #ifdef CONFIG_LV_NEMA_GFX_HAL_INCLUDE - #define LV_NEMA_GFX_HAL_INCLUDE CONFIG_LV_NEMA_GFX_HAL_INCLUDE + /** Select which NemaGFX HAL to use. Possible options: + * - LV_NEMA_HAL_CUSTOM + * - LV_NEMA_HAL_STM32 */ + #ifndef LV_USE_NEMA_HAL + #ifdef CONFIG_LV_USE_NEMA_HAL + #define LV_USE_NEMA_HAL CONFIG_LV_USE_NEMA_HAL #else - #define LV_NEMA_GFX_HAL_INCLUDE + #define LV_USE_NEMA_HAL LV_NEMA_HAL_CUSTOM + #endif + #endif + #if LV_USE_NEMA_HAL == LV_NEMA_HAL_STM32 + #ifndef LV_NEMA_STM32_HAL_INCLUDE + #ifdef CONFIG_LV_NEMA_STM32_HAL_INCLUDE + #define LV_NEMA_STM32_HAL_INCLUDE CONFIG_LV_NEMA_STM32_HAL_INCLUDE + #else + #define LV_NEMA_STM32_HAL_INCLUDE + #endif #endif #endif @@ -609,7 +624,6 @@ #define LV_USE_NEMA_VG 0 #endif #endif - #if LV_USE_NEMA_VG /*Define application's resolution used for VG related buffer allocation */ #ifndef LV_NEMA_GFX_MAX_RESX