Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cpu/stm32: FMC used for low-level LCD parallel interface #19943

Merged
merged 5 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions boards/stm32f723e-disco/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ config BOARD_STM32F723E_DISCO
select HAVE_FT5X06
select HAVE_ST7789
select HAVE_LCD_PARALLEL_16BIT if MODULE_ST7789
select HAVE_LCD_PARALLEL_LL_MCU if MODULE_ST7789

select MODULE_PERIPH_UART_HW_FC if HAS_PERIPH_UART_HW_FC && MODULE_PERIPH_UART
# Workaround due to stdout only working with stdin enabled
Expand Down
2 changes: 2 additions & 0 deletions boards/stm32f723e-disco/Makefile.dep
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ endif

ifneq (,$(filter st7789,$(USEMODULE)))
USEMODULE += lcd_parallel_16bit
USEMODULE += lcd_parallel_ll_mcu
FEATURES_REQUIRED += periph_fmc_nor_sram
endif

# TODO: remove the stdin dependency
Expand Down
43 changes: 43 additions & 0 deletions boards/stm32f723e-disco/include/periph_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#else
#include "cfg_usb_otg_fs.h"
#endif
#include "lcd_fmc.h"

#ifdef __cplusplus
extern "C" {
Expand Down Expand Up @@ -325,6 +326,29 @@ static const fmc_bank_conf_t fmc_bank_config[] = {
.bus_turnaround = 3, }, /* 3 HCLKs a 4.63 ns */
},
},
/* bank 1, subbank 2 is used for LCD with asynchronuous
* access in Mode 1, i.e. write timings are not used */
{
.bank = FMC_BANK_1,
.mem_type = FMC_SRAM,
.data_width = FMC_BUS_WIDTH_16BIT,
.address = 0x64000000, /* Bank 1, subbank 2 is mapped to 0x64000000 */
.size = 4, /* 1 word for command @ 0x64000000 and
1 word for data @ 0x64000001 */
.nor_sram = {
.sub_bank = 2,
.ext_mode = false, /* Mode 1 used, no separate w_timing */
/* timing requirements for ST7789H2:
- t_AST min 0 ns (Address setup time)
- t_DST min 10 ns (Data setup time)
- t_WRL min 15 ns (WE LOW time)
- t_WRH min 15 ns (WE HIGH time)
- t_WRC min 66 ns (WE cycle time) */
.r_timing = { .addr_setup = 2, /* t_AST = 10 ns (2 HCLKs a 4.63 ns) */
.data_setup = 8, /* t_DST = 37 ns (8 HCLKs a 4.63 ns) */
.bus_turnaround = 5, }, /* t_WRH = 23 ns (5 HCLKs a 4.63 ns) */
},
},
};

/**
Expand All @@ -333,6 +357,25 @@ static const fmc_bank_conf_t fmc_bank_config[] = {
#define FMC_BANK_NUMOF ARRAY_SIZE(fmc_bank_config)
/** @} */

/**
* @brief Descriptors of FMC banks used for LCDs
*/
static const lcd_fmc_desc_t lcd_fmc_desc[] = {
{
.bank = FMC_BANK_CONFIG(1), /* second bank (fmc_bank_config[1]) is used */
.cmd_offset = 0x0, /* address 0x64000000 (offset 0x0) used for commands */
.data_offset = 0x2, /* address 0x64000002 (offset 0x2) used for commands */
}
};

/**
* @brief Number of LCDs using FMC banks
*
* Because it is used by the preprocessor it has to be a number.
* The @ref ARRAY_SIZE can't be used here.
*/
#define LCD_FMC_NUMOF 1

#ifdef __cplusplus
}
#endif
Expand Down
1 change: 1 addition & 0 deletions boards/stm32l496g-disco/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ config BOARD_STM32L496G_DISCO
select HAVE_FT5X06
select HAVE_ST7789
select HAVE_LCD_PARALLEL_16BIT if MODULE_ST7789
select HAVE_LCD_PARALLEL_LL_MCU if MODULE_ST7789

select MODULE_PERIPH_LPUART if MODULE_PERIPH_UART
select MODULE_PERIPH_UART_HW_FC if MODULE_PERIPH_UART && !MODULE_PERIPH_SPI_STMOD && HAS_PERIPH_UART_HW_FC
Expand Down
2 changes: 2 additions & 0 deletions boards/stm32l496g-disco/Makefile.dep
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,6 @@ endif

ifneq (,$(filter st7789,$(USEMODULE)))
USEMODULE += lcd_parallel_16bit
USEMODULE += lcd_parallel_ll_mcu
FEATURES_REQUIRED += periph_fmc_nor_sram
endif
44 changes: 44 additions & 0 deletions boards/stm32l496g-disco/include/periph_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "clk_conf.h"
#include "cfg_rtt_default.h"
#include "cfg_usb_otg_fs.h"
#include "lcd_fmc.h"

#ifdef __cplusplus
extern "C" {
Expand Down Expand Up @@ -253,12 +254,55 @@ static const fmc_bank_conf_t fmc_bank_config[] = {
.bus_turnaround = 1, }, /* 1 HCLK a 12.5 ns */
},
},
/* bank 1, subbank 1 is used for LCD with asynchronuous
* access in Mode 1, i.e. write timings are not used */
{
.bank = FMC_BANK_1,
.mem_type = FMC_SRAM,
.data_width = FMC_BUS_WIDTH_16BIT,
.address = 0x60000000, /* Bank 1, subbank 1 is mapped to 0x60000000 */
.size = 2, /* 1 word for command @ 0x60000000 and
1 word for data @ 0x60080000 */
.nor_sram = {
.sub_bank = 1,
.ext_mode = false, /* Mode 1 used, no separate w_timing */
/* timing requirements for ST7789H2:
- t_AST min 0 ns (Address setup time)
- t_DST min 10 ns (Data setup time)
- t_WRL min 15 ns (WE LOW time)
- t_WRH min 15 ns (WE HIGH time)
- t_WRC min 66 ns (WE cycle time) */
.r_timing = { .addr_setup = 1, /* t_AST = 12 ns (1 HCLKs a 12.5 ns) */
.data_setup = 3, /* t_DST = 37 ns (3 HCLKs a 12.5 ns) */
.bus_turnaround = 2, }, /* t_WRH = 25 ns (2 HCLKs a 12.5 ns) */
},
},
};

/**
* @brief Number of configured FMC banks
*/
#define FMC_BANK_NUMOF ARRAY_SIZE(fmc_bank_config)

/**
* @brief Descriptors of FMC banks used for LCDs
*/
static const lcd_fmc_desc_t lcd_fmc_desc[] = {
{
.bank = FMC_BANK_CONFIG(1), /* second bank (fmc_bank_config[1]) is used */
.cmd_offset = 0x0, /* address 0x60000000 (offset 0x00000) used for commands */
.data_offset = 0x80000, /* address 0x60080000 (offset 0x80000) used for data */
}
};

/**
* @brief Number of LCDs using FMC banks
*
* Because it is used by the preprocessor it has to be a number.
* The @ref ARRAY_SIZE can't be used here.
*/
#define LCD_FMC_NUMOF 1

/** @} */

/**
Expand Down
1 change: 1 addition & 0 deletions cpu/stm32/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ rsource "periph/Kconfig.fmc"

if TEST_KCONFIG

rsource "lcd_fmc/Kconfig"
rsource "periph/Kconfig"
rsource "stmclk/Kconfig"
rsource "vectors/Kconfig"
Expand Down
4 changes: 4 additions & 0 deletions cpu/stm32/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@ ifneq (,$(filter bootloader_stm32,$(USEMODULE)))
DIRS += bootloader
endif

ifneq (,$(filter lcd_fmc,$(USEMODULE)))
DIRS += lcd_fmc
endif

include $(RIOTBASE)/Makefile.base
4 changes: 4 additions & 0 deletions cpu/stm32/Makefile.dep
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ ifneq (,$(filter stm32_eth,$(USEMODULE)))
endif
endif

ifneq (,$(filter lcd_parallel_ll_mcu,$(USEMODULE)))
USEMODULE += lcd_fmc
endif

ifneq (,$(filter periph_can,$(FEATURES_USED)))
FEATURES_REQUIRED += periph_gpio
FEATURES_REQUIRED += periph_gpio_irq
Expand Down
60 changes: 60 additions & 0 deletions cpu/stm32/include/lcd_fmc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Copyright (C) 2023 Gunar Schorcht
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/

/**
* @defgroup cpu_stm32_lcd_fmc STM32 FMC/FSMC LCD low-level parallel interface driver
* @ingroup cpu_stm32
*
* @{
*/

#ifndef LCD_FMC_H
#define LCD_FMC_H

#ifdef __cplusplus
extern "C" {
#endif

/**
* @brief Number of LCDs using FMC banks
*
* It represents the number of elements in LCD FMC bank descriptor array of
* type @ref lcd_fmc_desc_t. Because it is used by the preprocessor, it has
* to be defined as a number. It is not possible to use the @ref ARRAY_SIZE
* macro here.
*
* @note `LCD_FMC_NUMOF` has to be equal to the number of elements in the
* LCD FMC bank descriptor array of type @ref lcd_fmc_desc_t.
*/
#if DOXYGEN
#define LCD_FMC_NUMOF 1
#endif

/**
* @brief Descriptor of the FMC bank used for a LCD
*
* The board definition has to specify the array @ref lcd_fmc_desc of type
* @ref lcd_fmc_desc_t which defines the FMC banks and the address offsets used
* for the LCD displays that are connected to FMC banks.
*
* @note In the case that multiple LCDs are connected to FMC banks, the FMC
* bank descriptors for LCDs of type @ref lcd_fmc_desc_t
* must be defined in same order as the LCD devices.
*/
typedef struct {
const fmc_bank_conf_t *bank; /**< FMC bank config used for the LCD */
uint32_t cmd_offset; /**< offset to the bank address used for commands */
uint32_t data_offset; /**< offset to the bank address used for data */
} lcd_fmc_desc_t;

#ifdef __cplusplus
}
#endif

#endif /* LCD_FMC_H */
/** @} */
11 changes: 11 additions & 0 deletions cpu/stm32/include/periph/cpu_fmc.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,17 @@
extern "C" {
#endif

/**
* @brief Gives the configuration of n-th bank
*
* This macro gives a pointer to the n-th entry of type @ref fmc_bank_conf_t of
* the banks configured by the board in the @ref fmc_bank_config array. n is in
* the range 0 ... @ref FMC_BANK_NUMOF - 1.
*/
#ifndef FMC_BANK_CONFIG
#define FMC_BANK_CONFIG(n) (&fmc_bank_config[n])
#endif

/**
* @brief Number of data pins used
*
Expand Down Expand Up @@ -257,7 +268,7 @@
*
* The GPIOs are defined depending on used memory type according to the
* FMC pin definition in Table 12 of section 4 in the
* [Datasheet for STM32F765xx, STM32F767xx, STM32F768Ax, STM32F769xx](https://www.st.com/resource/en/datasheet/stm32f767zi.pdf).

Check warning on line 271 in cpu/stm32/include/periph/cpu_fmc.h

View workflow job for this annotation

GitHub Actions / static-tests

line is longer than 100 characters
* Which memory types are used is defined by the pseudomodules
* `periph_fmc_nor_sram`, `periph_fmc_nand` and `periph_fmc_sdram`
*
Expand Down
13 changes: 13 additions & 0 deletions cpu/stm32/lcd_fmc/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright (c) 2023 Gunar Schorcht
#
# This file is subject to the terms and conditions of the GNU Lesser
# General Public License v2.1. See the file LICENSE in the top level
# directory for more details.
#

config MODULE_LCD_FMC
bool
depends on MODULE_LCD
select MODULE_PERIPH_FMC
select MODULE_PERIPH_FMC_NOR_SRAM
default y if HAVE_LCD_PARALLEL_LL_MCU
3 changes: 3 additions & 0 deletions cpu/stm32/lcd_fmc/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
MODULE = lcd_fmc

include $(RIOTBASE)/Makefile.base
Loading
Loading