Display orange FT logo
Every second column appears to be switched
This commit is contained in:
		
							
								
								
									
										99
									
								
								Core/Src/hx8357d.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										99
									
								
								Core/Src/hx8357d.c
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,99 @@
 | 
			
		||||
#include "hx8357d.h"
 | 
			
		||||
 | 
			
		||||
#include "main.h"
 | 
			
		||||
 | 
			
		||||
void HX8357D_WriteData(uint8_t *data, size_t data_len) {
 | 
			
		||||
  for (size_t byte = 0; byte < data_len; byte++) {
 | 
			
		||||
    for (size_t bit = 0; bit < 8; bit++) {
 | 
			
		||||
      GPIO_PinState state =
 | 
			
		||||
          ((data[byte] >> (7 - bit)) & 1) ? GPIO_PIN_SET : GPIO_PIN_RESET;
 | 
			
		||||
      HAL_GPIO_WritePin(DISPSPI_SCL_GPIO_Port, DISPSPI_SCL_Pin, GPIO_PIN_RESET);
 | 
			
		||||
      HAL_GPIO_WritePin(DISPSPI_SDA_GPIO_Port, DISPSPI_SDA_Pin, state);
 | 
			
		||||
      HAL_Delay(1);
 | 
			
		||||
      HAL_GPIO_WritePin(DISPSPI_SCL_GPIO_Port, DISPSPI_SCL_Pin, GPIO_PIN_SET);
 | 
			
		||||
      HAL_Delay(1);
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void HX8357D_WriteReg(uint8_t addr, uint8_t *data, size_t data_len) {
 | 
			
		||||
  HAL_GPIO_WritePin(DISPSPI_CSX_GPIO_Port, DISPSPI_CSX_Pin, GPIO_PIN_RESET);
 | 
			
		||||
  HAL_GPIO_WritePin(DISPSPI_DCX_GPIO_Port, DISPSPI_DCX_Pin, GPIO_PIN_RESET);
 | 
			
		||||
  HAL_Delay(1);
 | 
			
		||||
 | 
			
		||||
  HX8357D_WriteData(&addr, 1);
 | 
			
		||||
  HAL_GPIO_WritePin(DISPSPI_DCX_GPIO_Port, DISPSPI_DCX_Pin, GPIO_PIN_SET);
 | 
			
		||||
  HAL_Delay(1);
 | 
			
		||||
 | 
			
		||||
  if (data_len > 0) {
 | 
			
		||||
    HX8357D_WriteData(data, data_len);
 | 
			
		||||
  }
 | 
			
		||||
  HAL_GPIO_WritePin(DISPSPI_CSX_GPIO_Port, DISPSPI_CSX_Pin, GPIO_PIN_SET);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void HX8357D_Init() {
 | 
			
		||||
  HAL_GPIO_WritePin(DISPSPI_CSX_GPIO_Port, DISPSPI_CSX_Pin, GPIO_PIN_SET);
 | 
			
		||||
  HAL_GPIO_WritePin(DISPSPI_SCL_GPIO_Port, DISPSPI_SCL_Pin, GPIO_PIN_SET);
 | 
			
		||||
  HAL_GPIO_WritePin(DISP_RESET_GPIO_Port, DISP_RESET_Pin, GPIO_PIN_RESET);
 | 
			
		||||
  HAL_Delay(150);
 | 
			
		||||
  HAL_GPIO_WritePin(DISP_RESET_GPIO_Port, DISP_RESET_Pin, GPIO_PIN_SET);
 | 
			
		||||
  HAL_Delay(150);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void HX8357D_Mode_RGB666() {
 | 
			
		||||
  // B9h: Enable extended commands
 | 
			
		||||
  uint8_t data0[] = {0xFF, 0x83, 0x57};
 | 
			
		||||
  HX8357D_WriteReg(0xB9, data0, sizeof(data0));
 | 
			
		||||
  // B1h: Set power control
 | 
			
		||||
  uint8_t data1[] = {0x00, 0x16, 0x1C, 0x1C, 0xC3, 0x5C};
 | 
			
		||||
  HX8357D_WriteReg(0xB1, data1, sizeof(data1));
 | 
			
		||||
  // B3h: Set RGB interface
 | 
			
		||||
  // Disable SDO pin
 | 
			
		||||
  // Write directly to display (not internal GRAM)
 | 
			
		||||
  // Data read on rising edge of DCLK
 | 
			
		||||
  // HSYNC & VSYNC Activ low
 | 
			
		||||
  // DE Active high
 | 
			
		||||
  // Horizontal back porch 5
 | 
			
		||||
  // Vertical back porch 2
 | 
			
		||||
  uint8_t data2[] = {0x53, 0x00, 0x05, 0x02};
 | 
			
		||||
  HX8357D_WriteReg(0xB3, data2, sizeof(data2));
 | 
			
		||||
  // SET cyc
 | 
			
		||||
  uint8_t data3[] = {0x32, 0x40, 0x00, 0x2A, 0x2A, 0x0D, 0x78};
 | 
			
		||||
  HX8357D_WriteReg(0xB4, data3, sizeof(data3));
 | 
			
		||||
  // VCOMDC
 | 
			
		||||
  uint8_t data4[] = {0x3C};
 | 
			
		||||
  HX8357D_WriteReg(0xB6, data4, sizeof(data4));
 | 
			
		||||
  // SET STBA
 | 
			
		||||
  uint8_t data5[] = {0x70, 0x50, 0x01, 0x3C, 0xC8, 0x08};
 | 
			
		||||
  HX8357D_WriteReg(0xC0, data5, sizeof(data5));
 | 
			
		||||
  // SET panel
 | 
			
		||||
  uint8_t data6[] = {0x0B};
 | 
			
		||||
  HX8357D_WriteReg(0xCC, data6, sizeof(data6));
 | 
			
		||||
  // VCOMDC
 | 
			
		||||
  uint8_t data7[] = {0x40};
 | 
			
		||||
  HX8357D_WriteReg(0xB6, data7, sizeof(data7));
 | 
			
		||||
  // Gamma
 | 
			
		||||
  uint8_t data8[] = {0x02, 0x0A, 0x10, 0x1A, 0x22, 0x34, 0x41, 0x4A, 0x4D,
 | 
			
		||||
                     0x44, 0x3A, 0x23, 0x19, 0x08, 0x09, 0x03, 0x02, 0x0A,
 | 
			
		||||
                     0x10, 0x1A, 0x22, 0x34, 0x41, 0x4A, 0x4D, 0x44, 0x3A,
 | 
			
		||||
                     0x23, 0x19, 0x08, 0x09, 0x03, 0x00, 0x01};
 | 
			
		||||
  HX8357D_WriteReg(0xE0, data8, sizeof(data8));
 | 
			
		||||
  // Display cycle register
 | 
			
		||||
  uint8_t data9[] = {0x00};
 | 
			
		||||
  HX8357D_WriteReg(0xB4, data9, sizeof(data9));
 | 
			
		||||
  // SET BGP
 | 
			
		||||
  uint8_t data10[] = {0x03, 0x03, 0x03};
 | 
			
		||||
  HX8357D_WriteReg(0xB5, data10, sizeof(data10));
 | 
			
		||||
  // ?
 | 
			
		||||
  uint8_t data11[] = {0xB0, 0x22, 0x3B};
 | 
			
		||||
  HX8357D_WriteReg(0xB6, data11, sizeof(data11));
 | 
			
		||||
  // COLMOD
 | 
			
		||||
  uint8_t data12[] = {0x66};
 | 
			
		||||
  HX8357D_WriteReg(0x3A, data12, sizeof(data12));
 | 
			
		||||
  // Sleep out
 | 
			
		||||
  HX8357D_WriteReg(0x11, NULL, 0);
 | 
			
		||||
  // Normal display mode
 | 
			
		||||
  HX8357D_WriteReg(0x13, NULL, 0);
 | 
			
		||||
  // Display on
 | 
			
		||||
  HX8357D_WriteReg(0x29, NULL, 0);
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										108
									
								
								Core/Src/main.c
									
									
									
									
									
								
							
							
						
						
									
										108
									
								
								Core/Src/main.c
									
									
									
									
									
								
							@ -21,6 +21,8 @@
 | 
			
		||||
 | 
			
		||||
/* Private includes ----------------------------------------------------------*/
 | 
			
		||||
/* USER CODE BEGIN Includes */
 | 
			
		||||
#include "ft_logo_orange_rgb565.h"
 | 
			
		||||
#include "hx8357d.h"
 | 
			
		||||
 | 
			
		||||
/* USER CODE END Includes */
 | 
			
		||||
 | 
			
		||||
@ -50,7 +52,6 @@ LTDC_HandleTypeDef hltdc;
 | 
			
		||||
 | 
			
		||||
OSPI_HandleTypeDef hospi1;
 | 
			
		||||
 | 
			
		||||
SPI_HandleTypeDef hspi1;
 | 
			
		||||
SPI_HandleTypeDef hspi3;
 | 
			
		||||
 | 
			
		||||
TIM_HandleTypeDef htim1;
 | 
			
		||||
@ -69,7 +70,6 @@ static void MX_FDCAN1_Init(void);
 | 
			
		||||
static void MX_LTDC_Init(void);
 | 
			
		||||
static void MX_JPEG_Init(void);
 | 
			
		||||
static void MX_OCTOSPI1_Init(void);
 | 
			
		||||
static void MX_SPI1_Init(void);
 | 
			
		||||
static void MX_SPI3_Init(void);
 | 
			
		||||
static void MX_TIM1_Init(void);
 | 
			
		||||
static void MX_TIM2_Init(void);
 | 
			
		||||
@ -116,7 +116,6 @@ int main(void) {
 | 
			
		||||
  MX_LTDC_Init();
 | 
			
		||||
  MX_JPEG_Init();
 | 
			
		||||
  MX_OCTOSPI1_Init();
 | 
			
		||||
  MX_SPI1_Init();
 | 
			
		||||
  MX_SPI3_Init();
 | 
			
		||||
  MX_TIM1_Init();
 | 
			
		||||
  MX_TIM2_Init();
 | 
			
		||||
@ -125,6 +124,10 @@ int main(void) {
 | 
			
		||||
  if (HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_4) != HAL_OK) {
 | 
			
		||||
    Error_Handler();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  HX8357D_Init();
 | 
			
		||||
  HX8357D_Mode_RGB666();
 | 
			
		||||
  HAL_Delay(500);
 | 
			
		||||
  /* USER CODE END 2 */
 | 
			
		||||
 | 
			
		||||
  /* Infinite loop */
 | 
			
		||||
@ -327,7 +330,6 @@ static void MX_LTDC_Init(void) {
 | 
			
		||||
  /* USER CODE END LTDC_Init 0 */
 | 
			
		||||
 | 
			
		||||
  LTDC_LayerCfgTypeDef pLayerCfg = {0};
 | 
			
		||||
  LTDC_LayerCfgTypeDef pLayerCfg1 = {0};
 | 
			
		||||
 | 
			
		||||
  /* USER CODE BEGIN LTDC_Init 1 */
 | 
			
		||||
 | 
			
		||||
@ -335,7 +337,7 @@ static void MX_LTDC_Init(void) {
 | 
			
		||||
  hltdc.Instance = LTDC;
 | 
			
		||||
  hltdc.Init.HSPolarity = LTDC_HSPOLARITY_AL;
 | 
			
		||||
  hltdc.Init.VSPolarity = LTDC_VSPOLARITY_AL;
 | 
			
		||||
  hltdc.Init.DEPolarity = LTDC_DEPOLARITY_AH;
 | 
			
		||||
  hltdc.Init.DEPolarity = LTDC_DEPOLARITY_AL;
 | 
			
		||||
  hltdc.Init.PCPolarity = LTDC_PCPOLARITY_IPC;
 | 
			
		||||
  hltdc.Init.HorizontalSync = 4;
 | 
			
		||||
  hltdc.Init.VerticalSync = 1;
 | 
			
		||||
@ -352,41 +354,23 @@ static void MX_LTDC_Init(void) {
 | 
			
		||||
    Error_Handler();
 | 
			
		||||
  }
 | 
			
		||||
  pLayerCfg.WindowX0 = 0;
 | 
			
		||||
  pLayerCfg.WindowX1 = 0;
 | 
			
		||||
  pLayerCfg.WindowX1 = 320;
 | 
			
		||||
  pLayerCfg.WindowY0 = 0;
 | 
			
		||||
  pLayerCfg.WindowY1 = 0;
 | 
			
		||||
  pLayerCfg.PixelFormat = LTDC_PIXEL_FORMAT_ARGB8888;
 | 
			
		||||
  pLayerCfg.Alpha = 0;
 | 
			
		||||
  pLayerCfg.WindowY1 = 480;
 | 
			
		||||
  pLayerCfg.PixelFormat = LTDC_PIXEL_FORMAT_RGB565;
 | 
			
		||||
  pLayerCfg.Alpha = 255;
 | 
			
		||||
  pLayerCfg.Alpha0 = 0;
 | 
			
		||||
  pLayerCfg.BlendingFactor1 = LTDC_BLENDING_FACTOR1_CA;
 | 
			
		||||
  pLayerCfg.BlendingFactor2 = LTDC_BLENDING_FACTOR2_CA;
 | 
			
		||||
  pLayerCfg.FBStartAdress = 0;
 | 
			
		||||
  pLayerCfg.ImageWidth = 0;
 | 
			
		||||
  pLayerCfg.ImageHeight = 0;
 | 
			
		||||
  pLayerCfg.FBStartAdress = (uint32_t)&image_data_ft_logo_orange_rgb565;
 | 
			
		||||
  pLayerCfg.ImageWidth = 320;
 | 
			
		||||
  pLayerCfg.ImageHeight = 480;
 | 
			
		||||
  pLayerCfg.Backcolor.Blue = 0;
 | 
			
		||||
  pLayerCfg.Backcolor.Green = 0;
 | 
			
		||||
  pLayerCfg.Backcolor.Red = 0;
 | 
			
		||||
  if (HAL_LTDC_ConfigLayer(&hltdc, &pLayerCfg, 0) != HAL_OK) {
 | 
			
		||||
    Error_Handler();
 | 
			
		||||
  }
 | 
			
		||||
  pLayerCfg1.WindowX0 = 0;
 | 
			
		||||
  pLayerCfg1.WindowX1 = 0;
 | 
			
		||||
  pLayerCfg1.WindowY0 = 0;
 | 
			
		||||
  pLayerCfg1.WindowY1 = 0;
 | 
			
		||||
  pLayerCfg1.PixelFormat = LTDC_PIXEL_FORMAT_ARGB8888;
 | 
			
		||||
  pLayerCfg1.Alpha = 0;
 | 
			
		||||
  pLayerCfg1.Alpha0 = 0;
 | 
			
		||||
  pLayerCfg1.BlendingFactor1 = LTDC_BLENDING_FACTOR1_CA;
 | 
			
		||||
  pLayerCfg1.BlendingFactor2 = LTDC_BLENDING_FACTOR2_CA;
 | 
			
		||||
  pLayerCfg1.FBStartAdress = 0;
 | 
			
		||||
  pLayerCfg1.ImageWidth = 0;
 | 
			
		||||
  pLayerCfg1.ImageHeight = 0;
 | 
			
		||||
  pLayerCfg1.Backcolor.Blue = 0;
 | 
			
		||||
  pLayerCfg1.Backcolor.Green = 0;
 | 
			
		||||
  pLayerCfg1.Backcolor.Red = 0;
 | 
			
		||||
  if (HAL_LTDC_ConfigLayer(&hltdc, &pLayerCfg1, 1) != HAL_OK) {
 | 
			
		||||
    Error_Handler();
 | 
			
		||||
  }
 | 
			
		||||
  /* USER CODE BEGIN LTDC_Init 2 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END LTDC_Init 2 */
 | 
			
		||||
@ -440,53 +424,6 @@ static void MX_OCTOSPI1_Init(void) {
 | 
			
		||||
  /* USER CODE END OCTOSPI1_Init 2 */
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief SPI1 Initialization Function
 | 
			
		||||
 * @param None
 | 
			
		||||
 * @retval None
 | 
			
		||||
 */
 | 
			
		||||
static void MX_SPI1_Init(void) {
 | 
			
		||||
 | 
			
		||||
  /* USER CODE BEGIN SPI1_Init 0 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END SPI1_Init 0 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE BEGIN SPI1_Init 1 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END SPI1_Init 1 */
 | 
			
		||||
  /* SPI1 parameter configuration*/
 | 
			
		||||
  hspi1.Instance = SPI1;
 | 
			
		||||
  hspi1.Init.Mode = SPI_MODE_MASTER;
 | 
			
		||||
  hspi1.Init.Direction = SPI_DIRECTION_1LINE;
 | 
			
		||||
  hspi1.Init.DataSize = SPI_DATASIZE_4BIT;
 | 
			
		||||
  hspi1.Init.CLKPolarity = SPI_POLARITY_LOW;
 | 
			
		||||
  hspi1.Init.CLKPhase = SPI_PHASE_1EDGE;
 | 
			
		||||
  hspi1.Init.NSS = SPI_NSS_HARD_OUTPUT;
 | 
			
		||||
  hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_2;
 | 
			
		||||
  hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB;
 | 
			
		||||
  hspi1.Init.TIMode = SPI_TIMODE_DISABLE;
 | 
			
		||||
  hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
 | 
			
		||||
  hspi1.Init.CRCPolynomial = 0x0;
 | 
			
		||||
  hspi1.Init.NSSPMode = SPI_NSS_PULSE_ENABLE;
 | 
			
		||||
  hspi1.Init.NSSPolarity = SPI_NSS_POLARITY_LOW;
 | 
			
		||||
  hspi1.Init.FifoThreshold = SPI_FIFO_THRESHOLD_01DATA;
 | 
			
		||||
  hspi1.Init.TxCRCInitializationPattern =
 | 
			
		||||
      SPI_CRC_INITIALIZATION_ALL_ZERO_PATTERN;
 | 
			
		||||
  hspi1.Init.RxCRCInitializationPattern =
 | 
			
		||||
      SPI_CRC_INITIALIZATION_ALL_ZERO_PATTERN;
 | 
			
		||||
  hspi1.Init.MasterSSIdleness = SPI_MASTER_SS_IDLENESS_00CYCLE;
 | 
			
		||||
  hspi1.Init.MasterInterDataIdleness = SPI_MASTER_INTERDATA_IDLENESS_00CYCLE;
 | 
			
		||||
  hspi1.Init.MasterReceiverAutoSusp = SPI_MASTER_RX_AUTOSUSP_DISABLE;
 | 
			
		||||
  hspi1.Init.MasterKeepIOState = SPI_MASTER_KEEP_IO_STATE_DISABLE;
 | 
			
		||||
  hspi1.Init.IOSwap = SPI_IO_SWAP_DISABLE;
 | 
			
		||||
  if (HAL_SPI_Init(&hspi1) != HAL_OK) {
 | 
			
		||||
    Error_Handler();
 | 
			
		||||
  }
 | 
			
		||||
  /* USER CODE BEGIN SPI1_Init 2 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END SPI1_Init 2 */
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief SPI3 Initialization Function
 | 
			
		||||
 * @param None
 | 
			
		||||
@ -730,13 +667,16 @@ static void MX_GPIO_Init(void) {
 | 
			
		||||
  __HAL_RCC_GPIOG_CLK_ENABLE();
 | 
			
		||||
 | 
			
		||||
  /*Configure GPIO pin Output Level */
 | 
			
		||||
  HAL_GPIO_WritePin(GPIOA, STATUS1_Pin | STATUS2_Pin, GPIO_PIN_RESET);
 | 
			
		||||
  HAL_GPIO_WritePin(
 | 
			
		||||
      GPIOA, STATUS1_Pin | STATUS2_Pin | DISPSPI_SCL_Pin | DISPSPI_SDA_Pin,
 | 
			
		||||
      GPIO_PIN_RESET);
 | 
			
		||||
 | 
			
		||||
  /*Configure GPIO pin Output Level */
 | 
			
		||||
  HAL_GPIO_WritePin(LED_LE_GPIO_Port, LED_LE_Pin, GPIO_PIN_RESET);
 | 
			
		||||
 | 
			
		||||
  /*Configure GPIO pin Output Level */
 | 
			
		||||
  HAL_GPIO_WritePin(GPIOG, DISPSPI_DCX_Pin | DISP_RESET_Pin, GPIO_PIN_RESET);
 | 
			
		||||
  HAL_GPIO_WritePin(GPIOG, DISPSPI_CSX_Pin | DISPSPI_DCX_Pin | DISP_RESET_Pin,
 | 
			
		||||
                    GPIO_PIN_RESET);
 | 
			
		||||
 | 
			
		||||
  /*Configure GPIO pin Output Level */
 | 
			
		||||
  HAL_GPIO_WritePin(BOOT0_SET_GPIO_Port, BOOT0_SET_Pin, GPIO_PIN_RESET);
 | 
			
		||||
@ -755,8 +695,10 @@ static void MX_GPIO_Init(void) {
 | 
			
		||||
  GPIO_InitStruct.Pull = GPIO_NOPULL;
 | 
			
		||||
  HAL_GPIO_Init(GPIOF, &GPIO_InitStruct);
 | 
			
		||||
 | 
			
		||||
  /*Configure GPIO pins : STATUS1_Pin STATUS2_Pin */
 | 
			
		||||
  GPIO_InitStruct.Pin = STATUS1_Pin | STATUS2_Pin;
 | 
			
		||||
  /*Configure GPIO pins : STATUS1_Pin STATUS2_Pin DISPSPI_SCL_Pin
 | 
			
		||||
   * DISPSPI_SDA_Pin */
 | 
			
		||||
  GPIO_InitStruct.Pin =
 | 
			
		||||
      STATUS1_Pin | STATUS2_Pin | DISPSPI_SCL_Pin | DISPSPI_SDA_Pin;
 | 
			
		||||
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
 | 
			
		||||
  GPIO_InitStruct.Pull = GPIO_NOPULL;
 | 
			
		||||
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
 | 
			
		||||
@ -769,8 +711,8 @@ static void MX_GPIO_Init(void) {
 | 
			
		||||
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
 | 
			
		||||
  HAL_GPIO_Init(LED_LE_GPIO_Port, &GPIO_InitStruct);
 | 
			
		||||
 | 
			
		||||
  /*Configure GPIO pins : DISPSPI_DCX_Pin DISP_RESET_Pin */
 | 
			
		||||
  GPIO_InitStruct.Pin = DISPSPI_DCX_Pin | DISP_RESET_Pin;
 | 
			
		||||
  /*Configure GPIO pins : DISPSPI_CSX_Pin DISPSPI_DCX_Pin DISP_RESET_Pin */
 | 
			
		||||
  GPIO_InitStruct.Pin = DISPSPI_CSX_Pin | DISPSPI_DCX_Pin | DISP_RESET_Pin;
 | 
			
		||||
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
 | 
			
		||||
  GPIO_InitStruct.Pull = GPIO_NOPULL;
 | 
			
		||||
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
 | 
			
		||||
 | 
			
		||||
@ -561,50 +561,7 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi)
 | 
			
		||||
{
 | 
			
		||||
  GPIO_InitTypeDef GPIO_InitStruct = {0};
 | 
			
		||||
  RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0};
 | 
			
		||||
  if(hspi->Instance==SPI1)
 | 
			
		||||
  {
 | 
			
		||||
  /* USER CODE BEGIN SPI1_MspInit 0 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END SPI1_MspInit 0 */
 | 
			
		||||
 | 
			
		||||
  /** Initializes the peripherals clock
 | 
			
		||||
  */
 | 
			
		||||
    PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_SPI1;
 | 
			
		||||
    PeriphClkInitStruct.Spi123ClockSelection = RCC_SPI123CLKSOURCE_PLL;
 | 
			
		||||
    if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)
 | 
			
		||||
    {
 | 
			
		||||
      Error_Handler();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /* Peripheral clock enable */
 | 
			
		||||
    __HAL_RCC_SPI1_CLK_ENABLE();
 | 
			
		||||
 | 
			
		||||
    __HAL_RCC_GPIOA_CLK_ENABLE();
 | 
			
		||||
    __HAL_RCC_GPIOG_CLK_ENABLE();
 | 
			
		||||
    /**SPI1 GPIO Configuration
 | 
			
		||||
    PA5     ------> SPI1_SCK
 | 
			
		||||
    PA7     ------> SPI1_MOSI
 | 
			
		||||
    PG10     ------> SPI1_NSS
 | 
			
		||||
    */
 | 
			
		||||
    GPIO_InitStruct.Pin = GPIO_PIN_5|GPIO_PIN_7;
 | 
			
		||||
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
 | 
			
		||||
    GPIO_InitStruct.Pull = GPIO_NOPULL;
 | 
			
		||||
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
 | 
			
		||||
    GPIO_InitStruct.Alternate = GPIO_AF5_SPI1;
 | 
			
		||||
    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
 | 
			
		||||
 | 
			
		||||
    GPIO_InitStruct.Pin = DISPSPI_CSX_Pin;
 | 
			
		||||
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
 | 
			
		||||
    GPIO_InitStruct.Pull = GPIO_NOPULL;
 | 
			
		||||
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
 | 
			
		||||
    GPIO_InitStruct.Alternate = GPIO_AF5_SPI1;
 | 
			
		||||
    HAL_GPIO_Init(DISPSPI_CSX_GPIO_Port, &GPIO_InitStruct);
 | 
			
		||||
 | 
			
		||||
  /* USER CODE BEGIN SPI1_MspInit 1 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END SPI1_MspInit 1 */
 | 
			
		||||
  }
 | 
			
		||||
  else if(hspi->Instance==SPI3)
 | 
			
		||||
  if(hspi->Instance==SPI3)
 | 
			
		||||
  {
 | 
			
		||||
  /* USER CODE BEGIN SPI3_MspInit 0 */
 | 
			
		||||
 | 
			
		||||
@ -649,28 +606,7 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi)
 | 
			
		||||
*/
 | 
			
		||||
void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi)
 | 
			
		||||
{
 | 
			
		||||
  if(hspi->Instance==SPI1)
 | 
			
		||||
  {
 | 
			
		||||
  /* USER CODE BEGIN SPI1_MspDeInit 0 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END SPI1_MspDeInit 0 */
 | 
			
		||||
    /* Peripheral clock disable */
 | 
			
		||||
    __HAL_RCC_SPI1_CLK_DISABLE();
 | 
			
		||||
 | 
			
		||||
    /**SPI1 GPIO Configuration
 | 
			
		||||
    PA5     ------> SPI1_SCK
 | 
			
		||||
    PA7     ------> SPI1_MOSI
 | 
			
		||||
    PG10     ------> SPI1_NSS
 | 
			
		||||
    */
 | 
			
		||||
    HAL_GPIO_DeInit(GPIOA, GPIO_PIN_5|GPIO_PIN_7);
 | 
			
		||||
 | 
			
		||||
    HAL_GPIO_DeInit(DISPSPI_CSX_GPIO_Port, DISPSPI_CSX_Pin);
 | 
			
		||||
 | 
			
		||||
  /* USER CODE BEGIN SPI1_MspDeInit 1 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END SPI1_MspDeInit 1 */
 | 
			
		||||
  }
 | 
			
		||||
  else if(hspi->Instance==SPI3)
 | 
			
		||||
  if(hspi->Instance==SPI3)
 | 
			
		||||
  {
 | 
			
		||||
  /* USER CODE BEGIN SPI3_MspDeInit 0 */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user