Skip to content

Commit

Permalink
stm32h7/linum-stm32h753bi: add touch screen support
Browse files Browse the repository at this point in the history
Signed-off-by: Jorge Guzman <[email protected]>
  • Loading branch information
JorgeGzm authored and xiaoxiang781216 committed Jan 20, 2025
1 parent 1fd21bb commit 4857ea2
Show file tree
Hide file tree
Showing 8 changed files with 386 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ EEPROM memory used is the 24LC256 with 256Kb with the control bytes value 0x54.
TOUCHSCREEN SENSOR
------------------

The touchscreen sensor used is the GT928.
The touchscreen sensor used is the FT5X06.

======== =====
GPIO PINS
Expand Down Expand Up @@ -817,7 +817,37 @@ Configures the board to use the SPI4 and enables RFID driver with MFRC522::
lvgl
----

Configures the board to use display of 7 inch with lvgl example.
Configures the board to use display of 7 inch with lvgl example. The touch screen functionality is implemented using
the FT5X06 capacitive touch controller connected to I2C3 interface, with interrupt handling configured on pin PH9 for touch event detection.

To verify if the touch controller is functioning correctly, use the **tc** command.::

nsh> tc 2
tc_main: nsamples: 2
tc_main: Opening /dev/input0
Sample :
npoints : 1
Point 1 :
id : 0
flags : 19
x : 0
y : 52
h : 0
w : 0
pressure : 0
timestamp : 0
Sample :
npoints : 1
Point 1 :
id : 0
flags : 1a
x : 0
y : 52
h : 0
w : 0
pressure : 0
timestamp : 0
Terminating!

To verify if the display is functioning correctly, use the **fb** command. You should see the display change colors.::

Expand Down Expand Up @@ -862,11 +892,11 @@ Once the **fd** command work, run the lvgl exemple. ::

**WARNING:** This example at the moment is not working correctly yet and have a bug fix to be done.
In the lvgl file **./apps/graphics/lvgl/lvgl/src/drivers/nuttx/lv_nuttx_fbdev.c**
search the function **lv_nuttx_fbdev_set_file** and modify line 156 as follows:
search the function **lv_nuttx_fbdev_set_file** and modify line 156 as follows::

dsc->mem_off_screen = malloc(data_size);
to
dsc->mem_off_screen = (void*)0xC00000000;
dsc->mem_off_screen = (void*)0xC0000000;

tone
----
Expand Down
7 changes: 7 additions & 0 deletions boards/arm/stm32h7/linum-stm32h753bi/configs/lvgl/defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,14 @@ CONFIG_DRIVERS_VIDEO=y
CONFIG_EXAMPLES_ALARM=y
CONFIG_EXAMPLES_FB=y
CONFIG_EXAMPLES_LVGLDEMO=y
CONFIG_EXAMPLES_TOUCHSCREEN=y
CONFIG_FB_OVERLAY=y
CONFIG_FS_PROCFS=y
CONFIG_FT5X06_SINGLEPOINT=y
CONFIG_GRAPHICS_LVGL=y
CONFIG_INIT_ENTRYPOINT="nsh_main"
CONFIG_INPUT=y
CONFIG_INPUT_FT5X06=y
CONFIG_INTELHEX_BINARY=y
CONFIG_LIBM=y
CONFIG_LINE_MAX=64
Expand All @@ -42,6 +46,7 @@ CONFIG_LV_USE_CLIB_SPRINTF=y
CONFIG_LV_USE_CLIB_STRING=y
CONFIG_LV_USE_DEMO_WIDGETS=y
CONFIG_LV_USE_NUTTX=y
CONFIG_LV_USE_NUTTX_TOUCHSCREEN=y
CONFIG_MM_REGIONS=5
CONFIG_NSH_ARCHINIT=y
CONFIG_NSH_BUILTIN_APPS=y
Expand All @@ -56,11 +61,13 @@ CONFIG_RR_INTERVAL=200
CONFIG_RTC_ALARM=y
CONFIG_RTC_DATETIME=y
CONFIG_RTC_DRIVER=y
CONFIG_SCHED_HPWORK=y
CONFIG_SCHED_WAITPID=y
CONFIG_START_DAY=6
CONFIG_START_MONTH=12
CONFIG_START_YEAR=2011
CONFIG_STM32H7_FMC=y
CONFIG_STM32H7_I2C3=y
CONFIG_STM32H7_LTDC=y
CONFIG_STM32H7_LTDC_FB_BASE=0xC0000000
CONFIG_STM32H7_LTDC_FB_SIZE=1228800
Expand Down
9 changes: 8 additions & 1 deletion boards/arm/stm32h7/linum-stm32h753bi/include/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -412,11 +412,18 @@
#define GPIO_SDMMC1_D2 (GPIO_SDMMC1_D2_0|GPIO_SPEED_100MHz) /* PC10 */
#define GPIO_SDMMC1_D3 (GPIO_SDMMC1_D3_0|GPIO_SPEED_100MHz) /* PC11 */

/* I2C3 - Used by eeprom memory */
/* I2C3 - Used by eeprom memory and touch screen */

#define GPIO_I2C3_SCL (GPIO_I2C3_SCL_2|GPIO_SPEED_100MHz) /* PH7 */
#define GPIO_I2C3_SDA (GPIO_I2C3_SDA_2|GPIO_SPEED_100MHz) /* PH8 */

/* I2C - There is a FT5336 TouchPanel on I2C3 using these pins: */

#define ADJ_SLEW_RATE(p) (((p) & ~GPIO_SPEED_MASK) | (GPIO_SPEED_100MHz))
#define GPIO_TP_INT (GPIO_INPUT|GPIO_FLOAT|GPIO_EXTI|GPIO_PORTH|GPIO_PIN9) /* PH9 */

#define FT5X06_I2C_ADDRESS (0x38)

/* PWM - Buzzer */
#define GPIO_TIM4_CH2OUT (GPIO_TIM4_CH2OUT_1|GPIO_SPEED_100MHz) /* PB7 */

Expand Down
4 changes: 4 additions & 0 deletions boards/arm/stm32h7/linum-stm32h753bi/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ if(CONFIG_STM32H7_LTDC)
list(APPEND SRCS stm32_lcd.c)
endif()

if(CONFIG_INPUT_FT5X06)
list(APPEND SRCS stm32_touchscreen.c)
endif()

target_sources(board PRIVATE ${SRCS})

set_property(GLOBAL PROPERTY LD_SCRIPT "${NUTTX_BOARD_DIR}/scripts/flash.ld")
4 changes: 4 additions & 0 deletions boards/arm/stm32h7/linum-stm32h753bi/src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,8 @@ ifeq ($(CONFIG_AUDIO_TONE),y)
CSRCS += stm32_tone.c
endif

ifeq ($(CONFIG_INPUT_FT5X06),y)
CSRCS += stm32_touchscreen.c
endif

include $(TOPDIR)/boards/Board.mk
21 changes: 21 additions & 0 deletions boards/arm/stm32h7/linum-stm32h753bi/src/linum-stm32h753bi.h
Original file line number Diff line number Diff line change
Expand Up @@ -287,4 +287,25 @@ int stm32_mfrc522initialize(const char *devpath);
int board_tone_initialize(int devno);
#endif

/****************************************************************************
* Name: stm32_tsc_setup
*
* Description:
* This function is called by board-bringup logic to configure the
* touchscreen device. This function will register the driver as
* /dev/inputN where N is the minor device number.
*
* Input Parameters:
* minor - The input device minor number
*
* Returned Value:
* Zero is returned on success. Otherwise, a negated errno value is
* returned to indicate the nature of the failure.
*
****************************************************************************/

#ifdef CONFIG_INPUT_FT5X06
int stm32_tsc_setup(int minor);
#endif

#endif /* __BOARDS_ARM_STM32H7_LINUM_STM32H753BI_SRC_LINUM_STM32H753BI_H */
10 changes: 10 additions & 0 deletions boards/arm/stm32h7/linum-stm32h753bi/src/stm32_bringup.c
Original file line number Diff line number Diff line change
Expand Up @@ -353,5 +353,15 @@ int stm32_bringup(void)
}
#endif

#ifdef CONFIG_INPUT_FT5X06
/* Initialize the touchscreen */

ret = stm32_tsc_setup(0);
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: stm32_tsc_setup failed: %d\n", ret);
}
#endif

return OK;
}
Loading

0 comments on commit 4857ea2

Please sign in to comment.