当前位置:   article > 正文

[STM32H7] STM32H750B-DK TouchGFX 测评——快速开发

stm32h750b-dk

搭建开发环境,首先下载STM32cubmx,图形化配置工具,非常强大,作为高端mcu,freertos是必备的,多任务开发,其他的软件包按照需求添加,比如文件系统,网络协议栈,USB、这些都是开发板上带的,必须加进去在添加软件包额时候,如果出现不合理的地方,点击生成代码的时候,会进行提示,  在SYS下降时钟从systick改成TIM1,警告消除;

类似的还有FREERTOS的newlib settings,直接改成enable

IDE开发工具当然选择STM32CubIDE,完成FREERTOS的系统工程,代码如下:

 

  1. /* USER CODE BEGIN Header */
  2. /**
  3.   ******************************************************************************
  4.   * [url=home.php?mod=space&uid=288409]@file[/url]           : main.c
  5.   * [url=home.php?mod=space&uid=247401]@brief[/url]          : Main program body
  6.   ******************************************************************************
  7.   * @attention
  8.   *
  9.   * Copyright (c) 2022 STMicroelectronics.
  10.   * All rights reserved.
  11.   *
  12.   * This software is licensed under terms that can be found in the LICENSE file
  13.   * in the root directory of this software component.
  14.   * If no LICENSE file comes with this software, it is provided AS-IS.
  15.   *
  16.   ******************************************************************************
  17.   */
  18. /* USER CODE END Header */
  19. /* Includes ------------------------------------------------------------------*/
  20. #include "main.h"
  21. #include "string.h"
  22. #include "cmsis_os.h"
  23. #include "fatfs.h"
  24. #include "libjpeg.h"
  25. #include "mbedtls.h"
  26. #include "usb_device.h"
  27. /* Private includes ----------------------------------------------------------*/
  28. /* USER CODE BEGIN Includes */
  29. /* USER CODE END Includes */
  30. /* Private typedef -----------------------------------------------------------*/
  31. /* USER CODE BEGIN PTD */
  32. /* USER CODE END PTD */
  33. /* Private define ------------------------------------------------------------*/
  34. /* USER CODE BEGIN PD */
  35. /* USER CODE END PD */
  36. /* Private macro -------------------------------------------------------------*/
  37. /* USER CODE BEGIN PM */
  38. /* USER CODE END PM */
  39. /* Private variables ---------------------------------------------------------*/
  40. #if defined ( __ICCARM__ ) /*!< IAR Compiler */
  41. #pragma location=0x30000000
  42. ETH_DMADescTypeDef  DMARxDscrTab[ETH_RX_DESC_CNT]; /* Ethernet Rx DMA Descriptors */
  43. #pragma location=0x30000200
  44. ETH_DMADescTypeDef  DMATxDscrTab[ETH_TX_DESC_CNT]; /* Ethernet Tx DMA Descriptors */
  45. #elif defined ( __CC_ARM )  /* MDK ARM Compiler */
  46. __attribute__((at(0x30000000))) ETH_DMADescTypeDef  DMARxDscrTab[ETH_RX_DESC_CNT]; /* Ethernet Rx DMA Descriptors */
  47. __attribute__((at(0x30000200))) ETH_DMADescTypeDef  DMATxDscrTab[ETH_TX_DESC_CNT]; /* Ethernet Tx DMA Descriptors */
  48. #elif defined ( __GNUC__ ) /* GNU Compiler */
  49. ETH_DMADescTypeDef DMARxDscrTab[ETH_RX_DESC_CNT] __attribute__((section(".RxDecripSection"))); /* Ethernet Rx DMA Descriptors */
  50. ETH_DMADescTypeDef DMATxDscrTab[ETH_TX_DESC_CNT] __attribute__((section(".TxDecripSection")));   /* Ethernet Tx DMA Descriptors */
  51. #endif
  52. ETH_TxPacketConfig TxConfig;
  53. ADC_HandleTypeDef hadc1;
  54. ADC_HandleTypeDef hadc2;
  55. ADC_HandleTypeDef hadc3;
  56. ETH_HandleTypeDef heth;
  57. FDCAN_HandleTypeDef hfdcan1;
  58. FDCAN_HandleTypeDef hfdcan2;
  59. LTDC_HandleTypeDef hltdc;
  60. QSPI_HandleTypeDef hqspi;
  61. RTC_HandleTypeDef hrtc;
  62. SAI_HandleTypeDef hsai_BlockA2;
  63. SAI_HandleTypeDef hsai_BlockB2;
  64. MMC_HandleTypeDef hmmc1;
  65. SPI_HandleTypeDef hspi2;
  66. UART_HandleTypeDef huart3;
  67. SDRAM_HandleTypeDef hsdram1;
  68. /* Definitions for defaultTask */
  69. osThreadId_t defaultTaskHandle;
  70. const osThreadAttr_t defaultTask_attributes = {
  71.   .name = "defaultTask",
  72.   .stack_size = 128 * 4,
  73.   .priority = (osPriority_t) osPriorityNormal,
  74. };
  75. /* USER CODE BEGIN PV */
  76. /* USER CODE END PV */
  77. /* Private function prototypes -----------------------------------------------*/
  78. void SystemClock_Config(void);
  79. void PeriphCommonClock_Config(void);
  80. static void MX_GPIO_Init(void);
  81. static void MX_ADC1_Init(void);
  82. static void MX_ADC2_Init(void);
  83. static void MX_ADC3_Init(void);
  84. static void MX_ETH_Init(void);
  85. static void MX_FDCAN1_Init(void);
  86. static void MX_FDCAN2_Init(void);
  87. static void MX_FMC_Init(void);
  88. static void MX_LTDC_Init(void);
  89. static void MX_QUADSPI_Init(void);
  90. static void MX_RTC_Init(void);
  91. static void MX_SAI2_Init(void);
  92. static void MX_SDMMC1_MMC_Init(void);
  93. static void MX_SPI2_Init(void);
  94. static void MX_USART3_UART_Init(void);
  95. void StartDefaultTask(void *argument);
  96. /* USER CODE BEGIN PFP */
  97. /* USER CODE END PFP */
  98. /* Private user code ---------------------------------------------------------*/
  99. /* USER CODE BEGIN 0 */
  100. /* USER CODE END 0 */
  101. /**
  102.   * [url=home.php?mod=space&uid=247401]@brief[/url]  The application entry point.
  103.   * @retval int
  104.   */
  105. int main(void)
  106. {
  107.   /* USER CODE BEGIN 1 */
  108.   /* USER CODE END 1 */
  109.   /* MCU Configuration--------------------------------------------------------*/
  110.   /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  111.   HAL_Init();
  112.   /* USER CODE BEGIN Init */
  113.   /* USER CODE END Init */
  114.   /* Configure the system clock */
  115.   SystemClock_Config();
  116. /* Configure the peripherals common clocks */
  117.   PeriphCommonClock_Config();
  118.   /* USER CODE BEGIN SysInit */
  119.   /* USER CODE END SysInit */
  120.   /* Initialize all configured peripherals */
  121.   MX_GPIO_Init();
  122.   MX_ADC1_Init();
  123.   MX_ADC2_Init();
  124.   MX_ADC3_Init();
  125.   MX_ETH_Init();
  126.   MX_FDCAN1_Init();
  127.   MX_FDCAN2_Init();
  128.   MX_FMC_Init();
  129.   MX_LTDC_Init();
  130.   MX_QUADSPI_Init();
  131.   MX_RTC_Init();
  132.   MX_SAI2_Init();
  133.   MX_SDMMC1_MMC_Init();
  134.   MX_SPI2_Init();
  135.   MX_USART3_UART_Init();
  136.   MX_FATFS_Init();
  137.   MX_LIBJPEG_Init();
  138.   MX_MBEDTLS_Init();
  139.   /* Call PreOsInit function */
  140.   MX_MBEDTLS_Init();
  141.   /* USER CODE BEGIN 2 */
  142.   /* USER CODE END 2 */
  143.   /* Init scheduler */
  144.   osKernelInitialize();
  145.   /* USER CODE BEGIN RTOS_MUTEX */
  146.   /* add mutexes, ... */
  147.   /* USER CODE END RTOS_MUTEX */
  148.   /* USER CODE BEGIN RTOS_SEMAPHORES */
  149.   /* add semaphores, ... */
  150.   /* USER CODE END RTOS_SEMAPHORES */
  151.   /* USER CODE BEGIN RTOS_TIMERS */
  152.   /* start timers, add new ones, ... */
  153.   /* USER CODE END RTOS_TIMERS */
  154.   /* USER CODE BEGIN RTOS_QUEUES */
  155.   /* add queues, ... */
  156.   /* USER CODE END RTOS_QUEUES */
  157.   /* Create the thread(s) */
  158.   /* creation of defaultTask */
  159.   defaultTaskHandle = osThreadNew(StartDefaultTask, NULL, &defaultTask_attributes);
  160.   /* USER CODE BEGIN RTOS_THREADS */
  161.   /* add threads, ... */
  162.   /* USER CODE END RTOS_THREADS */
  163.   /* USER CODE BEGIN RTOS_EVENTS */
  164.   /* add events, ... */
  165.   /* USER CODE END RTOS_EVENTS */
  166.   /* Start scheduler */
  167.   osKernelStart();
  168.   /* We should never get here as control is now taken by the scheduler */
  169.   /* Infinite loop */
  170.   /* USER CODE BEGIN WHILE */
  171.   while (1)
  172.   {
  173.     /* USER CODE END WHILE */
  174.     /* USER CODE BEGIN 3 */
  175.   }
  176.   /* USER CODE END 3 */
  177. }
  178. /**
  179.   * [url=home.php?mod=space&uid=247401]@brief[/url] System Clock Configuration
  180.   * @retval None
  181.   */
  182. void SystemClock_Config(void)
  183. {
  184.   RCC_OscInitTypeDef RCC_OscInitStruct = {0};
  185.   RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
  186.   /** Supply configuration update enable
  187.   */
  188.   HAL_PWREx_ConfigSupply(PWR_LDO_SUPPLY);
  189.   /** Configure the main internal regulator output voltage
  190.   */
  191.   __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE2);
  192.   while(!__HAL_PWR_GET_FLAG(PWR_FLAG_VOSRDY)) {}
  193.   /** Macro to configure the PLL clock source
  194.   */
  195.   __HAL_RCC_PLL_PLLSOURCE_CONFIG(RCC_PLLSOURCE_HSE);
  196.   /** Initializes the RCC Oscillators according to the specified parameters
  197.   * in the RCC_OscInitTypeDef structure.
  198.   */
  199.   RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI|RCC_OSCILLATORTYPE_LSI
  200.                               |RCC_OSCILLATORTYPE_HSE;
  201.   RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS;
  202.   RCC_OscInitStruct.HSIState = RCC_HSI_DIV1;
  203.   RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
  204.   RCC_OscInitStruct.LSIState = RCC_LSI_ON;
  205.   RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
  206.   RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
  207.   RCC_OscInitStruct.PLL.PLLM = 22;
  208.   RCC_OscInitStruct.PLL.PLLN = 169;
  209.   RCC_OscInitStruct.PLL.PLLP = 2;
  210.   RCC_OscInitStruct.PLL.PLLQ = 4;
  211.   RCC_OscInitStruct.PLL.PLLR = 2;
  212.   RCC_OscInitStruct.PLL.PLLRGE = RCC_PLL1VCIRANGE_0;
  213.   RCC_OscInitStruct.PLL.PLLVCOSEL = RCC_PLL1VCOWIDE;
  214.   RCC_OscInitStruct.PLL.PLLFRACN = 0;
  215.   if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
  216.   {
  217.     Error_Handler();
  218.   }
  219.   /** Initializes the CPU, AHB and APB buses clocks
  220.   */
  221.   RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
  222.                               |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2
  223.                               |RCC_CLOCKTYPE_D3PCLK1|RCC_CLOCKTYPE_D1PCLK1;
  224.   RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSI;
  225.   RCC_ClkInitStruct.SYSCLKDivider = RCC_SYSCLK_DIV1;
  226.   RCC_ClkInitStruct.AHBCLKDivider = RCC_HCLK_DIV1;
  227.   RCC_ClkInitStruct.APB3CLKDivider = RCC_APB3_DIV1;
  228.   RCC_ClkInitStruct.APB1CLKDivider = RCC_APB1_DIV1;
  229.   RCC_ClkInitStruct.APB2CLKDivider = RCC_APB2_DIV1;
  230.   RCC_ClkInitStruct.APB4CLKDivider = RCC_APB4_DIV1;
  231.   if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK)
  232.   {
  233.     Error_Handler();
  234.   }
  235. }
  236. /**
  237.   * @brief Peripherals Common Clock Configuration
  238.   * @retval None
  239.   */
  240. void PeriphCommonClock_Config(void)
  241. {
  242.   RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0};
  243.   /** Initializes the peripherals clock
  244.   */
  245.   PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_ADC;
  246.   PeriphClkInitStruct.PLL2.PLL2M = 2;
  247.   PeriphClkInitStruct.PLL2.PLL2N = 12;
  248.   PeriphClkInitStruct.PLL2.PLL2P = 5;
  249.   PeriphClkInitStruct.PLL2.PLL2Q = 2;
  250.   PeriphClkInitStruct.PLL2.PLL2R = 2;
  251.   PeriphClkInitStruct.PLL2.PLL2RGE = RCC_PLL2VCIRANGE_3;
  252.   PeriphClkInitStruct.PLL2.PLL2VCOSEL = RCC_PLL2VCOMEDIUM;
  253.   PeriphClkInitStruct.PLL2.PLL2FRACN = 0;
  254.   PeriphClkInitStruct.AdcClockSelection = RCC_ADCCLKSOURCE_PLL2;
  255.   if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)
  256.   {
  257.     Error_Handler();
  258.   }
  259. }
  260. /**
  261.   * @brief ADC1 Initialization Function
  262.   * @param None
  263.   * @retval None
  264.   */
  265. static void MX_ADC1_Init(void)
  266. {
  267.   /* USER CODE BEGIN ADC1_Init 0 */
  268.   /* USER CODE END ADC1_Init 0 */
  269.   ADC_MultiModeTypeDef multimode = {0};
  270.   ADC_ChannelConfTypeDef sConfig = {0};
  271.   /* USER CODE BEGIN ADC1_Init 1 */
  272.   /* USER CODE END ADC1_Init 1 */
  273.   /** Common config
  274.   */
  275.   hadc1.Instance = ADC1;
  276.   hadc1.Init.ClockPrescaler = ADC_CLOCK_ASYNC_DIV2;
  277.   hadc1.Init.Resolution = ADC_RESOLUTION_16B;
  278.   hadc1.Init.ScanConvMode = ADC_SCAN_DISABLE;
  279.   hadc1.Init.EOCSelection = ADC_EOC_SINGLE_CONV;
  280.   hadc1.Init.LowPowerAutoWait = DISABLE;
  281.   hadc1.Init.ContinuousConvMode = DISABLE;
  282.   hadc1.Init.NbrOfConversion = 1;
  283.   hadc1.Init.DiscontinuousConvMode = DISABLE;
  284.   hadc1.Init.ExternalTrigConv = ADC_SOFTWARE_START;
  285.   hadc1.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE;
  286.   hadc1.Init.ConversionDataManagement = ADC_CONVERSIONDATA_DR;
  287.   hadc1.Init.Overrun = ADC_OVR_DATA_PRESERVED;
  288.   hadc1.Init.LeftBitShift = ADC_LEFTBITSHIFT_NONE;
  289.   hadc1.Init.OversamplingMode = DISABLE;
  290.   if (HAL_ADC_Init(&hadc1) != HAL_OK)
  291.   {
  292.     Error_Handler();
  293.   }
  294.   /** Configure the ADC multi-mode
  295.   */
  296.   multimode.Mode = ADC_MODE_INDEPENDENT;
  297.   if (HAL_ADCEx_MultiModeConfigChannel(&hadc1, &multimode) != HAL_OK)
  298.   {
  299.     Error_Handler();
  300.   }
  301.   /** Configure Regular Channel
  302.   */
  303.   sConfig.Channel = ADC_CHANNEL_0;
  304.   sConfig.Rank = ADC_REGULAR_RANK_1;
  305.   sConfig.SamplingTime = ADC_SAMPLETIME_1CYCLE_5;
  306.   sConfig.SingleDiff = ADC_SINGLE_ENDED;
  307.   sConfig.OffsetNumber = ADC_OFFSET_NONE;
  308.   sConfig.Offset = 0;
  309.   sConfig.OffsetSignedSaturation = DISABLE;
  310.   if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
  311.   {
  312.     Error_Handler();
  313.   }
  314.   /* USER CODE BEGIN ADC1_Init 2 */
  315.   /* USER CODE END ADC1_Init 2 */
  316. }
  317. /**
  318.   * @brief ADC2 Initialization Function
  319.   * @param None
  320.   * @retval None
  321.   */
  322. static void MX_ADC2_Init(void)
  323. {
  324.   /* USER CODE BEGIN ADC2_Init 0 */
  325.   /* USER CODE END ADC2_Init 0 */
  326.   ADC_ChannelConfTypeDef sConfig = {0};
  327.   /* USER CODE BEGIN ADC2_Init 1 */
  328.   /* USER CODE END ADC2_Init 1 */
  329.   /** Common config
  330.   */
  331.   hadc2.Instance = ADC2;
  332.   hadc2.Init.ClockPrescaler = ADC_CLOCK_ASYNC_DIV2;
  333.   hadc2.Init.Resolution = ADC_RESOLUTION_16B;
  334.   hadc2.Init.ScanConvMode = ADC_SCAN_DISABLE;
  335.   hadc2.Init.EOCSelection = ADC_EOC_SINGLE_CONV;
  336.   hadc2.Init.LowPowerAutoWait = DISABLE;
  337.   hadc2.Init.ContinuousConvMode = DISABLE;
  338.   hadc2.Init.NbrOfConversion = 1;
  339.   hadc2.Init.DiscontinuousConvMode = DISABLE;
  340.   hadc2.Init.ExternalTrigConv = ADC_SOFTWARE_START;
  341.   hadc2.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE;
  342.   hadc2.Init.ConversionDataManagement = ADC_CONVERSIONDATA_DR;
  343.   hadc2.Init.Overrun = ADC_OVR_DATA_PRESERVED;
  344.   hadc2.Init.LeftBitShift = ADC_LEFTBITSHIFT_NONE;
  345.   hadc2.Init.OversamplingMode = DISABLE;
  346.   if (HAL_ADC_Init(&hadc2) != HAL_OK)
  347.   {
  348.     Error_Handler();
  349.   }
  350.   /** Configure Regular Channel
  351.   */
  352.   sConfig.Channel = ADC_CHANNEL_0;
  353.   sConfig.Rank = ADC_REGULAR_RANK_1;
  354.   sConfig.SamplingTime = ADC_SAMPLETIME_1CYCLE_5;
  355.   sConfig.SingleDiff = ADC_SINGLE_ENDED;
  356.   sConfig.OffsetNumber = ADC_OFFSET_NONE;
  357.   sConfig.Offset = 0;
  358.   sConfig.OffsetSignedSaturation = DISABLE;
  359.   if (HAL_ADC_ConfigChannel(&hadc2, &sConfig) != HAL_OK)
  360.   {
  361.     Error_Handler();
  362.   }
  363.   /* USER CODE BEGIN ADC2_Init 2 */
  364.   /* USER CODE END ADC2_Init 2 */
  365. }
  366. /**
  367.   * @brief ADC3 Initialization Function
  368.   * @param None
  369.   * @retval None
  370.   */
  371. static void MX_ADC3_Init(void)
  372. {
  373.   /* USER CODE BEGIN ADC3_Init 0 */
  374.   /* USER CODE END ADC3_Init 0 */
  375.   ADC_ChannelConfTypeDef sConfig = {0};
  376.   /* USER CODE BEGIN ADC3_Init 1 */
  377.   /* USER CODE END ADC3_Init 1 */
  378.   /** Common config
  379.   */
  380.   hadc3.Instance = ADC3;
  381.   hadc3.Init.Resolution = ADC_RESOLUTION_16B;
  382.   hadc3.Init.ScanConvMode = ADC_SCAN_DISABLE;
  383.   hadc3.Init.EOCSelection = ADC_EOC_SINGLE_CONV;
  384.   hadc3.Init.LowPowerAutoWait = DISABLE;
  385.   hadc3.Init.ContinuousConvMode = DISABLE;
  386.   hadc3.Init.NbrOfConversion = 1;
  387.   hadc3.Init.DiscontinuousConvMode = DISABLE;
  388.   hadc3.Init.ExternalTrigConv = ADC_SOFTWARE_START;
  389.   hadc3.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE;
  390.   hadc3.Init.ConversionDataManagement = ADC_CONVERSIONDATA_DR;
  391.   hadc3.Init.Overrun = ADC_OVR_DATA_PRESERVED;
  392.   hadc3.Init.LeftBitShift = ADC_LEFTBITSHIFT_NONE;
  393.   hadc3.Init.OversamplingMode = DISABLE;
  394.   if (HAL_ADC_Init(&hadc3) != HAL_OK)
  395.   {
  396.     Error_Handler();
  397.   }
  398.   /** Configure Regular Channel
  399.   */
  400.   sConfig.Channel = ADC_CHANNEL_7;
  401.   sConfig.Rank = ADC_REGULAR_RANK_1;
  402.   sConfig.SamplingTime = ADC_SAMPLETIME_1CYCLE_5;
  403.   sConfig.SingleDiff = ADC_SINGLE_ENDED;
  404.   sConfig.OffsetNumber = ADC_OFFSET_NONE;
  405.   sConfig.Offset = 0;
  406.   sConfig.OffsetSignedSaturation = DISABLE;
  407.   if (HAL_ADC_ConfigChannel(&hadc3, &sConfig) != HAL_OK)
  408.   {
  409.     Error_Handler();
  410.   }
  411.   /* USER CODE BEGIN ADC3_Init 2 */
  412.   /* USER CODE END ADC3_Init 2 */
  413. }
  414. /**
  415.   * @brief ETH Initialization Function
  416.   * @param None
  417.   * @retval None
  418.   */
  419. static void MX_ETH_Init(void)
  420. {
  421.   /* USER CODE BEGIN ETH_Init 0 */
  422.   /* USER CODE END ETH_Init 0 */
  423.    static uint8_t MACAddr[6];
  424.   /* USER CODE BEGIN ETH_Init 1 */
  425.   /* USER CODE END ETH_Init 1 */
  426.   heth.Instance = ETH;
  427.   MACAddr[0] = 0x00;
  428.   MACAddr[1] = 0x80;
  429.   MACAddr[2] = 0xE1;
  430.   MACAddr[3] = 0x00;
  431.   MACAddr[4] = 0x00;
  432.   MACAddr[5] = 0x00;
  433.   heth.Init.MACAddr = &MACAddr[0];
  434.   heth.Init.MediaInterface = HAL_ETH_MII_MODE;
  435.   heth.Init.TxDesc = DMATxDscrTab;
  436.   heth.Init.RxDesc = DMARxDscrTab;
  437.   heth.Init.RxBuffLen = 1524;
  438.   /* USER CODE BEGIN MACADDRESS */
  439.   /* USER CODE END MACADDRESS */
  440.   if (HAL_ETH_Init(&heth) != HAL_OK)
  441.   {
  442.     Error_Handler();
  443.   }
  444.   memset(&TxConfig, 0 , sizeof(ETH_TxPacketConfig));
  445.   TxConfig.Attributes = ETH_TX_PACKETS_FEATURES_CSUM | ETH_TX_PACKETS_FEATURES_CRCPAD;
  446.   TxConfig.ChecksumCtrl = ETH_CHECKSUM_IPHDR_PAYLOAD_INSERT_PHDR_CALC;
  447.   TxConfig.CRCPadCtrl = ETH_CRC_PAD_INSERT;
  448.   /* USER CODE BEGIN ETH_Init 2 */
  449.   /* USER CODE END ETH_Init 2 */
  450. }
  451. /**
  452.   * @brief FDCAN1 Initialization Function
  453.   * @param None
  454.   * @retval None
  455.   */
  456. static void MX_FDCAN1_Init(void)
  457. {
  458.   /* USER CODE BEGIN FDCAN1_Init 0 */
  459.   /* USER CODE END FDCAN1_Init 0 */
  460.   /* USER CODE BEGIN FDCAN1_Init 1 */
  461.   /* USER CODE END FDCAN1_Init 1 */
  462.   hfdcan1.Instance = FDCAN1;
  463.   hfdcan1.Init.FrameFormat = FDCAN_FRAME_CLASSIC;
  464.   hfdcan1.Init.Mode = FDCAN_MODE_NORMAL;
  465.   hfdcan1.Init.AutoRetransmission = DISABLE;
  466.   hfdcan1.Init.TransmitPause = DISABLE;
  467.   hfdcan1.Init.ProtocolException = DISABLE;
  468.   hfdcan1.Init.NominalPrescaler = 16;
  469.   hfdcan1.Init.NominalSyncJumpWidth = 1;
  470.   hfdcan1.Init.NominalTimeSeg1 = 2;
  471.   hfdcan1.Init.NominalTimeSeg2 = 2;
  472.   hfdcan1.Init.DataPrescaler = 1;
  473.   hfdcan1.Init.DataSyncJumpWidth = 1;
  474.   hfdcan1.Init.DataTimeSeg1 = 1;
  475.   hfdcan1.Init.DataTimeSeg2 = 1;
  476.   hfdcan1.Init.MessageRAMOffset = 0;
  477.   hfdcan1.Init.StdFiltersNbr = 0;
  478.   hfdcan1.Init.ExtFiltersNbr = 0;
  479.   hfdcan1.Init.RxFifo0ElmtsNbr = 0;
  480.   hfdcan1.Init.RxFifo0ElmtSize = FDCAN_DATA_BYTES_8;
  481.   hfdcan1.Init.RxFifo1ElmtsNbr = 0;
  482.   hfdcan1.Init.RxFifo1ElmtSize = FDCAN_DATA_BYTES_8;
  483.   hfdcan1.Init.RxBuffersNbr = 0;
  484.   hfdcan1.Init.RxBufferSize = FDCAN_DATA_BYTES_8;
  485.   hfdcan1.Init.TxEventsNbr = 0;
  486.   hfdcan1.Init.TxBuffersNbr = 0;
  487.   hfdcan1.Init.TxFifoQueueElmtsNbr = 0;
  488.   hfdcan1.Init.TxFifoQueueMode = FDCAN_TX_FIFO_OPERATION;
  489.   hfdcan1.Init.TxElmtSize = FDCAN_DATA_BYTES_8;
  490.   if (HAL_FDCAN_Init(&hfdcan1) != HAL_OK)
  491.   {
  492.     Error_Handler();
  493.   }
  494.   /* USER CODE BEGIN FDCAN1_Init 2 */
  495.   /* USER CODE END FDCAN1_Init 2 */
  496. }
  497. /**
  498.   * @brief FDCAN2 Initialization Function
  499.   * @param None
  500.   * @retval None
  501.   */
  502. static void MX_FDCAN2_Init(void)
  503. {
  504.   /* USER CODE BEGIN FDCAN2_Init 0 */
  505.   /* USER CODE END FDCAN2_Init 0 */
  506.   /* USER CODE BEGIN FDCAN2_Init 1 */
  507.   /* USER CODE END FDCAN2_Init 1 */
  508.   hfdcan2.Instance = FDCAN2;
  509.   hfdcan2.Init.FrameFormat = FDCAN_FRAME_CLASSIC;
  510.   hfdcan2.Init.Mode = FDCAN_MODE_NORMAL;
  511.   hfdcan2.Init.AutoRetransmission = DISABLE;
  512.   hfdcan2.Init.TransmitPause = DISABLE;
  513.   hfdcan2.Init.ProtocolException = DISABLE;
  514.   hfdcan2.Init.NominalPrescaler = 16;
  515.   hfdcan2.Init.NominalSyncJumpWidth = 1;
  516.   hfdcan2.Init.NominalTimeSeg1 = 2;
  517.   hfdcan2.Init.NominalTimeSeg2 = 2;
  518.   hfdcan2.Init.DataPrescaler = 1;
  519.   hfdcan2.Init.DataSyncJumpWidth = 1;
  520.   hfdcan2.Init.DataTimeSeg1 = 1;
  521.   hfdcan2.Init.DataTimeSeg2 = 1;
  522.   hfdcan2.Init.MessageRAMOffset = 0;
  523.   hfdcan2.Init.StdFiltersNbr = 0;
  524.   hfdcan2.Init.ExtFiltersNbr = 0;
  525.   hfdcan2.Init.RxFifo0ElmtsNbr = 0;
  526.   hfdcan2.Init.RxFifo0ElmtSize = FDCAN_DATA_BYTES_8;
  527.   hfdcan2.Init.RxFifo1ElmtsNbr = 0;
  528.   hfdcan2.Init.RxFifo1ElmtSize = FDCAN_DATA_BYTES_8;
  529.   hfdcan2.Init.RxBuffersNbr = 0;
  530.   hfdcan2.Init.RxBufferSize = FDCAN_DATA_BYTES_8;
  531.   hfdcan2.Init.TxEventsNbr = 0;
  532.   hfdcan2.Init.TxBuffersNbr = 0;
  533.   hfdcan2.Init.TxFifoQueueElmtsNbr = 0;
  534.   hfdcan2.Init.TxFifoQueueMode = FDCAN_TX_FIFO_OPERATION;
  535.   hfdcan2.Init.TxElmtSize = FDCAN_DATA_BYTES_8;
  536.   if (HAL_FDCAN_Init(&hfdcan2) != HAL_OK)
  537.   {
  538.     Error_Handler();
  539.   }
  540.   /* USER CODE BEGIN FDCAN2_Init 2 */
  541.   /* USER CODE END FDCAN2_Init 2 */
  542. }
  543. /**
  544.   * @brief LTDC Initialization Function
  545.   * @param None
  546.   * @retval None
  547.   */
  548. static void MX_LTDC_Init(void)
  549. {
  550.   /* USER CODE BEGIN LTDC_Init 0 */
  551.   /* USER CODE END LTDC_Init 0 */
  552.   LTDC_LayerCfgTypeDef pLayerCfg = {0};
  553.   LTDC_LayerCfgTypeDef pLayerCfg1 = {0};
  554.   /* USER CODE BEGIN LTDC_Init 1 */
  555.   /* USER CODE END LTDC_Init 1 */
  556.   hltdc.Instance = LTDC;
  557.   hltdc.Init.HSPolarity = LTDC_HSPOLARITY_AL;
  558.   hltdc.Init.VSPolarity = LTDC_VSPOLARITY_AL;
  559.   hltdc.Init.DEPolarity = LTDC_DEPOLARITY_AL;
  560.   hltdc.Init.PCPolarity = LTDC_PCPOLARITY_IPC;
  561.   hltdc.Init.HorizontalSync = 7;
  562.   hltdc.Init.VerticalSync = 3;
  563.   hltdc.Init.AccumulatedHBP = 14;
  564.   hltdc.Init.AccumulatedVBP = 5;
  565.   hltdc.Init.AccumulatedActiveW = 654;
  566.   hltdc.Init.AccumulatedActiveH = 485;
  567.   hltdc.Init.TotalWidth = 660;
  568.   hltdc.Init.TotalHeigh = 487;
  569.   hltdc.Init.Backcolor.Blue = 0;
  570.   hltdc.Init.Backcolor.Green = 0;
  571.   hltdc.Init.Backcolor.Red = 0;
  572.   if (HAL_LTDC_Init(&hltdc) != HAL_OK)
  573.   {
  574.     Error_Handler();
  575.   }
  576.   pLayerCfg.WindowX0 = 0;
  577.   pLayerCfg.WindowX1 = 0;
  578.   pLayerCfg.WindowY0 = 0;
  579.   pLayerCfg.WindowY1 = 0;
  580.   pLayerCfg.PixelFormat = LTDC_PIXEL_FORMAT_ARGB8888;
  581.   pLayerCfg.Alpha = 0;
  582.   pLayerCfg.Alpha0 = 0;
  583.   pLayerCfg.BlendingFactor1 = LTDC_BLENDING_FACTOR1_CA;
  584.   pLayerCfg.BlendingFactor2 = LTDC_BLENDING_FACTOR2_CA;
  585.   pLayerCfg.FBStartAdress = 0;
  586.   pLayerCfg.ImageWidth = 0;
  587.   pLayerCfg.ImageHeight = 0;
  588.   pLayerCfg.Backcolor.Blue = 0;
  589.   pLayerCfg.Backcolor.Green = 0;
  590.   pLayerCfg.Backcolor.Red = 0;
  591.   if (HAL_LTDC_ConfigLayer(&hltdc, &pLayerCfg, 0) != HAL_OK)
  592.   {
  593.     Error_Handler();
  594.   }
  595.   pLayerCfg1.WindowX0 = 0;
  596.   pLayerCfg1.WindowX1 = 0;
  597.   pLayerCfg1.WindowY0 = 0;
  598.   pLayerCfg1.WindowY1 = 0;
  599.   pLayerCfg1.PixelFormat = LTDC_PIXEL_FORMAT_ARGB8888;
  600.   pLayerCfg1.Alpha = 0;
  601.   pLayerCfg1.Alpha0 = 0;
  602.   pLayerCfg1.BlendingFactor1 = LTDC_BLENDING_FACTOR1_CA;
  603.   pLayerCfg1.BlendingFactor2 = LTDC_BLENDING_FACTOR2_CA;
  604.   pLayerCfg1.FBStartAdress = 0;
  605.   pLayerCfg1.ImageWidth = 0;
  606.   pLayerCfg1.ImageHeight = 0;
  607.   pLayerCfg1.Backcolor.Blue = 0;
  608.   pLayerCfg1.Backcolor.Green = 0;
  609.   pLayerCfg1.Backcolor.Red = 0;
  610.   if (HAL_LTDC_ConfigLayer(&hltdc, &pLayerCfg1, 1) != HAL_OK)
  611.   {
  612.     Error_Handler();
  613.   }
  614.   /* USER CODE BEGIN LTDC_Init 2 */
  615.   /* USER CODE END LTDC_Init 2 */
  616. }
  617. /**
  618.   * @brief QUADSPI Initialization Function
  619.   * @param None
  620.   * @retval None
  621.   */
  622. static void MX_QUADSPI_Init(void)
  623. {
  624.   /* USER CODE BEGIN QUADSPI_Init 0 */
  625.   /* USER CODE END QUADSPI_Init 0 */
  626.   /* USER CODE BEGIN QUADSPI_Init 1 */
  627.   /* USER CODE END QUADSPI_Init 1 */
  628.   /* QUADSPI parameter configuration*/
  629.   hqspi.Instance = QUADSPI;
  630.   hqspi.Init.ClockPrescaler = 255;
  631.   hqspi.Init.FifoThreshold = 1;
  632.   hqspi.Init.SampleShifting = QSPI_SAMPLE_SHIFTING_NONE;
  633.   hqspi.Init.FlashSize = 1;
  634.   hqspi.Init.ChipSelectHighTime = QSPI_CS_HIGH_TIME_1_CYCLE;
  635.   hqspi.Init.ClockMode = QSPI_CLOCK_MODE_0;
  636.   hqspi.Init.FlashID = QSPI_FLASH_ID_1;
  637.   hqspi.Init.DualFlash = QSPI_DUALFLASH_DISABLE;
  638.   if (HAL_QSPI_Init(&hqspi) != HAL_OK)
  639.   {
  640.     Error_Handler();
  641.   }
  642.   /* USER CODE BEGIN QUADSPI_Init 2 */
  643.   /* USER CODE END QUADSPI_Init 2 */
  644. }
  645. /**
  646.   * @brief RTC Initialization Function
  647.   * @param None
  648.   * @retval None
  649.   */
  650. static void MX_RTC_Init(void)
  651. {
  652.   /* USER CODE BEGIN RTC_Init 0 */
  653.   /* USER CODE END RTC_Init 0 */
  654.   /* USER CODE BEGIN RTC_Init 1 */
  655.   /* USER CODE END RTC_Init 1 */
  656.   /** Initialize RTC Only
  657.   */
  658.   hrtc.Instance = RTC;
  659.   hrtc.Init.HourFormat = RTC_HOURFORMAT_24;
  660.   hrtc.Init.AsynchPrediv = 127;
  661.   hrtc.Init.SynchPrediv = 255;
  662.   hrtc.Init.OutPut = RTC_OUTPUT_DISABLE;
  663.   hrtc.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH;
  664.   hrtc.Init.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN;
  665.   hrtc.Init.OutPutRemap = RTC_OUTPUT_REMAP_NONE;
  666.   if (HAL_RTC_Init(&hrtc) != HAL_OK)
  667.   {
  668.     Error_Handler();
  669.   }
  670.   /* USER CODE BEGIN RTC_Init 2 */
  671.   /* USER CODE END RTC_Init 2 */
  672. }
  673. /**
  674.   * @brief SAI2 Initialization Function
  675.   * @param None
  676.   * @retval None
  677.   */
  678. static void MX_SAI2_Init(void)
  679. {
  680.   /* USER CODE BEGIN SAI2_Init 0 */
  681.   /* USER CODE END SAI2_Init 0 */
  682.   /* USER CODE BEGIN SAI2_Init 1 */
  683.   /* USER CODE END SAI2_Init 1 */
  684.   hsai_BlockA2.Instance = SAI2_Block_A;
  685.   hsai_BlockA2.Init.Protocol = SAI_FREE_PROTOCOL;
  686.   hsai_BlockA2.Init.AudioMode = SAI_MODEMASTER_TX;
  687.   hsai_BlockA2.Init.DataSize = SAI_DATASIZE_8;
  688.   hsai_BlockA2.Init.FirstBit = SAI_FIRSTBIT_MSB;
  689.   hsai_BlockA2.Init.ClockStrobing = SAI_CLOCKSTROBING_FALLINGEDGE;
  690.   hsai_BlockA2.Init.Synchro = SAI_ASYNCHRONOUS;
  691.   hsai_BlockA2.Init.OutputDrive = SAI_OUTPUTDRIVE_DISABLE;
  692.   hsai_BlockA2.Init.NoDivider = SAI_MASTERDIVIDER_ENABLE;
  693.   hsai_BlockA2.Init.FIFOThreshold = SAI_FIFOTHRESHOLD_EMPTY;
  694.   hsai_BlockA2.Init.AudioFrequency = SAI_AUDIO_FREQUENCY_192K;
  695.   hsai_BlockA2.Init.SynchroExt = SAI_SYNCEXT_DISABLE;
  696.   hsai_BlockA2.Init.MonoStereoMode = SAI_STEREOMODE;
  697.   hsai_BlockA2.Init.CompandingMode = SAI_NOCOMPANDING;
  698.   hsai_BlockA2.Init.TriState = SAI_OUTPUT_NOTRELEASED;
  699.   hsai_BlockA2.Init.PdmInit.Activation = DISABLE;
  700.   hsai_BlockA2.Init.PdmInit.MicPairsNbr = 1;
  701.   hsai_BlockA2.Init.PdmInit.ClockEnable = SAI_PDM_CLOCK1_ENABLE;
  702.   hsai_BlockA2.FrameInit.FrameLength = 8;
  703.   hsai_BlockA2.FrameInit.ActiveFrameLength = 1;
  704.   hsai_BlockA2.FrameInit.FSDefinition = SAI_FS_STARTFRAME;
  705.   hsai_BlockA2.FrameInit.FSPolarity = SAI_FS_ACTIVE_LOW;
  706.   hsai_BlockA2.FrameInit.FSOffset = SAI_FS_FIRSTBIT;
  707.   hsai_BlockA2.SlotInit.FirstBitOffset = 0;
  708.   hsai_BlockA2.SlotInit.SlotSize = SAI_SLOTSIZE_DATASIZE;
  709.   hsai_BlockA2.SlotInit.SlotNumber = 1;
  710.   hsai_BlockA2.SlotInit.SlotActive = 0x00000000;
  711.   if (HAL_SAI_Init(&hsai_BlockA2) != HAL_OK)
  712.   {
  713.     Error_Handler();
  714.   }
  715.   hsai_BlockB2.Instance = SAI2_Block_B;
  716.   hsai_BlockB2.Init.Protocol = SAI_FREE_PROTOCOL;
  717.   hsai_BlockB2.Init.AudioMode = SAI_MODESLAVE_RX;
  718.   hsai_BlockB2.Init.DataSize = SAI_DATASIZE_8;
  719.   hsai_BlockB2.Init.FirstBit = SAI_FIRSTBIT_MSB;
  720.   hsai_BlockB2.Init.ClockStrobing = SAI_CLOCKSTROBING_FALLINGEDGE;
  721.   hsai_BlockB2.Init.Synchro = SAI_SYNCHRONOUS;
  722.   hsai_BlockB2.Init.OutputDrive = SAI_OUTPUTDRIVE_DISABLE;
  723.   hsai_BlockB2.Init.FIFOThreshold = SAI_FIFOTHRESHOLD_EMPTY;
  724.   hsai_BlockB2.Init.SynchroExt = SAI_SYNCEXT_DISABLE;
  725.   hsai_BlockB2.Init.MonoStereoMode = SAI_STEREOMODE;
  726.   hsai_BlockB2.Init.CompandingMode = SAI_NOCOMPANDING;
  727.   hsai_BlockB2.Init.TriState = SAI_OUTPUT_NOTRELEASED;
  728.   hsai_BlockB2.Init.PdmInit.Activation = DISABLE;
  729.   hsai_BlockB2.Init.PdmInit.MicPairsNbr = 1;
  730.   hsai_BlockB2.Init.PdmInit.ClockEnable = SAI_PDM_CLOCK1_ENABLE;
  731.   hsai_BlockB2.FrameInit.FrameLength = 8;
  732.   hsai_BlockB2.FrameInit.ActiveFrameLength = 1;
  733.   hsai_BlockB2.FrameInit.FSDefinition = SAI_FS_STARTFRAME;
  734.   hsai_BlockB2.FrameInit.FSPolarity = SAI_FS_ACTIVE_LOW;
  735.   hsai_BlockB2.FrameInit.FSOffset = SAI_FS_FIRSTBIT;
  736.   hsai_BlockB2.SlotInit.FirstBitOffset = 0;
  737.   hsai_BlockB2.SlotInit.SlotSize = SAI_SLOTSIZE_DATASIZE;
  738.   hsai_BlockB2.SlotInit.SlotNumber = 1;
  739.   hsai_BlockB2.SlotInit.SlotActive = 0x00000000;
  740.   if (HAL_SAI_Init(&hsai_BlockB2) != HAL_OK)
  741.   {
  742.     Error_Handler();
  743.   }
  744.   /* USER CODE BEGIN SAI2_Init 2 */
  745.   /* USER CODE END SAI2_Init 2 */
  746. }
  747. /**
  748.   * @brief SDMMC1 Initialization Function
  749.   * @param None
  750.   * @retval None
  751.   */
  752. static void MX_SDMMC1_MMC_Init(void)
  753. {
  754.   /* USER CODE BEGIN SDMMC1_Init 0 */
  755.   /* USER CODE END SDMMC1_Init 0 */
  756.   /* USER CODE BEGIN SDMMC1_Init 1 */
  757.   /* USER CODE END SDMMC1_Init 1 */
  758.   hmmc1.Instance = SDMMC1;
  759.   hmmc1.Init.ClockEdge = SDMMC_CLOCK_EDGE_RISING;
  760.   hmmc1.Init.ClockPowerSave = SDMMC_CLOCK_POWER_SAVE_DISABLE;
  761.   hmmc1.Init.BusWide = SDMMC_BUS_WIDE_8B;
  762.   hmmc1.Init.HardwareFlowControl = SDMMC_HARDWARE_FLOW_CONTROL_DISABLE;
  763.   hmmc1.Init.ClockDiv = 0;
  764.   if (HAL_MMC_Init(&hmmc1) != HAL_OK)
  765.   {
  766.     Error_Handler();
  767.   }
  768.   /* USER CODE BEGIN SDMMC1_Init 2 */
  769.   /* USER CODE END SDMMC1_Init 2 */
  770. }
  771. /**
  772.   * @brief SPI2 Initialization Function
  773.   * @param None
  774.   * @retval None
  775.   */
  776. static void MX_SPI2_Init(void)
  777. {
  778.   /* USER CODE BEGIN SPI2_Init 0 */
  779.   /* USER CODE END SPI2_Init 0 */
  780.   /* USER CODE BEGIN SPI2_Init 1 */
  781.   /* USER CODE END SPI2_Init 1 */
  782.   /* SPI2 parameter configuration*/
  783.   hspi2.Instance = SPI2;
  784.   hspi2.Init.Mode = SPI_MODE_MASTER;
  785.   hspi2.Init.Direction = SPI_DIRECTION_2LINES;
  786.   hspi2.Init.DataSize = SPI_DATASIZE_4BIT;
  787.   hspi2.Init.CLKPolarity = SPI_POLARITY_LOW;
  788.   hspi2.Init.CLKPhase = SPI_PHASE_1EDGE;
  789.   hspi2.Init.NSS = SPI_NSS_HARD_INPUT;
  790.   hspi2.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_2;
  791.   hspi2.Init.FirstBit = SPI_FIRSTBIT_MSB;
  792.   hspi2.Init.TIMode = SPI_TIMODE_DISABLE;
  793.   hspi2.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
  794.   hspi2.Init.CRCPolynomial = 0x0;
  795.   hspi2.Init.NSSPMode = SPI_NSS_PULSE_ENABLE;
  796.   hspi2.Init.NSSPolarity = SPI_NSS_POLARITY_LOW;
  797.   hspi2.Init.FifoThreshold = SPI_FIFO_THRESHOLD_01DATA;
  798.   hspi2.Init.TxCRCInitializationPattern = SPI_CRC_INITIALIZATION_ALL_ZERO_PATTERN;
  799.   hspi2.Init.RxCRCInitializationPattern = SPI_CRC_INITIALIZATION_ALL_ZERO_PATTERN;
  800.   hspi2.Init.MasterSSIdleness = SPI_MASTER_SS_IDLENESS_00CYCLE;
  801.   hspi2.Init.MasterInterDataIdleness = SPI_MASTER_INTERDATA_IDLENESS_00CYCLE;
  802.   hspi2.Init.MasterReceiverAutoSusp = SPI_MASTER_RX_AUTOSUSP_DISABLE;
  803.   hspi2.Init.MasterKeepIOState = SPI_MASTER_KEEP_IO_STATE_DISABLE;
  804.   hspi2.Init.IOSwap = SPI_IO_SWAP_DISABLE;
  805.   if (HAL_SPI_Init(&hspi2) != HAL_OK)
  806.   {
  807.     Error_Handler();
  808.   }
  809.   /* USER CODE BEGIN SPI2_Init 2 */
  810.   /* USER CODE END SPI2_Init 2 */
  811. }
  812. /**
  813.   * @brief USART3 Initialization Function
  814.   * @param None
  815.   * @retval None
  816.   */
  817. static void MX_USART3_UART_Init(void)
  818. {
  819.   /* USER CODE BEGIN USART3_Init 0 */
  820.   /* USER CODE END USART3_Init 0 */
  821.   /* USER CODE BEGIN USART3_Init 1 */
  822.   /* USER CODE END USART3_Init 1 */
  823.   huart3.Instance = USART3;
  824.   huart3.Init.BaudRate = 115200;
  825.   huart3.Init.WordLength = UART_WORDLENGTH_8B;
  826.   huart3.Init.StopBits = UART_STOPBITS_1;
  827.   huart3.Init.Parity = UART_PARITY_NONE;
  828.   huart3.Init.Mode = UART_MODE_TX_RX;
  829.   huart3.Init.HwFlowCtl = UART_HWCONTROL_NONE;
  830.   huart3.Init.OverSampling = UART_OVERSAMPLING_16;
  831.   huart3.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
  832.   huart3.Init.ClockPrescaler = UART_PRESCALER_DIV1;
  833.   huart3.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
  834.   if (HAL_UART_Init(&huart3) != HAL_OK)
  835.   {
  836.     Error_Handler();
  837.   }
  838.   if (HAL_UARTEx_SetTxFifoThreshold(&huart3, UART_TXFIFO_THRESHOLD_1_8) != HAL_OK)
  839.   {
  840.     Error_Handler();
  841.   }
  842.   if (HAL_UARTEx_SetRxFifoThreshold(&huart3, UART_RXFIFO_THRESHOLD_1_8) != HAL_OK)
  843.   {
  844.     Error_Handler();
  845.   }
  846.   if (HAL_UARTEx_DisableFifoMode(&huart3) != HAL_OK)
  847.   {
  848.     Error_Handler();
  849.   }
  850.   /* USER CODE BEGIN USART3_Init 2 */
  851.   /* USER CODE END USART3_Init 2 */
  852. }
  853. /* FMC initialization function */
  854. static void MX_FMC_Init(void)
  855. {
  856.   /* USER CODE BEGIN FMC_Init 0 */
  857.   /* USER CODE END FMC_Init 0 */
  858.   FMC_SDRAM_TimingTypeDef SdramTiming = {0};
  859.   /* USER CODE BEGIN FMC_Init 1 */
  860.   /* USER CODE END FMC_Init 1 */
  861.   /** Perform the SDRAM1 memory initialization sequence
  862.   */
  863.   hsdram1.Instance = FMC_SDRAM_DEVICE;
  864.   /* hsdram1.Init */
  865.   hsdram1.Init.SDBank = FMC_SDRAM_BANK2;
  866.   hsdram1.Init.ColumnBitsNumber = FMC_SDRAM_COLUMN_BITS_NUM_8;
  867.   hsdram1.Init.RowBitsNumber = FMC_SDRAM_ROW_BITS_NUM_12;
  868.   hsdram1.Init.MemoryDataWidth = FMC_SDRAM_MEM_BUS_WIDTH_16;
  869.   hsdram1.Init.InternalBankNumber = FMC_SDRAM_INTERN_BANKS_NUM_4;
  870.   hsdram1.Init.CASLatency = FMC_SDRAM_CAS_LATENCY_1;
  871.   hsdram1.Init.WriteProtection = FMC_SDRAM_WRITE_PROTECTION_DISABLE;
  872.   hsdram1.Init.SDClockPeriod = FMC_SDRAM_CLOCK_DISABLE;
  873.   hsdram1.Init.ReadBurst = FMC_SDRAM_RBURST_DISABLE;
  874.   hsdram1.Init.ReadPipeDelay = FMC_SDRAM_RPIPE_DELAY_0;
  875.   /* SdramTiming */
  876.   SdramTiming.LoadToActiveDelay = 16;
  877.   SdramTiming.ExitSelfRefreshDelay = 16;
  878.   SdramTiming.SelfRefreshTime = 16;
  879.   SdramTiming.RowCycleDelay = 16;
  880.   SdramTiming.WriteRecoveryTime = 16;
  881.   SdramTiming.RPDelay = 16;
  882.   SdramTiming.RCDDelay = 16;
  883.   if (HAL_SDRAM_Init(&hsdram1, &SdramTiming) != HAL_OK)
  884.   {
  885.     Error_Handler( );
  886.   }
  887.   /* USER CODE BEGIN FMC_Init 2 */
  888.   /* USER CODE END FMC_Init 2 */
  889. }
  890. /**
  891.   * @brief GPIO Initialization Function
  892.   * @param None
  893.   * @retval None
  894.   */
  895. static void MX_GPIO_Init(void)
  896. {
  897.   GPIO_InitTypeDef GPIO_InitStruct = {0};
  898.   /* GPIO Ports Clock Enable */
  899.   __HAL_RCC_GPIOI_CLK_ENABLE();
  900.   __HAL_RCC_GPIOB_CLK_ENABLE();
  901.   __HAL_RCC_GPIOK_CLK_ENABLE();
  902.   __HAL_RCC_GPIOG_CLK_ENABLE();
  903.   __HAL_RCC_GPIOC_CLK_ENABLE();
  904.   __HAL_RCC_GPIOE_CLK_ENABLE();
  905.   __HAL_RCC_GPIOJ_CLK_ENABLE();
  906.   __HAL_RCC_GPIOD_CLK_ENABLE();
  907.   __HAL_RCC_GPIOH_CLK_ENABLE();
  908.   __HAL_RCC_GPIOA_CLK_ENABLE();
  909.   __HAL_RCC_GPIOF_CLK_ENABLE();
  910.   /*Configure GPIO pin Output Level */
  911.   HAL_GPIO_WritePin(LD2_GPIO_Port, LD2_Pin, GPIO_PIN_RESET);
  912.   /*Configure GPIO pin Output Level */
  913.   HAL_GPIO_WritePin(LD1_GPIO_Port, LD1_Pin, GPIO_PIN_RESET);
  914.   /*Configure GPIO pin Output Level */
  915.   HAL_GPIO_WritePin(LCD_RST_GPIO_Port, LCD_RST_Pin, GPIO_PIN_RESET);
  916.   /*Configure GPIO pin : PH15 */
  917.   GPIO_InitStruct.Pin = GPIO_PIN_15;
  918.   GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  919.   GPIO_InitStruct.Pull = GPIO_NOPULL;
  920.   GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  921.   GPIO_InitStruct.Alternate = GPIO_AF3_TIM8;
  922.   HAL_GPIO_Init(GPIOH, &GPIO_InitStruct);
  923.   /*Configure GPIO pin : LCD_DISPD7_Pin */
  924.   GPIO_InitStruct.Pin = LCD_DISPD7_Pin;
  925.   GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  926.   GPIO_InitStruct.Pull = GPIO_NOPULL;
  927.   HAL_GPIO_Init(LCD_DISPD7_GPIO_Port, &GPIO_InitStruct);
  928.   /*Configure GPIO pins : PE5 PE4 */
  929.   GPIO_InitStruct.Pin = GPIO_PIN_5|GPIO_PIN_4;
  930.   GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  931.   GPIO_InitStruct.Pull = GPIO_NOPULL;
  932.   GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  933.   GPIO_InitStruct.Alternate = GPIO_AF10_SAI4;
  934.   HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
  935.   /*Configure GPIO pin : USB_OTG_FS2_ID_Pin */
  936.   GPIO_InitStruct.Pin = USB_OTG_FS2_ID_Pin;
  937.   GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  938.   GPIO_InitStruct.Pull = GPIO_NOPULL;
  939.   HAL_GPIO_Init(USB_OTG_FS2_ID_GPIO_Port, &GPIO_InitStruct);
  940.   /*Configure GPIO pin : B1_Pin */
  941.   GPIO_InitStruct.Pin = B1_Pin;
  942.   GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  943.   GPIO_InitStruct.Pull = GPIO_NOPULL;
  944.   HAL_GPIO_Init(B1_GPIO_Port, &GPIO_InitStruct);
  945.   /*Configure GPIO pin : PA8 */
  946.   GPIO_InitStruct.Pin = GPIO_PIN_8;
  947.   GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  948.   GPIO_InitStruct.Pull = GPIO_NOPULL;
  949.   GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  950.   GPIO_InitStruct.Alternate = GPIO_AF1_TIM1;
  951.   HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  952.   /*Configure GPIO pin : LD2_Pin */
  953.   GPIO_InitStruct.Pin = LD2_Pin;
  954.   GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  955.   GPIO_InitStruct.Pull = GPIO_NOPULL;
  956.   GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  957.   HAL_GPIO_Init(LD2_GPIO_Port, &GPIO_InitStruct);
  958.   /*Configure GPIO pin : LCD_INT_Pin */
  959.   GPIO_InitStruct.Pin = LCD_INT_Pin;
  960.   GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
  961.   GPIO_InitStruct.Pull = GPIO_NOPULL;
  962.   HAL_GPIO_Init(LCD_INT_GPIO_Port, &GPIO_InitStruct);
  963.   /*Configure GPIO pin : LCD_BL_Pin */
  964.   GPIO_InitStruct.Pin = LCD_BL_Pin;
  965.   GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  966.   GPIO_InitStruct.Pull = GPIO_NOPULL;
  967.   HAL_GPIO_Init(LCD_BL_GPIO_Port, &GPIO_InitStruct);
  968.   /*Configure GPIO pin : OTG_FS2_OverCurrent_Pin */
  969.   GPIO_InitStruct.Pin = OTG_FS2_OverCurrent_Pin;
  970.   GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
  971.   GPIO_InitStruct.Pull = GPIO_NOPULL;
  972.   HAL_GPIO_Init(OTG_FS2_OverCurrent_GPIO_Port, &GPIO_InitStruct);
  973.   /*Configure GPIO pin : PA6 */
  974.   GPIO_InitStruct.Pin = GPIO_PIN_6;
  975.   GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  976.   GPIO_InitStruct.Pull = GPIO_NOPULL;
  977.   GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  978.   GPIO_InitStruct.Alternate = GPIO_AF9_TIM13;
  979.   HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  980.   /*Configure GPIO pin : LD1_Pin */
  981.   GPIO_InitStruct.Pin = LD1_Pin;
  982.   GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  983.   GPIO_InitStruct.Pull = GPIO_NOPULL;
  984.   GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  985.   HAL_GPIO_Init(LD1_GPIO_Port, &GPIO_InitStruct);
  986.   /*Configure GPIO pin : LCD_RST_Pin */
  987.   GPIO_InitStruct.Pin = LCD_RST_Pin;
  988.   GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  989.   GPIO_InitStruct.Pull = GPIO_NOPULL;
  990.   GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  991.   HAL_GPIO_Init(LCD_RST_GPIO_Port, &GPIO_InitStruct);
  992. }
  993. /* USER CODE BEGIN 4 */
  994. /* USER CODE END 4 */
  995. /* USER CODE BEGIN Header_StartDefaultTask */
  996. /**
  997.   * @brief  Function implementing the defaultTask thread.
  998.   * @param  argument: Not used
  999.   * @retval None
  1000.   */
  1001. /* USER CODE END Header_StartDefaultTask */
  1002. void StartDefaultTask(void *argument)
  1003. {
  1004.   /* init code for USB_DEVICE */
  1005.   MX_USB_DEVICE_Init();
  1006.   /* USER CODE BEGIN 5 */
  1007.   /* Infinite loop */
  1008.   for(;;)
  1009.   {
  1010.     osDelay(1);
  1011.   }
  1012.   /* USER CODE END 5 */
  1013. }
  1014. /**
  1015.   * @brief  Period elapsed callback in non blocking mode
  1016.   * [url=home.php?mod=space&uid=536309]@NOTE[/url]   This function is called  when TIM1 interrupt took place, inside
  1017.   * HAL_TIM_IRQHandler(). It makes a direct call to HAL_IncTick() to increment
  1018.   * a global variable "uwTick" used as application time base.
  1019.   * @param  htim : TIM handle
  1020.   * @retval None
  1021.   */
  1022. void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
  1023. {
  1024.   /* USER CODE BEGIN Callback 0 */
  1025.   /* USER CODE END Callback 0 */
  1026.   if (htim->Instance == TIM1) {
  1027.     HAL_IncTick();
  1028.   }
  1029.   /* USER CODE BEGIN Callback 1 */
  1030.   /* USER CODE END Callback 1 */
  1031. }
  1032. /**
  1033.   * @brief  This function is executed in case of error occurrence.
  1034.   * @retval None
  1035.   */
  1036. void Error_Handler(void)
  1037. {
  1038.   /* USER CODE BEGIN Error_Handler_Debug */
  1039.   /* User can add his own implementation to report the HAL error return state */
  1040.   __disable_irq();
  1041.   while (1)
  1042.   {
  1043.   }
  1044.   /* USER CODE END Error_Handler_Debug */
  1045. }
  1046. #ifdef  USE_FULL_ASSERT
  1047. /**
  1048.   * @brief  Reports the name of the source file and the source line number
  1049.   *         where the assert_param error has occurred.
  1050.   * @param  file: pointer to the source file name
  1051.   * @param  line: assert_param error line source number
  1052.   * @retval None
  1053.   */
  1054. void assert_failed(uint8_t *file, uint32_t line)
  1055. {
  1056.   /* USER CODE BEGIN 6 */
  1057.   /* User can add his own implementation to report the file name and line number,
  1058.      ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
  1059.   /* USER CODE END 6 */
  1060. }
  1061. #endif /* USE_FULL_ASSERT */

我们开始编译测试,看到编译成功


这套工具开发非常方便,节省了大量的时间;能够快速进入应用代码开发;真的是工程师的福音!
ui界面开发,下载图形界面开发工具TouchGFX 4.21.0 Designer,最新版本4.21,话不多说,直奔目标在搜索框输入750,开发板就出来了 
新建工程,进入开发界面,异常简单方便,里面有丰富的组件,突然就想起了以前开发MFC的日子了。这个开发工具的图形界面底层使用的C++,点击右下角的生成代码,其实新建工程的时候直接会生成一个完整的工程包,在操作此软件的过程中会把自动生成的C++代码自动添加到工程中,可以加载到IDE中

第一个工程就是图形界面生成的工程主程序代码如下:

  1. /* USER CODE BEGIN Header */
  2. /**
  3.   ******************************************************************************
  4.   * [url=home.php?mod=space&uid=288409]@file[/url]           : main.c
  5.   * @brief          : Main program body
  6.   ******************************************************************************
  7.   * @attention
  8.   *
  9.   * <h2><center>© Copyright (c) 2020 STMicroelectronics.
  10.   * All rights reserved.</center></h2>
  11.   *
  12.   * This software component is licensed by ST under Ultimate Liberty license
  13.   * SLA0044, the "License"; You may not use this file except in compliance with
  14.   * the License. You may obtain a copy of the License at:
  15.   *                             www.st.com/SLA0044
  16.   *
  17.   ******************************************************************************
  18.   */
  19. /* USER CODE END Header */
  20. /* Includes ------------------------------------------------------------------*/
  21. #include "main.h"
  22. #include "cmsis_os.h"
  23. #include "libjpeg.h"
  24. #include "app_touchgfx.h"
  25. /* Private includes ----------------------------------------------------------*/
  26. /* USER CODE BEGIN Includes */
  27. #include "stm32h750b_discovery_qspi.h"
  28. #include "stm32h750b_discovery_sdram.h"
  29. /* USER CODE END Includes */
  30. /* Private typedef -----------------------------------------------------------*/
  31. /* USER CODE BEGIN PTD */
  32. /* USER CODE END PTD */
  33. /* Private define ------------------------------------------------------------*/
  34. /* USER CODE BEGIN PD */
  35. /* USER CODE END PD */
  36. /* Private macro -------------------------------------------------------------*/
  37. /* USER CODE BEGIN PM */
  38. /* USER CODE END PM */
  39. /* Private variables ---------------------------------------------------------*/
  40. CRC_HandleTypeDef hcrc;
  41. DMA2D_HandleTypeDef hdma2d;
  42. JPEG_HandleTypeDef hjpeg;
  43. MDMA_HandleTypeDef hmdma_jpeg_infifo_th;
  44. MDMA_HandleTypeDef hmdma_jpeg_outfifo_th;
  45. LTDC_HandleTypeDef hltdc;
  46. QSPI_HandleTypeDef hqspi;
  47. SDRAM_HandleTypeDef hsdram2;
  48. /* Definitions for defaultTask */
  49. osThreadId_t defaultTaskHandle;
  50. const osThreadAttr_t defaultTask_attributes = {
  51.   .name = "defaultTask",
  52.   .stack_size = 128 * 4,
  53.   .priority = (osPriority_t) osPriorityNormal,
  54. };
  55. /* Definitions for GUITask */
  56. osThreadId_t GUITaskHandle;
  57. const osThreadAttr_t GUITask_attributes = {
  58.   .name = "GUITask",
  59.   .stack_size = 8192 * 4,
  60.   .priority = (osPriority_t) osPriorityNormal,
  61. };
  62. /* Definitions for videoTask */
  63. osThreadId_t videoTaskHandle;
  64. const osThreadAttr_t videoTask_attributes = {
  65.   .name = "videoTask",
  66.   .stack_size = 1000 * 4,
  67.   .priority = (osPriority_t) osPriorityLow,
  68. };
  69. /* USER CODE BEGIN PV */
  70. /* USER CODE END PV */
  71. /* Private function prototypes -----------------------------------------------*/
  72. void SystemClock_Config(void);
  73. static void MPU_Config(void);
  74. static void MX_GPIO_Init(void);
  75. static void MX_MDMA_Init(void);
  76. static void MX_LTDC_Init(void);
  77. static void MX_DMA2D_Init(void);
  78. static void MX_QUADSPI_Init(void);
  79. static void MX_FMC_Init(void);
  80. static void MX_JPEG_Init(void);
  81. static void MX_CRC_Init(void);
  82. void StartDefaultTask(void *argument);
  83. extern void TouchGFX_Task(void *argument);
  84. extern void videoTaskFunc(void *argument);
  85. /* USER CODE BEGIN PFP */
  86. /* USER CODE END PFP */
  87. /* Private user code ---------------------------------------------------------*/
  88. /* USER CODE BEGIN 0 */
  89. /* USER CODE END 0 */
  90. /**
  91.   * @brief  The application entry point.
  92.   * @retval int
  93.   */
  94. int main(void)
  95. {
  96.   /* USER CODE BEGIN 1 */
  97.   /* USER CODE END 1 */
  98.   /* MPU Configuration--------------------------------------------------------*/
  99.   MPU_Config();
  100.   /* Enable I-Cache---------------------------------------------------------*/
  101.   SCB_EnableICache();
  102.   /* Enable D-Cache---------------------------------------------------------*/
  103.   SCB_EnableDCache();
  104.   /* MCU Configuration--------------------------------------------------------*/
  105.   /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  106.   HAL_Init();
  107.   /* USER CODE BEGIN Init */
  108.   /* USER CODE END Init */
  109.   /* Configure the system clock */
  110.   SystemClock_Config();
  111.   /* USER CODE BEGIN SysInit */
  112.   /* Explicit enabling interrupt to support debugging in CubeIDE when using external flash loader */
  113.   __enable_irq();
  114.   /* USER CODE END SysInit */
  115.   /* Initialize all configured peripherals */
  116.   MX_GPIO_Init();
  117.   MX_MDMA_Init();
  118.   MX_LTDC_Init();
  119.   MX_DMA2D_Init();
  120.   MX_FMC_Init();
  121.   MX_LIBJPEG_Init();
  122.   MX_JPEG_Init();
  123.   MX_CRC_Init();
  124.   MX_TouchGFX_Init();
  125.   /* Call PreOsInit function */
  126.   MX_TouchGFX_PreOSInit();
  127.   /* USER CODE BEGIN 2 */
  128.   /* USER CODE END 2 */
  129.   /* Init scheduler */
  130.   osKernelInitialize();
  131.   /* USER CODE BEGIN RTOS_MUTEX */
  132.   /* add mutexes, ... */
  133.   /* USER CODE END RTOS_MUTEX */
  134.   /* USER CODE BEGIN RTOS_SEMAPHORES */
  135.   /* add semaphores, ... */
  136.   /* USER CODE END RTOS_SEMAPHORES */
  137.   /* USER CODE BEGIN RTOS_TIMERS */
  138.   /* start timers, add new ones, ... */
  139.   /* USER CODE END RTOS_TIMERS */
  140.   /* USER CODE BEGIN RTOS_QUEUES */
  141.   /* add queues, ... */
  142.   /* USER CODE END RTOS_QUEUES */
  143.   /* Create the thread(s) */
  144.   /* creation of defaultTask */
  145.   defaultTaskHandle = osThreadNew(StartDefaultTask, NULL, &defaultTask_attributes);
  146.   /* creation of GUITask */
  147.   GUITaskHandle = osThreadNew(TouchGFX_Task, NULL, &GUITask_attributes);
  148.   /* creation of videoTask */
  149.   videoTaskHandle = osThreadNew(videoTaskFunc, NULL, &videoTask_attributes);
  150.   /* USER CODE BEGIN RTOS_THREADS */
  151.   /* add threads, ... */
  152.   /* USER CODE END RTOS_THREADS */
  153.   /* USER CODE BEGIN RTOS_EVENTS */
  154.   /* add events, ... */
  155.   /* USER CODE END RTOS_EVENTS */
  156.   /* Start scheduler */
  157.   osKernelStart();
  158.   /* We should never get here as control is now taken by the scheduler */
  159.   /* Infinite loop */
  160.   /* USER CODE BEGIN WHILE */
  161.   while (1)
  162.   {
  163.     /* USER CODE END WHILE */
  164.     /* USER CODE BEGIN 3 */
  165.   }
  166.   /* USER CODE END 3 */
  167. }
  168. /**
  169.   * @brief System Clock Configuration
  170.   * @retval None
  171.   */
  172. void SystemClock_Config(void)
  173. {
  174.   RCC_OscInitTypeDef RCC_OscInitStruct = {0};
  175.   RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
  176.   /** Supply configuration update enable
  177.   */
  178.   HAL_PWREx_ConfigSupply(PWR_LDO_SUPPLY);
  179.   /** Configure the main internal regulator output voltage
  180.   */
  181.   __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
  182.   while(!__HAL_PWR_GET_FLAG(PWR_FLAG_VOSRDY)) {}
  183.   /** Macro to configure the PLL clock source
  184.   */
  185.   __HAL_RCC_PLL_PLLSOURCE_CONFIG(RCC_PLLSOURCE_HSE);
  186.   /** Initializes the RCC Oscillators according to the specified parameters
  187.   * in the RCC_OscInitTypeDef structure.
  188.   */
  189.   RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
  190.   RCC_OscInitStruct.HSEState = RCC_HSE_ON;
  191.   RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
  192.   RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
  193.   RCC_OscInitStruct.PLL.PLLM = 5;
  194.   RCC_OscInitStruct.PLL.PLLN = 160;
  195.   RCC_OscInitStruct.PLL.PLLP = 2;
  196.   RCC_OscInitStruct.PLL.PLLQ = 4;
  197.   RCC_OscInitStruct.PLL.PLLR = 2;
  198.   RCC_OscInitStruct.PLL.PLLRGE = RCC_PLL1VCIRANGE_2;
  199.   RCC_OscInitStruct.PLL.PLLVCOSEL = RCC_PLL1VCOWIDE;
  200.   RCC_OscInitStruct.PLL.PLLFRACN = 0;
  201.   if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
  202.   {
  203.     Error_Handler();
  204.   }
  205.   /** Initializes the CPU, AHB and APB buses clocks
  206.   */
  207.   RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
  208.                               |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2
  209.                               |RCC_CLOCKTYPE_D3PCLK1|RCC_CLOCKTYPE_D1PCLK1;
  210.   RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
  211.   RCC_ClkInitStruct.SYSCLKDivider = RCC_SYSCLK_DIV1;
  212.   RCC_ClkInitStruct.AHBCLKDivider = RCC_HCLK_DIV2;
  213.   RCC_ClkInitStruct.APB3CLKDivider = RCC_APB3_DIV2;
  214.   RCC_ClkInitStruct.APB1CLKDivider = RCC_APB1_DIV2;
  215.   RCC_ClkInitStruct.APB2CLKDivider = RCC_APB2_DIV2;
  216.   RCC_ClkInitStruct.APB4CLKDivider = RCC_APB4_DIV2;
  217.   if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK)
  218.   {
  219.     Error_Handler();
  220.   }
  221. }
  222. /**
  223.   * @brief CRC Initialization Function
  224.   * @param None
  225.   * @retval None
  226.   */
  227. static void MX_CRC_Init(void)
  228. {
  229.   /* USER CODE BEGIN CRC_Init 0 */
  230.   /* USER CODE END CRC_Init 0 */
  231.   /* USER CODE BEGIN CRC_Init 1 */
  232.   /* USER CODE END CRC_Init 1 */
  233.   hcrc.Instance = CRC;
  234.   hcrc.Init.DefaultPolynomialUse = DEFAULT_POLYNOMIAL_ENABLE;
  235.   hcrc.Init.DefaultInitValueUse = DEFAULT_INIT_VALUE_ENABLE;
  236.   hcrc.Init.InputDataInversionMode = CRC_INPUTDATA_INVERSION_NONE;
  237.   hcrc.Init.OutputDataInversionMode = CRC_OUTPUTDATA_INVERSION_DISABLE;
  238.   hcrc.InputDataFormat = CRC_INPUTDATA_FORMAT_BYTES;
  239.   if (HAL_CRC_Init(&hcrc) != HAL_OK)
  240.   {
  241.     Error_Handler();
  242.   }
  243.   /* USER CODE BEGIN CRC_Init 2 */
  244.   /* USER CODE END CRC_Init 2 */
  245. }
  246. /**
  247.   * @brief DMA2D Initialization Function
  248.   * @param None
  249.   * @retval None
  250.   */
  251. static void MX_DMA2D_Init(void)
  252. {
  253.   /* USER CODE BEGIN DMA2D_Init 0 */
  254.   /* USER CODE END DMA2D_Init 0 */
  255.   /* USER CODE BEGIN DMA2D_Init 1 */
  256.   /* USER CODE END DMA2D_Init 1 */
  257.   hdma2d.Instance = DMA2D;
  258.   hdma2d.Init.Mode = DMA2D_M2M;
  259.   hdma2d.Init.ColorMode = DMA2D_OUTPUT_RGB565;
  260.   hdma2d.Init.OutputOffset = 0;
  261.   hdma2d.LayerCfg[1].InputOffset = 0;
  262.   hdma2d.LayerCfg[1].InputColorMode = DMA2D_INPUT_RGB565;
  263.   hdma2d.LayerCfg[1].AlphaMode = DMA2D_NO_MODIF_ALPHA;
  264.   hdma2d.LayerCfg[1].InputAlpha = 0;
  265.   hdma2d.LayerCfg[1].AlphaInverted = DMA2D_REGULAR_ALPHA;
  266.   hdma2d.LayerCfg[1].RedBlueSwap = DMA2D_RB_REGULAR;
  267.   hdma2d.LayerCfg[1].ChromaSubSampling = DMA2D_NO_CSS;
  268.   if (HAL_DMA2D_Init(&hdma2d) != HAL_OK)
  269.   {
  270.     Error_Handler();
  271.   }
  272.   if (HAL_DMA2D_ConfigLayer(&hdma2d, 1) != HAL_OK)
  273.   {
  274.     Error_Handler();
  275.   }
  276.   /* USER CODE BEGIN DMA2D_Init 2 */
  277.   /* USER CODE END DMA2D_Init 2 */
  278. }
  279. /**
  280.   * @brief JPEG Initialization Function
  281.   * @param None
  282.   * @retval None
  283.   */
  284. static void MX_JPEG_Init(void)
  285. {
  286.   /* USER CODE BEGIN JPEG_Init 0 */
  287.   /* USER CODE END JPEG_Init 0 */
  288.   /* USER CODE BEGIN JPEG_Init 1 */
  289.   /* USER CODE END JPEG_Init 1 */
  290.   hjpeg.Instance = JPEG;
  291.   if (HAL_JPEG_Init(&hjpeg) != HAL_OK)
  292.   {
  293.     Error_Handler();
  294.   }
  295.   /* USER CODE BEGIN JPEG_Init 2 */
  296.   /* USER CODE END JPEG_Init 2 */
  297. }
  298. /**
  299.   * @brief LTDC Initialization Function
  300.   * @param None
  301.   * @retval None
  302.   */
  303. static void MX_LTDC_Init(void)
  304. {
  305.   /* USER CODE BEGIN LTDC_Init 0 */
  306.   /* USER CODE END LTDC_Init 0 */
  307.   LTDC_LayerCfgTypeDef pLayerCfg = {0};
  308.   /* USER CODE BEGIN LTDC_Init 1 */
  309.   /* USER CODE END LTDC_Init 1 */
  310.   hltdc.Instance = LTDC;
  311.   hltdc.Init.HSPolarity = LTDC_HSPOLARITY_AL;
  312.   hltdc.Init.VSPolarity = LTDC_VSPOLARITY_AL;
  313.   hltdc.Init.DEPolarity = LTDC_DEPOLARITY_AL;
  314.   hltdc.Init.PCPolarity = LTDC_PCPOLARITY_IPC;
  315.   hltdc.Init.HorizontalSync = 39;
  316.   hltdc.Init.VerticalSync = 8;
  317.   hltdc.Init.AccumulatedHBP = 42;
  318.   hltdc.Init.AccumulatedVBP = 11;
  319.   hltdc.Init.AccumulatedActiveW = 522;
  320.   hltdc.Init.AccumulatedActiveH = 283;
  321.   hltdc.Init.TotalWidth = 528;
  322.   hltdc.Init.TotalHeigh = 285;
  323.   hltdc.Init.Backcolor.Blue = 0;
  324.   hltdc.Init.Backcolor.Green = 0;
  325.   hltdc.Init.Backcolor.Red = 0;
  326.   if (HAL_LTDC_Init(&hltdc) != HAL_OK)
  327.   {
  328.     Error_Handler();
  329.   }
  330.   pLayerCfg.WindowX0 = 0;
  331.   pLayerCfg.WindowX1 = 480;
  332.   pLayerCfg.WindowY0 = 0;
  333.   pLayerCfg.WindowY1 = 272;
  334.   pLayerCfg.PixelFormat = LTDC_PIXEL_FORMAT_RGB565;
  335.   pLayerCfg.Alpha = 255;
  336.   pLayerCfg.Alpha0 = 0;
  337.   pLayerCfg.BlendingFactor1 = LTDC_BLENDING_FACTOR1_CA;
  338.   pLayerCfg.BlendingFactor2 = LTDC_BLENDING_FACTOR2_CA;
  339.   pLayerCfg.FBStartAdress = 0;
  340.   pLayerCfg.ImageWidth = 480;
  341.   pLayerCfg.ImageHeight = 272;
  342.   pLayerCfg.Backcolor.Blue = 0;
  343.   pLayerCfg.Backcolor.Green = 0;
  344.   pLayerCfg.Backcolor.Red = 0;
  345.   if (HAL_LTDC_ConfigLayer(&hltdc, &pLayerCfg, 0) != HAL_OK)
  346.   {
  347.     Error_Handler();
  348.   }
  349.   /* USER CODE BEGIN LTDC_Init 2 */
  350.   /* USER CODE END LTDC_Init 2 */
  351. }
  352. /**
  353.   * @brief QUADSPI Initialization Function
  354.   * @param None
  355.   * @retval None
  356.   */
  357. static void MX_QUADSPI_Init(void)
  358. {
  359.   /* USER CODE BEGIN QUADSPI_Init 0 */
  360.   BSP_QSPI_Init_t qspi_initParams ;
  361.   /* USER CODE END QUADSPI_Init 0 */
  362.   /* USER CODE BEGIN QUADSPI_Init 1 */
  363.   /* USER CODE END QUADSPI_Init 1 */
  364.   /* QUADSPI parameter configuration*/
  365.   hqspi.Instance = QUADSPI;
  366.   hqspi.Init.ClockPrescaler = 3;
  367.   hqspi.Init.FifoThreshold = 1;
  368.   hqspi.Init.SampleShifting = QSPI_SAMPLE_SHIFTING_NONE;
  369.   hqspi.Init.FlashSize = 26;
  370.   hqspi.Init.ChipSelectHighTime = QSPI_CS_HIGH_TIME_4_CYCLE;
  371.   hqspi.Init.ClockMode = QSPI_CLOCK_MODE_0;
  372.   hqspi.Init.DualFlash = QSPI_DUALFLASH_ENABLE;
  373.   if (HAL_QSPI_Init(&hqspi) != HAL_OK)
  374.   {
  375.     Error_Handler();
  376.   }
  377.   /* USER CODE BEGIN QUADSPI_Init 2 */
  378.   qspi_initParams.InterfaceMode = MT25TL01G_QPI_MODE;
  379.   qspi_initParams.TransferRate  = MT25TL01G_DTR_TRANSFER ;
  380.   qspi_initParams.DualFlashMode = MT25TL01G_DUALFLASH_ENABLE;
  381.   BSP_QSPI_DeInit(0);
  382.   if (BSP_QSPI_Init(0, &qspi_initParams) != BSP_ERROR_NONE)
  383.   {
  384.     Error_Handler( );
  385.   }
  386.   if(BSP_QSPI_EnableMemoryMappedMode(0) != BSP_ERROR_NONE)
  387.   {
  388.     Error_Handler( );
  389.   }
  390.   /* USER CODE END QUADSPI_Init 2 */
  391. }
  392. /**
  393.   * Enable MDMA controller clock
  394.   */
  395. static void MX_MDMA_Init(void)
  396. {
  397.   /* MDMA controller clock enable */
  398.   __HAL_RCC_MDMA_CLK_ENABLE();
  399.   /* Local variables */
  400.   /* MDMA interrupt initialization */
  401.   /* MDMA_IRQn interrupt configuration */
  402.   HAL_NVIC_SetPriority(MDMA_IRQn, 5, 0);
  403.   HAL_NVIC_EnableIRQ(MDMA_IRQn);
  404. }
  405. /* FMC initialization function */
  406. static void MX_FMC_Init(void)
  407. {
  408.   /* USER CODE BEGIN FMC_Init 0 */
  409.   /* USER CODE END FMC_Init 0 */
  410.   FMC_SDRAM_TimingTypeDef SdramTiming = {0};
  411.   /* USER CODE BEGIN FMC_Init 1 */
  412.   /* USER CODE END FMC_Init 1 */
  413.   /** Perform the SDRAM2 memory initialization sequence
  414.   */
  415.   hsdram2.Instance = FMC_SDRAM_DEVICE;
  416.   /* hsdram2.Init */
  417.   hsdram2.Init.SDBank = FMC_SDRAM_BANK2;
  418.   hsdram2.Init.ColumnBitsNumber = FMC_SDRAM_COLUMN_BITS_NUM_8;
  419.   hsdram2.Init.RowBitsNumber = FMC_SDRAM_ROW_BITS_NUM_12;
  420.   hsdram2.Init.MemoryDataWidth = FMC_SDRAM_MEM_BUS_WIDTH_16;
  421.   hsdram2.Init.InternalBankNumber = FMC_SDRAM_INTERN_BANKS_NUM_4;
  422.   hsdram2.Init.CASLatency = FMC_SDRAM_CAS_LATENCY_3;
  423.   hsdram2.Init.WriteProtection = FMC_SDRAM_WRITE_PROTECTION_DISABLE;
  424.   hsdram2.Init.SDClockPeriod = FMC_SDRAM_CLOCK_PERIOD_2;
  425.   hsdram2.Init.ReadBurst = FMC_SDRAM_RBURST_ENABLE;
  426.   hsdram2.Init.ReadPipeDelay = FMC_SDRAM_RPIPE_DELAY_0;
  427.   /* SdramTiming */
  428.   SdramTiming.LoadToActiveDelay = 2;
  429.   SdramTiming.ExitSelfRefreshDelay = 7;
  430.   SdramTiming.SelfRefreshTime = 4;
  431.   SdramTiming.RowCycleDelay = 7;
  432.   SdramTiming.WriteRecoveryTime = 5;
  433.   SdramTiming.RPDelay = 2;
  434.   SdramTiming.RCDDelay = 2;
  435.   if (HAL_SDRAM_Init(&hsdram2, &SdramTiming) != HAL_OK)
  436.   {
  437.     Error_Handler( );
  438.   }
  439.   /* USER CODE BEGIN FMC_Init 2 */
  440.   BSP_SDRAM_DeInit(0);
  441.   if(BSP_SDRAM_Init(0) != BSP_ERROR_NONE)
  442.   {
  443.     Error_Handler( );
  444.   }
  445.   /* USER CODE END FMC_Init 2 */
  446. }
  447. /**
  448.   * @brief GPIO Initialization Function
  449.   * @param None
  450.   * @retval None
  451.   */
  452. static void MX_GPIO_Init(void)
  453. {
  454.   GPIO_InitTypeDef GPIO_InitStruct = {0};
  455.   /* GPIO Ports Clock Enable */
  456.   __HAL_RCC_GPIOK_CLK_ENABLE();
  457.   __HAL_RCC_GPIOG_CLK_ENABLE();
  458.   __HAL_RCC_GPIOI_CLK_ENABLE();
  459.   __HAL_RCC_GPIOE_CLK_ENABLE();
  460.   __HAL_RCC_GPIOB_CLK_ENABLE();
  461.   __HAL_RCC_GPIOJ_CLK_ENABLE();
  462.   __HAL_RCC_GPIOD_CLK_ENABLE();
  463.   __HAL_RCC_GPIOF_CLK_ENABLE();
  464.   __HAL_RCC_GPIOH_CLK_ENABLE();
  465.   __HAL_RCC_GPIOA_CLK_ENABLE();
  466.   /*Configure GPIO pin Output Level */
  467.   HAL_GPIO_WritePin(GPIOB, FRAME_RATE_Pin|RENDER_TIME_Pin, GPIO_PIN_RESET);
  468.   /*Configure GPIO pin Output Level */
  469.   HAL_GPIO_WritePin(LCD_DE_GPIO_Port, LCD_DE_Pin, GPIO_PIN_RESET);
  470.   /*Configure GPIO pin Output Level */
  471.   HAL_GPIO_WritePin(VSYNC_FREQ_GPIO_Port, VSYNC_FREQ_Pin, GPIO_PIN_RESET);
  472.   /*Configure GPIO pin Output Level */
  473.   HAL_GPIO_WritePin(LCD_BL_CTRL_GPIO_Port, LCD_BL_CTRL_Pin, GPIO_PIN_SET);
  474.   /*Configure GPIO pin Output Level */
  475.   HAL_GPIO_WritePin(GPIOA, LCD_RESET_Pin|MCU_ACTIVE_Pin, GPIO_PIN_RESET);
  476.   /*Configure GPIO pins : FRAME_RATE_Pin RENDER_TIME_Pin */
  477.   GPIO_InitStruct.Pin = FRAME_RATE_Pin|RENDER_TIME_Pin;
  478.   GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  479.   GPIO_InitStruct.Pull = GPIO_NOPULL;
  480.   GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  481.   HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  482.   /*Configure GPIO pin : LCD_DE_Pin */
  483.   GPIO_InitStruct.Pin = LCD_DE_Pin;
  484.   GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  485.   GPIO_InitStruct.Pull = GPIO_NOPULL;
  486.   GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  487.   HAL_GPIO_Init(LCD_DE_GPIO_Port, &GPIO_InitStruct);
  488.   /*Configure GPIO pin : VSYNC_FREQ_Pin */
  489.   GPIO_InitStruct.Pin = VSYNC_FREQ_Pin;
  490.   GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  491.   GPIO_InitStruct.Pull = GPIO_NOPULL;
  492.   GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  493.   HAL_GPIO_Init(VSYNC_FREQ_GPIO_Port, &GPIO_InitStruct);
  494.   /*Configure GPIO pin : LCD_BL_CTRL_Pin */
  495.   GPIO_InitStruct.Pin = LCD_BL_CTRL_Pin;
  496.   GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  497.   GPIO_InitStruct.Pull = GPIO_NOPULL;
  498.   GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  499.   HAL_GPIO_Init(LCD_BL_CTRL_GPIO_Port, &GPIO_InitStruct);
  500.   /*Configure GPIO pin : LCD_RESET_Pin */
  501.   GPIO_InitStruct.Pin = LCD_RESET_Pin;
  502.   GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  503.   GPIO_InitStruct.Pull = GPIO_NOPULL;
  504.   GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  505.   HAL_GPIO_Init(LCD_RESET_GPIO_Port, &GPIO_InitStruct);
  506.   /*Configure GPIO pin : MCU_ACTIVE_Pin */
  507.   GPIO_InitStruct.Pin = MCU_ACTIVE_Pin;
  508.   GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  509.   GPIO_InitStruct.Pull = GPIO_NOPULL;
  510.   GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  511.   HAL_GPIO_Init(MCU_ACTIVE_GPIO_Port, &GPIO_InitStruct);
  512. }
  513. /* USER CODE BEGIN 4 */
  514. /* USER CODE END 4 */
  515. /* USER CODE BEGIN Header_StartDefaultTask */
  516. /**
  517.   * @brief  Function implementing the defaultTask thread.
  518.   * @param  argument: Not used
  519.   * @retval None
  520.   */
  521. /* USER CODE END Header_StartDefaultTask */
  522. void StartDefaultTask(void *argument)
  523. {
  524.   /* USER CODE BEGIN 5 */
  525.   /* Infinite loop */
  526.   for(;;)
  527.   {
  528.     osDelay(100);
  529.   }
  530.   /* USER CODE END 5 */
  531. }
  532. /* MPU Configuration */
  533. void MPU_Config(void)
  534. {
  535.   MPU_Region_InitTypeDef MPU_InitStruct = {0};
  536.   /* Disables the MPU */
  537.   HAL_MPU_Disable();
  538.   /** Initializes and configures the Region and the memory to be protected
  539.   */
  540.   MPU_InitStruct.Enable = MPU_REGION_ENABLE;
  541.   MPU_InitStruct.Number = MPU_REGION_NUMBER0;
  542.   MPU_InitStruct.BaseAddress = 0x24000000;
  543.   MPU_InitStruct.Size = MPU_REGION_SIZE_512KB;
  544.   MPU_InitStruct.SubRegionDisable = 0x0;
  545.   MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL0;
  546.   MPU_InitStruct.AccessPermission = MPU_REGION_FULL_ACCESS;
  547.   MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_DISABLE;
  548.   MPU_InitStruct.IsShareable = MPU_ACCESS_NOT_SHAREABLE;
  549.   MPU_InitStruct.IsCacheable = MPU_ACCESS_CACHEABLE;
  550.   MPU_InitStruct.IsBufferable = MPU_ACCESS_BUFFERABLE;
  551.   HAL_MPU_ConfigRegion(&MPU_InitStruct);
  552.   /** Initializes and configures the Region and the memory to be protected
  553.   */
  554.   MPU_InitStruct.Number = MPU_REGION_NUMBER1;
  555.   MPU_InitStruct.BaseAddress = 0x90000000;
  556.   MPU_InitStruct.Size = MPU_REGION_SIZE_256MB;
  557.   MPU_InitStruct.AccessPermission = MPU_REGION_NO_ACCESS;
  558.   MPU_InitStruct.IsCacheable = MPU_ACCESS_NOT_CACHEABLE;
  559.   MPU_InitStruct.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE;
  560.   HAL_MPU_ConfigRegion(&MPU_InitStruct);
  561.   /** Initializes and configures the Region and the memory to be protected
  562.   */
  563.   MPU_InitStruct.Number = MPU_REGION_NUMBER2;
  564.   MPU_InitStruct.Size = MPU_REGION_SIZE_128MB;
  565.   MPU_InitStruct.AccessPermission = MPU_REGION_FULL_ACCESS;
  566.   MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_ENABLE;
  567.   MPU_InitStruct.IsCacheable = MPU_ACCESS_CACHEABLE;
  568.   MPU_InitStruct.IsBufferable = MPU_ACCESS_BUFFERABLE;
  569.   HAL_MPU_ConfigRegion(&MPU_InitStruct);
  570.   /** Initializes and configures the Region and the memory to be protected
  571.   */
  572.   MPU_InitStruct.Number = MPU_REGION_NUMBER3;
  573.   MPU_InitStruct.BaseAddress = 0xD0000000;
  574.   MPU_InitStruct.Size = MPU_REGION_SIZE_256MB;
  575.   MPU_InitStruct.AccessPermission = MPU_REGION_NO_ACCESS;
  576.   MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_DISABLE;
  577.   MPU_InitStruct.IsCacheable = MPU_ACCESS_NOT_CACHEABLE;
  578.   MPU_InitStruct.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE;
  579.   HAL_MPU_ConfigRegion(&MPU_InitStruct);
  580.   /** Initializes and configures the Region and the memory to be protected
  581.   */
  582.   MPU_InitStruct.Number = MPU_REGION_NUMBER4;
  583.   MPU_InitStruct.Size = MPU_REGION_SIZE_32MB;
  584.   MPU_InitStruct.AccessPermission = MPU_REGION_FULL_ACCESS;
  585.   MPU_InitStruct.IsCacheable = MPU_ACCESS_CACHEABLE;
  586.   HAL_MPU_ConfigRegion(&MPU_InitStruct);
  587.   /* Enables the MPU */
  588.   HAL_MPU_Enable(MPU_PRIVILEGED_DEFAULT);
  589. }
  590. /**
  591.   * @brief  Period elapsed callback in non blocking mode
  592.   * [url=home.php?mod=space&uid=536309]@NOTE[/url]   This function is called  when TIM6 interrupt took place, inside
  593.   * HAL_TIM_IRQHandler(). It makes a direct call to HAL_IncTick() to increment
  594.   * a global variable "uwTick" used as application time base.
  595.   * @param  htim : TIM handle
  596.   * @retval None
  597.   */
  598. void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
  599. {
  600.   /* USER CODE BEGIN Callback 0 */
  601.   /* USER CODE END Callback 0 */
  602.   if (htim->Instance == TIM6) {
  603.     HAL_IncTick();
  604.   }
  605.   /* USER CODE BEGIN Callback 1 */
  606.   /* USER CODE END Callback 1 */
  607. }
  608. /**
  609.   * @brief  This function is executed in case of error occurrence.
  610.   * @retval None
  611.   */
  612. void Error_Handler(void)
  613. {
  614.   /* USER CODE BEGIN Error_Handler_Debug */
  615.   /* User can add his own implementation to report the HAL error return state */
  616.   /* USER CODE END Error_Handler_Debug */
  617. }
  618. #ifdef  USE_FULL_ASSERT
  619. /**
  620.   * @brief  Reports the name of the source file and the source line number
  621.   *         where the assert_param error has occurred.
  622.   * @param  file: pointer to the source file name
  623.   * @param  line: assert_param error line source number
  624.   * @retval None
  625.   */
  626. void assert_failed(uint8_t *file, uint32_t line)
  627. {
  628.   /* USER CODE BEGIN 6 */
  629.   /* User can add his own implementation to report the file name and line number,
  630.      tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
  631.   /* USER CODE END 6 */
  632. }
  633. #endif /* USE_FULL_ASSERT */

点击编译,也是没有任何问题编译成功


加入一个闪屏效果,点击按钮切换屏幕然后自动切换回来;

这个软件还是有改进空间,很多图片格式不支持,转换起来不叫麻烦。

  1. /* USER CODE BEGIN Header */
  2. /**
  3.   ******************************************************************************
  4.   * File Name          : TouchGFXHAL.cpp
  5.   ******************************************************************************
  6.   * This file is generated by TouchGFX Generator 4.20.0.
  7.   ******************************************************************************
  8.   * @attention
  9.   *
  10.   * Copyright (c) 2022 STMicroelectronics.
  11.   * All rights reserved.
  12.   *
  13.   * This software is licensed under terms that can be found in the LICENSE file
  14.   * in the root directory of this software component.
  15.   * If no LICENSE file comes with this software, it is provided AS-IS.
  16.   *
  17.   ******************************************************************************
  18.   */
  19. /* USER CODE END Header */
  20. #include <TouchGFXHAL.hpp>
  21. /* USER CODE BEGIN TouchGFXHAL.cpp */
  22. #include "main.h"
  23. #include "stm32h7xx.h"
  24. #include <touchgfx/hal/OSWrappers.hpp>
  25. #include "FreeRTOS.h"
  26. #include "task.h"
  27. using namespace touchgfx;
  28. LOCATION_PRAGMA("TouchGFX_Framebuffer")
  29. uint32_t animationBuffer[(480 * 272 * 2 + 3) / 4] LOCATION_ATTRIBUTE_NOLOAD("TouchGFX_Framebuffer");
  30. void TouchGFXHAL::initialize()
  31. {
  32.     // Calling parent implementation of initialize().
  33.     //
  34.     // To overwrite the generated implementation, omit call to parent function
  35.     // and implemented needed functionality here.
  36.     // Please note, HAL::initialize() must be called to initialize the framework.
  37.     TouchGFXGeneratedHAL::initialize();
  38.     setFrameBufferStartAddresses((void*)frameBuffer0, (void*)frameBuffer1, (void*)animationBuffer);
  39.     instrumentation.init();
  40.     setMCUInstrumentation(&instrumentation);
  41.     enableMCULoadCalculation(true);
  42. }
  43. void TouchGFXHAL::taskEntry()
  44. {
  45.     enableLCDControllerInterrupt();
  46.     enableInterrupts();
  47.     OSWrappers::waitForVSync();
  48.     backPorchExited();
  49. #if defined(LCD_RESET_GPIO_Port) && defined(LCD_RESET_Pin)
  50.     /* Display Enable */
  51.     HAL_GPIO_WritePin(LCD_RESET_GPIO_Port, LCD_RESET_Pin, GPIO_PIN_SET);
  52. #endif
  53. #if defined(LCD_DE_GPIO_Port) && defined(LCD_DE_Pin)
  54.     /* Data Enable */
  55.     HAL_GPIO_WritePin(LCD_DE_GPIO_Port, LCD_DE_Pin, GPIO_PIN_SET);
  56. #endif
  57. #if defined(LCD_BL_CTRL_GPIO_Port) && defined(LCD_BL_CTRL_Pin)
  58.     /* Backlight Enable */
  59.     HAL_GPIO_WritePin(LCD_BL_CTRL_GPIO_Port, LCD_BL_CTRL_Pin, GPIO_PIN_SET);
  60. #endif
  61.     for (;;)
  62.     {
  63.         OSWrappers::waitForVSync();
  64.         backPorchExited();
  65.     }
  66. }
  67. /**
  68. * Gets the frame buffer address used by the TFT controller.
  69. *
  70. * [url=home.php?mod=space&uid=266161]@return[/url] The address of the frame buffer currently being displayed on the TFT.
  71. */
  72. uint16_t* TouchGFXHAL::getTFTFrameBuffer() const
  73. {
  74.     // Calling parent implementation of getTFTFrameBuffer().
  75.     //
  76.     // To overwrite the generated implementation, omit call to parent function
  77.     // and implemented needed functionality here.
  78.     return TouchGFXGeneratedHAL::getTFTFrameBuffer();
  79. }
  80. /**
  81. * Sets the frame buffer address used by the TFT controller.
  82. *
  83. * @param [in] address New frame buffer address.
  84. */
  85. void TouchGFXHAL::setTFTFrameBuffer(uint16_t* address)
  86. {
  87.     // Calling parent implementation of setTFTFrameBuffer(uint16_t* address).
  88.     //
  89.     // To overwrite the generated implementation, omit call to parent function
  90.     // and implemented needed functionality here.
  91.     TouchGFXGeneratedHAL::setTFTFrameBuffer(address);
  92. }
  93. /**
  94. * This function is called whenever the framework has performed a partial draw.
  95. *
  96. * @param rect The area of the screen that has been drawn, expressed in absolute coordinates.
  97. *
  98. * [url=home.php?mod=space&uid=8537]@see[/url] flushFrameBuffer().
  99. */
  100. void TouchGFXHAL::flushFrameBuffer(const touchgfx::Rect& rect)
  101. {
  102.     // Calling parent implementation of flushFrameBuffer(const touchgfx::Rect& rect).
  103.     //
  104.     // To overwrite the generated implementation, omit call to parent function
  105.     // and implemented needed functionality here.
  106.     // Please note, HAL::flushFrameBuffer(const touchgfx::Rect& rect) must
  107.     // be called to notify the touchgfx framework that flush has been performed.
  108.     TouchGFXGeneratedHAL::flushFrameBuffer(rect);
  109.     // If the framebuffer is placed in Write Through cached memory (e.g. SRAM) then we need
  110.     // to flush the Dcache to make sure framebuffer is correct in RAM. That's done
  111.     // using SCB_CleanInvalidateDCache().
  112.     SCB_CleanInvalidateDCache();
  113. }
  114. /**
  115. * Configures the interrupts relevant for TouchGFX. This primarily entails setting
  116. * the interrupt priorities for the DMA and LCD interrupts.
  117. */
  118. void TouchGFXHAL::configureInterrupts()
  119. {
  120.     // Calling parent implementation of configureInterrupts().
  121.     //
  122.     // To overwrite the generated implementation, omit call to parent function
  123.     // and implemented needed functionality here.
  124.     TouchGFXGeneratedHAL::configureInterrupts();
  125. }
  126. /**
  127. * Used for enabling interrupts set in configureInterrupts()
  128. */
  129. void TouchGFXHAL::enableInterrupts()
  130. {
  131.     // Calling parent implementation of enableInterrupts().
  132.     //
  133.     // To overwrite the generated implementation, omit call to parent function
  134.     // and implemented needed functionality here.
  135.     TouchGFXGeneratedHAL::enableInterrupts();
  136. }
  137. /**
  138. * Used for disabling interrupts set in configureInterrupts()
  139. */
  140. void TouchGFXHAL::disableInterrupts()
  141. {
  142.     // Calling parent implementation of disableInterrupts().
  143.     //
  144.     // To overwrite the generated implementation, omit call to parent function
  145.     // and implemented needed functionality here.
  146.     TouchGFXGeneratedHAL::disableInterrupts();
  147. }
  148. /**
  149. * Configure the LCD controller to fire interrupts at VSYNC. Called automatically
  150. * once TouchGFX initialization has completed.
  151. */
  152. void TouchGFXHAL::enableLCDControllerInterrupt()
  153. {
  154.     // Calling parent implementation of enableLCDControllerInterrupt().
  155.     //
  156.     // To overwrite the generated implementation, omit call to parent function
  157.     // and implemented needed functionality here.
  158.     TouchGFXGeneratedHAL::enableLCDControllerInterrupt();
  159. }
  160. extern "C"
  161. {
  162.     portBASE_TYPE IdleTaskHook(void* p)
  163.     {
  164.         if ((int)p) //idle task sched out
  165.         {
  166.             touchgfx::HAL::getInstance()->setMCUActive(true);
  167.         }
  168.         else //idle task sched in
  169.         {
  170.             touchgfx::HAL::getInstance()->setMCUActive(false);
  171.         }
  172.         return pdTRUE;
  173.     }
  174. }
  175. /* USER CODE END TouchGFXHAL.cpp */
  176. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

 测试开机动画,加界面切换如下:

---------------------
作者:ROSHEN_007
链接:https://bbs.21ic.com/icview-3275200-1-1.html
来源:21ic.com
此文章已获得原创/原创奖标签,著作权归21ic所有,任何人未经允许禁止转载。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小蓝xlanll/article/detail/684986
推荐阅读