/* USER CODE BEGIN Header */ /** ****************************************************************************** * @file : main.h * @brief : Header for main.c file. * This file contains the common defines of the application. ****************************************************************************** * @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 */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __MAIN_H #define __MAIN_H #ifdef __cplusplus extern "C" { #endif /* Includes ------------------------------------------------------------------*/ #include "stm32f4xx_hal.h" /* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ /* USER CODE END Includes */ /* Exported types ------------------------------------------------------------*/ /* USER CODE BEGIN ET */ /* USER CODE END ET */ /* Exported constants --------------------------------------------------------*/ /* USER CODE BEGIN EC */ /* USER CODE END EC */ /* Exported macro ------------------------------------------------------------*/ /* USER CODE BEGIN EM */ /* USER CODE END EM */ /* Exported functions prototypes ---------------------------------------------*/ void Error_Handler(void); /* USER CODE BEGIN EFP */ /* USER CODE END EFP */ /* Private defines -----------------------------------------------------------*/ #define PC14_OSC32_IN_Pin GPIO_PIN_14 #define PC14_OSC32_IN_GPIO_Port GPIOC #define PC15_OSC32_OUT_Pin GPIO_PIN_15 #define PC15_OSC32_OUT_GPIO_Port GPIOC #define A0_Pin GPIO_PIN_0 #define A0_GPIO_Port GPIOF #define A1_Pin GPIO_PIN_1 #define A1_GPIO_Port GPIOF #define A2_Pin GPIO_PIN_2 #define A2_GPIO_Port GPIOF #define A3_Pin GPIO_PIN_3 #define A3_GPIO_Port GPIOF #define A4_Pin GPIO_PIN_4 #define A4_GPIO_Port GPIOF #define A5_Pin GPIO_PIN_5 #define A5_GPIO_Port GPIOF #define SPI5_SCK_Pin GPIO_PIN_7 #define SPI5_SCK_GPIO_Port GPIOF #define SPI5_MISO_Pin GPIO_PIN_8 #define SPI5_MISO_GPIO_Port GPIOF #define SPI5_MOSI_Pin GPIO_PIN_9 #define SPI5_MOSI_GPIO_Port GPIOF #define ENABLE_Pin GPIO_PIN_10 #define ENABLE_GPIO_Port GPIOF #define PH0_OSC_IN_Pin GPIO_PIN_0 #define PH0_OSC_IN_GPIO_Port GPIOH #define PH1_OSC_OUT_Pin GPIO_PIN_1 #define PH1_OSC_OUT_GPIO_Port GPIOH #define SDNWE_Pin GPIO_PIN_0 #define SDNWE_GPIO_Port GPIOC #define NCS_MEMS_SPI_Pin GPIO_PIN_1 #define NCS_MEMS_SPI_GPIO_Port GPIOC #define CSX_Pin GPIO_PIN_2 #define CSX_GPIO_Port GPIOC #define B1_Pin GPIO_PIN_0 #define B1_GPIO_Port GPIOA #define MEMS_INT1_Pin GPIO_PIN_1 #define MEMS_INT1_GPIO_Port GPIOA #define MEMS_INT2_Pin GPIO_PIN_2 #define MEMS_INT2_GPIO_Port GPIOA #define B5_Pin GPIO_PIN_3 #define B5_GPIO_Port GPIOA #define VSYNC_Pin GPIO_PIN_4 #define VSYNC_GPIO_Port GPIOA #define G2_Pin GPIO_PIN_6 #define G2_GPIO_Port GPIOA #define ACP_RST_Pin GPIO_PIN_7 #define ACP_RST_GPIO_Port GPIOA #define OTG_FS_PSO_Pin GPIO_PIN_4 #define OTG_FS_PSO_GPIO_Port GPIOC #define OTG_FS_OC_Pin GPIO_PIN_5 #define OTG_FS_OC_GPIO_Port GPIOC #define R3_Pin GPIO_PIN_0 #define R3_GPIO_Port GPIOB #define R6_Pin GPIO_PIN_1 #define R6_GPIO_Port GPIOB #define BOOT1_Pin GPIO_PIN_2 #define BOOT1_GPIO_Port GPIOB #define SDNRAS_Pin GPIO_PIN_11 #define SDNRAS_GPIO_Port GPIOF #define A6_Pin GPIO_PIN_12 #define A6_GPIO_Port GPIOF #define A7_Pin GPIO_PIN_13 #define A7_GPIO_Port GPIOF #define A8_Pin GPIO_PIN_14 #define A8_GPIO_Port GPIOF #define A9_Pin GPIO_PIN_15 #define A9_GPIO_Port GPIOF #define A10_Pin GPIO_PIN_0 #define A10_GPIO_Port GPIOG #define A11_Pin GPIO_PIN_1 #define A11_GPIO_Port GPIOG #define D4_Pin GPIO_PIN_7 #define D4_GPIO_Port GPIOE #define D5_Pin GPIO_PIN_8 #define D5_GPIO_Port GPIOE #define D6_Pin GPIO_PIN_9 #define D6_GPIO_Port GPIOE #define D7_Pin GPIO_PIN_10 #define D7_GPIO_Port GPIOE #define D8_Pin GPIO_PIN_11 #define D8_GPIO_Port GPIOE #define D9_Pin GPIO_PIN_12 #define D9_GPIO_Port GPIOE #define D10_Pin GPIO_PIN_13 #define D10_GPIO_Port GPIOE #define D11_Pin GPIO_PIN_14 #define D11_GPIO_Port GPIOE #define D12_Pin GPIO_PIN_15 #define D12_GPIO_Port GPIOE #define G4_Pin GPIO_PIN_10 #define G4_GPIO_Port GPIOB #define G5_Pin GPIO_PIN_11 #define G5_GPIO_Port GPIOB #define OTG_HS_ID_Pin GPIO_PIN_12 #define OTG_HS_ID_GPIO_Port GPIOB #define VBUS_HS_Pin GPIO_PIN_13 #define VBUS_HS_GPIO_Port GPIOB #define OTG_HS_DM_Pin GPIO_PIN_14 #define OTG_HS_DM_GPIO_Port GPIOB #define OTG_HS_DP_Pin GPIO_PIN_15 #define OTG_HS_DP_GPIO_Port GPIOB #define D13_Pin GPIO_PIN_8 #define D13_GPIO_Port GPIOD #define D14_Pin GPIO_PIN_9 #define D14_GPIO_Port GPIOD #define D15_Pin GPIO_PIN_10 #define D15_GPIO_Port GPIOD #define TE_Pin GPIO_PIN_11 #define TE_GPIO_Port GPIOD #define RDX_Pin GPIO_PIN_12 #define RDX_GPIO_Port GPIOD #define WRX_DCX_Pin GPIO_PIN_13 #define WRX_DCX_GPIO_Port GPIOD #define D0_Pin GPIO_PIN_14 #define D0_GPIO_Port GPIOD #define D1_Pin GPIO_PIN_15 #define D1_GPIO_Port GPIOD #define BA0_Pin GPIO_PIN_4 #define BA0_GPIO_Port GPIOG #define BA1_Pin GPIO_PIN_5 #define BA1_GPIO_Port GPIOG #define R7_Pin GPIO_PIN_6 #define R7_GPIO_Port GPIOG #define DOTCLK_Pin GPIO_PIN_7 #define DOTCLK_GPIO_Port GPIOG #define SDCLK_Pin GPIO_PIN_8 #define SDCLK_GPIO_Port GPIOG #define HSYNC_Pin GPIO_PIN_6 #define HSYNC_GPIO_Port GPIOC #define G6_Pin GPIO_PIN_7 #define G6_GPIO_Port GPIOC #define I2C3_SDA_Pin GPIO_PIN_9 #define I2C3_SDA_GPIO_Port GPIOC #define I2C3_SCL_Pin GPIO_PIN_8 #define I2C3_SCL_GPIO_Port GPIOA #define STLINK_RX_Pin GPIO_PIN_9 #define STLINK_RX_GPIO_Port GPIOA #define STLINK_TX_Pin GPIO_PIN_10 #define STLINK_TX_GPIO_Port GPIOA #define R4_Pin GPIO_PIN_11 #define R4_GPIO_Port GPIOA #define R5_Pin GPIO_PIN_12 #define R5_GPIO_Port GPIOA #define SWDIO_Pin GPIO_PIN_13 #define SWDIO_GPIO_Port GPIOA #define SWCLK_Pin GPIO_PIN_14 #define SWCLK_GPIO_Port GPIOA #define TP_INT1_Pin GPIO_PIN_15 #define TP_INT1_GPIO_Port GPIOA #define R2_Pin GPIO_PIN_10 #define R2_GPIO_Port GPIOC #define D2_Pin GPIO_PIN_0 #define D2_GPIO_Port GPIOD #define D3_Pin GPIO_PIN_1 #define D3_GPIO_Port GPIOD #define BUTTON1_Pin GPIO_PIN_2 #define BUTTON1_GPIO_Port GPIOD #define G7_Pin GPIO_PIN_3 #define G7_GPIO_Port GPIOD #define BUTTON2_Pin GPIO_PIN_4 #define BUTTON2_GPIO_Port GPIOD #define BUTTON3_Pin GPIO_PIN_5 #define BUTTON3_GPIO_Port GPIOD #define B2_Pin GPIO_PIN_6 #define B2_GPIO_Port GPIOD #define BUTTON4_Pin GPIO_PIN_7 #define BUTTON4_GPIO_Port GPIOD #define BUTTON5_Pin GPIO_PIN_9 #define BUTTON5_GPIO_Port GPIOG #define G3_Pin GPIO_PIN_10 #define G3_GPIO_Port GPIOG #define B3_Pin GPIO_PIN_11 #define B3_GPIO_Port GPIOG #define B4_Pin GPIO_PIN_12 #define B4_GPIO_Port GPIOG #define LD3_Pin GPIO_PIN_13 #define LD3_GPIO_Port GPIOG #define LD4_Pin GPIO_PIN_14 #define LD4_GPIO_Port GPIOG #define SDNCAS_Pin GPIO_PIN_15 #define SDNCAS_GPIO_Port GPIOG #define SDCKE1_Pin GPIO_PIN_5 #define SDCKE1_GPIO_Port GPIOB #define SDNE1_Pin GPIO_PIN_6 #define SDNE1_GPIO_Port GPIOB #define B6_Pin GPIO_PIN_8 #define B6_GPIO_Port GPIOB #define B7_Pin GPIO_PIN_9 #define B7_GPIO_Port GPIOB #define NBL0_Pin GPIO_PIN_0 #define NBL0_GPIO_Port GPIOE #define NBL1_Pin GPIO_PIN_1 #define NBL1_GPIO_Port GPIOE /* USER CODE BEGIN Private defines */ #define LCD_RES_HIGH(void) GPIOA->BSRR=GPIO_BSRR_BS7 #define LCD_RES_LOW(void) GPIOA->BSRR=GPIO_BSRR_BR7 #define LCD_CS_HIGH(void) GPIOC->BSRR=GPIO_BSRR_BS2 #define LCD_CS_LOW(void) GPIOC->BSRR=GPIO_BSRR_BR2 #define LCD_DC_HIGH(void) GPIOD->BSRR=GPIO_BSRR_BS13 #define LCD_DC_LOW(void) GPIOD->BSRR=GPIO_BSRR_BR13 #define ILI9341_HSYNC ((uint32_t)9) /* Horizontal synchronization */ #define ILI9341_HBP ((uint32_t)29) /* Horizontal back porch */ #define ILI9341_HFP ((uint32_t)2) /* Horizontal front porch */ #define ILI9341_VSYNC ((uint32_t)1) /* Vertical synchronization */ #define ILI9341_VBP ((uint32_t)3) /* Vertical back porch */ #define ILI9341_VFP ((uint32_t)2) /* Vertical front porch */ /** * @brief ILI9341 Registers */ /* Level 1 Commands */ /* Level 1 Commands */ #define ILI9341_SWRESET 0x01U /* Software Reset */ #define ILI9341_READ_DISPLAY_ID 0x04U /* Read display identification information */ #define ILI9341_RDDST 0x09U /* Read Display Status */ #define ILI9341_RDDPM 0x0AU /* Read Display Power Mode */ #define ILI9341_RDDMADCTL 0x0BU /* Read Display MADCTL */ #define ILI9341_RDDCOLMOD 0x0CU /* Read Display Pixel Format */ #define ILI9341_RDDIM 0x0DU /* Read Display Image Format */ #define ILI9341_RDDSM 0x0EU /* Read Display Signal Mode */ #define ILI9341_RDDSDR 0x0FU /* Read Display Self-Diagnostic Result */ #define ILI9341_SPLIN 0x10U /* Enter Sleep Mode */ #define ILI9341_SLEEP_OUT 0x11U /* Sleep out register */ #define ILI9341_PTLON 0x12U /* Partial Mode ON */ #define ILI9341_NORMAL_MODE_ON 0x13U /* Normal Display Mode ON */ #define ILI9341_DINVOFF 0x20U /* Display Inversion OFF */ #define ILI9341_DINVON 0x21U /* Display Inversion ON */ #define ILI9341_GAMMA 0x26U /* Gamma register */ #define ILI9341_DISPLAY_OFF 0x28U /* Display off register */ #define ILI9341_DISPLAY_ON 0x29U /* Display on register */ #define ILI9341_CASET 0x2AU /* Column address register */ #define ILI9341_RASET 0x2BU /* Page address register */ #define ILI9341_GRAM 0x2CU /* GRAM register */ #define ILI9341_RGBSET 0x2DU /* Color SET */ #define ILI9341_RAMRD 0x2EU /* Memory Read */ #define ILI9341_PLTAR 0x30U /* Partial Area */ #define ILI9341_VSCRDEF 0x33U /* Vertical Scrolling Definition */ #define ILI9341_TEOFF 0x34U /* Tearing Effect Line OFF */ #define ILI9341_TEON 0x35U /* Tearing Effect Line ON */ #define ILI9341_MAC 0x36U /* Memory Access Control register*/ #define ILI9341_VSCRSADD 0x37U /* Vertical Scrolling Start Address */ #define ILI9341_IDMOFF 0x38U /* Idle Mode OFF */ #define ILI9341_IDMON 0x39U /* Idle Mode ON */ #define ILI9341_PIXEL_FORMAT 0x3AU /* Pixel Format register */ #define ILI9341_WRITE_MEM_CONTINUE 0x3CU /* Write Memory Continue */ #define ILI9341_READ_MEM_CONTINUE 0x3EU /* Read Memory Continue */ #define ILI9341_SET_TEAR_SCANLINE 0x44U /* Set Tear Scanline */ #define ILI9341_GET_SCANLINE 0x45U /* Get Scanline */ #define ILI9341_WDB 0x51U /* Write Brightness Display register */ #define ILI9341_RDDISBV 0x52U /* Read Display Brightness */ #define ILI9341_WCD 0x53U /* Write Control Display register*/ #define ILI9341_RDCTRLD 0x54U /* Read CTRL Display */ #define ILI9341_WRCABC 0x55U /* Write Content Adaptive Brightness Control */ #define ILI9341_RDCABC 0x56U /* Read Content Adaptive Brightness Control */ #define ILI9341_WRITE_CABC 0x5EU /* Write CABC Minimum Brightness */ #define ILI9341_READ_CABC 0x5FU /* Read CABC Minimum Brightness */ #define ILI9341_READ_ID1 0xDAU /* Read ID1 */ #define ILI9341_READ_ID2 0xDBU /* Read ID2 */ #define ILI9341_READ_ID3 0xDCU /* Read ID3 */ /* Level 2 Commands */ #define ILI9341_RGB_INTERFACE 0xB0U /* RGB Interface Signal Control */ #define ILI9341_FRMCTR1 0xB1U /* Frame Rate Control (In Normal Mode) */ #define ILI9341_FRMCTR2 0xB2U /* Frame Rate Control (In Idle Mode) */ #define ILI9341_FRMCTR3 0xB3U /* Frame Rate Control (In Partial Mode) */ #define ILI9341_INVTR 0xB4U /* Display Inversion Control */ #define ILI9341_BPC 0xB5U /* Blanking Porch Control register */ #define ILI9341_DFC 0xB6U /* Display Function Control register */ #define ILI9341_ETMOD 0xB7U /* Entry Mode Set */ #define ILI9341_BACKLIGHT1 0xB8U /* Backlight Control 1 */ #define ILI9341_BACKLIGHT2 0xB9U /* Backlight Control 2 */ #define ILI9341_BACKLIGHT3 0xBAU /* Backlight Control 3 */ #define ILI9341_BACKLIGHT4 0xBBU /* Backlight Control 4 */ #define ILI9341_BACKLIGHT5 0xBCU /* Backlight Control 5 */ #define ILI9341_BACKLIGHT7 0xBEU /* Backlight Control 7 */ #define ILI9341_BACKLIGHT8 0xBFU /* Backlight Control 8 */ #define ILI9341_POWER1 0xC0U /* Power Control 1 register */ #define ILI9341_POWER2 0xC1U /* Power Control 2 register */ #define ILI9341_VCOM1 0xC5U /* VCOM Control 1 register */ #define ILI9341_VCOM2 0xC7U /* VCOM Control 2 register */ #define ILI9341_NVMWR 0xD0U /* NV Memory Write */ #define ILI9341_NVMPKEY 0xD1U /* NV Memory Protection Key */ #define ILI9341_RDNVM 0xD2U /* NV Memory Status Read */ #define ILI9341_READ_ID4 0xD3U /* Read ID4 */ #define ILI9341_PGAMMA 0xE0U /* Positive Gamma Correction register */ #define ILI9341_NGAMMA 0xE1U /* Negative Gamma Correction register */ #define ILI9341_DGAMCTRL1 0xE2U /* Digital Gamma Control 1 */ #define ILI9341_DGAMCTRL2 0xE3U /* Digital Gamma Control 2 */ #define ILI9341_INTERFACE 0xF6U /* Interface control register */ /* Extend register commands */ #define ILI9341_POWERA 0xCBU /* Power control A register */ #define ILI9341_POWERB 0xCFU /* Power control B register */ #define ILI9341_DTCA 0xE8U /* Driver timing control A */ #define ILI9341_DTCB 0xEAU /* Driver timing control B */ #define ILI9341_POWER_SEQ 0xEDU /* Power on sequence register */ #define ILI9341_3GAMMA_EN 0xF2U /* 3 Gamma enable register */ #define ILI9341_PRC 0xF7U /* Pump ratio control register */ #define MADCTL_MY 0x80 ///< Bottom to top #define MADCTL_MX 0x40 ///< Right to left #define MADCTL_MV 0x20 ///< Reverse Mode #define MADCTL_ML 0x10 ///< LCD refresh Bottom to top #define MADCTL_RGB 0x00 ///< Red-Green-Blue pixel order #define MADCTL_BGR 0x08 ///< Blue-Green-Red pixel order #define MADCTL_MH 0x04 ///< LCD refresh right to left /* Size of read registers */ #define LCD_READ_ID4_SIZE 3 /* Size of Read ID4 */ /* USER CODE END Private defines */ #ifdef __cplusplus } #endif #endif /* __MAIN_H */