TouchGFX之存储器映射闪存

对于大多数项目,建议使用外部闪存,因为这允许应用程序使用多个大型图像。 即便最普通的应用程序,内部闪存也可能会很快被占用完。

1.配置QSPI(嵌入式基础知识,此处不做分析)

TouchGFX之存储器映射闪存_第1张图片TouchGFX之存储器映射闪存_第2张图片

2.编写W25Q256配置代码(copy正点原子例程)

w25q256.c

#include "w25q256.h"
#include "quadspi.h"

#define QUAD_INOUT_FAST_READ_4_BYTE_ADDR_CMD 0xEC
void QSPI_MemoryMapped(void)
{
	QSPI_CommandTypeDef s_command = {0};
	QSPI_MemoryMappedTypeDef s_mem_mapped_cfg = {0};

	s_command.InstructionMode = QSPI_INSTRUCTION_1_LINE;
	s_command.AddressSize = QSPI_ADDRESS_32_BITS;
	s_command.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE;
	s_command.DdrMode = QSPI_DDR_MODE_DISABLE;
	s_command.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY;
	s_command.SIOOMode = QSPI_SIOO_INST_EVERY_CMD;

	s_command.Instruction = QUAD_INOUT_FAST_READ_4_BYTE_ADDR_CMD;
	s_command.AddressMode = QSPI_ADDRESS_4_LINES;
	s_command.DataMode = QSPI_DATA_4_LINES;
	s_command.DummyCycles = 6;

	s_mem_mapped_cfg.TimeOutActivation = QSPI_TIMEOUT_COUNTER_DISABLE;
	s_mem_mapped_cfg.TimeOutPeriod = 0;

	if(HAL_QSPI_MemoryMapped(&hqspi, &s_command, &s_mem_mapped_cfg) != HAL_OK)
	{
		Error_Handler();
	}
}
quadspi.c
 
  /* USER CODE BEGIN QUADSPI_Init 2 */
	QSPI_MemoryMapped();
  /* USER CODE END QUADSPI_Init 2 */

3.修改分散加载文件

; *************************************************************
; *** Scatter-Loading Description File generated by uVision ***
; *************************************************************

LR_IROM1 0x08000000 0x00200000  {    ; load region size_region
  ER_IROM1 0x08000000 0x00200000  {  ; load address = execution address
   *.o (RESET, +First)
   *(InRoot$$Sections)
   .ANY (+RO)
   .ANY (+XO)
  }
  RW_IRAM1 0x20000000 0x00020000  {  ; RW data
   .ANY (+RW +ZI)
  }
  RW_IRAM2 0x24000000 0x00080000  {
   *(.RAM_D1)
  }
  RW_IRAM3 0x30000000 0x00048000  {
   *(.RAM_D2)
  }
  RW_IRAM4 0x38000000 0x00010000  {
   *(.RAM_D3)
  }
;  RW_IRAM5 0xC0000000 UNINIT 0x02000000  {
;   *(.RAM_SDRAM)
;  }
}

LR_ROM1 0x90000000 0x02000000  {
  ER_ROM1 0x90000000 0x02000000  {  ; load address = execution address
	*.o (ExtFlashSection)
	*.o (TextFlashSection)
	*.o (FontFlashSection)
  }
}

4.添加下载算法(嵌入式基础知识,此处不做分析)

TouchGFX之存储器映射闪存_第3张图片

5.创建变量,仿真运行

/* USER CODE BEGIN PV */
//uint16_t framebuffer[1024 * 200];  //16 bpp framebuffer
uint16_t *framebuffer = (uint16_t *)0xC0000000;  //16 bpp framebuffer

__attribute__((section ("ExtFlashSection"))) const unsigned char qspi_flash[100];
/* USER CODE END PV */

TouchGFX之存储器映射闪存_第4张图片

你可能感兴趣的:(TouchGFX,arm开发)