185 lines
5.2 KiB
C
185 lines
5.2 KiB
C
/**
|
||
******************************************************************
|
||
* @file main.c
|
||
* @author fire
|
||
* @version V1.0
|
||
* @date 2019-xx-xx
|
||
* @brief 电容触摸屏-触摸画板
|
||
******************************************************************
|
||
* @attention
|
||
*
|
||
* 实验平台:野火 STM32H750开发板
|
||
* 论坛 :http://www.firebbs.cn
|
||
* 淘宝 :http://firestm32.taobao.com
|
||
*
|
||
******************************************************************
|
||
*/
|
||
#include "stm32h7xx.h"
|
||
#include "main.h"
|
||
#include "./led/bsp_led.h"
|
||
#include "./usart/bsp_debug_usart.h"
|
||
#include "./sdram/bsp_sdram.h"
|
||
#include "./lcd/bsp_lcd.h"
|
||
#include "./touch/bsp_i2c_touch.h"
|
||
#include "./touch/bsp_touch_gtxx.h"
|
||
#include "./touch/palette.h"
|
||
#include "./delay/core_delay.h"
|
||
#include "./touch/palette.h"
|
||
#include "./mpu/bsp_mpu.h"
|
||
|
||
extern void GTP_TouchProcess(void);
|
||
|
||
void Delay(__IO uint32_t nCount);
|
||
|
||
void LCD_Test(void);
|
||
/**
|
||
* @brief 主函数
|
||
* @param 无
|
||
* @retval 无
|
||
*/
|
||
int main(void)
|
||
{
|
||
|
||
/* 系统时钟初始化成480MHz */
|
||
SystemClock_Config();
|
||
/* LED 端口初始化 */
|
||
LED_GPIO_Config();
|
||
|
||
/* 配置 MPU */
|
||
Board_MPU_Config(0, MPU_Normal_WT, 0xD0000000, MPU_32MB);
|
||
Board_MPU_Config(1, MPU_Normal_WT, 0x24000000, MPU_512KB);
|
||
|
||
SCB_EnableICache(); // 使能指令 Cache
|
||
SCB_EnableDCache(); // 使能数据 Cache
|
||
|
||
|
||
/* 配置串口1为:115200 8-N-1 */
|
||
DEBUG_USART_Config();
|
||
printf("\r\n欢迎使用野火STM32H743开发板。\r\n");
|
||
printf("\r\n野火STM32H743 触摸画板测试例程\r\n");
|
||
/* 初始化触摸屏 */
|
||
GTP_Init_Panel();
|
||
|
||
printf("\r\n提示:\r\n"
|
||
"如果是4.3寸/5寸的RGB屏幕,使用的触摸芯片可能是GT1151QM。\r\n"
|
||
"如果触摸或显示异常,请确认使用的屏幕触摸芯片型号,"
|
||
"在“bsp_i2c_touch.h”文件修改宏定义 LCD_TOUCH_IC_GT1151QM。\r\n\r\n");
|
||
|
||
/* LCD 端口初始化 */
|
||
LCD_Init();
|
||
/* LCD 第一层初始化 */
|
||
LCD_LayerInit(0, LCD_FB_START_ADDRESS,RGB888);
|
||
/* LCD 第二层初始化 */
|
||
LCD_LayerInit(1, LCD_FB_START_ADDRESS+(LCD_GetXSize()*LCD_GetYSize()*4),RGB888);
|
||
/* 使能LCD,包括开背光 */
|
||
LCD_DisplayOn();
|
||
|
||
/* 选择LCD第一层 */
|
||
LCD_SelectLayer(0);
|
||
|
||
/* 第一层清屏,显示全黑 */
|
||
LCD_Clear(LCD_COLOR_BLACK);
|
||
|
||
/* 选择LCD第二层 */
|
||
LCD_SelectLayer(1);
|
||
|
||
/* 第二层清屏,显示全黑 */
|
||
LCD_Clear(LCD_COLOR_TRANSPARENT);
|
||
|
||
/* 配置第一和第二层的透明度,最小值为0,最大值为255*/
|
||
LCD_SetTransparency(0, 0);
|
||
LCD_SetTransparency(1, 255);
|
||
/*调用画板函数*/
|
||
Palette_Init();
|
||
|
||
Delay(0xfff);
|
||
while(1)
|
||
{
|
||
// GTP_TouchProcess();
|
||
// HAL_Delay(20);
|
||
|
||
}
|
||
}
|
||
|
||
/**
|
||
* @brief System Clock 配置
|
||
* system Clock 配置如下:
|
||
* System Clock source = PLL (HSE)
|
||
* SYSCLK(Hz) = 480000000 (CPU Clock)
|
||
* HCLK(Hz) = 240000000 (AXI and AHBs Clock)
|
||
* AHB Prescaler = 2
|
||
* D1 APB3 Prescaler = 2 (APB3 Clock 120MHz)
|
||
* D2 APB1 Prescaler = 2 (APB1 Clock 120MHz)
|
||
* D2 APB2 Prescaler = 2 (APB2 Clock 120MHz)
|
||
* D3 APB4 Prescaler = 2 (APB4 Clock 120MHz)
|
||
* HSE Frequency(Hz) = 25000000
|
||
* PLL_M = 5
|
||
* PLL_N = 192
|
||
* PLL_P = 2
|
||
* PLL_Q = 4
|
||
* PLL_R = 2
|
||
* VDD(V) = 3.3
|
||
* Flash Latency(WS) = 4
|
||
* @param None
|
||
* @retval None
|
||
*/
|
||
/**
|
||
* @brief System Clock Configuration
|
||
* @retval None
|
||
*/
|
||
void SystemClock_Config(void)
|
||
{
|
||
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
|
||
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
|
||
|
||
/** 启用电源配置更新
|
||
*/
|
||
HAL_PWREx_ConfigSupply(PWR_LDO_SUPPLY);
|
||
/** 配置主内稳压器输出电压
|
||
*/
|
||
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE0);
|
||
|
||
while(!__HAL_PWR_GET_FLAG(PWR_FLAG_VOSRDY)) {}
|
||
/** 初始化CPU、AHB和APB总线时钟
|
||
*/
|
||
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 = 192;
|
||
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)
|
||
{
|
||
while(1);
|
||
}
|
||
/** 初始化CPU、AHB和APB总线时钟
|
||
*/
|
||
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_DIV2;
|
||
|
||
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4) != HAL_OK)
|
||
{
|
||
while(1);
|
||
}
|
||
}
|
||
|
||
void Delay(__IO uint32_t nCount) //简单的延时函数
|
||
{
|
||
for(; nCount != 0; nCount--);
|
||
}
|
||
/****************************END OF FILE***************************/
|