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

Draft
wants to merge 18 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
18 changes: 17 additions & 1 deletion Core/Src/adc.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 @@ -204,6 +204,16 @@ void HAL_ADC_MspInit(ADC_HandleTypeDef* adcHandle)
if(HAL_RCC_ADC12_CLK_ENABLED==1){
__HAL_RCC_ADC12_CLK_ENABLE();
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file should be reverted.

__HAL_RCC_GPIOA_CLK_ENABLE();
/**ADC2 GPIO Configuration
PA3 ------> ADC2_IN8
*/
GPIO_InitStruct.Pin = GPIO_PIN_3;
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

/* USER CODE BEGIN ADC2_MspInit 1 */

/* USER CODE END ADC2_MspInit 1 */
Expand Down Expand Up @@ -244,6 +254,12 @@ void HAL_ADC_MspDeInit(ADC_HandleTypeDef* adcHandle)
if(HAL_RCC_ADC12_CLK_ENABLED==0){
__HAL_RCC_ADC12_CLK_DISABLE();
}

/**ADC2 GPIO Configuration
PA3 ------> ADC2_IN8
*/
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_3);

/* USER CODE BEGIN ADC2_MspDeInit 1 */

/* USER CODE END ADC2_MspDeInit 1 */
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
37 changes: 34 additions & 3 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 All @@ -39,12 +40,20 @@ void MX_DMA2D_Init(void)
/* USER CODE END DMA2D_Init 1 */
hdma2d.Instance = DMA2D;
hdma2d.Init.Mode = DMA2D_M2M;
hdma2d.Init.ColorMode = DMA2D_OUTPUT_RGB565;
hdma2d.Init.ColorMode = DMA2D_OUTPUT_RGB565; /* LCD is RGB565 */
hdma2d.Init.OutputOffset = 0;
hdma2d.Init.BytesSwap = DMA2D_BYTES_REGULAR;
hdma2d.Init.LineOffsetMode = DMA2D_LOM_PIXELS;
hdma2d.LayerCfg[1].InputOffset = 0;
#if LV_COLOR_DEPTH == 32
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we editing a generated file? If so, can we change this setting in an LVGL file later?

hdma2d.LayerCfg[1].InputColorMode = DMA2D_INPUT_ARGB8888;
#elif LV_COLOR_DEPTH == 24
hdma2d.LayerCfg[1].InputColorMode = DMA2D_INPUT_RGB888;
#elif LV_COLOR_DEPTH == 16
hdma2d.LayerCfg[1].InputColorMode = DMA2D_INPUT_RGB565;
#elif LV_COLOR_DEPTH == 8
hdma2d.LayerCfg[1].InputColorMode = DMA2D_INPUT_L8;
#endif
hdma2d.LayerCfg[1].AlphaMode = DMA2D_NO_MODIF_ALPHA;
hdma2d.LayerCfg[1].InputAlpha = 0;
hdma2d.LayerCfg[1].AlphaInverted = DMA2D_REGULAR_ALPHA;
Expand All @@ -57,6 +66,26 @@ void MX_DMA2D_Init(void)
{
Error_Handler();
}

#if LV_COLOR_DEPTH == 8
uint8_t clut[256 * 3]; /* assuming the stack is large enough */
for(uint32_t i = 0; i < 256; i++) {
clut[i * 3] = i;
clut[i * 3 + 1] = i;
clut[i * 3 + 2] = i;
}
DMA2D_CLUTCfgTypeDef clut_cfg = {.pCLUT=(uint32_t *)clut,
.CLUTColorMode=DMA2D_CCM_RGB888,
.Size=0xff};
if (HAL_DMA2D_CLUTStartLoad(&hdma2d, &clut_cfg, 1) != HAL_OK)
{
Error_Handler();
}
if (HAL_DMA2D_PollForTransfer(&hdma2d, HAL_MAX_DELAY) != HAL_OK)
{
Error_Handler();
}
#endif
/* USER CODE BEGIN DMA2D_Init 2 */

/* USER CODE END DMA2D_Init 2 */
Expand All @@ -73,8 +102,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
54 changes: 43 additions & 11 deletions Core/Src/gpio.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 @@ -42,6 +42,8 @@
PC15-OSC32_OUT (PC15) ------> RCC_OSC32_OUT
PA13 (JTMS/SWDIO) ------> DEBUG_JTMS-SWDIO
PA10 ------> USB_OTG_HS_ID
PB3 (JTDO/TRACESWO) ------> DEBUG_JTDO-SWO
PA9 ------> USB_OTG_HS_VBUS
PH0-OSC_IN (PH0) ------> RCC_OSC_IN
*/
void MX_GPIO_Init(void)
Expand All @@ -67,12 +69,21 @@ void MX_GPIO_Init(void)
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(CTP_RST_GPIO_Port, CTP_RST_Pin, GPIO_PIN_RESET);

/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOI, GPIO_PIN_6, GPIO_PIN_RESET);

/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOG, USB_PWR_EN_Pin|R_CS_Pin, GPIO_PIN_RESET);

/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(R_RST_GPIO_Port, R_RST_Pin, GPIO_PIN_RESET);

/*Configure GPIO pin : PA15 */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file should be reverted.

GPIO_InitStruct.Pin = GPIO_PIN_15;
GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

/*Configure GPIO pin : PA8 */
GPIO_InitStruct.Pin = GPIO_PIN_8;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
Expand All @@ -81,6 +92,12 @@ void MX_GPIO_Init(void)
GPIO_InitStruct.Alternate = GPIO_AF0_MCO;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

/*Configure GPIO pin : PH3 */
GPIO_InitStruct.Pin = GPIO_PIN_3;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOH, &GPIO_InitStruct);

/*Configure GPIO pin : PtPin */
GPIO_InitStruct.Pin = LCD_DISP_RESET_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
Expand All @@ -102,6 +119,19 @@ void MX_GPIO_Init(void)
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(CTP_RST_GPIO_Port, &GPIO_InitStruct);

/*Configure GPIO pins : PJPin PJPin */
// GPIO_InitStruct.Pin = USR_BTN_1_Pin|USB_OVERCURRENT_Pin;
// GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
// GPIO_InitStruct.Pull = GPIO_NOPULL;
// HAL_GPIO_Init(GPIOJ, &GPIO_InitStruct);

/*Configure GPIO pin : PI6 */
GPIO_InitStruct.Pin = GPIO_PIN_6;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOI, &GPIO_InitStruct);

/*Configure GPIO pin : PA10 */
GPIO_InitStruct.Pin = GPIO_PIN_10;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
Expand All @@ -116,36 +146,38 @@ void MX_GPIO_Init(void)
GPIO_InitStruct.Pull = GPIO_PULLUP;
HAL_GPIO_Init(CTP_INT_GPIO_Port, &GPIO_InitStruct);

/*Configure GPIO pin : PA9 */
GPIO_InitStruct.Pin = GPIO_PIN_9;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

/*Configure GPIO pins : PGPin PGPin */
GPIO_InitStruct.Pin = USB_PWR_EN_Pin|R_CS_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);

/*Configure GPIO pin : PtPin */
GPIO_InitStruct.Pin = USB_OVERCURRENT_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(USB_OVERCURRENT_GPIO_Port, &GPIO_InitStruct);

/*Configure GPIO pin : PtPin */
GPIO_InitStruct.Pin = R_RST_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_PULLDOWN;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(R_RST_GPIO_Port, &GPIO_InitStruct);

/*Configure GPIO pin : PH11 */
GPIO_InitStruct.Pin = GPIO_PIN_11;
GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOH, &GPIO_InitStruct);

/*Configure GPIO pin : PtPin */
GPIO_InitStruct.Pin = R_INT_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(R_INT_GPIO_Port, &GPIO_InitStruct);

/* EXTI interrupt init*/
HAL_NVIC_SetPriority(EXTI6_IRQn, 5, 0);
HAL_NVIC_EnableIRQ(EXTI6_IRQn);

}

/* USER CODE BEGIN 2 */
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
19 changes: 6 additions & 13 deletions Core/Src/i2c.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 @@ -246,23 +246,16 @@ void HAL_I2C_MspInit(I2C_HandleTypeDef* i2cHandle)

__HAL_RCC_GPIOB_CLK_ENABLE();
/**I2C4 GPIO Configuration
PB7 ------> I2C4_SDA
PB6 ------> I2C4_SCL
PB11 ------> I2C4_SDA
*/
GPIO_InitStruct.Pin = GPIO_PIN_6;
GPIO_InitStruct.Pin = GPIO_PIN_7|GPIO_PIN_6;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file should be reverted.

GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF5_I2C4;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);

GPIO_InitStruct.Pin = GPIO_PIN_11;
GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF3_I2C4;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);

/* I2C4 clock enable */
__HAL_RCC_I2C4_CLK_ENABLE();
/* USER CODE BEGIN I2C4_MspInit 1 */
Expand Down Expand Up @@ -323,12 +316,12 @@ void HAL_I2C_MspDeInit(I2C_HandleTypeDef* i2cHandle)
__HAL_RCC_I2C4_CLK_DISABLE();

/**I2C4 GPIO Configuration
PB7 ------> I2C4_SDA
PB6 ------> I2C4_SCL
PB11 ------> I2C4_SDA
*/
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_6);
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_7);

HAL_GPIO_DeInit(GPIOB, GPIO_PIN_11);
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_6);

/* USER CODE BEGIN I2C4_MspDeInit 1 */

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
Loading