summaryrefslogtreecommitdiff
path: root/bsp
diff options
context:
space:
mode:
authorsolar_li <[email protected]>2022-06-30 10:27:16 +0800
committerGitHub <[email protected]>2022-06-30 10:27:16 +0800
commitb19602bcaab3627b9736862d015ee90ce62cf548 (patch)
treeb3d0d5c11b81547e85909272037b3fe0b3485661 /bsp
parent0d9fb87a9b73f408849833522c9b607c25c5ea45 (diff)
Docking lvgl for stm32f469-st-disco bsp using ft6336 touch chip (#6121)
* Add touch V2 version * Added touch driver ft6336 for stm32f469 bsp
Diffstat (limited to 'bsp')
-rw-r--r--bsp/stm32/stm32f469-st-disco/board/Kconfig73
-rw-r--r--bsp/stm32/stm32f469-st-disco/board/ports/touch/SConscript14
-rw-r--r--bsp/stm32/stm32f469-st-disco/board/ports/touch/drv_touch.c6
-rw-r--r--bsp/stm32/stm32f469-st-disco/board/ports/touch/drv_touch.h2
-rw-r--r--bsp/stm32/stm32f469-st-disco/board/ports/touch/drv_touch_ft6206.c (renamed from bsp/stm32/stm32f469-st-disco/board/ports/touch/drv_touch_ft.c)6
-rw-r--r--bsp/stm32/stm32f469-st-disco/board/ports/touch/drv_touch_ft6x36.c86
6 files changed, 147 insertions, 40 deletions
diff --git a/bsp/stm32/stm32f469-st-disco/board/Kconfig b/bsp/stm32/stm32f469-st-disco/board/Kconfig
index 8f433171a8..8f05844f71 100644
--- a/bsp/stm32/stm32f469-st-disco/board/Kconfig
+++ b/bsp/stm32/stm32f469-st-disco/board/Kconfig
@@ -8,28 +8,11 @@ config SOC_STM32F469NI
default y
menu "Onboard Peripheral Drivers"
-
- config BSP_USING_SDRAM
- bool "Enable SDRAM"
- select BSP_USING_FMC
- default n
-
- config BSP_USING_LCD_MIPI
- bool
- default n
-
- config BSP_USING_LCD_OTM8009A
- bool "Enable LCD OTM8009A"
- select BSP_USING_SDRAM
- select BSP_USING_LTDC
- select BSP_USING_LCD_MIPI
- default n
-
config BSP_USING_LVGL
bool "Enable LVGL for LCD"
select BSP_USING_LCD_OTM8009A
- select BSP_USING_TOUCH
select PKG_USING_LVGL
+ select BSP_USING_TOUCH
default n
if BSP_USING_LVGL
@@ -39,6 +22,11 @@ menu "Onboard Peripheral Drivers"
default n
endif
+ config BSP_USING_SDRAM
+ bool "Enable SDRAM"
+ select BSP_USING_FMC
+ default n
+
config BSP_USING_QSPI_FLASH
bool "Enable QSPI FLASH (N25Q128A qspi1)"
select BSP_USING_QSPI
@@ -63,25 +51,50 @@ menu "Onboard Peripheral Drivers"
select RT_USING_DFS_ELMFAT
select RT_USING_PIN
default n
- if BSP_USING_SDCARD
+
config SDIO_MAX_FREQ
int "sdio max freq"
range 0 24000000
+ depends on BSP_USING_SDCARD
default 24000000
- endif
config BSP_USING_TOUCH
- bool "Enable TOUCH"
- select BSP_USING_I2C1
+ bool "Enable touch screen"
+
+ choice
+ prompt "Touch IC type"
+ depends on BSP_USING_TOUCH
+ default BSP_CHOICE_TOUCH_FT6X36
+
+ config BSP_USING_TOUCH_FT6206
+ bool "FT6206"
+ select BSP_USING_I2C1
+ if BSP_USING_TOUCH_FT6206
+ config BSP_TOUCH_INT_PIN
+ int # "Touch IC interrupt pin"
+ default 149
+ config BSP_TOUCH_I2C_NAME
+ string # "I2C Bus Name"
+ default "i2c1"
+ endif
+
+ config BSP_USING_TOUCH_FT6X36
+ bool "FT6x36"
+ select BSP_USING_I2C1
+ select PKG_USING_TOUCH_DRIVERS
+ select PKG_USING_FT6236
+ endchoice
+
+ config BSP_USING_LCD_MIPI
+ bool
+ default n
+
+ config BSP_USING_LCD_OTM8009A
+ bool "Enable LCD OTM8009A"
+ select BSP_USING_SDRAM
+ select BSP_USING_LTDC
+ select BSP_USING_LCD_MIPI
default n
- if BSP_USING_TOUCH
- config BSP_TOUCH_INT_PIN
- int "Touch interrupt pin"
- default 149
- config BSP_I2C_NAME
- string "I2C Bus Name"
- default "i2c1"
- endif
endmenu
menu "On-chip Peripheral Drivers"
diff --git a/bsp/stm32/stm32f469-st-disco/board/ports/touch/SConscript b/bsp/stm32/stm32f469-st-disco/board/ports/touch/SConscript
index 618e45d87a..2fba1fb030 100644
--- a/bsp/stm32/stm32f469-st-disco/board/ports/touch/SConscript
+++ b/bsp/stm32/stm32f469-st-disco/board/ports/touch/SConscript
@@ -1,9 +1,17 @@
from building import *
cwd = GetCurrentDir()
-src = Glob('*.c')
-CPPPATH = [cwd, str(Dir('#'))]
+src = []
-group = DefineGroup('Drivers', src, depend = ['BSP_USING_TOUCH'], CPPPATH = CPPPATH)
+if GetDepend(['BSP_USING_TOUCH_FT6206']):
+ src += Glob('drv_touch.c')
+ src += Glob('drv_touch_ft6206.c')
+
+if GetDepend(['BSP_USING_TOUCH_FT6X36']):
+ src += Glob('drv_touch_ft6x36.c')
+
+CPPPATH = [cwd]
+
+group = DefineGroup('Drivers', src, depend = [''], CPPPATH = CPPPATH)
Return('group')
diff --git a/bsp/stm32/stm32f469-st-disco/board/ports/touch/drv_touch.c b/bsp/stm32/stm32f469-st-disco/board/ports/touch/drv_touch.c
index d6c29e059f..4fafd795b5 100644
--- a/bsp/stm32/stm32f469-st-disco/board/ports/touch/drv_touch.c
+++ b/bsp/stm32/stm32f469-st-disco/board/ports/touch/drv_touch.c
@@ -10,7 +10,7 @@
#include <rtconfig.h>
-#ifdef BSP_USING_TOUCH
+#ifdef BSP_USING_TOUCH_FT6206
#include "drv_touch.h"
#include <string.h>
#ifdef PKG_USING_GUIENGINE
@@ -154,7 +154,7 @@ static int rt_touch_thread_init(void)
rt_list_t *l;
touch_drv_t current_driver;
rt_thread_t tid = RT_NULL;
- i2c_bus = (struct rt_i2c_bus_device *)rt_device_find(BSP_I2C_NAME);
+ i2c_bus = (struct rt_i2c_bus_device *)rt_device_find(BSP_TOUCH_I2C_NAME);
RT_ASSERT(i2c_bus);
current_driver = RT_NULL;
if (rt_device_open((rt_device_t)i2c_bus, RT_DEVICE_OFLAG_RDWR) != RT_EOK)
@@ -204,4 +204,4 @@ static int touc_bg_init(void)
}
INIT_COMPONENT_EXPORT(touc_bg_init);
-#endif /* BSP_USING_TOUCH */
+#endif /* BSP_USING_TOUCH_FT6206 */
diff --git a/bsp/stm32/stm32f469-st-disco/board/ports/touch/drv_touch.h b/bsp/stm32/stm32f469-st-disco/board/ports/touch/drv_touch.h
index 21bea39f83..8041c471c1 100644
--- a/bsp/stm32/stm32f469-st-disco/board/ports/touch/drv_touch.h
+++ b/bsp/stm32/stm32f469-st-disco/board/ports/touch/drv_touch.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006-2021, RT-Thread Development Team
+ * Copyright (c) 2006-2022, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
diff --git a/bsp/stm32/stm32f469-st-disco/board/ports/touch/drv_touch_ft.c b/bsp/stm32/stm32f469-st-disco/board/ports/touch/drv_touch_ft6206.c
index bd2db859ba..aa76f709e2 100644
--- a/bsp/stm32/stm32f469-st-disco/board/ports/touch/drv_touch_ft.c
+++ b/bsp/stm32/stm32f469-st-disco/board/ports/touch/drv_touch_ft6206.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006-2021, RT-Thread Development Team
+ * Copyright (c) 2006-2022, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
@@ -17,7 +17,7 @@
#include <stdint.h>
#include <string.h>
-#ifdef BSP_USING_TOUCH
+#ifdef BSP_USING_TOUCH_FT6206
#define DBG_ENABLE
#define DBG_SECTION_NAME "TOUCH.ft"
@@ -212,4 +212,4 @@ int ft_driver_register(void)
}
INIT_DEVICE_EXPORT(ft_driver_register);
-#endif
+#endif /* BSP_USING_TOUCH_FT6206 */
diff --git a/bsp/stm32/stm32f469-st-disco/board/ports/touch/drv_touch_ft6x36.c b/bsp/stm32/stm32f469-st-disco/board/ports/touch/drv_touch_ft6x36.c
new file mode 100644
index 0000000000..9ee7097ba5
--- /dev/null
+++ b/bsp/stm32/stm32f469-st-disco/board/ports/touch/drv_touch_ft6x36.c
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2006-2022, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2022-06-29 solar the first version
+ */
+
+#include <rtthread.h>
+#include <rtdevice.h>
+#include "touch.h"
+#include "lcd_port.h"
+#include "drv_common.h"
+
+#define DBG_TAG "ft6236"
+#define DBG_LVL DBG_LOG
+#include <rtdbg.h>
+
+#ifdef BSP_USING_TOUCH_FT6X36
+
+#include "ft6236.h"
+
+#define BSP_TOUCH_I2C_BUS_NAME "i2c1"
+#define BSP_TOUCH_I2C_RESET_PIN 119 /* PH.7 */
+
+#ifdef PKG_USING_LVGL
+#include <lvgl.h>
+extern void lv_port_indev_input(rt_int16_t x, rt_int16_t y, lv_indev_state_t state);
+#endif /* PKG_USING_LVGL */
+
+rt_thread_t ft6236_thread;
+rt_device_t touch;
+
+void ft6236_thread_entry(void *parameter)
+{
+ struct rt_touch_data *read_data;
+
+ read_data = (struct rt_touch_data *)rt_calloc(1, sizeof(struct rt_touch_data));
+
+ while (1)
+ {
+ rt_device_read(touch, 0, read_data, 1);
+#ifdef PKG_USING_LVGL
+ /* Since the origin of the LCD screen and the origin of the touch screen are
+ * different, the parameters passed in here need to be simply converted. */
+ if (read_data->event == RT_TOUCH_EVENT_DOWN)
+ lv_port_indev_input(read_data->y_coordinate, read_data->x_coordinate, LV_INDEV_STATE_PR);
+
+ if (read_data->event == RT_TOUCH_EVENT_MOVE)
+ lv_port_indev_input(read_data->y_coordinate, read_data->x_coordinate, LV_INDEV_STATE_PR);
+
+ if (read_data->event == RT_TOUCH_EVENT_UP)
+ lv_port_indev_input(read_data->y_coordinate, read_data->x_coordinate, LV_INDEV_STATE_REL);
+#endif /* PKG_USING_LVGL */
+ if (read_data->event != RT_TOUCH_EVENT_NONE)
+ LOG_I("LCD point x: %03d y: %03d", read_data->y_coordinate, LCD_HEIGHT - read_data->x_coordinate);
+ rt_thread_delay(10);
+ }
+}
+
+int ft6236_for_lvgl(void)
+{
+ struct rt_touch_config cfg;
+
+ cfg.dev_name = BSP_TOUCH_I2C_BUS_NAME;
+ rt_hw_ft6236_init("touch", &cfg, BSP_TOUCH_I2C_RESET_PIN);
+
+ touch = rt_device_find("touch");
+ rt_device_open(touch, RT_DEVICE_FLAG_RDONLY);
+
+ ft6236_thread = rt_thread_create("touch", ft6236_thread_entry, RT_NULL, 1024, 10, 20);
+ if (ft6236_thread == RT_NULL)
+ {
+ LOG_D("create ft6236 thread err");
+
+ return -RT_ENOMEM;
+ }
+ rt_thread_startup(ft6236_thread);
+
+ return RT_EOK;
+}
+INIT_ENV_EXPORT(ft6236_for_lvgl);
+
+#endif /* BSP_USING_TOUCH_FT6X36 */