Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nema: Use NemaGFX Renderer #1

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
7504cc8
test Nema
kisvegabor Aug 1, 2024
ac24702
work from RAM
kisvegabor Sep 24, 2024
fae3178
works
kisvegabor Sep 27, 2024
c80b905
squash: dma2d flush, depth 16 by default
liamHowatt Oct 4, 2024
0aa2793
submodule bump
liamHowatt Oct 4, 2024
8afddb3
fix LV_OS_FREERTOS
liamHowatt Oct 7, 2024
8ef8d2d
support color depth 24
liamHowatt Oct 7, 2024
5e4c20b
support color depth 8
liamHowatt Oct 7, 2024
249d374
submodule bump and use smaller buffer
liamHowatt Oct 7, 2024
ec0f6f7
fix regression with LV_OS_NONE
liamHowatt Oct 10, 2024
4b0cbd0
submodule bump
liamHowatt Oct 11, 2024
59fb631
submodule track master now. enable fonts required by new benchmark
liamHowatt Oct 14, 2024
df3a610
feedback 1
liamHowatt Oct 17, 2024
dbf468c
add back template for completeness
liamHowatt Oct 29, 2024
a2e4b57
track chore PR
liamHowatt Oct 29, 2024
6163fe3
submodule bump
liamHowatt Nov 4, 2024
f1c2232
remove NemaGFX Middleware dir
liamHowatt Nov 4, 2024
740e25d
config hal change and submodule bump
liamHowatt Nov 5, 2024
8465c5a
Merge remote-tracking branch 'origin/master' into nema
liamHowatt Jan 17, 2025
ea02506
feedback: 4 reverts
liamHowatt Jan 17, 2025
0f525c3
feedback: move dma2d edits out of gen file
liamHowatt Jan 17, 2025
32b0099
remove include
liamHowatt Jan 17, 2025
94378b4
lv_conf.defaults and submodule bump
liamHowatt Jan 17, 2025
e835382
use LVGL LTDC driver
liamHowatt Jan 17, 2025
a365edb
update README
liamHowatt Jan 17, 2025
f2ab05e
I realized we actually can do direct double
liamHowatt Jan 19, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Core/Inc/stm32u5xx_hal_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@
#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */
#define USE_HAL_JPEG_REGISTER_CALLBACKS 0U /* JPEG register callback disabled */
#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U /* LPTIM register callback disabled */
#define USE_HAL_LTDC_REGISTER_CALLBACKS 0U /* LTDC register callback disabled */
#define USE_HAL_LTDC_REGISTER_CALLBACKS 1U /* LTDC register callback disabled */
#define USE_HAL_MDF_REGISTER_CALLBACKS 0U /* MDF register callback disabled */
#define USE_HAL_MMC_REGISTER_CALLBACKS 0U /* MMC register callback disabled */
#define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */
Expand Down
4 changes: 2 additions & 2 deletions Core/Src/app_freertos.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ osThreadId_t lvglTimerHandle;
const osThreadAttr_t lvglTimer_attributes = {
.name = "lvglTimer",
.priority = (osPriority_t) osPriorityNormal,
.stack_size = 4* 1024
.stack_size = 16* 1024
};
/* USER CODE END Variables */
/* Definitions for defaultTask */
osThreadId_t defaultTaskHandle;
const osThreadAttr_t defaultTask_attributes = {
.name = "defaultTask",
.priority = (osPriority_t) osPriorityNormal,
.stack_size = 128 * 4
.stack_size = 128 * 4 * 32
};

/* Private function prototypes -----------------------------------------------*/
Expand Down
2 changes: 1 addition & 1 deletion Core/Src/cordic.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
******************************************************************************
* @attention
*
* Copyright (c) 2023 STMicroelectronics.
* Copyright (c) 2024 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
Expand Down
2 changes: 1 addition & 1 deletion Core/Src/crc.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
******************************************************************************
* @attention
*
* Copyright (c) 2023 STMicroelectronics.
* Copyright (c) 2024 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
Expand Down
2 changes: 1 addition & 1 deletion Core/Src/dac.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
******************************************************************************
* @attention
*
* Copyright (c) 2023 STMicroelectronics.
* Copyright (c) 2024 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
Expand Down
2 changes: 1 addition & 1 deletion Core/Src/dcache.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
******************************************************************************
* @attention
*
* Copyright (c) 2023 STMicroelectronics.
* Copyright (c) 2024 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
Expand Down
7 changes: 5 additions & 2 deletions Core/Src/dma2d.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
******************************************************************************
* @attention
*
* Copyright (c) 2023 STMicroelectronics.
* Copyright (c) 2024 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
Expand All @@ -19,6 +19,7 @@
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "dma2d.h"
#include "lvgl/lvgl.h"

/* USER CODE BEGIN 0 */

Expand Down Expand Up @@ -73,8 +74,10 @@ void HAL_DMA2D_MspInit(DMA2D_HandleTypeDef* dma2dHandle)
/* USER CODE END DMA2D_MspInit 0 */
/* DMA2D clock enable */
__HAL_RCC_DMA2D_CLK_ENABLE();
__HAL_RCC_DMA2D_FORCE_RESET();
__HAL_RCC_DMA2D_RELEASE_RESET();

/* DMA2D interrupt Init */
/* Enable DMA2D global Interrupt */
HAL_NVIC_SetPriority(DMA2D_IRQn, 5, 0);
HAL_NVIC_EnableIRQ(DMA2D_IRQn);
/* USER CODE BEGIN DMA2D_MspInit 1 */
Expand Down
2 changes: 1 addition & 1 deletion Core/Src/fdcan.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
******************************************************************************
* @attention
*
* Copyright (c) 2023 STMicroelectronics.
* Copyright (c) 2024 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
Expand Down
2 changes: 1 addition & 1 deletion Core/Src/gpu2d.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
******************************************************************************
* @attention
*
* Copyright (c) 2023 STMicroelectronics.
* Copyright (c) 2024 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
Expand Down
2 changes: 1 addition & 1 deletion Core/Src/hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
******************************************************************************
* @attention
*
* Copyright (c) 2023 STMicroelectronics.
* Copyright (c) 2024 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
Expand Down
2 changes: 1 addition & 1 deletion Core/Src/icache.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
******************************************************************************
* @attention
*
* Copyright (c) 2023 STMicroelectronics.
* Copyright (c) 2024 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
Expand Down
2 changes: 1 addition & 1 deletion Core/Src/lptim.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
******************************************************************************
* @attention
*
* Copyright (c) 2023 STMicroelectronics.
* Copyright (c) 2024 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
Expand Down
28 changes: 19 additions & 9 deletions Core/Src/ltdc.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
******************************************************************************
* @attention
*
* Copyright (c) 2023 STMicroelectronics.
* Copyright (c) 2024 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
Expand Down Expand Up @@ -118,15 +118,16 @@ void HAL_LTDC_MspInit(LTDC_HandleTypeDef* ltdcHandle)

__HAL_RCC_GPIOE_CLK_ENABLE();
__HAL_RCC_GPIOD_CLK_ENABLE();
__HAL_RCC_GPIOC_CLK_ENABLE();
__HAL_RCC_GPIOG_CLK_ENABLE();
__HAL_RCC_GPIOF_CLK_ENABLE();
/**LTDC GPIO Configuration
PE0 ------> LTDC_HSYNC
PD3 ------> LTDC_CLK
PD1 ------> LTDC_B5
PC6 ------> LTDC_R0
PD0 ------> LTDC_B4
PG6 ------> LTDC_R1
PE2 ------> LTDC_R0
PD15 ------> LTDC_B3
PD11 ------> LTDC_R6
PF13 ------> LTDC_B1
Expand All @@ -150,9 +151,9 @@ void HAL_LTDC_MspInit(LTDC_HandleTypeDef* ltdcHandle)
PF14 ------> LTDC_G0
PE14 ------> LTDC_G7
*/
GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_2|GPIO_PIN_8|GPIO_PIN_13
|GPIO_PIN_7|GPIO_PIN_15|GPIO_PIN_12|GPIO_PIN_9
|GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_14;
GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_8|GPIO_PIN_13|GPIO_PIN_7
|GPIO_PIN_15|GPIO_PIN_12|GPIO_PIN_9|GPIO_PIN_10
|GPIO_PIN_11|GPIO_PIN_14;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
Expand All @@ -168,6 +169,13 @@ void HAL_LTDC_MspInit(LTDC_HandleTypeDef* ltdcHandle)
GPIO_InitStruct.Alternate = GPIO_AF8_LTDC;
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);

GPIO_InitStruct.Pin = GPIO_PIN_6;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF7_LTDC;
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);

GPIO_InitStruct.Pin = GPIO_PIN_6;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
Expand Down Expand Up @@ -207,9 +215,9 @@ void HAL_LTDC_MspDeInit(LTDC_HandleTypeDef* ltdcHandle)
PE0 ------> LTDC_HSYNC
PD3 ------> LTDC_CLK
PD1 ------> LTDC_B5
PC6 ------> LTDC_R0
PD0 ------> LTDC_B4
PG6 ------> LTDC_R1
PE2 ------> LTDC_R0
PD15 ------> LTDC_B3
PD11 ------> LTDC_R6
PF13 ------> LTDC_B1
Expand All @@ -233,14 +241,16 @@ void HAL_LTDC_MspDeInit(LTDC_HandleTypeDef* ltdcHandle)
PF14 ------> LTDC_G0
PE14 ------> LTDC_G7
*/
HAL_GPIO_DeInit(GPIOE, GPIO_PIN_0|GPIO_PIN_2|GPIO_PIN_8|GPIO_PIN_13
|GPIO_PIN_7|GPIO_PIN_15|GPIO_PIN_12|GPIO_PIN_9
|GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_14);
HAL_GPIO_DeInit(GPIOE, GPIO_PIN_0|GPIO_PIN_8|GPIO_PIN_13|GPIO_PIN_7
|GPIO_PIN_15|GPIO_PIN_12|GPIO_PIN_9|GPIO_PIN_10
|GPIO_PIN_11|GPIO_PIN_14);

HAL_GPIO_DeInit(GPIOD, GPIO_PIN_3|GPIO_PIN_1|GPIO_PIN_0|GPIO_PIN_15
|GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_8|GPIO_PIN_13
|GPIO_PIN_14|GPIO_PIN_10|GPIO_PIN_9);

HAL_GPIO_DeInit(GPIOC, GPIO_PIN_6);

HAL_GPIO_DeInit(GPIOG, GPIO_PIN_6);

HAL_GPIO_DeInit(GPIOF, GPIO_PIN_13|GPIO_PIN_12|GPIO_PIN_11|GPIO_PIN_15
Expand Down
50 changes: 10 additions & 40 deletions Core/Src/lvgl_port_display.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,9 @@
* STATIC PROTOTYPES
**********************/

static void disp_flush (lv_display_t *, const lv_area_t *, uint8_t *);
static void disp_flush_complete (DMA2D_HandleTypeDef*);

/**********************
* STATIC VARIABLES
**********************/
static lv_display_t * disp;
static __attribute__((aligned(32))) uint8_t buf_1[MY_DISP_HOR_RES * MY_DISP_VER_RES * 2];

/**********************
* GLOBAL FUNCTIONS
Expand All @@ -28,43 +23,18 @@ void lvgl_display_init (void)
{
/* display initialization */

disp = lv_display_create(MY_DISP_HOR_RES, MY_DISP_VER_RES);
lv_display_set_buffers(disp, buf_1, NULL, sizeof(buf_1), LV_DISPLAY_RENDER_MODE_PARTIAL);
lv_display_set_flush_cb(disp, disp_flush);

/* interrupt callback for DMA2D transfer */
hdma2d.XferCpltCallback = disp_flush_complete;

#if LV_COLOR_FORMAT == 16
static __attribute__((aligned(32))) uint8_t buf_2[MY_DISP_HOR_RES * MY_DISP_VER_RES * 2];
lv_st_ltdc_create_direct((void *)0x20000000, buf_2, 0);
#elif LV_COLOR_FORMAT == 24 || LV_COLOR_FORMAT == 32
static __attribute__((aligned(32))) uint8_t buf_1[MY_DISP_HOR_RES * MY_DISP_VER_RES];
static __attribute__((aligned(32))) uint8_t buf_2[MY_DISP_HOR_RES * MY_DISP_VER_RES];
lv_st_ltdc_create_partial(buf_1, buf_2, sizeof(buf_1), 0);
#else
#error LV_COLOR_FORMAT not supported
#endif
}

/**********************
* STATIC FUNCTIONS
**********************/

static void
disp_flush (lv_display_t * display,
const lv_area_t * area,
uint8_t * px_map)
{
lv_coord_t width = lv_area_get_width(area);
lv_coord_t height = lv_area_get_height(area);

DMA2D->CR = 0x0U << DMA2D_CR_MODE_Pos;
DMA2D->FGPFCCR = DMA2D_INPUT_RGB565;
DMA2D->FGMAR = (uint32_t)px_map;
DMA2D->FGOR = 0;
DMA2D->OPFCCR = DMA2D_OUTPUT_RGB565;
DMA2D->OMAR = hltdc.LayerCfg[0].FBStartAdress + 2 * \
(area->y1 * MY_DISP_HOR_RES + area->x1);
DMA2D->OOR = MY_DISP_HOR_RES - width;
DMA2D->NLR = (width << DMA2D_NLR_PL_Pos) | (height << DMA2D_NLR_NL_Pos);
DMA2D->IFCR = 0x3FU;
DMA2D->CR |= DMA2D_CR_TCIE;
DMA2D->CR |= DMA2D_CR_START;
}

static void
disp_flush_complete (DMA2D_HandleTypeDef *hdma2d)
{
lv_display_flush_ready(disp);
}
17 changes: 14 additions & 3 deletions Core/Src/lvgl_port_touch.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@
#include "lvgl_port_touch.h"
#include "main.h"
#include "i2c.h"
#include "cmsis_os2.h"

/*********************
* DEFINES
*********************/

#if LV_USE_OS == LV_OS_NONE
#define DELAY_API(ms) HAL_Delay(ms)
#else
#define DELAY_API(ms) osDelay(ms)
#endif

/**********************
* STATIC VARIABLES
Expand Down Expand Up @@ -32,11 +43,11 @@ lvgl_touchscreen_init (void)
/* 'i2c1' bus and touchscreen reset pin are already configure by CubeMX,
* here we just need to reset touchscreen controller */
HAL_GPIO_WritePin(CTP_RST_GPIO_Port, CTP_RST_Pin, GPIO_PIN_SET);
HAL_Delay(10);
DELAY_API(10);
HAL_GPIO_WritePin(CTP_RST_GPIO_Port, CTP_RST_Pin, GPIO_PIN_RESET);
HAL_Delay(10);
DELAY_API(10);
HAL_GPIO_WritePin(CTP_RST_GPIO_Port, CTP_RST_Pin, GPIO_PIN_SET);
HAL_Delay(10);
DELAY_API(10);

/* basic LVGL driver initialization */
lv_indev_t * indev = lv_indev_create();
Expand Down
Loading