ESP32では既に使えていました。今回、STM32CubeIDE上のWeAct STM32H750VBT6でも出来ました。当初はFMC接続で挑戦しましたが叶わず。でも、データピン D0~D15 を PB0~PB15 に接続、ビット直叩きなので速いと思います。次のサイトのLibraryを使用(ありがとうございます)。
使用物品/環境は以下。
・Windows 11 Pro 25H2
・STM32CubeMX
・STM32CubeIDE 2.1.1
・STM32CubeProgrammer
・WeAct Studio STM32H750VBT6 128KB ROM, 1MB RAM
・7.0inch 16BIT Module SSD1963(LCD_wiki)
・ST-LINK V2(互換品)
ディスプレイの初期化関数void LCD_ResetDevice(void)に苦労しました。やっと初期化できたと思ったら左右逆表示(mirror image)になってました。データシートを参考に
LCD_WriteCommand(0x36); //Set the read order from frame buffer to the display panel
Clr_Cs;
LCD_WriteData(0x02); // 0b 0000 0010 Flip Horizontal
//Set_Cs; //A[] 7654 3210
とすることで正常に。
手順を箇条書きします。
1.STM32CubeIDEフォルダー下のworkspace_2.1.1内に対象プロジェクト用のフォルダーを新規作成
2.STM32CubeMXを起動しMCUを選択後、RCC、Clock、GPIO、Tim1などを設定(SPIは設定するも使わず)。

3.設定後、作成したフォルダーと同名のプロジェクトにし、STM32CubeIDEが起動するようにします。

4.お好みでmain.cを編集します。
5.ビルドしてSTM32CubeProgrammerで書込む。
上掲のサイトのライブラリのうち必要なものだけに絞り、main.cに詰め込みました。一部はILI9488のライブラリを流用しました。グーグルのAI君の提示したコードも使ってます。
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file : main.c
* @brief : Main program body
******************************************************************************
* @attention
*
* Copyright (c) 2026 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "main.h"
#include "spi.h"
#include "tim.h"
#include "gpio.h"
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include "string.h"
#include <stdbool.h>
#include <stdint.h>
/* USER CODE END Includes */
/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN PTD */
typedef uint32_t u32;
typedef uint16_t u16;
typedef uint8_t u8;
typedef int16_t s16;
/* USER CODE END PTD */
/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */
#define LCD_RST 8//PA8
#define LCD_CS 9//PC9
#define LCD_RD 8//PC8
#define LCD_WR 7//PC7
#define LCD_RS 6//PC6
#define Set_Rst GPIOA->BSRR=(1<<LCD_RST)
#define Clr_Rst GPIOA->BSRR=(1<<(LCD_RST + 16))
#define Set_Cs GPIOC->BSRR=(1<<LCD_CS)
#define Clr_Cs GPIOC->BSRR=(1<<(LCD_CS + 16))
#define Set_nRd GPIOC->BSRR=(1<<LCD_RD)
#define Clr_nRd GPIOC->BSRR=(1<<(LCD_RD + 16))
#define Set_nWr GPIOC->BSRR=(1<<LCD_WR)
#define Clr_nWr GPIOC->BSRR=(1<<(LCD_WR + 16))
#define Set_Rs GPIOC->BSRR=(1<<LCD_RS)
#define Clr_Rs GPIOC->BSRR=(1<<(LCD_RS + 16))
#define DATAOUT(x) GPIOB->ODR=x;//PB0 - PB15
#define DATAIN GPIOB->IDR;
#define LCD_WriteCommand(cmd) {Clr_Rs; DATAOUT(cmd); Clr_Cs; Clr_nWr; Set_nWr; Set_Cs;};
#define LCD_WriteData(data) {Set_Rs; DATAOUT(data); Clr_nWr; Set_nWr;};
#define DISP_HOR_RESOLUTION 800
#define DISP_VER_RESOLUTION 480
//Horizontal synchronization timing in pixels from the glass datasheet
#define DISP_HOR_PULSE_WIDTH 1
#define DISP_HOR_BACK_PORCH 210
#define DISP_HOR_FRONT_PORCH 45
//Vertical synchronization timing in linesfrom the glass datasheet
#define DISP_VER_PULSE_WIDTH 1
#define DISP_VER_BACK_PORCH 34
#define DISP_VER_FRONT_PORCH 10
#define HPS (DISP_HOR_PULSE_WIDTH + DISP_HOR_BACK_PORCH)
#define HT (DISP_HOR_PULSE_WIDTH + DISP_HOR_BACK_PORCH + DISP_HOR_RESOLUTION + DISP_HOR_FRONT_PORCH)
#define VSP (DISP_VER_PULSE_WIDTH + DISP_VER_BACK_PORCH)
#define VT (DISP_VER_PULSE_WIDTH + DISP_VER_BACK_PORCH + DISP_VER_RESOLUTION + DISP_VER_FRONT_PORCH)
// SSD1963 command table
#define CMD_SET_COLUMN 0x2A
#define CMD_SET_PAGE 0x2B
#define CMD_WR_MEMSTART 0x2C
// Color Definition
#define BLACK 0x0000 /* 0, 0, 0 */
#define NAVY 0x000F /* 0, 0, 128 */
#define DARKGREEN 0x03E0 /* 0, 128, 0 */
#define MAROON 0x7800 /* 128, 0, 0 */
#define DARKCYAN 0x03EF /* 0, 128, 128 */
#define PURPLE 0x780F /* 128, 0, 128 */
#define OLIVE 0x7BE0 /* 128, 128, 0 */
#define BLUE 0x001F /* 0, 0, 255 */
#define GREEN 0x07E0 /* 0, 255, 0 */
#define RED 0xF800 /* 255, 0, 0 */
#define CYAN 0x07FF /* 0, 255, 255 */
#define MAGENTA 0xF81F /* 255, 0, 255 */
#define YELLOW 0xFFE0 /* 255, 255, 0 */
#define DARKGREY 0x7BEF /* 128, 128, 128 */
#define LIGHTGREY 0xC618 /* 192, 192, 192 */
#define WHITE 0xFFFF /* 255, 255, 255 */
#define GREENYELLOW 0xAFE5 /* 173, 255, 47 */
#define ORANGE 0xFD20 /* 255, 165, 0 */
#define pgm_read_byte(addr) (*(const unsigned char *)(addr))
/* USER CODE END PD */
/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM */
/* USER CODE END PM */
/* Private variables ---------------------------------------------------------*/
/* USER CODE BEGIN PV */
static //Text simple font array (You can your own font)
const unsigned char font1[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x3E, 0x5B, 0x4F,
0x5B, 0x3E, 0x3E, 0x6B, 0x4F, 0x6B, 0x3E, 0x1C, 0x3E, 0x7C, 0x3E, 0x1C,
0x18, 0x3C, 0x7E, 0x3C, 0x18, 0x1C, 0x57, 0x7D, 0x57, 0x1C, 0x1C, 0x5E,
0x7F, 0x5E, 0x1C, 0x00, 0x18, 0x3C, 0x18, 0x00, 0xFF, 0xE7, 0xC3, 0xE7,
0xFF, 0x00, 0x18, 0x24, 0x18, 0x00, 0xFF, 0xE7, 0xDB, 0xE7, 0xFF, 0x30,
0x48, 0x3A, 0x06, 0x0E, 0x26, 0x29, 0x79, 0x29, 0x26, 0x40, 0x7F, 0x05,
0x05, 0x07, 0x40, 0x7F, 0x05, 0x25, 0x3F, 0x5A, 0x3C, 0xE7, 0x3C, 0x5A,
0x7F, 0x3E, 0x1C, 0x1C, 0x08, 0x08, 0x1C, 0x1C, 0x3E, 0x7F, 0x14, 0x22,
0x7F, 0x22, 0x14, 0x5F, 0x5F, 0x00, 0x5F, 0x5F, 0x06, 0x09, 0x7F, 0x01,
0x7F, 0x00, 0x66, 0x89, 0x95, 0x6A, 0x60, 0x60, 0x60, 0x60, 0x60, 0x94,
0xA2, 0xFF, 0xA2, 0x94, 0x08, 0x04, 0x7E, 0x04, 0x08, 0x10, 0x20, 0x7E,
0x20, 0x10, 0x08, 0x08, 0x2A, 0x1C, 0x08, 0x08, 0x1C, 0x2A, 0x08, 0x08,
0x1E, 0x10, 0x10, 0x10, 0x10, 0x0C, 0x1E, 0x0C, 0x1E, 0x0C, 0x30, 0x38,
0x3E, 0x38, 0x30, 0x06, 0x0E, 0x3E, 0x0E, 0x06, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x5F, 0x00, 0x00, 0x00, 0x07, 0x00, 0x07, 0x00, 0x14,
0x7F, 0x14, 0x7F, 0x14, 0x24, 0x2A, 0x7F, 0x2A, 0x12, 0x23, 0x13, 0x08,
0x64, 0x62, 0x36, 0x49, 0x56, 0x20, 0x50, 0x00, 0x08, 0x07, 0x03, 0x00,
0x00, 0x1C, 0x22, 0x41, 0x00, 0x00, 0x41, 0x22, 0x1C, 0x00, 0x2A, 0x1C,
0x7F, 0x1C, 0x2A, 0x08, 0x08, 0x3E, 0x08, 0x08, 0x00, 0x80, 0x70, 0x30,
0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 0x60, 0x60, 0x00, 0x20,
0x10, 0x08, 0x04, 0x02, 0x3E, 0x51, 0x49, 0x45, 0x3E, 0x00, 0x42, 0x7F,
0x40, 0x00, 0x72, 0x49, 0x49, 0x49, 0x46, 0x21, 0x41, 0x49, 0x4D, 0x33,
0x18, 0x14, 0x12, 0x7F, 0x10, 0x27, 0x45, 0x45, 0x45, 0x39, 0x3C, 0x4A,
0x49, 0x49, 0x31, 0x41, 0x21, 0x11, 0x09, 0x07, 0x36, 0x49, 0x49, 0x49,
0x36, 0x46, 0x49, 0x49, 0x29, 0x1E, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00,
0x40, 0x34, 0x00, 0x00, 0x00, 0x08, 0x14, 0x22, 0x41, 0x14, 0x14, 0x14,
0x14, 0x14, 0x00, 0x41, 0x22, 0x14, 0x08, 0x02, 0x01, 0x59, 0x09, 0x06,
0x3E, 0x41, 0x5D, 0x59, 0x4E, 0x7C, 0x12, 0x11, 0x12, 0x7C, 0x7F, 0x49,
0x49, 0x49, 0x36, 0x3E, 0x41, 0x41, 0x41, 0x22, 0x7F, 0x41, 0x41, 0x41,
0x3E, 0x7F, 0x49, 0x49, 0x49, 0x41, 0x7F, 0x09, 0x09, 0x09, 0x01, 0x3E,
0x41, 0x41, 0x51, 0x73, 0x7F, 0x08, 0x08, 0x08, 0x7F, 0x00, 0x41, 0x7F,
0x41, 0x00, 0x20, 0x40, 0x41, 0x3F, 0x01, 0x7F, 0x08, 0x14, 0x22, 0x41,
0x7F, 0x40, 0x40, 0x40, 0x40, 0x7F, 0x02, 0x1C, 0x02, 0x7F, 0x7F, 0x04,
0x08, 0x10, 0x7F, 0x3E, 0x41, 0x41, 0x41, 0x3E, 0x7F, 0x09, 0x09, 0x09,
0x06, 0x3E, 0x41, 0x51, 0x21, 0x5E, 0x7F, 0x09, 0x19, 0x29, 0x46, 0x26,
0x49, 0x49, 0x49, 0x32, 0x03, 0x01, 0x7F, 0x01, 0x03, 0x3F, 0x40, 0x40,
0x40, 0x3F, 0x1F, 0x20, 0x40, 0x20, 0x1F, 0x3F, 0x40, 0x38, 0x40, 0x3F,
0x63, 0x14, 0x08, 0x14, 0x63, 0x03, 0x04, 0x78, 0x04, 0x03, 0x61, 0x59,
0x49, 0x4D, 0x43, 0x00, 0x7F, 0x41, 0x41, 0x41, 0x02, 0x04, 0x08, 0x10,
0x20, 0x00, 0x41, 0x41, 0x41, 0x7F, 0x04, 0x02, 0x01, 0x02, 0x04, 0x40,
0x40, 0x40, 0x40, 0x40, 0x00, 0x03, 0x07, 0x08, 0x00, 0x20, 0x54, 0x54,
0x78, 0x40, 0x7F, 0x28, 0x44, 0x44, 0x38, 0x38, 0x44, 0x44, 0x44, 0x28,
0x38, 0x44, 0x44, 0x28, 0x7F, 0x38, 0x54, 0x54, 0x54, 0x18, 0x00, 0x08,
0x7E, 0x09, 0x02, 0x18, 0xA4, 0xA4, 0x9C, 0x78, 0x7F, 0x08, 0x04, 0x04,
0x78, 0x00, 0x44, 0x7D, 0x40, 0x00, 0x20, 0x40, 0x40, 0x3D, 0x00, 0x7F,
0x10, 0x28, 0x44, 0x00, 0x00, 0x41, 0x7F, 0x40, 0x00, 0x7C, 0x04, 0x78,
0x04, 0x78, 0x7C, 0x08, 0x04, 0x04, 0x78, 0x38, 0x44, 0x44, 0x44, 0x38,
0xFC, 0x18, 0x24, 0x24, 0x18, 0x18, 0x24, 0x24, 0x18, 0xFC, 0x7C, 0x08,
0x04, 0x04, 0x08, 0x48, 0x54, 0x54, 0x54, 0x24, 0x04, 0x04, 0x3F, 0x44,
0x24, 0x3C, 0x40, 0x40, 0x20, 0x7C, 0x1C, 0x20, 0x40, 0x20, 0x1C, 0x3C,
0x40, 0x30, 0x40, 0x3C, 0x44, 0x28, 0x10, 0x28, 0x44, 0x4C, 0x90, 0x90,
0x90, 0x7C, 0x44, 0x64, 0x54, 0x4C, 0x44, 0x00, 0x08, 0x36, 0x41, 0x00,
0x00, 0x00, 0x77, 0x00, 0x00, 0x00, 0x41, 0x36, 0x08, 0x00, 0x02, 0x01,
0x02, 0x04, 0x02, 0x3C, 0x26, 0x23, 0x26, 0x3C, 0x1E, 0xA1, 0xA1, 0x61,
0x12, 0x3A, 0x40, 0x40, 0x20, 0x7A, 0x38, 0x54, 0x54, 0x55, 0x59, 0x21,
0x55, 0x55, 0x79, 0x41, 0x22, 0x54, 0x54, 0x78, 0x42, 0x21, 0x55, 0x54,
0x78, 0x40, 0x20, 0x54, 0x55, 0x79, 0x40, 0x0C, 0x1E, 0x52, 0x72, 0x12,
0x39, 0x55, 0x55, 0x55, 0x59, 0x39, 0x54, 0x54, 0x54, 0x59, 0x39, 0x55,
0x54, 0x54, 0x58, 0x00, 0x00, 0x45, 0x7C, 0x41, 0x00, 0x02, 0x45, 0x7D,
0x42, 0x00, 0x01, 0x45, 0x7C, 0x40, 0x7D, 0x12, 0x11, 0x12, 0x7D, 0xF0,
0x28, 0x25, 0x28, 0xF0, 0x7C, 0x54, 0x55, 0x45, 0x00, 0x20, 0x54, 0x54,
0x7C, 0x54, 0x7C, 0x0A, 0x09, 0x7F, 0x49, 0x32, 0x49, 0x49, 0x49, 0x32,
0x3A, 0x44, 0x44, 0x44, 0x3A, 0x32, 0x4A, 0x48, 0x48, 0x30, 0x3A, 0x41,
0x41, 0x21, 0x7A, 0x3A, 0x42, 0x40, 0x20, 0x78, 0x00, 0x9D, 0xA0, 0xA0,
0x7D, 0x3D, 0x42, 0x42, 0x42, 0x3D, 0x3D, 0x40, 0x40, 0x40, 0x3D, 0x3C,
0x24, 0xFF, 0x24, 0x24, 0x48, 0x7E, 0x49, 0x43, 0x66, 0x2B, 0x2F, 0xFC,
0x2F, 0x2B, 0xFF, 0x09, 0x29, 0xF6, 0x20, 0xC0, 0x88, 0x7E, 0x09, 0x03,
0x20, 0x54, 0x54, 0x79, 0x41, 0x00, 0x00, 0x44, 0x7D, 0x41, 0x30, 0x48,
0x48, 0x4A, 0x32, 0x38, 0x40, 0x40, 0x22, 0x7A, 0x00, 0x7A, 0x0A, 0x0A,
0x72, 0x7D, 0x0D, 0x19, 0x31, 0x7D, 0x26, 0x29, 0x29, 0x2F, 0x28, 0x26,
0x29, 0x29, 0x29, 0x26, 0x30, 0x48, 0x4D, 0x40, 0x20, 0x38, 0x08, 0x08,
0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x38, 0x2F, 0x10, 0xC8, 0xAC, 0xBA,
0x2F, 0x10, 0x28, 0x34, 0xFA, 0x00, 0x00, 0x7B, 0x00, 0x00, 0x08, 0x14,
0x2A, 0x14, 0x22, 0x22, 0x14, 0x2A, 0x14, 0x08, 0x55, 0x00, 0x55, 0x00,
0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0xFF, 0x55, 0xFF, 0x55, 0xFF, 0x00,
0x00, 0x00, 0xFF, 0x00, 0x10, 0x10, 0x10, 0xFF, 0x00, 0x14, 0x14, 0x14,
0xFF, 0x00, 0x10, 0x10, 0xFF, 0x00, 0xFF, 0x10, 0x10, 0xF0, 0x10, 0xF0,
0x14, 0x14, 0x14, 0xFC, 0x00, 0x14, 0x14, 0xF7, 0x00, 0xFF, 0x00, 0x00,
0xFF, 0x00, 0xFF, 0x14, 0x14, 0xF4, 0x04, 0xFC, 0x14, 0x14, 0x17, 0x10,
0x1F, 0x10, 0x10, 0x1F, 0x10, 0x1F, 0x14, 0x14, 0x14, 0x1F, 0x00, 0x10,
0x10, 0x10, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x10, 0x10, 0x10, 0x10,
0x1F, 0x10, 0x10, 0x10, 0x10, 0xF0, 0x10, 0x00, 0x00, 0x00, 0xFF, 0x10,
0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0xFF, 0x10, 0x00, 0x00,
0x00, 0xFF, 0x14, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x1F, 0x10,
0x17, 0x00, 0x00, 0xFC, 0x04, 0xF4, 0x14, 0x14, 0x17, 0x10, 0x17, 0x14,
0x14, 0xF4, 0x04, 0xF4, 0x00, 0x00, 0xFF, 0x00, 0xF7, 0x14, 0x14, 0x14,
0x14, 0x14, 0x14, 0x14, 0xF7, 0x00, 0xF7, 0x14, 0x14, 0x14, 0x17, 0x14,
0x10, 0x10, 0x1F, 0x10, 0x1F, 0x14, 0x14, 0x14, 0xF4, 0x14, 0x10, 0x10,
0xF0, 0x10, 0xF0, 0x00, 0x00, 0x1F, 0x10, 0x1F, 0x00, 0x00, 0x00, 0x1F,
0x14, 0x00, 0x00, 0x00, 0xFC, 0x14, 0x00, 0x00, 0xF0, 0x10, 0xF0, 0x10,
0x10, 0xFF, 0x10, 0xFF, 0x14, 0x14, 0x14, 0xFF, 0x14, 0x10, 0x10, 0x10,
0x1F, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x10, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,
0x00, 0xFF, 0xFF, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x38, 0x44, 0x44, 0x38,
0x44, 0xFC, 0x4A, 0x4A, 0x4A, 0x34, 0x7E, 0x02, 0x02, 0x06, 0x06, 0x02,
0x7E, 0x02, 0x7E, 0x02, 0x63, 0x55, 0x49, 0x41, 0x63, 0x38, 0x44, 0x44,
0x3C, 0x04, 0x40, 0x7E, 0x20, 0x1E, 0x20, 0x06, 0x02, 0x7E, 0x02, 0x02,
0x99, 0xA5, 0xE7, 0xA5, 0x99, 0x1C, 0x2A, 0x49, 0x2A, 0x1C, 0x4C, 0x72,
0x01, 0x72, 0x4C, 0x30, 0x4A, 0x4D, 0x4D, 0x30, 0x30, 0x48, 0x78, 0x48,
0x30, 0xBC, 0x62, 0x5A, 0x46, 0x3D, 0x3E, 0x49, 0x49, 0x49, 0x00, 0x7E,
0x01, 0x01, 0x01, 0x7E, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x44, 0x44, 0x5F,
0x44, 0x44, 0x40, 0x51, 0x4A, 0x44, 0x40, 0x40, 0x44, 0x4A, 0x51, 0x40,
0x00, 0x00, 0xFF, 0x01, 0x03, 0xE0, 0x80, 0xFF, 0x00, 0x00, 0x08, 0x08,
0x6B, 0x6B, 0x08, 0x36, 0x12, 0x36, 0x24, 0x36, 0x06, 0x0F, 0x09, 0x0F,
0x06, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x30,
0x40, 0xFF, 0x01, 0x01, 0x00, 0x1F, 0x01, 0x01, 0x1E, 0x00, 0x19, 0x1D,
0x17, 0x12, 0x00, 0x3C, 0x3C, 0x3C, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00 };
/* USER CODE END PV */
/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
static void MPU_Config(void);
/* USER CODE BEGIN PFP */
/* USER CODE END PFP */
/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
static void LED_Blink(u32 Hdelay, u32 Ldelay) {
HAL_GPIO_WritePin(PE3_GPIO_Port, PE3_Pin, GPIO_PIN_SET);
HAL_Delay(Hdelay - 1);
HAL_GPIO_WritePin(PE3_GPIO_Port, PE3_Pin, GPIO_PIN_RESET);
HAL_Delay(Ldelay - 1);
}
u16 _width = DISP_HOR_RESOLUTION;
u16 _height = DISP_VER_RESOLUTION;
u16 _clipRgn;
// Left clipping region border
u16 _clipLeft;
// Top clipping region border
u16 _clipTop;
// Right clipping region border
u16 _clipRight;
// Bottom clipping region border
u16 _clipBottom;
// Active and Visual Pages
u8 _activePage;
//u8 _visualPage;
static u16 colArray[] = {
DARKCYAN, PURPLE, OLIVE, BLUE, GREEN, RED, CYAN, MAGENTA, YELLOW, DARKGREY };
void LCD_SetArea(u16 start_x, u16 start_y, u16 end_x, u16 end_y) {
u32 offset;
offset = (u32) (_activePage * (_height + 1));
start_y = offset + start_y;
end_y = offset + end_y;
LCD_WriteCommand(CMD_SET_COLUMN); //0x2A
Clr_Cs;
LCD_WriteData(start_x >> 8);
LCD_WriteData(start_x);
LCD_WriteData(end_x >> 8);
LCD_WriteData(end_x);
Set_Cs;
LCD_WriteCommand(CMD_SET_PAGE); //0x2B
Clr_Cs;
LCD_WriteData(start_y >> 8);
LCD_WriteData(start_y);
LCD_WriteData(end_y >> 8);
LCD_WriteData(end_y);
Set_Cs;
LCD_WriteCommand(CMD_WR_MEMSTART);
}
void LCD_Clear(u16 color) {
u32 x, y;
LCD_SetArea(0, 0, _width, _height);
//LCD_WriteCommand(CMD_WR_MEMSTART);
Clr_Cs;
for (y = 0; y < _height + 1; y++) { // important _height + 1
for (x = 0; x < _width; x++) // remark _width + 1
LCD_WriteData(color);
}
//Set_Cs;
}
void LCD_PutPixel(u16 x, u16 y, u16 color) {
if (_clipRgn) {
if (x < _clipLeft)
return;
if (x > _clipRight)
return;
if (y < _clipTop)
return;
if (y > _clipBottom)
return;
}
LCD_SetArea(x, y, x + 1, y + 1); //GetMaxX(),GetMaxY());
//LCD_WriteCommand(CMD_WR_MEMSTART);
Clr_Cs;
LCD_WriteData(color);
//Set_Cs;
}
void LCD_Line(u16 x0, u16 y0, u16 x1, u16 y1, u16 color) {
u16 x, y;
u16 dx; // = abs(x1 - x0);
u16 dy; // = abs(y1 - y0);
if (y0 == y1) {
if (x0 <= x1) {
x = x0;
} else {
x = x1;
x1 = x0;
}
while (x <= x1) {
LCD_PutPixel(x, y0, color);
x++;
}
return;
} else if (y0 > y1) {
dy = y0 - y1;
} else {
dy = y1 - y0;
}
if (x0 == x1) {
if (y0 <= y1) {
y = y0;
} else {
y = y1;
y1 = y0;
}
while (y <= y1) {
LCD_PutPixel(x0, y, color);
y++;
}
return;
} else if (x0 > x1) {
dx = x0 - x1;
x = x1;
x1 = x0;
y = y1;
y1 = y0;
} else {
dx = x1 - x0;
x = x0;
y = y0;
}
if (dx == dy) {
while (x <= x1) {
x++;
if (y > y1) {
y--;
} else {
y++;
}
LCD_PutPixel(x, y, color);
}
} else {
LCD_PutPixel(x, y, color);
if (y < y1) {
if (dx > dy) {
s16 p = dy * 2 - dx;
s16 twoDy = 2 * dy;
s16 twoDyMinusDx = 2 * (dy - dx);
while (x < x1) {
x++;
if (p < 0) {
p += twoDy;
} else {
y++;
p += twoDyMinusDx;
}
LCD_PutPixel(x, y, color);
}
} else {
s16 p = dx * 2 - dy;
s16 twoDx = 2 * dx;
s16 twoDxMinusDy = 2 * (dx - dy);
while (y < y1) {
y++;
if (p < 0) {
p += twoDx;
} else {
x++;
p += twoDxMinusDy;
}
LCD_PutPixel(x, y, color);
}
}
} else {
if (dx > dy) {
s16 p = dy * 2 - dx;
s16 twoDy = 2 * dy;
s16 twoDyMinusDx = 2 * (dy - dx);
while (x < x1) {
x++;
if (p < 0) {
p += twoDy;
} else {
y--;
p += twoDyMinusDx;
}
LCD_PutPixel(x, y, color);
}
} else {
s16 p = dx * 2 - dy;
s16 twoDx = 2 * dx;
s16 twoDxMinusDy = 2 * (dx - dy);
while (y1 < y) {
y--;
if (p < 0) {
p += twoDx;
} else {
x++;
p += twoDxMinusDy;
}
LCD_PutPixel(x, y, color);
}
}
}
}
}
void LCD_Rectangle(u16 left, u16 top, u16 right, u16 bottom, u16 color,
bool fill) {
u16 x, y;
if (!fill) {
LCD_Line(left, top, left, bottom, color);
LCD_Line(left, bottom, right, bottom, color);
LCD_Line(right, bottom, right, top, color);
LCD_Line(right, top, left, top, color);
} else { // Filled Rectangle
if (_clipRgn) {
if (left < _clipLeft)
left = _clipLeft;
if (right > _clipRight)
right = _clipRight;
if (top < _clipTop)
top = _clipTop;
if (bottom > _clipBottom)
bottom = _clipBottom;
}
LCD_SetArea(left, top, right, bottom);
//LCD_WriteCommand(CMD_WR_MEMSTART);
Clr_Cs;
for (y = top; y < bottom + 1; y++) {
for (x = left; x < right + 1; x++) {
LCD_WriteData(color);
}
}
Set_Cs;
}
}
void DrawFillRect(u16 x0, u16 y0, u16 width, u16 height, u16 color, bool fill) {
LCD_Rectangle(x0, y0, x0 + width, y0 + height, color, fill);
}
void DrawChar(u16 x, u16 y, u8 c, u16 color, u16 bg, u8 size) {
// フォントデータから対象文字のパターンを取得する
// 5x7システムのフォントテーブルを参照
u8 line;
if (c < ' ' || c > '~')
return; // サポート外の文字除外
// ピクセル単位での描画ループ
for (u8 i = 0; i < 5; i++) {
line = pgm_read_byte(font1 + (c * 5) + i);
for (u8 j = 0; j < 8; j++) {
u16 p_color = (line & (1 << j)) ? color : bg;
// size(拡大率)に応じた矩形またはピクセル描画
if (size == 1) {
LCD_PutPixel(x + i, y + j, p_color);
} else {
DrawFillRect(x + i * size, y + j * size, size, size, p_color,
true);
}
}
}
}
void ILI9488_printText(u8 text[], u16 x, u16 y, u16 color, u16 bg, u8 size) {
u16 offset;
offset = size * 6; //5x7フォント 隙間を空ける
u16 len = strlen((char*) text);
for (u16 i = 0; i < len && text[i] != '\0'; i++) {
DrawChar(x + (offset * i), y, text[i], color, bg, size);
}
}
void LCD_Circle(u16 cx, u16 cy, u16 r, u16 color, u8 fill) {
u16 x, y;
s16 delta, tmp;
x = 0;
y = r;
delta = 3 - (r << 1);
while (y > x) {
if (fill) {
LCD_Line(cx + x, cy + y, cx - x, cy + y, color);
LCD_Line(cx + x, cy - y, cx - x, cy - y, color);
LCD_Line(cx + y, cy + x, cx - y, cy + x, color);
LCD_Line(cx + y, cy - x, cx - y, cy - x, color);
} else {
LCD_PutPixel(cx + x, cy + y, color);
LCD_PutPixel(cx - x, cy + y, color);
LCD_PutPixel(cx + x, cy - y, color);
LCD_PutPixel(cx - x, cy - y, color);
LCD_PutPixel(cx + y, cy + x, color);
LCD_PutPixel(cx - y, cy + x, color);
LCD_PutPixel(cx + y, cy - x, color);
LCD_PutPixel(cx - y, cy - x, color);
}
x++;
if (delta >= 0) {
y--;
tmp = (x << 2);
tmp -= (y << 2);
delta += (tmp + 10);
} else {
delta += ((x << 2) + 6);
}
}
}
void LCD_ResetDevice(void) {
Set_Rst;
Set_Cs; // SSD1963 is not selected by default
Set_nRd;
Set_nWr;
Clr_Rst;
HAL_Delay(100); // wait stablize
Set_Rst; // release from reset state to sleep state
HAL_Delay(50); // wait stablize
LCD_WriteCommand(0xE2);
Clr_Cs;
LCD_WriteData(0x23);
LCD_WriteData(0x02);
LCD_WriteData(0x54);
Set_Cs;
LCD_WriteCommand(0xE0); // Start PLL command
Clr_Cs;
LCD_WriteData(0x01); // enable PLL
//Set_Cs;
HAL_Delay(10); // wait stablize
LCD_WriteCommand(0xE0); // Start PLL command again
Clr_Cs;
LCD_WriteData(0x03); // now, use PLL output as system clock
//Set_Cs;
LCD_WriteCommand(0x01); // Soft reset
HAL_Delay(10);
LCD_WriteCommand(0xE6);
Clr_Cs;
LCD_WriteData(0x04);
LCD_WriteData(0xff);
LCD_WriteData(0xff);
//Set_Cs;
//Set panel mode, varies from individual manufacturer
LCD_WriteCommand(0xB0);
Clr_Cs;
LCD_WriteData(0x10); // set 18-bit for 7" panel TY700TFT800480
LCD_WriteData(0x80); // set TTL mode
LCD_WriteData((DISP_HOR_RESOLUTION-1)>>8); //Set panel size
LCD_WriteData(DISP_HOR_RESOLUTION-1);
LCD_WriteData((DISP_VER_RESOLUTION-1)>>8);
LCD_WriteData(DISP_VER_RESOLUTION-1);
LCD_WriteData(0x00); //RGB sequence
//Set_Cs;
//Set horizontal period
LCD_WriteCommand(0xB4);
Clr_Cs;
LCD_WriteData((HT-1)>>8);
LCD_WriteData(HT-1);
LCD_WriteData((HPS-1)>>8);
LCD_WriteData(HPS-1);
LCD_WriteData(DISP_HOR_PULSE_WIDTH-1);
LCD_WriteData(0x00);
LCD_WriteData(0x00);
LCD_WriteData(0x00);
//Set_Cs;
//Set vertical period
LCD_WriteCommand(0xB6);
Clr_Cs;
LCD_WriteData((VT-1)>>8);
LCD_WriteData(VT-1);
LCD_WriteData((VSP-1)>>8);
LCD_WriteData(VSP-1);
LCD_WriteData(DISP_VER_PULSE_WIDTH-1);
LCD_WriteData(0x00);
LCD_WriteData(0x00);
//Set_Cs;
LCD_WriteCommand(0x36); //Set the read order from frame buffer to the display panel
Clr_Cs;
LCD_WriteData(0x02); // 0b 0000 0010 Flip Horizontal
//Set_Cs; //A[] 7654 3210
LCD_WriteCommand(0x3A); //Set pixel format
Clr_Cs;
LCD_WriteData(0x55); // set 16bpp
//Set_Cs;
//Set pixel data interface
LCD_WriteCommand(0xF0);
Clr_Cs;
LCD_WriteData(0x03); //16-bit(565 format) data for 16bpp PIC32MX only
LCD_WriteCommand(0x29); // Turn on display;
}
/* USER CODE END 0 */
/**
* @brief The application entry point.
* @retval int
*/
int main(void) {
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* MPU Configuration--------------------------------------------------------*/
MPU_Config();
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_SPI2_Init();
MX_TIM1_Init();
/* USER CODE BEGIN 2 */
/* Set LCD Backlight intensity by PE10_PWM */
__HAL_TIM_SET_COMPARE(&htim1, TIM_CHANNEL_2, 50); // Dark 50/1000
HAL_TIMEx_PWMN_Start(&htim1, TIM_CHANNEL_2);
LCD_ResetDevice();
HAL_Delay(100);
LCD_Clear(WHITE);
HAL_Delay(1000);
LCD_Clear(BLACK);
HAL_Delay(1000);
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1) {
LCD_Clear(BLACK);
for (int16_t i = 0; i < 70; i++) {
LCD_PutPixel(3 + i, i, GREEN);
LCD_PutPixel(2 + i, 1 + i, GREEN);
LCD_PutPixel(1 + i, 2 + i, GREEN);
LCD_PutPixel(i, 3 + i, GREEN);
LCD_Rectangle(788 - 11 * i, 2 * i, 799 - 11 * i, 5 * i,
colArray[i % 10], (i % 2 == 0) ? true : false);
LCD_Circle(470 + i * 2, 280, 10 + i * 2, colArray[i % 10], false);
DrawChar(100 + 6 * i, 460, ' ' + i, WHITE, RED, 1);
}
ILI9488_printText(
(u8*) " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`a",
5, 380, WHITE, RED, 2);
HAL_Delay(5000);
for (int i = 0; i < 10; i++)
LCD_Clear(colArray[i % 11]);
for (int i = 0; i < 10; i++)
DrawFillRect(0, 48 * i, _width, 48, colArray[i % 10], true);
HAL_Delay(2000);
LCD_Clear(0x0006);
for (int i = 0; i < 11; i++)
LCD_Line(0, 0, _width - 1, 48 * i, colArray[i % 11]);
HAL_Delay(2000);
LCD_Clear(0x0006);
for (int i = 0; i < 40; i++)
LCD_Line(20 * i, 0, 20 * i, _height - 1, colArray[i % 11]);
HAL_Delay(2000);
LCD_Clear(0x0006);
for (int i = 0; i < 24; i++)
LCD_Line(0, 20 * i, _width, 20 * i, colArray[i % 11]);
HAL_Delay(2000);
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
LED_Blink(998, 2);
}
/* USER CODE END 3 */
}
/**
* @brief System Clock Configuration
* @retval None
*/
void SystemClock_Config(void) {
RCC_OscInitTypeDef RCC_OscInitStruct = { 0 };
RCC_ClkInitTypeDef RCC_ClkInitStruct = { 0 };
/** Supply configuration update enable
*/
HAL_PWREx_ConfigSupply(PWR_LDO_SUPPLY);
/** Configure the main internal regulator output voltage
*/
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE0);
while (!__HAL_PWR_GET_FLAG(PWR_FLAG_VOSRDY)) {
}
/** Initializes the RCC Oscillators according to the specified parameters
* in the RCC_OscInitTypeDef structure.
*/
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
RCC_OscInitStruct.HSIState = RCC_HSI_DIV1;
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
RCC_OscInitStruct.PLL.PLLM = 4;
RCC_OscInitStruct.PLL.PLLN = 60;
RCC_OscInitStruct.PLL.PLLP = 2;
RCC_OscInitStruct.PLL.PLLQ = 5;
RCC_OscInitStruct.PLL.PLLR = 2;
RCC_OscInitStruct.PLL.PLLRGE = RCC_PLL1VCIRANGE_3;
RCC_OscInitStruct.PLL.PLLVCOSEL = RCC_PLL1VCOWIDE;
RCC_OscInitStruct.PLL.PLLFRACN = 0;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) {
Error_Handler();
}
/** Initializes the CPU, AHB and APB buses clocks
*/
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK
| RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2 | RCC_CLOCKTYPE_D3PCLK1
| RCC_CLOCKTYPE_D1PCLK1;
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.SYSCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.AHBCLKDivider = RCC_HCLK_DIV2;
RCC_ClkInitStruct.APB3CLKDivider = RCC_APB3_DIV2;
RCC_ClkInitStruct.APB1CLKDivider = RCC_APB1_DIV2;
RCC_ClkInitStruct.APB2CLKDivider = RCC_APB2_DIV2;
RCC_ClkInitStruct.APB4CLKDivider = RCC_APB4_DIV2;
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4) != HAL_OK) {
Error_Handler();
}
}
/* USER CODE BEGIN 4 */
/* USER CODE END 4 */
/* MPU Configuration */
void MPU_Config(void) {
MPU_Region_InitTypeDef MPU_InitStruct = { 0 };
/* Disables the MPU */
HAL_MPU_Disable();
/** Initializes and configures the Region and the memory to be protected
*/
MPU_InitStruct.Enable = MPU_REGION_ENABLE;
MPU_InitStruct.Number = MPU_REGION_NUMBER0;
MPU_InitStruct.BaseAddress = 0x0;
MPU_InitStruct.Size = MPU_REGION_SIZE_4GB;
MPU_InitStruct.SubRegionDisable = 0x87;
MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL0;
MPU_InitStruct.AccessPermission = MPU_REGION_NO_ACCESS;
MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_DISABLE;
MPU_InitStruct.IsShareable = MPU_ACCESS_SHAREABLE;
MPU_InitStruct.IsCacheable = MPU_ACCESS_NOT_CACHEABLE;
MPU_InitStruct.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE;
HAL_MPU_ConfigRegion(&MPU_InitStruct);
/* Enables the MPU */
HAL_MPU_Enable(MPU_PRIVILEGED_DEFAULT);
}
/**
* @brief This function is executed in case of error occurrence.
* @retval None
*/
void Error_Handler(void) {
/* USER CODE BEGIN Error_Handler_Debug */
/* User can add his own implementation to report the HAL error return state */
/* USER CODE END Error_Handler_Debug */
}
#ifdef USE_FULL_ASSERT
/**
* @brief Reports the name of the source file and the source line number
* where the assert_param error has occurred.
* @param file: pointer to the source file name
* @param line: assert_param error line source number
* @retval None
*/
void assert_failed(uint8_t *file, uint32_t line)
{
/* USER CODE BEGIN 6 */
/* User can add his own implementation to report the file name and line number,
ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
/* USER CODE END 6 */
}
#endif /* USE_FULL_ASSERT */
