STM32H750 LTDC ATK-4342 RGBLCD

/* USER CODE BEGIN Header */
/**
  ******************************************************************************
  * @file           : main.c
  * @brief          : Main program body
  ******************************************************************************
  * @attention
  *
  * 

© Copyright (c) 2022 STMicroelectronics. * All rights reserved.

* * This software component is licensed by ST under BSD 3-Clause license, * the "License"; You may not use this file except in compliance with the * License. You may obtain a copy of the License at: * opensource.org/licenses/BSD-3-Clause * ****************************************************************************** */ /* USER CODE END Header */ /* Includes ------------------------------------------------------------------*/ #include "main.h" /* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ #include "bsp_delay.h" #include "bsp_sdram.h" #include "bsp_lcd.h" /* USER CODE END Includes */ /* Private typedef -----------------------------------------------------------*/ /* USER CODE BEGIN PTD */ /* USER CODE END PTD */ /* Private define ------------------------------------------------------------*/ /* USER CODE BEGIN PD */ /* USER CODE END PD */ /* Private macro -------------------------------------------------------------*/ /* USER CODE BEGIN PM */ /* USER CODE END PM */ /* Private variables ---------------------------------------------------------*/ LTDC_HandleTypeDef hltdc; SDRAM_HandleTypeDef hsdram1; /* USER CODE BEGIN PV */ /* USER CODE END PV */ /* Private function prototypes -----------------------------------------------*/ void SystemClock_Config(void); static void MX_GPIO_Init(void); static void MX_FMC_Init(void); static void MX_LTDC_Init(void); /* USER CODE BEGIN PFP */ /* USER CODE END PFP */ /* Private user code ---------------------------------------------------------*/ /* USER CODE BEGIN 0 */ /* USER CODE END 0 */ /** * @brief The application entry point. * @retval int */ int main(void) { /* USER CODE BEGIN 1 */ /* USER CODE END 1 */ /* MCU Configuration--------------------------------------------------------*/ /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ HAL_Init(); /* USER CODE BEGIN Init */ /* USER CODE END Init */ /* Configure the system clock */ SystemClock_Config(); /* USER CODE BEGIN SysInit */ /* USER CODE END SysInit */ /* Initialize all configured peripherals */ MX_GPIO_Init(); MX_FMC_Init(); MX_LTDC_Init(); /* USER CODE BEGIN 2 */ delay_init(400); Sdram_Init_Sequence(); uint8_t x=0; lcd_init(); /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ while (1) { switch(x) { case 0:LTDC_Clear(WHITE);break; case 1:LTDC_Clear(BLACK);break; case 2:LTDC_Clear(BLUE);break; case 3:LTDC_Clear(RED);break; case 4:LTDC_Clear(MAGENTA);break; case 5:LTDC_Clear(GREEN);break; case 6:LTDC_Clear(CYAN);break; case 7:LTDC_Clear(YELLOW);break; case 8:LTDC_Clear(BRRED);break; case 9:LTDC_Clear(GRAY);break; case 10:LTDC_Clear(LGRAY);break; case 11:LTDC_Clear(BROWN);break; } POINT_COLOR=RED; LCD_ShowString(10,40,260,32,32,"Apollo STM32F4/F7"); LCD_ShowString(10,80,240,24,24,"LTDC TEST"); LCD_ShowString(10,110,240,16,16,"ATOM@ALIENTEK"); LCD_ShowString(10,150,240,12,12,"2016/7/12"); x++; if(x==12)x=0; delay_ms(1000); HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_0); /* USER CODE END WHILE */ /* USER CODE BEGIN 3 */ } /* USER CODE END 3 */ } /** * @brief System Clock Configuration * @retval None */ void SystemClock_Config(void) { RCC_OscInitTypeDef RCC_OscInitStruct = {0}; RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; /** Supply configuration update enable */ HAL_PWREx_ConfigSupply(PWR_LDO_SUPPLY); /** Configure the main internal regulator output voltage */ __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); while(!__HAL_PWR_GET_FLAG(PWR_FLAG_VOSRDY)) {} /** Macro to configure the PLL clock source */ __HAL_RCC_PLL_PLLSOURCE_CONFIG(RCC_PLLSOURCE_HSE); /** Initializes the RCC Oscillators according to the specified parameters * in the RCC_OscInitTypeDef structure. */ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; RCC_OscInitStruct.HSEState = RCC_HSE_ON; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; RCC_OscInitStruct.PLL.PLLM = 5; RCC_OscInitStruct.PLL.PLLN = 160; RCC_OscInitStruct.PLL.PLLP = 2; RCC_OscInitStruct.PLL.PLLQ = 4; RCC_OscInitStruct.PLL.PLLR = 2; RCC_OscInitStruct.PLL.PLLRGE = RCC_PLL1VCIRANGE_2; RCC_OscInitStruct.PLL.PLLVCOSEL = RCC_PLL1VCOWIDE; RCC_OscInitStruct.PLL.PLLFRACN = 0; if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { Error_Handler(); } /** Initializes the CPU, AHB and APB buses clocks */ RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2 |RCC_CLOCKTYPE_D3PCLK1|RCC_CLOCKTYPE_D1PCLK1; RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; RCC_ClkInitStruct.SYSCLKDivider = RCC_SYSCLK_DIV1; RCC_ClkInitStruct.AHBCLKDivider = RCC_HCLK_DIV2; RCC_ClkInitStruct.APB3CLKDivider = RCC_APB3_DIV2; RCC_ClkInitStruct.APB1CLKDivider = RCC_APB1_DIV2; RCC_ClkInitStruct.APB2CLKDivider = RCC_APB2_DIV2; RCC_ClkInitStruct.APB4CLKDivider = RCC_APB4_DIV4; if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK) { Error_Handler(); } } /** * @brief LTDC Initialization Function * @param None * @retval None */ static void MX_LTDC_Init(void) { /* USER CODE BEGIN LTDC_Init 0 */ /* USER CODE END LTDC_Init 0 */ LTDC_LayerCfgTypeDef pLayerCfg = {0}; /* USER CODE BEGIN LTDC_Init 1 */ /* USER CODE END LTDC_Init 1 */ hltdc.Instance = LTDC; hltdc.Init.HSPolarity = LTDC_HSPOLARITY_AL; hltdc.Init.VSPolarity = LTDC_VSPOLARITY_AL; hltdc.Init.DEPolarity = LTDC_DEPOLARITY_AL; hltdc.Init.PCPolarity = LTDC_PCPOLARITY_IPC; hltdc.Init.HorizontalSync = 0; hltdc.Init.VerticalSync = 0; hltdc.Init.AccumulatedHBP = 40; hltdc.Init.AccumulatedVBP = 8; hltdc.Init.AccumulatedActiveW = 520; hltdc.Init.AccumulatedActiveH = 280; hltdc.Init.TotalWidth = 525; hltdc.Init.TotalHeigh = 288; hltdc.Init.Backcolor.Blue = 0; hltdc.Init.Backcolor.Green = 0; hltdc.Init.Backcolor.Red = 0; if (HAL_LTDC_Init(&hltdc) != HAL_OK) { Error_Handler(); } pLayerCfg.WindowX0 = 0; pLayerCfg.WindowX1 = 480; pLayerCfg.WindowY0 = 0; pLayerCfg.WindowY1 = 272; pLayerCfg.PixelFormat = LTDC_PIXEL_FORMAT_RGB565; pLayerCfg.Alpha = 255; pLayerCfg.Alpha0 = 0; pLayerCfg.BlendingFactor1 = LTDC_BLENDING_FACTOR1_PAxCA; pLayerCfg.BlendingFactor2 = LTDC_BLENDING_FACTOR2_PAxCA; pLayerCfg.FBStartAdress = 0xc0000000; pLayerCfg.ImageWidth = 480; pLayerCfg.ImageHeight = 272; pLayerCfg.Backcolor.Blue = 0; pLayerCfg.Backcolor.Green = 0; pLayerCfg.Backcolor.Red = 0; if (HAL_LTDC_ConfigLayer(&hltdc, &pLayerCfg, 0) != HAL_OK) { Error_Handler(); } /* USER CODE BEGIN LTDC_Init 2 */ /* USER CODE END LTDC_Init 2 */ } /* FMC initialization function */ static void MX_FMC_Init(void) { /* USER CODE BEGIN FMC_Init 0 */ /* USER CODE END FMC_Init 0 */ FMC_SDRAM_TimingTypeDef SdramTiming = {0}; /* USER CODE BEGIN FMC_Init 1 */ /* USER CODE END FMC_Init 1 */ /** Perform the SDRAM1 memory initialization sequence */ hsdram1.Instance = FMC_SDRAM_DEVICE; /* hsdram1.Init */ hsdram1.Init.SDBank = FMC_SDRAM_BANK1; hsdram1.Init.ColumnBitsNumber = FMC_SDRAM_COLUMN_BITS_NUM_9; hsdram1.Init.RowBitsNumber = FMC_SDRAM_ROW_BITS_NUM_13; hsdram1.Init.MemoryDataWidth = FMC_SDRAM_MEM_BUS_WIDTH_32; hsdram1.Init.InternalBankNumber = FMC_SDRAM_INTERN_BANKS_NUM_4; hsdram1.Init.CASLatency = FMC_SDRAM_CAS_LATENCY_3; hsdram1.Init.WriteProtection = FMC_SDRAM_WRITE_PROTECTION_DISABLE; hsdram1.Init.SDClockPeriod = FMC_SDRAM_CLOCK_PERIOD_2; hsdram1.Init.ReadBurst = FMC_SDRAM_RBURST_ENABLE; hsdram1.Init.ReadPipeDelay = FMC_SDRAM_RPIPE_DELAY_0; /* SdramTiming */ SdramTiming.LoadToActiveDelay = 3; SdramTiming.ExitSelfRefreshDelay = 8; SdramTiming.SelfRefreshTime = 5; SdramTiming.RowCycleDelay = 7; SdramTiming.WriteRecoveryTime = 3; SdramTiming.RPDelay = 2; SdramTiming.RCDDelay = 2; if (HAL_SDRAM_Init(&hsdram1, &SdramTiming) != HAL_OK) { Error_Handler( ); } /* USER CODE BEGIN FMC_Init 2 */ /* USER CODE END FMC_Init 2 */ } /** * @brief GPIO Initialization Function * @param None * @retval None */ static void MX_GPIO_Init(void) { GPIO_InitTypeDef GPIO_InitStruct = {0}; /* GPIO Ports Clock Enable */ __HAL_RCC_GPIOI_CLK_ENABLE(); __HAL_RCC_GPIOB_CLK_ENABLE(); __HAL_RCC_GPIOK_CLK_ENABLE(); __HAL_RCC_GPIOE_CLK_ENABLE(); __HAL_RCC_GPIOJ_CLK_ENABLE(); __HAL_RCC_GPIOA_CLK_ENABLE(); __HAL_RCC_GPIOH_CLK_ENABLE(); __HAL_RCC_GPIOC_CLK_ENABLE(); __HAL_RCC_GPIOG_CLK_ENABLE(); __HAL_RCC_GPIOD_CLK_ENABLE(); __HAL_RCC_GPIOF_CLK_ENABLE(); /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(GPIOB, GPIO_PIN_5|GPIO_PIN_0, GPIO_PIN_RESET); /*Configure GPIO pin : PB5 */ GPIO_InitStruct.Pin = GPIO_PIN_5; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); /*Configure GPIO pins : PF6 PF7 */ GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_7; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_PULLUP; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; GPIO_InitStruct.Alternate = GPIO_AF9_QUADSPI; HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); /*Configure GPIO pins : PF8 PF9 */ GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_9; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_PULLUP; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; GPIO_InitStruct.Alternate = GPIO_AF10_QUADSPI; HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); /*Configure GPIO pin : PB2 */ GPIO_InitStruct.Pin = GPIO_PIN_2; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_PULLUP; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; GPIO_InitStruct.Alternate = GPIO_AF9_QUADSPI; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); /*Configure GPIO pin : PB0 */ GPIO_InitStruct.Pin = GPIO_PIN_0; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); } /* USER CODE BEGIN 4 */ /* USER CODE END 4 */ /** * @brief This function is executed in case of error occurrence. * @retval None */ void Error_Handler(void) { /* USER CODE BEGIN Error_Handler_Debug */ /* User can add his own implementation to report the HAL error return state */ __disable_irq(); while (1) { } /* USER CODE END Error_Handler_Debug */ } #ifdef USE_FULL_ASSERT /** * @brief Reports the name of the source file and the source line number * where the assert_param error has occurred. * @param file: pointer to the source file name * @param line: assert_param error line source number * @retval None */ void assert_failed(uint8_t *file, uint32_t line) { /* USER CODE BEGIN 6 */ /* User can add his own implementation to report the file name and line number, ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ /* USER CODE END 6 */ } #endif /* USE_FULL_ASSERT */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
#ifndef __BSP_LCD_H
#define __BSP_LCD_H

#ifdef __cplusplus
extern "C" {
#endif

#include "main.h"

#define LCD_WIDTH 480
#define LCD_HEIGHT 272

extern uint16_t FBuffer[LCD_WIDTH*LCD_HEIGHT];
extern uint32_t POINT_COLOR;		//画笔颜色
extern uint32_t BACK_COLOR;  	//背景色 

//画笔颜色
#define WHITE			0xFFFF
#define BLACK			0x0000	  
#define BLUE			0x001F  
#define BRED			0XF81F
#define GRED			0XFFE0
#define GBLUE			0X07FF
#define RED				0xF800
#define MAGENTA		0xF81F
#define GREEN			0x07E0
#define CYAN			0x7FFF
#define YELLOW		0xFFE0
#define BROWN			0XBC40 //棕色
#define BRRED			0XFC07 //棕红色
#define GRAY			0X8430 //灰色
#define LGRAY			0XC618 //浅灰色(PANNEL),窗体背景色

void lcd_init(void);
void LTDC_Draw_Point(uint16_t x,uint16_t y,uint32_t color);
void LCD_ShowChar(uint16_t x, uint16_t y, uint8_t num, uint8_t size, uint8_t mode);
void LCD_ShowString(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint8_t size, uint8_t *p);
void LTDC_Clear(uint32_t color);
void LTDC_Fill(uint16_t sx, uint16_t sy, uint16_t ex, uint16_t ey, uint32_t color);
void LCD_ShowNum(uint16_t x,uint16_t y,uint32_t num,uint8_t len,uint8_t size);
uint32_t LCD_Pow(uint8_t m,uint8_t n);
void LCD_Set_Dir(uint8_t dir);

#ifdef __cplusplus
}
#endif

#endif /* __BSP_LCD_H */



#include "bsp_lcd.h"
#include "bsp_font.h"

uint16_t FBuffer[LCD_WIDTH*LCD_HEIGHT] __attribute__((at(0xC0000000)));
uint32_t POINT_COLOR;		//画笔颜色
uint32_t BACK_COLOR;  	//背景色 

uint8_t lcd_dir = 0;//0:横屏、1:竖屏

void lcd_init(void)
{
	HAL_GPIO_WritePin(GPIOB, GPIO_PIN_5, GPIO_PIN_SET);
	LCD_Set_Dir(1);
}

//画点函数
//x,y:坐标
//color:颜色值
void LTDC_Draw_Point(uint16_t x,uint16_t y,uint32_t color)
{ 
	uint16_t dev_x, dev_y;
	
	if(lcd_dir)//竖屏
	{
		dev_x = y;
		dev_y = LCD_HEIGHT - 1 - x;
	}
	else//横屏
	{
		dev_x = x;
		dev_y = y;
	}
	if((dev_y < LCD_HEIGHT) && (dev_x < LCD_WIDTH)) FBuffer[dev_y * LCD_WIDTH + dev_x]=color; 
}

//在指定位置显示一个字符
//x,y:起始坐标
//num:要显示的字符:" "--->"~"
//size:字体大小 12/16/24/32
//mode:叠加方式(1)还是非叠加方式(0)
void LCD_ShowChar(uint16_t x, uint16_t y, uint8_t num, uint8_t size, uint8_t mode)
{  							  
  uint8_t temp,t1,t;
	uint16_t y0=y;
	uint8_t csize=(size/8+((size%8)?1:0))*(size/2);		//得到字体一个字符对应点阵集所占的字节数	
 	num=num-' ';//得到偏移后的值(ASCII字库是从空格开始取模,所以-' '就是对应字符的字库)
	for(t=0;t=LCD_HEIGHT)return;		//超区域了
			if((y-y0)==size)
			{
				y=y0;
				x++;
				if(x>=LCD_WIDTH)return;	//超区域了
				break;
			}
		}  	 
	}  	    	   	 	  
}   

//显示字符串
//x,y:起点坐标
//width,height:区域大小  
//size:字体大小
//*p:字符串起始地址		  
void LCD_ShowString(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint8_t size, uint8_t *p)
{         
	uint8_t x0=x;
	width+=x;
	height+=y;
	while((*p<='~')&&(*p>=' '))//判断是不是非法字符!
	{       
		if(x>=width){x=x0;y+=size;}
		if(y>=height)break;//退出
		LCD_ShowChar(x,y,*p,size,0);
		x+=size/2;
		p++;
	}  
}

//LCD清屏
//color:颜色值
void LTDC_Clear(uint32_t color)
{
	if(lcd_dir)//竖屏
	{
		LTDC_Fill(0,0,LCD_HEIGHT-1,LCD_WIDTH-1,color);
	}
	else//横屏
	{
		LTDC_Fill(0,0,LCD_WIDTH-1,LCD_HEIGHT-1,color);
	}
	
	
//	HAL_DMA2D_Start(&hdma2d, color, (uint32_t)FBuffer, LCD_WIDTH, LCD_HEIGHT); 
//	HAL_DMA2D_PollForTransfer(&hdma2d, 0X1FFFFF);
}

//(sx,sy),(ex,ey):填充矩形对角坐标,区域大小为:(ex-sx+1)*(ey-sy+1)   
//注意:sx,ex,不能大于lcddev.width-1;sy,ey,不能大于lcddev.height-1!!!
//color:要填充的颜色
void LTDC_Fill(uint16_t sx, uint16_t sy, uint16_t ex, uint16_t ey, uint32_t color)
{ 
 
	uint16_t i,j;
	for(j = sy; j <= ey; j++)
	{
		for(i = sx; i <= ex; i++)
		{
			LTDC_Draw_Point(i, j, color);
		}
	}
}

//显示数字,高位为0,则不显示
//x,y :起点坐标	 
//len :数字的位数
//size:字体大小
//color:颜色 
//num:数值(0~4294967295);	 
void LCD_ShowNum(uint16_t x,uint16_t y,uint32_t num,uint8_t len,uint8_t size)
{         	
	uint8_t t,temp;
	uint8_t enshow=0;						   
	for(t=0;t
/* USER CODE BEGIN Header */
/**
  ******************************************************************************
  * @file         stm32h7xx_hal_msp.c
  * @brief        This file provides code for the MSP Initialization
  *               and de-Initialization codes.
  ******************************************************************************
  * @attention
  *
  * 

© Copyright (c) 2022 STMicroelectronics. * All rights reserved.

* * This software component is licensed by ST under BSD 3-Clause license, * the "License"; You may not use this file except in compliance with the * License. You may obtain a copy of the License at: * opensource.org/licenses/BSD-3-Clause * ****************************************************************************** */ /* USER CODE END Header */ /* Includes ------------------------------------------------------------------*/ #include "main.h" /* USER CODE BEGIN Includes */ /* USER CODE END Includes */ /* Private typedef -----------------------------------------------------------*/ /* USER CODE BEGIN TD */ /* USER CODE END TD */ /* Private define ------------------------------------------------------------*/ /* USER CODE BEGIN Define */ /* USER CODE END Define */ /* Private macro -------------------------------------------------------------*/ /* USER CODE BEGIN Macro */ /* USER CODE END Macro */ /* Private variables ---------------------------------------------------------*/ /* USER CODE BEGIN PV */ /* USER CODE END PV */ /* Private function prototypes -----------------------------------------------*/ /* USER CODE BEGIN PFP */ /* USER CODE END PFP */ /* External functions --------------------------------------------------------*/ /* USER CODE BEGIN ExternalFunctions */ /* USER CODE END ExternalFunctions */ /* USER CODE BEGIN 0 */ /* USER CODE END 0 */ /** * Initializes the Global MSP. */ void HAL_MspInit(void) { /* USER CODE BEGIN MspInit 0 */ /* USER CODE END MspInit 0 */ __HAL_RCC_SYSCFG_CLK_ENABLE(); /* System interrupt init*/ /* USER CODE BEGIN MspInit 1 */ /* USER CODE END MspInit 1 */ } /** * @brief LTDC MSP Initialization * This function configures the hardware resources used in this example * @param hltdc: LTDC handle pointer * @retval None */ void HAL_LTDC_MspInit(LTDC_HandleTypeDef* hltdc) { GPIO_InitTypeDef GPIO_InitStruct = {0}; RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; if(hltdc->Instance==LTDC) { /* USER CODE BEGIN LTDC_MspInit 0 */ /* USER CODE END LTDC_MspInit 0 */ /** Initializes the peripherals clock */ PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LTDC; PeriphClkInitStruct.PLL3.PLL3M = 25; PeriphClkInitStruct.PLL3.PLL3N = 288; PeriphClkInitStruct.PLL3.PLL3P = 2; PeriphClkInitStruct.PLL3.PLL3Q = 2; PeriphClkInitStruct.PLL3.PLL3R = 32; PeriphClkInitStruct.PLL3.PLL3RGE = RCC_PLL3VCIRANGE_0; PeriphClkInitStruct.PLL3.PLL3VCOSEL = RCC_PLL3VCOWIDE; PeriphClkInitStruct.PLL3.PLL3FRACN = 0; if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) { Error_Handler(); } /* Peripheral clock enable */ __HAL_RCC_LTDC_CLK_ENABLE(); __HAL_RCC_GPIOK_CLK_ENABLE(); __HAL_RCC_GPIOJ_CLK_ENABLE(); __HAL_RCC_GPIOI_CLK_ENABLE(); /**LTDC GPIO Configuration PK5 ------> LTDC_B6 PK4 ------> LTDC_B5 PJ15 ------> LTDC_B3 PK6 ------> LTDC_B7 PK3 ------> LTDC_B4 PK7 ------> LTDC_DE PI12 ------> LTDC_HSYNC PI13 ------> LTDC_VSYNC PI14 ------> LTDC_CLK PK2 ------> LTDC_G7 PK0 ------> LTDC_G5 PK1 ------> LTDC_G6 PJ11 ------> LTDC_G4 PJ10 ------> LTDC_G3 PJ9 ------> LTDC_G2 PJ6 ------> LTDC_R7 PJ5 ------> LTDC_R6 PJ2 ------> LTDC_R3 PJ3 ------> LTDC_R4 PJ4 ------> LTDC_R5 */ GPIO_InitStruct.Pin = GPIO_PIN_5|GPIO_PIN_4|GPIO_PIN_6|GPIO_PIN_3 |GPIO_PIN_7|GPIO_PIN_2|GPIO_PIN_0|GPIO_PIN_1; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; GPIO_InitStruct.Alternate = GPIO_AF14_LTDC; HAL_GPIO_Init(GPIOK, &GPIO_InitStruct); GPIO_InitStruct.Pin = GPIO_PIN_15|GPIO_PIN_11|GPIO_PIN_10|GPIO_PIN_9 |GPIO_PIN_6|GPIO_PIN_5|GPIO_PIN_2|GPIO_PIN_3 |GPIO_PIN_4; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; GPIO_InitStruct.Alternate = GPIO_AF14_LTDC; HAL_GPIO_Init(GPIOJ, &GPIO_InitStruct); GPIO_InitStruct.Pin = GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; GPIO_InitStruct.Alternate = GPIO_AF14_LTDC; HAL_GPIO_Init(GPIOI, &GPIO_InitStruct); /* USER CODE BEGIN LTDC_MspInit 1 */ /* USER CODE END LTDC_MspInit 1 */ } } /** * @brief LTDC MSP De-Initialization * This function freeze the hardware resources used in this example * @param hltdc: LTDC handle pointer * @retval None */ void HAL_LTDC_MspDeInit(LTDC_HandleTypeDef* hltdc) { if(hltdc->Instance==LTDC) { /* USER CODE BEGIN LTDC_MspDeInit 0 */ /* USER CODE END LTDC_MspDeInit 0 */ /* Peripheral clock disable */ __HAL_RCC_LTDC_CLK_DISABLE(); /**LTDC GPIO Configuration PK5 ------> LTDC_B6 PK4 ------> LTDC_B5 PJ15 ------> LTDC_B3 PK6 ------> LTDC_B7 PK3 ------> LTDC_B4 PK7 ------> LTDC_DE PI12 ------> LTDC_HSYNC PI13 ------> LTDC_VSYNC PI14 ------> LTDC_CLK PK2 ------> LTDC_G7 PK0 ------> LTDC_G5 PK1 ------> LTDC_G6 PJ11 ------> LTDC_G4 PJ10 ------> LTDC_G3 PJ9 ------> LTDC_G2 PJ6 ------> LTDC_R7 PJ5 ------> LTDC_R6 PJ2 ------> LTDC_R3 PJ3 ------> LTDC_R4 PJ4 ------> LTDC_R5 */ HAL_GPIO_DeInit(GPIOK, GPIO_PIN_5|GPIO_PIN_4|GPIO_PIN_6|GPIO_PIN_3 |GPIO_PIN_7|GPIO_PIN_2|GPIO_PIN_0|GPIO_PIN_1); HAL_GPIO_DeInit(GPIOJ, GPIO_PIN_15|GPIO_PIN_11|GPIO_PIN_10|GPIO_PIN_9 |GPIO_PIN_6|GPIO_PIN_5|GPIO_PIN_2|GPIO_PIN_3 |GPIO_PIN_4); HAL_GPIO_DeInit(GPIOI, GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14); /* USER CODE BEGIN LTDC_MspDeInit 1 */ /* USER CODE END LTDC_MspDeInit 1 */ } } static uint32_t FMC_Initialized = 0; static void HAL_FMC_MspInit(void){ /* USER CODE BEGIN FMC_MspInit 0 */ /* USER CODE END FMC_MspInit 0 */ GPIO_InitTypeDef GPIO_InitStruct ={0}; if (FMC_Initialized) { return; } FMC_Initialized = 1; RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; /** Initializes the peripherals clock */ PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_FMC; PeriphClkInitStruct.FmcClockSelection = RCC_FMCCLKSOURCE_D1HCLK; if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) { Error_Handler(); } /* Peripheral clock enable */ __HAL_RCC_FMC_CLK_ENABLE(); /** FMC GPIO Configuration PI6 ------> FMC_D28 PI5 ------> FMC_NBL3 PI4 ------> FMC_NBL2 PI1 ------> FMC_D25 PI0 ------> FMC_D24 PI7 ------> FMC_D29 PE1 ------> FMC_NBL1 PI2 ------> FMC_D26 PH15 ------> FMC_D23 PH14 ------> FMC_D22 PE0 ------> FMC_NBL0 PI3 ------> FMC_D27 PG15 ------> FMC_SDNCAS PD0 ------> FMC_D2 PH13 ------> FMC_D21 PI9 ------> FMC_D30 PD1 ------> FMC_D3 PI10 ------> FMC_D31 PG8 ------> FMC_SDCLK PF2 ------> FMC_A2 PF1 ------> FMC_A1 PF0 ------> FMC_A0 PG5 ------> FMC_BA1 PF3 ------> FMC_A3 PG4 ------> FMC_BA0 PG2 ------> FMC_A12 PF5 ------> FMC_A5 PF4 ------> FMC_A4 PC0 ------> FMC_SDNWE PC2 ------> FMC_SDNE0 PC3 ------> FMC_SDCKE0 PE10 ------> FMC_D7 PF13 ------> FMC_A7 PF14 ------> FMC_A8 PE9 ------> FMC_D6 PE11 ------> FMC_D8 PH10 ------> FMC_D18 PH11 ------> FMC_D19 PD15 ------> FMC_D1 PD14 ------> FMC_D0 PF12 ------> FMC_A6 PF15 ------> FMC_A9 PE12 ------> FMC_D9 PE15 ------> FMC_D12 PH9 ------> FMC_D17 PH12 ------> FMC_D20 PF11 ------> FMC_SDNRAS PG0 ------> FMC_A10 PE8 ------> FMC_D5 PE13 ------> FMC_D10 PH8 ------> FMC_D16 PD10 ------> FMC_D15 PD9 ------> FMC_D14 PG1 ------> FMC_A11 PE7 ------> FMC_D4 PE14 ------> FMC_D11 PD8 ------> FMC_D13 */ GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_5|GPIO_PIN_4|GPIO_PIN_1 |GPIO_PIN_0|GPIO_PIN_7|GPIO_PIN_2|GPIO_PIN_3 |GPIO_PIN_9|GPIO_PIN_10; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; GPIO_InitStruct.Alternate = GPIO_AF12_FMC; HAL_GPIO_Init(GPIOI, &GPIO_InitStruct); GPIO_InitStruct.Pin = GPIO_PIN_1|GPIO_PIN_0|GPIO_PIN_10|GPIO_PIN_9 |GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_15|GPIO_PIN_8 |GPIO_PIN_13|GPIO_PIN_7|GPIO_PIN_14; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; GPIO_InitStruct.Alternate = GPIO_AF12_FMC; HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); GPIO_InitStruct.Pin = GPIO_PIN_15|GPIO_PIN_14|GPIO_PIN_13|GPIO_PIN_10 |GPIO_PIN_11|GPIO_PIN_9|GPIO_PIN_12|GPIO_PIN_8; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; GPIO_InitStruct.Alternate = GPIO_AF12_FMC; HAL_GPIO_Init(GPIOH, &GPIO_InitStruct); GPIO_InitStruct.Pin = GPIO_PIN_15|GPIO_PIN_8|GPIO_PIN_5|GPIO_PIN_4 |GPIO_PIN_2|GPIO_PIN_0|GPIO_PIN_1; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; GPIO_InitStruct.Alternate = GPIO_AF12_FMC; HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_15|GPIO_PIN_14 |GPIO_PIN_10|GPIO_PIN_9|GPIO_PIN_8; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; GPIO_InitStruct.Alternate = GPIO_AF12_FMC; HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); GPIO_InitStruct.Pin = GPIO_PIN_2|GPIO_PIN_1|GPIO_PIN_0|GPIO_PIN_3 |GPIO_PIN_5|GPIO_PIN_4|GPIO_PIN_13|GPIO_PIN_14 |GPIO_PIN_12|GPIO_PIN_15|GPIO_PIN_11; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; GPIO_InitStruct.Alternate = GPIO_AF12_FMC; HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_2|GPIO_PIN_3; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; GPIO_InitStruct.Alternate = GPIO_AF12_FMC; HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); /* USER CODE BEGIN FMC_MspInit 1 */ /* USER CODE END FMC_MspInit 1 */ } void HAL_SDRAM_MspInit(SDRAM_HandleTypeDef* hsdram){ /* USER CODE BEGIN SDRAM_MspInit 0 */ /* USER CODE END SDRAM_MspInit 0 */ HAL_FMC_MspInit(); /* USER CODE BEGIN SDRAM_MspInit 1 */ /* USER CODE END SDRAM_MspInit 1 */ } static uint32_t FMC_DeInitialized = 0; static void HAL_FMC_MspDeInit(void){ /* USER CODE BEGIN FMC_MspDeInit 0 */ /* USER CODE END FMC_MspDeInit 0 */ if (FMC_DeInitialized) { return; } FMC_DeInitialized = 1; /* Peripheral clock enable */ __HAL_RCC_FMC_CLK_DISABLE(); /** FMC GPIO Configuration PI6 ------> FMC_D28 PI5 ------> FMC_NBL3 PI4 ------> FMC_NBL2 PI1 ------> FMC_D25 PI0 ------> FMC_D24 PI7 ------> FMC_D29 PE1 ------> FMC_NBL1 PI2 ------> FMC_D26 PH15 ------> FMC_D23 PH14 ------> FMC_D22 PE0 ------> FMC_NBL0 PI3 ------> FMC_D27 PG15 ------> FMC_SDNCAS PD0 ------> FMC_D2 PH13 ------> FMC_D21 PI9 ------> FMC_D30 PD1 ------> FMC_D3 PI10 ------> FMC_D31 PG8 ------> FMC_SDCLK PF2 ------> FMC_A2 PF1 ------> FMC_A1 PF0 ------> FMC_A0 PG5 ------> FMC_BA1 PF3 ------> FMC_A3 PG4 ------> FMC_BA0 PG2 ------> FMC_A12 PF5 ------> FMC_A5 PF4 ------> FMC_A4 PC0 ------> FMC_SDNWE PC2 ------> FMC_SDNE0 PC3 ------> FMC_SDCKE0 PE10 ------> FMC_D7 PF13 ------> FMC_A7 PF14 ------> FMC_A8 PE9 ------> FMC_D6 PE11 ------> FMC_D8 PH10 ------> FMC_D18 PH11 ------> FMC_D19 PD15 ------> FMC_D1 PD14 ------> FMC_D0 PF12 ------> FMC_A6 PF15 ------> FMC_A9 PE12 ------> FMC_D9 PE15 ------> FMC_D12 PH9 ------> FMC_D17 PH12 ------> FMC_D20 PF11 ------> FMC_SDNRAS PG0 ------> FMC_A10 PE8 ------> FMC_D5 PE13 ------> FMC_D10 PH8 ------> FMC_D16 PD10 ------> FMC_D15 PD9 ------> FMC_D14 PG1 ------> FMC_A11 PE7 ------> FMC_D4 PE14 ------> FMC_D11 PD8 ------> FMC_D13 */ HAL_GPIO_DeInit(GPIOI, GPIO_PIN_6|GPIO_PIN_5|GPIO_PIN_4|GPIO_PIN_1 |GPIO_PIN_0|GPIO_PIN_7|GPIO_PIN_2|GPIO_PIN_3 |GPIO_PIN_9|GPIO_PIN_10); HAL_GPIO_DeInit(GPIOE, GPIO_PIN_1|GPIO_PIN_0|GPIO_PIN_10|GPIO_PIN_9 |GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_15|GPIO_PIN_8 |GPIO_PIN_13|GPIO_PIN_7|GPIO_PIN_14); HAL_GPIO_DeInit(GPIOH, GPIO_PIN_15|GPIO_PIN_14|GPIO_PIN_13|GPIO_PIN_10 |GPIO_PIN_11|GPIO_PIN_9|GPIO_PIN_12|GPIO_PIN_8); HAL_GPIO_DeInit(GPIOG, GPIO_PIN_15|GPIO_PIN_8|GPIO_PIN_5|GPIO_PIN_4 |GPIO_PIN_2|GPIO_PIN_0|GPIO_PIN_1); HAL_GPIO_DeInit(GPIOD, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_15|GPIO_PIN_14 |GPIO_PIN_10|GPIO_PIN_9|GPIO_PIN_8); HAL_GPIO_DeInit(GPIOF, GPIO_PIN_2|GPIO_PIN_1|GPIO_PIN_0|GPIO_PIN_3 |GPIO_PIN_5|GPIO_PIN_4|GPIO_PIN_13|GPIO_PIN_14 |GPIO_PIN_12|GPIO_PIN_15|GPIO_PIN_11); HAL_GPIO_DeInit(GPIOC, GPIO_PIN_0|GPIO_PIN_2|GPIO_PIN_3); /* USER CODE BEGIN FMC_MspDeInit 1 */ /* USER CODE END FMC_MspDeInit 1 */ } void HAL_SDRAM_MspDeInit(SDRAM_HandleTypeDef* hsdram){ /* USER CODE BEGIN SDRAM_MspDeInit 0 */ /* USER CODE END SDRAM_MspDeInit 0 */ HAL_FMC_MspDeInit(); /* USER CODE BEGIN SDRAM_MspDeInit 1 */ /* USER CODE END SDRAM_MspDeInit 1 */ } /* USER CODE BEGIN 1 */ /* USER CODE END 1 */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

总结:
1、LTDC时钟设置为9MHz
STM32H750 LTDC ATK-4342 RGBLCD_第1张图片
STM32H750 LTDC ATK-4342 RGBLCD_第2张图片
STM32H750 LTDC ATK-4342 RGBLCD_第3张图片
2、同步时序图
STM32H750 LTDC ATK-4342 RGBLCD_第4张图片

3、
在这里插入图片描述
STM32H750 LTDC ATK-4342 RGBLCD_第5张图片
4、
在这里插入图片描述
STM32H750 LTDC ATK-4342 RGBLCD_第6张图片
5、
在这里插入图片描述
STM32H750 LTDC ATK-4342 RGBLCD_第7张图片
6、
在这里插入图片描述
STM32H750 LTDC ATK-4342 RGBLCD_第8张图片
7、
在这里插入图片描述
STM32H750 LTDC ATK-4342 RGBLCD_第9张图片
8、
在这里插入图片描述
STM32H750 LTDC ATK-4342 RGBLCD_第10张图片
9、
在这里插入图片描述
STM32H750 LTDC ATK-4342 RGBLCD_第11张图片
10、
在这里插入图片描述
STM32H750 LTDC ATK-4342 RGBLCD_第12张图片
11、
STM32H750 LTDC ATK-4342 RGBLCD_第13张图片
STM32H750 LTDC ATK-4342 RGBLCD_第14张图片
12、
STM32H750 LTDC ATK-4342 RGBLCD_第15张图片
STM32H750 LTDC ATK-4342 RGBLCD_第16张图片
在这里插入图片描述
13、
STM32H750 LTDC ATK-4342 RGBLCD_第17张图片
STM32H750 LTDC ATK-4342 RGBLCD_第18张图片
STM32H750 LTDC ATK-4342 RGBLCD_第19张图片
STM32H750 LTDC ATK-4342 RGBLCD_第20张图片
14、
在这里插入图片描述
STM32H750 LTDC ATK-4342 RGBLCD_第21张图片
STM32H750 LTDC ATK-4342 RGBLCD_第22张图片
15、
在这里插入图片描述

STM32H750 LTDC ATK-4342 RGBLCD_第23张图片
STM32H750 LTDC ATK-4342 RGBLCD_第24张图片
16、
在这里插入图片描述
STM32H750 LTDC ATK-4342 RGBLCD_第25张图片
17、
在这里插入图片描述

STM32H750 LTDC ATK-4342 RGBLCD_第26张图片
18、
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
19、
STM32H750 LTDC ATK-4342 RGBLCD_第27张图片
20、
STM32H750 LTDC ATK-4342 RGBLCD_第28张图片
STM32H750 LTDC ATK-4342 RGBLCD_第29张图片
STM32H750 LTDC ATK-4342 RGBLCD_第30张图片

你可能感兴趣的:(STM32,stm32,单片机,嵌入式硬件)