Docking lvgl for stm32f469-st-disco bsp using ft6336 touch chip (#6121)
* Add touch V2 version * Added touch driver ft6336 for stm32f469 bsp
This commit is contained in:
parent
0d9fb87a9b
commit
b19602bcaa
|
@ -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"
|
||||
|
|
|
@ -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')
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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 */
|
|
@ -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 */
|
Loading…
Reference in New Issue