diff --git a/boards/stm32f746g-disco/Kconfig b/boards/stm32f746g-disco/Kconfig index 7c27affbaf..d8e16429a5 100644 --- a/boards/stm32f746g-disco/Kconfig +++ b/boards/stm32f746g-disco/Kconfig @@ -16,6 +16,7 @@ config BOARD_STM32F746G_DISCO select HAS_PERIPH_DMA select HAS_PERIPH_ETH select HAS_PERIPH_I2C + select HAS_PERIPH_LTDC select HAS_PERIPH_RTC select HAS_PERIPH_RTT select HAS_PERIPH_SPI diff --git a/boards/stm32f746g-disco/Makefile.features b/boards/stm32f746g-disco/Makefile.features index 431f2899c4..cebfc5d744 100644 --- a/boards/stm32f746g-disco/Makefile.features +++ b/boards/stm32f746g-disco/Makefile.features @@ -5,6 +5,7 @@ CPU_MODEL = stm32f746ng FEATURES_PROVIDED += periph_dma FEATURES_PROVIDED += periph_eth FEATURES_PROVIDED += periph_i2c +FEATURES_PROVIDED += periph_ltdc FEATURES_PROVIDED += periph_rtc FEATURES_PROVIDED += periph_rtt FEATURES_PROVIDED += periph_spi diff --git a/boards/stm32f746g-disco/board.c b/boards/stm32f746g-disco/board.c index 87765a1632..c0af996922 100644 --- a/boards/stm32f746g-disco/board.c +++ b/boards/stm32f746g-disco/board.c @@ -18,9 +18,19 @@ * @} */ +#include "kernel_defines.h" #include "board.h" #include "periph/gpio.h" void board_init(void) { + gpio_init(BACKLIGHT_PIN, GPIO_OUT); + if (IS_USED(MODULE_PERIPH_LTDC)) { + gpio_init(LCD_DISP_PIN, GPIO_OUT); + gpio_set(LCD_DISP_PIN); + gpio_set(BACKLIGHT_PIN); + } + else { + gpio_clear(BACKLIGHT_PIN); + } } diff --git a/boards/stm32f746g-disco/doc.txt b/boards/stm32f746g-disco/doc.txt index 68f7618f4d..f44eca573d 100644 --- a/boards/stm32f746g-disco/doc.txt +++ b/boards/stm32f746g-disco/doc.txt @@ -27,7 +27,7 @@ Current hardware support: | Ethernet | X | | | USB OTG FS | X | | | USB OTG HS | - | | -| TFT LCD | - | | +| TFT LCD | X | | | Capacitive touch screen | - | | | User microphones | - | | | External Quad-SPI Flash | - | | diff --git a/boards/stm32f746g-disco/include/board.h b/boards/stm32f746g-disco/include/board.h index 24e647dcbc..7bfa240f66 100644 --- a/boards/stm32f746g-disco/include/board.h +++ b/boards/stm32f746g-disco/include/board.h @@ -27,6 +27,36 @@ extern "C" { #endif +/** + * @name LCD Backlight control defines + * @{ + */ +#define BACKLIGHT_PIN GPIO_PIN(PORT_K, 3) /**< Backlight pin */ +#define BACKLIGHT_MASK (1 << 3) /**< Backlight pin mask */ + +/** Set the backlight pin */ +#define BACKLIGHT_ON (GPIOK->BSRR = BACKLIGHT_MASK) +/** Clear the backlight pin */ +#define BACKLIGHT_OFF (GPIOK->BSRR = (BACKLIGHT_MASK << 16)) +/** Toggle the backlight pin */ +#define BACKLIGHT_TOGGLE (GPIOK->ODR ^= BACKLIGHT_MASK) +/** @} */ + +/** + * @name LCD display enable pin + * @{ + */ +#define LCD_DISP_PIN GPIO_PIN(PORT_I, 12) /**< LCD screen enable pin */ +/** @} */ + +/** + * @name LCD screen dimensions + * @{ + */ +#define LCD_SCREEN_WIDTH 480 /**< LCD screen width */ +#define LCD_SCREEN_HEIGHT 272 /**< LCD screen height */ +/** @} */ + /** * @name User button * @{ diff --git a/boards/stm32f746g-disco/include/periph_conf.h b/boards/stm32f746g-disco/include/periph_conf.h index 6664a527fd..4b4250edf7 100644 --- a/boards/stm32f746g-disco/include/periph_conf.h +++ b/boards/stm32f746g-disco/include/periph_conf.h @@ -173,6 +173,62 @@ static const eth_conf_t eth_config = { #define ETH_DMA_ISR isr_dma2_stream0 /** @} */ +/** + * @name LTDC configuration + * @{ + */ +/** LTDC static configuration struct */ +static const ltdc_conf_t ltdc_config = { + .bus = APB2, + .rcc_mask = RCC_APB2ENR_LTDCEN, + .clk_pin = { .pin = GPIO_PIN(PORT_I, 14), .af = GPIO_AF14, }, + .de_pin = { .pin = GPIO_PIN(PORT_K, 7), .af = GPIO_AF14, }, + .hsync_pin = { .pin = GPIO_PIN(PORT_I, 10), .af = GPIO_AF14, }, + .vsync_pin = { .pin = GPIO_PIN(PORT_I, 9), .af = GPIO_AF14, }, + .r_pin = { + { .pin = GPIO_PIN(PORT_I, 15), .af = GPIO_AF14, }, + { .pin = GPIO_PIN(PORT_J, 0), .af = GPIO_AF14, }, + { .pin = GPIO_PIN(PORT_J, 1), .af = GPIO_AF14, }, + { .pin = GPIO_PIN(PORT_J, 2), .af = GPIO_AF14, }, + { .pin = GPIO_PIN(PORT_J, 3), .af = GPIO_AF14, }, + { .pin = GPIO_PIN(PORT_J, 4), .af = GPIO_AF14, }, + { .pin = GPIO_PIN(PORT_J, 5), .af = GPIO_AF14, }, + { .pin = GPIO_PIN(PORT_J, 6), .af = GPIO_AF14, }, + }, + .g_pin = { + { .pin = GPIO_PIN(PORT_J, 7), .af = GPIO_AF14, }, + { .pin = GPIO_PIN(PORT_J, 8), .af = GPIO_AF14, }, + { .pin = GPIO_PIN(PORT_J, 9), .af = GPIO_AF14, }, + { .pin = GPIO_PIN(PORT_J, 10), .af = GPIO_AF14, }, + { .pin = GPIO_PIN(PORT_J, 11), .af = GPIO_AF14, }, + { .pin = GPIO_PIN(PORT_K, 0), .af = GPIO_AF14, }, + { .pin = GPIO_PIN(PORT_K, 1), .af = GPIO_AF14, }, + { .pin = GPIO_PIN(PORT_K, 2), .af = GPIO_AF14, }, + }, + .b_pin = { + { .pin = GPIO_PIN(PORT_E, 4), .af = GPIO_AF14, }, + { .pin = GPIO_PIN(PORT_J, 13), .af = GPIO_AF14, }, + { .pin = GPIO_PIN(PORT_J, 14), .af = GPIO_AF14, }, + { .pin = GPIO_PIN(PORT_J, 15), .af = GPIO_AF14, }, + { .pin = GPIO_PIN(PORT_G, 12), .af = GPIO_AF9, }, + { .pin = GPIO_PIN(PORT_K, 4), .af = GPIO_AF14, }, + { .pin = GPIO_PIN(PORT_K, 5), .af = GPIO_AF14, }, + { .pin = GPIO_PIN(PORT_K, 6), .af = GPIO_AF14, }, + }, + /* values below come from STM32CubeF7 code and differ from the typical + * values mentioned in the RK043FN48H datasheet. Both sets of values work + * with the display. + * See the discussion in https://community.st.com/s/question/0D50X0000BOvdWP/how-to-set-displays-parameters- + */ + .hsync = 41, + .vsync = 10, + .hbp = 13, + .hfp = 32, + .vbp = 2, + .vfp = 2, +}; +/** @} */ + #ifdef __cplusplus } #endif