mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-29 08:21:18 +01:00
Merge pull request #17448 from aabadie/pr/drivers/ft5336
drivers/ft5x06: add support for touch panel controller
This commit is contained in:
commit
c49f156e6e
@ -28,6 +28,7 @@ config BOARD_STM32F723E_DISCO
|
||||
select BOARD_HAS_LSE
|
||||
|
||||
select HAVE_SAUL_GPIO
|
||||
select HAVE_FT6X06
|
||||
select MODULE_PERIPH_UART_HW_FC if TEST_KCONFIG && HAS_PERIPH_UART_HW_FC
|
||||
# Workaround due to stdout only working with stdin enabled
|
||||
select MODULE_STDIN if TEST_KCONFIG
|
||||
|
||||
@ -4,5 +4,9 @@ ifneq (,$(filter saul_default,$(USEMODULE)))
|
||||
USEMODULE += saul_gpio
|
||||
endif
|
||||
|
||||
ifneq (,$(filter touch_dev,$(USEMODULE)))
|
||||
USEMODULE += ft6x06
|
||||
endif
|
||||
|
||||
# TODO: remove the stdin dependency
|
||||
USEMODULE += stdin
|
||||
|
||||
@ -60,6 +60,16 @@ extern "C" {
|
||||
#define BTN0_MODE GPIO_IN
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name FT5X06 touch panel configuration
|
||||
* @{
|
||||
*/
|
||||
#define FT5X06_PARAM_I2C_DEV I2C_DEV(1) /**< I2C device */
|
||||
#define FT5X06_PARAM_INT_PIN GPIO_PIN(PORT_I, 9) /**< Interrupt pin */
|
||||
#define FT5X06_PARAM_XMAX (240) /**< Max width */
|
||||
#define FT5X06_PARAM_YMAX (240) /**< Max height */
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @brief Initialize board specific hardware, including clock, LEDs and std-IO
|
||||
*/
|
||||
|
||||
@ -155,10 +155,34 @@ static const i2c_conf_t i2c_config[] = {
|
||||
.bus = APB1,
|
||||
.rcc_mask = RCC_APB1ENR_I2C2EN,
|
||||
.irqn = I2C2_ER_IRQn,
|
||||
}
|
||||
},
|
||||
{ /* Connected to touchscreen controller */
|
||||
.dev = I2C3,
|
||||
.speed = I2C_SPEED_NORMAL,
|
||||
.scl_pin = GPIO_PIN(PORT_A, 8),
|
||||
.sda_pin = GPIO_PIN(PORT_H, 8),
|
||||
.scl_af = GPIO_AF4,
|
||||
.sda_af = GPIO_AF4,
|
||||
.bus = APB1,
|
||||
.rcc_mask = RCC_APB1ENR_I2C3EN,
|
||||
.irqn = I2C3_ER_IRQn,
|
||||
},
|
||||
{
|
||||
.dev = I2C1,
|
||||
.speed = I2C_SPEED_NORMAL,
|
||||
.scl_pin = GPIO_PIN(PORT_B, 8),
|
||||
.sda_pin = GPIO_PIN(PORT_B, 9),
|
||||
.scl_af = GPIO_AF4,
|
||||
.sda_af = GPIO_AF4,
|
||||
.bus = APB1,
|
||||
.rcc_mask = RCC_APB1ENR_I2C1EN,
|
||||
.irqn = I2C1_ER_IRQn,
|
||||
},
|
||||
};
|
||||
|
||||
#define I2C_0_ISR isr_i2c2_er
|
||||
#define I2C_1_ISR isr_i2c3_er
|
||||
#define I2C_2_ISR isr_i2c1_er
|
||||
|
||||
#define I2C_NUMOF ARRAY_SIZE(i2c_config)
|
||||
/** @} */
|
||||
|
||||
@ -29,5 +29,6 @@ config BOARD_STM32F746G_DISCO
|
||||
select BOARD_HAS_LSE
|
||||
|
||||
select HAVE_SAUL_GPIO
|
||||
select HAVE_FT5336
|
||||
|
||||
source "$(RIOTBOARD)/common/stm32/Kconfig"
|
||||
|
||||
@ -9,3 +9,7 @@ endif
|
||||
ifneq (,$(filter disp_dev,$(USEMODULE)))
|
||||
FEATURES_REQUIRED += periph_ltdc
|
||||
endif
|
||||
|
||||
ifneq (,$(filter touch_dev,$(USEMODULE)))
|
||||
USEMODULE += ft5336
|
||||
endif
|
||||
|
||||
@ -28,7 +28,7 @@ Current hardware support:
|
||||
| USB OTG FS | X | |
|
||||
| USB OTG HS | - | |
|
||||
| TFT LCD | X | |
|
||||
| Capacitive touch screen | - | |
|
||||
| Capacitive touch screen | X | |
|
||||
| User microphones | - | |
|
||||
| External Quad-SPI Flash | - | |
|
||||
| External SDRAM | - | |
|
||||
|
||||
@ -65,6 +65,16 @@ extern "C" {
|
||||
#define BTN0_MODE GPIO_IN /**< BTN0 pin mode */
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name FT5X06 touch panel configuration
|
||||
* @{
|
||||
*/
|
||||
#define FT5X06_PARAM_I2C_DEV I2C_DEV(1) /**< I2C device */
|
||||
#define FT5X06_PARAM_INT_PIN GPIO_PIN(PORT_I, 13) /**< Interrupt pin */
|
||||
#define FT5X06_PARAM_XMAX (480) /**< Max width */
|
||||
#define FT5X06_PARAM_YMAX (272) /**< Max height */
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @brief Initialize board specific hardware
|
||||
*/
|
||||
|
||||
@ -36,7 +36,6 @@
|
||||
|
||||
#include "periph_cpu.h"
|
||||
#include "clk_conf.h"
|
||||
#include "cfg_i2c1_pb8_pb9.h"
|
||||
#include "cfg_rtt_default.h"
|
||||
#include "cfg_timer_tim2.h"
|
||||
#include "cfg_usb_otg_fs.h"
|
||||
@ -147,6 +146,41 @@ static const spi_conf_t spi_config[] = {
|
||||
#define SPI_NUMOF ARRAY_SIZE(spi_config)
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name I2C configuration
|
||||
* @{
|
||||
*/
|
||||
static const i2c_conf_t i2c_config[] = {
|
||||
{
|
||||
.dev = I2C1,
|
||||
.speed = I2C_SPEED_NORMAL,
|
||||
.scl_pin = GPIO_PIN(PORT_B, 8),
|
||||
.sda_pin = GPIO_PIN(PORT_B, 9),
|
||||
.scl_af = GPIO_AF4,
|
||||
.sda_af = GPIO_AF4,
|
||||
.bus = APB1,
|
||||
.rcc_mask = RCC_APB1ENR_I2C1EN,
|
||||
.irqn = I2C1_ER_IRQn,
|
||||
},
|
||||
{
|
||||
.dev = I2C3,
|
||||
.speed = I2C_SPEED_NORMAL,
|
||||
.scl_pin = GPIO_PIN(PORT_H, 7),
|
||||
.sda_pin = GPIO_PIN(PORT_H, 8),
|
||||
.scl_af = GPIO_AF4,
|
||||
.sda_af = GPIO_AF4,
|
||||
.bus = APB1,
|
||||
.rcc_mask = RCC_APB1ENR_I2C3EN,
|
||||
.irqn = I2C3_ER_IRQn,
|
||||
},
|
||||
};
|
||||
|
||||
#define I2C_0_ISR isr_i2c1_er
|
||||
#define I2C_1_ISR isr_i2c3_er
|
||||
|
||||
#define I2C_NUMOF ARRAY_SIZE(i2c_config)
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name ETH configuration
|
||||
* @{
|
||||
|
||||
62
dist/tools/doccheck/exclude_patterns
vendored
62
dist/tools/doccheck/exclude_patterns
vendored
@ -14581,6 +14581,12 @@ boards/stm32f746g\-disco/include/periph_conf\.h:[0-9]+: warning: Member SPI_NUMO
|
||||
boards/stm32f746g\-disco/include/periph_conf\.h:[0-9]+: warning: Member spi_config\[\] \(variable\) of file periph_conf\.h is not documented\.
|
||||
boards/stm32f746g\-disco/include/periph_conf\.h:[0-9]+: warning: Member ETH_DMA_ISR \(macro definition\) of file periph_conf\.h is not documented\.
|
||||
boards/stm32f746g\-disco/include/periph_conf\.h:[0-9]+: warning: Member eth_config \(variable\) of file periph_conf\.h is not documented\.
|
||||
boards/stm32f746g\-disco/include/periph_conf\.h:[0-9]+: warning: Member I2C_0_ISR \(macro definition\) of file periph_conf\.h is not documented\.
|
||||
boards/stm32f746g\-disco/include/periph_conf\.h:[0-9]+: warning: Member I2C_1_ISR \(macro definition\) of file periph_conf\.h is not documented\.
|
||||
boards/stm32f746g\-disco/include/periph_conf\.h:[0-9]+: warning: Member I2C_NUMOF \(macro definition\) of file periph_conf\.h is not documented\.
|
||||
boards/stm32f746g\-disco/include/periph_conf\.h:[0-9]+: warning: Member i2c_config\[\] \(variable\) of file periph_conf\.h is not documented\.
|
||||
boards/stm32f723e\-disco/include/periph_conf\.h:[0-9]+: warning: Member I2C_1_ISR \(macro definition\) of file periph_conf\.h is not documented\.
|
||||
boards/stm32f723e\-disco/include/periph_conf\.h:[0-9]+: warning: Member I2C_2_ISR \(macro definition\) of file periph_conf\.h is not documented\.
|
||||
boards/stm32g0316\-disco/include/periph_conf\.h:[0-9]+: warning: Member TIMER_0_ISR \(macro definition\) of file periph_conf\.h is not documented\.
|
||||
boards/stm32g0316\-disco/include/periph_conf\.h:[0-9]+: warning: Member TIMER_NUMOF \(macro definition\) of file periph_conf\.h is not documented\.
|
||||
boards/stm32g0316\-disco/include/periph_conf\.h:[0-9]+: warning: Member timer_config\[\] \(variable\) of file periph_conf\.h is not documented\.
|
||||
@ -14643,3 +14649,59 @@ cpu/stm32/include/clk/cfg_clock_common_lx_u5_wx\.h:[0-9]+: warning: Member CLOCK
|
||||
cpu/stm32/include/clk/cfg_clock_common_lx_u5_wx\.h:[0-9]+: warning: Member CLOCK_HSI \(macro definition\) of file cfg_clock_common_lx_u5_wx\.h is not documented\.
|
||||
cpu/stm32/include/clk/cfg_clock_common_lx_u5_wx\.h:[0-9]+: warning: Member CONFIG_CLOCK_MSI \(macro definition\) of file cfg_clock_common_lx_u5_wx\.h is not documented\.
|
||||
cpu/stm32/include/clk/cfg_clock_common_lx_u5_wx\.h:[0-9]+: warning: Member CONFIG_USE_CLOCK_PLL \(macro definition\) of file cfg_clock_common_lx_u5_wx\.h is not documented\.
|
||||
drivers/ft5x06/include/ft5x06_params\.h:[0-9]+: warning: Member FT5X06_PARAM_I2C_DEV \(macro definition\) of file ft5x06_params\.h is not documented\.
|
||||
drivers/ft5x06/include/ft5x06_params\.h:[0-9]+: warning: Member FT5X06_PARAM_ADDR \(macro definition\) of file ft5x06_params\.h is not documented\.
|
||||
drivers/ft5x06/include/ft5x06_params\.h:[0-9]+: warning: Member FT5X06_PARAM_INT_PIN \(macro definition\) of file ft5x06_params\.h is not documented\.
|
||||
drivers/ft5x06/include/ft5x06_params\.h:[0-9]+: warning: Member FT5X06_PARAM_XMAX \(macro definition\) of file ft5x06_params\.h is not documented\.
|
||||
drivers/ft5x06/include/ft5x06_params\.h:[0-9]+: warning: Member FT5X06_PARAM_YMAX \(macro definition\) of file ft5x06_params\.h is not documented\.
|
||||
drivers/ft5x06/include/ft5x06_params\.h:[0-9]+: warning: Member FT5X06_PARAMS \(macro definition\) of file ft5x06_params\.h is not documented\.
|
||||
drivers/ft5x06/include/ft5x06_constants\.h:[0-9]+: warning: Member FT5X06_I2C_DEFAULT_ADDRESS \(macro definition\) of file ft5x06_constants\.h is not documented\.
|
||||
drivers/ft5x06/include/ft5x06_constants\.h:[0-9]+: warning: Member FT5X06_VENDOR_ID \(macro definition\) of file ft5x06_constants\.h is not documented\.
|
||||
drivers/ft5x06/include/ft5x06_constants\.h:[0-9]+: warning: Member FT5X06_TOUCHES_COUNT_MAX \(macro definition\) of file ft5x06_constants\.h is not documented\.
|
||||
drivers/ft5x06/include/ft5x06_constants\.h:[0-9]+: warning: Member FT5X06_AUTO_CALIB_NEEDED \(macro definition\) of file ft5x06_constants\.h is not documented\.
|
||||
drivers/ft5x06/include/ft5x06_constants\.h:[0-9]+: warning: Member FT5X06_DEVIDE_MODE_REG \(macro definition\) of file ft5x06_constants\.h is not documented\.
|
||||
drivers/ft5x06/include/ft5x06_constants\.h:[0-9]+: warning: Member FT5X06_GESTURE_ID_REG \(macro definition\) of file ft5x06_constants\.h is not documented\.
|
||||
drivers/ft5x06/include/ft5x06_constants\.h:[0-9]+: warning: Member FT5X06_TD_STATUS_REG \(macro definition\) of file ft5x06_constants\.h is not documented\.
|
||||
drivers/ft5x06/include/ft5x06_constants\.h:[0-9]+: warning: Member FT5X06_TOUCH1_XH_REG \(macro definition\) of file ft5x06_constants\.h is not documented\.
|
||||
drivers/ft5x06/include/ft5x06_constants\.h:[0-9]+: warning: Member FT5X06_TOUCH1_XL_REG \(macro definition\) of file ft5x06_constants\.h is not documented\.
|
||||
drivers/ft5x06/include/ft5x06_constants\.h:[0-9]+: warning: Member FT5X06_TOUCH1_YH_REG \(macro definition\) of file ft5x06_constants\.h is not documented\.
|
||||
drivers/ft5x06/include/ft5x06_constants\.h:[0-9]+: warning: Member FT5X06_TOUCH1_YL_REG \(macro definition\) of file ft5x06_constants\.h is not documented\.
|
||||
drivers/ft5x06/include/ft5x06_constants\.h:[0-9]+: warning: Member FT5X06_TOUCH2_XH_REG \(macro definition\) of file ft5x06_constants\.h is not documented\.
|
||||
drivers/ft5x06/include/ft5x06_constants\.h:[0-9]+: warning: Member FT5X06_TOUCH2_XL_REG \(macro definition\) of file ft5x06_constants\.h is not documented\.
|
||||
drivers/ft5x06/include/ft5x06_constants\.h:[0-9]+: warning: Member FT5X06_TOUCH2_YH_REG \(macro definition\) of file ft5x06_constants\.h is not documented\.
|
||||
drivers/ft5x06/include/ft5x06_constants\.h:[0-9]+: warning: Member FT5X06_TOUCH2_YL_REG \(macro definition\) of file ft5x06_constants\.h is not documented\.
|
||||
drivers/ft5x06/include/ft5x06_constants\.h:[0-9]+: warning: Member FT5X06_TOUCH3_XH_REG \(macro definition\) of file ft5x06_constants\.h is not documented\.
|
||||
drivers/ft5x06/include/ft5x06_constants\.h:[0-9]+: warning: Member FT5X06_TOUCH3_XL_REG \(macro definition\) of file ft5x06_constants\.h is not documented\.
|
||||
drivers/ft5x06/include/ft5x06_constants\.h:[0-9]+: warning: Member FT5X06_TOUCH3_YH_REG \(macro definition\) of file ft5x06_constants\.h is not documented\.
|
||||
drivers/ft5x06/include/ft5x06_constants\.h:[0-9]+: warning: Member FT5X06_TOUCH3_YL_REG \(macro definition\) of file ft5x06_constants\.h is not documented\.
|
||||
drivers/ft5x06/include/ft5x06_constants\.h:[0-9]+: warning: Member FT5X06_TOUCH4_XH_REG \(macro definition\) of file ft5x06_constants\.h is not documented\.
|
||||
drivers/ft5x06/include/ft5x06_constants\.h:[0-9]+: warning: Member FT5X06_TOUCH4_XL_REG \(macro definition\) of file ft5x06_constants\.h is not documented\.
|
||||
drivers/ft5x06/include/ft5x06_constants\.h:[0-9]+: warning: Member FT5X06_TOUCH4_YH_REG \(macro definition\) of file ft5x06_constants\.h is not documented\.
|
||||
drivers/ft5x06/include/ft5x06_constants\.h:[0-9]+: warning: Member FT5X06_TOUCH4_YL_REG \(macro definition\) of file ft5x06_constants\.h is not documented\.
|
||||
drivers/ft5x06/include/ft5x06_constants\.h:[0-9]+: warning: Member FT5X06_TOUCH5_XH_REG \(macro definition\) of file ft5x06_constants\.h is not documented\.
|
||||
drivers/ft5x06/include/ft5x06_constants\.h:[0-9]+: warning: Member FT5X06_TOUCH5_XL_REG \(macro definition\) of file ft5x06_constants\.h is not documented\.
|
||||
drivers/ft5x06/include/ft5x06_constants\.h:[0-9]+: warning: Member FT5X06_TOUCH5_YH_REG \(macro definition\) of file ft5x06_constants\.h is not documented\.
|
||||
drivers/ft5x06/include/ft5x06_constants\.h:[0-9]+: warning: Member FT5X06_TOUCH5_YL_REG \(macro definition\) of file ft5x06_constants\.h is not documented\.
|
||||
drivers/ft5x06/include/ft5x06_constants\.h:[0-9]+: warning: Member FT5X06_G_AUTO_CLB_MODE_REG \(macro definition\) of file ft5x06_constants\.h is not documented\.
|
||||
drivers/ft5x06/include/ft5x06_constants\.h:[0-9]+: warning: Member FT5X06_G_CIPHER_REG \(macro definition\) of file ft5x06_constants\.h is not documented\.
|
||||
drivers/ft5x06/include/ft5x06_constants\.h:[0-9]+: warning: Member FT5X06_G_LIB_VERSION_H_REG \(macro definition\) of file ft5x06_constants\.h is not documented\.
|
||||
drivers/ft5x06/include/ft5x06_constants\.h:[0-9]+: warning: Member FT5X06_G_LIB_VERSION_L_REG \(macro definition\) of file ft5x06_constants\.h is not documented\.
|
||||
drivers/ft5x06/include/ft5x06_constants\.h:[0-9]+: warning: Member FT5X06_G_MODE_REG \(macro definition\) of file ft5x06_constants\.h is not documented\.
|
||||
drivers/ft5x06/include/ft5x06_constants\.h:[0-9]+: warning: Member FT5X06_G_PMODE_REG \(macro definition\) of file ft5x06_constants\.h is not documented\.
|
||||
drivers/ft5x06/include/ft5x06_constants\.h:[0-9]+: warning: Member FT5X06_G_FIRMID_REG \(macro definition\) of file ft5x06_constants\.h is not documented\.
|
||||
drivers/ft5x06/include/ft5x06_constants\.h:[0-9]+: warning: Member FT5X06_G_STATE_REG \(macro definition\) of file ft5x06_constants\.h is not documented\.
|
||||
drivers/ft5x06/include/ft5x06_constants\.h:[0-9]+: warning: Member FT5X06_G_VENDOR_ID_REG \(macro definition\) of file ft5x06_constants\.h is not documented\.
|
||||
drivers/ft5x06/include/ft5x06_constants\.h:[0-9]+: warning: Member FT5X06_GESTURE_ID_MOVE_UP \(macro definition\) of file ft5x06_constants\.h is not documented\.
|
||||
drivers/ft5x06/include/ft5x06_constants\.h:[0-9]+: warning: Member FT5X06_GESTURE_ID_MOVE_LEFT \(macro definition\) of file ft5x06_constants\.h is not documented\.
|
||||
drivers/ft5x06/include/ft5x06_constants\.h:[0-9]+: warning: Member FT5X06_GESTURE_ID_MOVE_DOWN \(macro definition\) of file ft5x06_constants\.h is not documented\.
|
||||
drivers/ft5x06/include/ft5x06_constants\.h:[0-9]+: warning: Member FT5X06_GESTURE_ID_MOVE_RIGHT \(macro definition\) of file ft5x06_constants\.h is not documented\.
|
||||
drivers/ft5x06/include/ft5x06_constants\.h:[0-9]+: warning: Member FT5X06_GESTURE_ID_ZOOM_IN \(macro definition\) of file ft5x06_constants\.h is not documented\.
|
||||
drivers/ft5x06/include/ft5x06_constants\.h:[0-9]+: warning: Member FT5X06_GESTURE_ID_ZOOM_OUT \(macro definition\) of file ft5x06_constants\.h is not documented\.
|
||||
drivers/ft5x06/include/ft5x06_constants\.h:[0-9]+: warning: Member FT5X06_GESTURE_ID_NONE \(macro definition\) of file ft5x06_constants\.h is not documented\.
|
||||
drivers/ft5x06/include/ft5x06_constants\.h:[0-9]+: warning: Member FT5X06_TD_STATUS_MASK \(macro definition\) of file ft5x06_constants\.h is not documented\.
|
||||
drivers/ft5x06/include/ft5x06_constants\.h:[0-9]+: warning: Member FT5X06_TOUCH_POS_LSB_MASK \(macro definition\) of file ft5x06_constants\.h is not documented\.
|
||||
drivers/ft5x06/include/ft5x06_constants\.h:[0-9]+: warning: Member FT5X06_TOUCH_POS_MSB_MASK \(macro definition\) of file ft5x06_constants\.h is not documented\.
|
||||
drivers/ft5x06/include/ft5x06_constants\.h:[0-9]+: warning: Member FT5X06_G_MODE_INTERRUPT_MASK \(macro definition\) of file ft5x06_constants\.h is not documented\.
|
||||
drivers/ft5x06/include/ft5x06_constants\.h:[0-9]+: warning: Member FT5X06_G_MODE_INTERRUPT_SHIFT \(macro definition\) of file ft5x06_constants\.h is not documented\.
|
||||
drivers/ft5x06/include/ft5x06_constants\.h:[0-9]+: warning: Member FT5X06_G_MODE_INTERRUPT_POLLING \(macro definition\) of file ft5x06_constants\.h is not documented\.
|
||||
drivers/ft5x06/include/ft5x06_constants\.h:[0-9]+: warning: Member FT5X06_G_MODE_INTERRUPT_TRIGGER \(macro definition\) of file ft5x06_constants\.h is not documented\.
|
||||
|
||||
@ -76,6 +76,7 @@ rsource "dcf77/Kconfig"
|
||||
rsource "dht/Kconfig"
|
||||
rsource "ds18/Kconfig"
|
||||
rsource "ds75lx/Kconfig"
|
||||
rsource "ft5x06/Kconfig"
|
||||
rsource "fxos8700/Kconfig"
|
||||
rsource "gp2y10xx/Kconfig"
|
||||
rsource "hdc1000/Kconfig"
|
||||
|
||||
@ -52,6 +52,10 @@ ifneq (,$(filter ethos_%,$(USEMODULE)))
|
||||
USEMODULE += ethos
|
||||
endif
|
||||
|
||||
ifneq (,$(filter ft6% ft5% ft3%,$(USEMODULE)))
|
||||
USEMODULE += ft5x06
|
||||
endif
|
||||
|
||||
ifneq (,$(filter hmc5883l_%,$(USEMODULE)))
|
||||
USEMODULE += hmc5883l
|
||||
endif
|
||||
|
||||
109
drivers/ft5x06/Kconfig
Normal file
109
drivers/ft5x06/Kconfig
Normal file
@ -0,0 +1,109 @@
|
||||
# Copyright (c) 2021 Inria
|
||||
#
|
||||
# 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_FT5X06
|
||||
bool "FT5X06 touch panel driver"
|
||||
depends on TEST_KCONFIG
|
||||
depends on HAS_PERIPH_GPIO_IRQ
|
||||
depends on HAS_PERIPH_I2C
|
||||
select MODULE_PERIPH_GPIO_IRQ
|
||||
select MODULE_PERIPH_I2C
|
||||
select MODULE_ZTIMER
|
||||
select MODULE_ZTIMER_MSEC
|
||||
|
||||
config MODULE_FT5606
|
||||
bool "FT5606 touch panel driver"
|
||||
select MODULE_FT5X06
|
||||
|
||||
config MODULE_FT5X16
|
||||
bool "FT5X16 touch panel driver"
|
||||
select MODULE_FT5X06
|
||||
|
||||
config MODULE_FT6X06
|
||||
bool "FT6X06 touch panel driver"
|
||||
select MODULE_FT5X06
|
||||
|
||||
config MODULE_FT6X36
|
||||
bool "FT6X36 touch panel driver"
|
||||
select MODULE_FT5X06
|
||||
|
||||
config MODULE_FT5X06I
|
||||
bool "FT5X06I touch panel driver"
|
||||
select MODULE_FT5X06
|
||||
|
||||
config MODULE_FT5336
|
||||
bool "FT5336 touch panel driver"
|
||||
select MODULE_FT5X06
|
||||
|
||||
config MODULE_FT3316
|
||||
bool "FT3316 touch panel driver"
|
||||
select MODULE_FT5X06
|
||||
|
||||
config MODULE_FT5436I
|
||||
bool "FT5436I touch panel driver"
|
||||
select MODULE_FT5X06
|
||||
|
||||
config MODULE_FT5336I
|
||||
bool "FT5336I touch panel driver"
|
||||
select MODULE_FT5X06
|
||||
|
||||
config MODULE_FT5X46
|
||||
bool "FT5X46 touch panel driver"
|
||||
select MODULE_FT5X06
|
||||
|
||||
config HAVE_FT5606
|
||||
bool
|
||||
select MODULE_FT5606 if MODULE_TOUCH_DEV
|
||||
help
|
||||
Indicates that an FT5606 touch panel is present.
|
||||
|
||||
config HAVE_FT5X16
|
||||
bool
|
||||
select MODULE_FT5X16 if MODULE_TOUCH_DEV
|
||||
help
|
||||
Indicates that an FT5X16 touch panel is present.
|
||||
|
||||
config HAVE_FT6X06
|
||||
bool
|
||||
select MODULE_FT6X06 if MODULE_TOUCH_DEV
|
||||
help
|
||||
Indicates that an FT6X06 touch panel is present.
|
||||
|
||||
config HAVE_FT6X36
|
||||
bool
|
||||
select MODULE_FT6X36 if MODULE_TOUCH_DEV
|
||||
help
|
||||
Indicates that an FT6X36 touch panel is present.
|
||||
|
||||
config HAVE_FT5X06I
|
||||
bool
|
||||
select MODULE_FT5X06I if MODULE_TOUCH_DEV
|
||||
help
|
||||
Indicates that an FT5X06I touch panel is present.
|
||||
|
||||
config HAVE_FT5336
|
||||
bool
|
||||
select MODULE_FT5336 if MODULE_TOUCH_DEV
|
||||
help
|
||||
Indicates that an FT5336 touch panel is present.
|
||||
|
||||
config HAVE_FT3316
|
||||
bool
|
||||
select MODULE_FT3316 if MODULE_TOUCH_DEV
|
||||
help
|
||||
Indicates that an FT3316 touch panel is present.
|
||||
|
||||
config HAVE_FT5436I
|
||||
bool
|
||||
select MODULE_FT5436I if MODULE_TOUCH_DEV
|
||||
help
|
||||
Indicates that an FT5436I touch panel is present.
|
||||
|
||||
config HAVE_FT5X46
|
||||
bool
|
||||
select MODULE_FT5X46 if MODULE_TOUCH_DEV
|
||||
help
|
||||
Indicates that an FT5X46 touch panel is present.
|
||||
1
drivers/ft5x06/Makefile
Normal file
1
drivers/ft5x06/Makefile
Normal file
@ -0,0 +1 @@
|
||||
include $(RIOTMAKE)/driver_with_touch_dev.mk
|
||||
5
drivers/ft5x06/Makefile.dep
Normal file
5
drivers/ft5x06/Makefile.dep
Normal file
@ -0,0 +1,5 @@
|
||||
FEATURES_REQUIRED += periph_gpio_irq
|
||||
FEATURES_REQUIRED += periph_i2c
|
||||
|
||||
USEMODULE += ztimer
|
||||
USEMODULE += ztimer_msec
|
||||
13
drivers/ft5x06/Makefile.include
Normal file
13
drivers/ft5x06/Makefile.include
Normal file
@ -0,0 +1,13 @@
|
||||
USEMODULE_INCLUDES_ft5x06 := $(LAST_MAKEFILEDIR)/include
|
||||
USEMODULE_INCLUDES += $(USEMODULE_INCLUDES_ft5x06)
|
||||
|
||||
PSEUDOMODULES += ft5606
|
||||
PSEUDOMODULES += ft5x16
|
||||
PSEUDOMODULES += ft6x06
|
||||
PSEUDOMODULES += ft6x36
|
||||
PSEUDOMODULES += ft5x06i
|
||||
PSEUDOMODULES += ft5336
|
||||
PSEUDOMODULES += ft3316
|
||||
PSEUDOMODULES += ft5436i
|
||||
PSEUDOMODULES += ft5336i
|
||||
PSEUDOMODULES += ft5x46
|
||||
157
drivers/ft5x06/ft5x06.c
Normal file
157
drivers/ft5x06/ft5x06.c
Normal file
@ -0,0 +1,157 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Inria
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup drivers_ft5x06
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Device driver implementation for the FT5x06 touch driver
|
||||
*
|
||||
* @author Alexandre Abadie <alexandre.abadie@inria.fr>
|
||||
*
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "periph/i2c.h"
|
||||
#include "periph/gpio.h"
|
||||
|
||||
#include "ztimer.h"
|
||||
|
||||
#include "ft5x06.h"
|
||||
#include "ft5x06_constants.h"
|
||||
#include "ft5x06_params.h"
|
||||
|
||||
#define ENABLE_DEBUG 0
|
||||
#include "debug.h"
|
||||
|
||||
#define FT5X06_BUS (dev->params.i2c)
|
||||
#define FT5X06_ADDR (dev->params.addr)
|
||||
|
||||
#define FT5X06_RESET_DELAY_MS (200)
|
||||
|
||||
int ft5x06_init(ft5x06_t *dev, const ft5x06_params_t *params, ft5x06_event_cb_t cb, void *arg)
|
||||
{
|
||||
dev->params = *params;
|
||||
|
||||
/* Wait at least 200ms after power up before accessing registers */
|
||||
ztimer_sleep(ZTIMER_MSEC, FT5X06_RESET_DELAY_MS);
|
||||
|
||||
i2c_acquire(FT5X06_BUS);
|
||||
|
||||
uint8_t vendor_id = 0;
|
||||
if (i2c_read_reg(FT5X06_BUS, FT5X06_ADDR, FT5X06_G_VENDOR_ID_REG, &vendor_id, 0) != 0) {
|
||||
i2c_release(FT5X06_BUS);
|
||||
return -EPROTO;
|
||||
}
|
||||
|
||||
if (vendor_id != FT5X06_VENDOR_ID) {
|
||||
DEBUG("[ft5x06] init: invalid vendor ID: '0x%02x' (expected: 0x%02x)\n",
|
||||
vendor_id, FT5X06_VENDOR_ID);
|
||||
i2c_release(FT5X06_BUS);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
/* Auto-calibrate if needed */
|
||||
if (IS_ACTIVE(FT5X06_AUTO_CALIB_NEEDED)) {
|
||||
DEBUG("[ft5x06] init: enable device auto-calibration\n");
|
||||
i2c_write_reg(FT5X06_BUS, FT5X06_ADDR, FT5X06_G_AUTO_CLB_MODE_REG, 0, 0);
|
||||
}
|
||||
|
||||
/* Configure interrupt */
|
||||
if (gpio_is_valid(dev->params.int_pin)) {
|
||||
DEBUG("[ft5x06] init: configuring touchscreen interrupt\n");
|
||||
gpio_init_int(dev->params.int_pin, GPIO_IN, GPIO_RISING, cb, arg);
|
||||
i2c_write_reg(FT5X06_BUS, FT5X06_ADDR, FT5X06_G_MODE_REG, FT5X06_G_MODE_INTERRUPT_TRIGGER & 0x01, 0);
|
||||
}
|
||||
|
||||
i2c_release(FT5X06_BUS);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const uint8_t touch_reg_map[FT5X06_TOUCHES_COUNT_MAX] = {
|
||||
FT5X06_TOUCH1_XH_REG,
|
||||
FT5X06_TOUCH2_XH_REG,
|
||||
#if FT5X06_TOUCHES_COUNT_MAX > 2
|
||||
FT5X06_TOUCH3_XH_REG,
|
||||
FT5X06_TOUCH4_XH_REG,
|
||||
FT5X06_TOUCH5_XH_REG,
|
||||
#endif
|
||||
};
|
||||
|
||||
int ft5x06_read_touch_positions(const ft5x06_t *dev, ft5x06_touch_position_t *positions, size_t len)
|
||||
{
|
||||
i2c_acquire(FT5X06_BUS);
|
||||
for (uint8_t touch = 0; touch < len; touch++) {
|
||||
uint8_t regs[4];
|
||||
uint16_t pos_x = 0, pos_y = 0;
|
||||
i2c_read_regs(FT5X06_BUS, FT5X06_ADDR, touch_reg_map[touch], ®s, 4, 0);
|
||||
pos_x = (uint16_t)((regs[1] & FT5X06_TOUCH_POS_LSB_MASK) | (uint16_t)(regs[0] & FT5X06_TOUCH_POS_MSB_MASK) << 8);
|
||||
pos_y = (uint16_t)((regs[3] & FT5X06_TOUCH_POS_LSB_MASK) | (uint16_t)(regs[2] & FT5X06_TOUCH_POS_MSB_MASK) << 8);
|
||||
/* X and Y positions are swapped compared to the display */
|
||||
positions[touch].x = pos_y;
|
||||
positions[touch].y = pos_x;
|
||||
}
|
||||
i2c_release(FT5X06_BUS);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ft5x06_read_touch_count(const ft5x06_t *dev, uint8_t *count)
|
||||
{
|
||||
i2c_acquire(FT5X06_BUS);
|
||||
i2c_read_reg(FT5X06_BUS, FT5X06_ADDR, FT5X06_TD_STATUS_REG, count, 0);
|
||||
i2c_release(FT5X06_BUS);
|
||||
*count &= FT5X06_TD_STATUS_MASK;
|
||||
|
||||
if (*count > FT5X06_TOUCHES_COUNT_MAX) {
|
||||
*count = 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ft5x06_read_touch_gesture(const ft5x06_t *dev, ft5x06_touch_gesture_t *gesture)
|
||||
{
|
||||
uint8_t gesture_id = 0;
|
||||
i2c_acquire(FT5X06_BUS);
|
||||
i2c_read_reg(FT5X06_BUS, FT5X06_ADDR, FT5X06_GESTURE_ID_REG, &gesture_id, 0);
|
||||
i2c_release(FT5X06_BUS);
|
||||
|
||||
DEBUG("[ft5x06] read gesture_id '0x%02X'\n", gesture_id);
|
||||
|
||||
switch (gesture_id) {
|
||||
case FT5X06_GESTURE_ID_MOVE_UP:
|
||||
*gesture = FT5X06_TOUCH_MOVE_UP;
|
||||
break;
|
||||
case FT5X06_GESTURE_ID_MOVE_LEFT:
|
||||
*gesture = FT5X06_TOUCH_MOVE_LEFT;
|
||||
break;
|
||||
case FT5X06_GESTURE_ID_MOVE_DOWN:
|
||||
*gesture = FT5X06_TOUCH_MOVE_DOWN;
|
||||
break;
|
||||
case FT5X06_GESTURE_ID_MOVE_RIGHT:
|
||||
*gesture = FT5X06_TOUCH_MOVE_RIGHT;
|
||||
break;
|
||||
case FT5X06_GESTURE_ID_ZOOM_IN:
|
||||
*gesture = FT5X06_TOUCH_ZOOM_IN;
|
||||
break;
|
||||
case FT5X06_GESTURE_ID_ZOOM_OUT:
|
||||
*gesture = FT5X06_TOUCH_ZOOM_OUT;
|
||||
break;
|
||||
default: /* Fallback to None */
|
||||
*gesture = FT5X06_TOUCH_NO_GESTURE;
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
81
drivers/ft5x06/ft5x06_touch_dev.c
Normal file
81
drivers/ft5x06/ft5x06_touch_dev.c
Normal file
@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Inria
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup drivers_ft5x06
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Driver adaption to touch_dev generic interface
|
||||
*
|
||||
* @author Alexandre Abadie <alexandre.abadie@inria.fr>
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "kernel_defines.h"
|
||||
#include "periph/gpio.h"
|
||||
|
||||
#include "ft5x06.h"
|
||||
#include "ft5x06_touch_dev.h"
|
||||
|
||||
#define ENABLE_DEBUG 0
|
||||
#include "debug.h"
|
||||
|
||||
uint16_t _ft5x06_height(const touch_dev_t *touch_dev)
|
||||
{
|
||||
const ft5x06_t *dev = (const ft5x06_t *)touch_dev;
|
||||
assert(dev);
|
||||
|
||||
return dev->params.ymax;
|
||||
}
|
||||
|
||||
uint16_t _ft5x06_width(const touch_dev_t *touch_dev)
|
||||
{
|
||||
const ft5x06_t *dev = (const ft5x06_t *)touch_dev;
|
||||
assert(dev);
|
||||
|
||||
return dev->params.xmax;
|
||||
}
|
||||
|
||||
uint8_t _ft5x06_touches(const touch_dev_t *touch_dev, touch_t *touches, size_t len)
|
||||
{
|
||||
ft5x06_t *dev = (ft5x06_t *)touch_dev;
|
||||
assert(dev);
|
||||
|
||||
uint8_t ret;
|
||||
ft5x06_read_touch_count(dev, &ret);
|
||||
|
||||
if (ret && touches != NULL) {
|
||||
assert(len <= FT5X06_TOUCHES_COUNT_MAX);
|
||||
ft5x06_read_touch_positions(dev, (ft5x06_touch_position_t *)touches, len);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void _ft5x06_set_event_callback(const touch_dev_t *touch_dev, touch_event_cb_t cb, void *arg)
|
||||
{
|
||||
ft5x06_t *dev = (ft5x06_t *)touch_dev;
|
||||
assert(dev);
|
||||
|
||||
if (gpio_is_valid(dev->params.int_pin)) {
|
||||
gpio_init_int(dev->params.int_pin, GPIO_IN, GPIO_RISING, cb, arg);
|
||||
}
|
||||
}
|
||||
|
||||
const touch_dev_driver_t ft5x06_touch_dev_driver = {
|
||||
.height = _ft5x06_height,
|
||||
.width = _ft5x06_width,
|
||||
.touches = _ft5x06_touches,
|
||||
.set_event_callback = _ft5x06_set_event_callback,
|
||||
};
|
||||
133
drivers/ft5x06/include/ft5x06_constants.h
Normal file
133
drivers/ft5x06/include/ft5x06_constants.h
Normal file
@ -0,0 +1,133 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Inria
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup drivers_ft5x06
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Internal register addresses, bitfields and constants
|
||||
*
|
||||
* @author Alexandre Abadie <alexandre.abadie@inria.fr>
|
||||
*/
|
||||
|
||||
#ifndef FT5X06_CONSTANTS_H
|
||||
#define FT5X06_CONSTANTS_H
|
||||
|
||||
#include "kernel_defines.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @name Constants (depends on variants)
|
||||
* @{
|
||||
*/
|
||||
#define FT5X06_I2C_DEFAULT_ADDRESS (0x38)
|
||||
#if IS_USED(MODULE_FT6X06) || IS_USED(MODULE_FT6X36)
|
||||
#define FT5X06_VENDOR_ID (0xcd)
|
||||
#else
|
||||
#define FT5X06_VENDOR_ID (0x51)
|
||||
#endif
|
||||
#if IS_USED(MODULE_FT6X06) || IS_USED(MODULE_FT6X36)
|
||||
#define FT5X06_TOUCHES_COUNT_MAX (2)
|
||||
#else
|
||||
#define FT5X06_TOUCHES_COUNT_MAX (5)
|
||||
#endif
|
||||
#if IS_USED(MODULE_FT6X06) || IS_USED(MODULE_FT6X36) || IS_USED(MODULE_FT5336) || \
|
||||
IS_USED(MODULE_FT3316) || IS_USED(MODULE_FT5436I) || IS_USED(MODULE_FT5336I) || \
|
||||
IS_USED(MODULE_FT5X46)
|
||||
#define FT5X06_AUTO_CALIB_NEEDED 0
|
||||
#else
|
||||
#define FT5X06_AUTO_CALIB_NEEDED 1
|
||||
#endif
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name Register addresses
|
||||
* @{
|
||||
*/
|
||||
#define FT5X06_DEVIDE_MODE_REG (0x00)
|
||||
#define FT5X06_GESTURE_ID_REG (0x01)
|
||||
#define FT5X06_TD_STATUS_REG (0x02)
|
||||
#define FT5X06_TOUCH1_XH_REG (0x03)
|
||||
#define FT5X06_TOUCH1_XL_REG (0x04)
|
||||
#define FT5X06_TOUCH1_YH_REG (0x05)
|
||||
#define FT5X06_TOUCH1_YL_REG (0x06)
|
||||
#define FT5X06_TOUCH2_XH_REG (0x09)
|
||||
#define FT5X06_TOUCH2_XL_REG (0x0A)
|
||||
#define FT5X06_TOUCH2_YH_REG (0x0B)
|
||||
#define FT5X06_TOUCH2_YL_REG (0x0C)
|
||||
#define FT5X06_TOUCH3_XH_REG (0x0F)
|
||||
#define FT5X06_TOUCH3_XL_REG (0x11)
|
||||
#define FT5X06_TOUCH3_YH_REG (0x12)
|
||||
#define FT5X06_TOUCH3_YL_REG (0x13)
|
||||
#define FT5X06_TOUCH4_XH_REG (0x15)
|
||||
#define FT5X06_TOUCH4_XL_REG (0x16)
|
||||
#define FT5X06_TOUCH4_YH_REG (0x17)
|
||||
#define FT5X06_TOUCH4_YL_REG (0x18)
|
||||
#define FT5X06_TOUCH5_XH_REG (0x1B)
|
||||
#define FT5X06_TOUCH5_XL_REG (0x1C)
|
||||
#define FT5X06_TOUCH5_YH_REG (0x1D)
|
||||
#define FT5X06_TOUCH5_YL_REG (0x1E)
|
||||
#define FT5X06_G_AUTO_CLB_MODE_REG (0xA0)
|
||||
#define FT5X06_G_CIPHER_REG (0xA1)
|
||||
#define FT5X06_G_LIB_VERSION_H_REG (0xA2)
|
||||
#define FT5X06_G_LIB_VERSION_L_REG (0xA3)
|
||||
#define FT5X06_G_MODE_REG (0xA4)
|
||||
#define FT5X06_G_PMODE_REG (0xA5)
|
||||
#define FT5X06_G_FIRMID_REG (0xA6)
|
||||
#define FT5X06_G_STATE_REG (0xA7)
|
||||
#define FT5X06_G_VENDOR_ID_REG (0xA8)
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name Gesture ID register bitfields
|
||||
* @{
|
||||
*/
|
||||
#define FT5X06_GESTURE_ID_MOVE_UP (0x10)
|
||||
#define FT5X06_GESTURE_ID_MOVE_LEFT (0x14)
|
||||
#define FT5X06_GESTURE_ID_MOVE_DOWN (0x18)
|
||||
#define FT5X06_GESTURE_ID_MOVE_RIGHT (0x1C)
|
||||
#define FT5X06_GESTURE_ID_ZOOM_IN (0x48)
|
||||
#define FT5X06_GESTURE_ID_ZOOM_OUT (0x49)
|
||||
#define FT5X06_GESTURE_ID_NONE (0x00)
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name Touch detect status register bitfields
|
||||
* @{
|
||||
*/
|
||||
#define FT5X06_TD_STATUS_MASK (0x0F)
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name Touch position (LSB/MSB) registers masks
|
||||
* @{
|
||||
*/
|
||||
#define FT5X06_TOUCH_POS_LSB_MASK (0xFF)
|
||||
#define FT5X06_TOUCH_POS_MSB_MASK (0x0F)
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name Interrupt mode register masks and bitfields
|
||||
* @{
|
||||
*/
|
||||
#define FT5X06_G_MODE_INTERRUPT_MASK (0x03)
|
||||
#define FT5X06_G_MODE_INTERRUPT_SHIFT (0x00)
|
||||
#define FT5X06_G_MODE_INTERRUPT_POLLING (0x00)
|
||||
#define FT5X06_G_MODE_INTERRUPT_TRIGGER (0x01)
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* FT5X06_CONSTANTS_H */
|
||||
/** @} */
|
||||
90
drivers/ft5x06/include/ft5x06_params.h
Normal file
90
drivers/ft5x06/include/ft5x06_params.h
Normal file
@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Inria
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup drivers_ft5x06
|
||||
*
|
||||
* @{
|
||||
* @file
|
||||
* @brief Default configuration
|
||||
*
|
||||
* @author Alexandre Abadie <alexandre.abadie@inria.fr>
|
||||
*/
|
||||
|
||||
#ifndef FT5X06_PARAMS_H
|
||||
#define FT5X06_PARAMS_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "board.h"
|
||||
#include "ft5x06.h"
|
||||
#include "ft5x06_constants.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @name Set default configuration parameters
|
||||
* @{
|
||||
*/
|
||||
/* I2C configuration */
|
||||
#ifndef FT5X06_PARAM_I2C_DEV
|
||||
#define FT5X06_PARAM_I2C_DEV I2C_DEV(0)
|
||||
#endif
|
||||
#ifndef FT5X06_PARAM_ADDR
|
||||
#define FT5X06_PARAM_ADDR (FT5X06_I2C_DEFAULT_ADDRESS)
|
||||
#endif
|
||||
#ifndef FT5X06_PARAM_INT_PIN
|
||||
#define FT5X06_PARAM_INT_PIN GPIO_UNDEF
|
||||
#endif
|
||||
#ifndef FT5X06_PARAM_XMAX
|
||||
#define FT5X06_PARAM_XMAX (480U)
|
||||
#endif
|
||||
#ifndef FT5X06_PARAM_YMAX
|
||||
#define FT5X06_PARAM_YMAX (272U)
|
||||
#endif
|
||||
|
||||
#define FT5X06_PARAMS { \
|
||||
.i2c = FT5X06_PARAM_I2C_DEV, \
|
||||
.addr = FT5X06_PARAM_ADDR, \
|
||||
.int_pin = FT5X06_PARAM_INT_PIN, \
|
||||
.xmax = FT5X06_PARAM_XMAX, \
|
||||
.ymax = FT5X06_PARAM_YMAX, \
|
||||
}
|
||||
/**@}*/
|
||||
|
||||
/**
|
||||
* @brief Configuration struct
|
||||
*/
|
||||
static const ft5x06_params_t ft5x06_params[] =
|
||||
{
|
||||
FT5X06_PARAMS
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Default screen identifiers
|
||||
*/
|
||||
#ifndef FT5X06_PARAM_SCREEN_IDS
|
||||
#define FT5X06_PARAM_SCREEN_IDS 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Configure screen identifiers
|
||||
*/
|
||||
static const uint8_t ft5x06_screen_ids[] =
|
||||
{
|
||||
FT5X06_PARAM_SCREEN_IDS,
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* FT5X06_PARAMS_H */
|
||||
/** @} */
|
||||
38
drivers/ft5x06/include/ft5x06_touch_dev.h
Normal file
38
drivers/ft5x06/include/ft5x06_touch_dev.h
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Inria
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup drivers_ft5x06
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Definition of the driver for the touch_dev generic interface
|
||||
*
|
||||
* @author Alexandre Abadie <alexandre.abadie@inria.fr>
|
||||
*/
|
||||
|
||||
#ifndef FT5X06_TOUCH_DEV_H
|
||||
#define FT5X06_TOUCH_DEV_H
|
||||
|
||||
#include "touch_dev.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Reference to the touch device driver struct
|
||||
*/
|
||||
extern const touch_dev_driver_t ft5x06_touch_dev_driver;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* FT5X06_TOUCH_DEV_H */
|
||||
/** @} */
|
||||
145
drivers/include/ft5x06.h
Normal file
145
drivers/include/ft5x06.h
Normal file
@ -0,0 +1,145 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Inria
|
||||
*
|
||||
* 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 drivers_ft5x06 FocalTech FT5x06 touch panel driver
|
||||
* @ingroup drivers_sensors
|
||||
* @brief Multi-touch capacitive panel controller
|
||||
*
|
||||
* This driver should also support FT5x06,FT5606,FT5x16,FT6x06,Ft6x36
|
||||
* FT5x06i,FT5336,FT3316,FT5436i,FT5336i,FT5x46.
|
||||
*
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
*
|
||||
* @author Alexandre Abadie <alexandre.abadie@inria.fr>
|
||||
*/
|
||||
|
||||
#ifndef FT5X06_H
|
||||
#define FT5X06_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "periph/gpio.h"
|
||||
#include "periph/i2c.h"
|
||||
|
||||
#include "ft5x06_constants.h"
|
||||
|
||||
#ifdef MODULE_TOUCH_DEV
|
||||
#include "touch_dev.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Touch position structure
|
||||
*/
|
||||
typedef struct {
|
||||
uint16_t x; /**< X position */
|
||||
uint16_t y; /**< Y position */
|
||||
} ft5x06_touch_position_t;
|
||||
|
||||
/**
|
||||
* @brief Touch gesture
|
||||
*/
|
||||
typedef enum {
|
||||
FT5X06_TOUCH_NO_GESTURE, /**< No gesture detected */
|
||||
FT5X06_TOUCH_MOVE_UP, /**< Move up gesture detected */
|
||||
FT5X06_TOUCH_MOVE_LEFT, /**< Move left gesture detected */
|
||||
FT5X06_TOUCH_MOVE_DOWN, /**< Move down gesture detected */
|
||||
FT5X06_TOUCH_MOVE_RIGHT, /**< Move right gesture detected */
|
||||
FT5X06_TOUCH_ZOOM_IN, /**< Zoom int gesture detected */
|
||||
FT5X06_TOUCH_ZOOM_OUT, /**< Zoom out gesture detected */
|
||||
} ft5x06_touch_gesture_t;
|
||||
|
||||
/**
|
||||
* @brief Signature of the touch event callback triggered from interrupt
|
||||
*
|
||||
* @param[in] arg optional context for the callback
|
||||
*/
|
||||
typedef void (*ft5x06_event_cb_t)(void *arg);
|
||||
|
||||
/**
|
||||
* @brief Device initialization parameters
|
||||
*/
|
||||
typedef struct {
|
||||
i2c_t i2c; /**< I2C device which is used */
|
||||
uint8_t addr; /**< Device I2C address */
|
||||
gpio_t int_pin; /**< Touch screen interrupt pin */
|
||||
uint16_t xmax; /**< Touch screen max X position */
|
||||
uint16_t ymax; /**< Touch screen max Y position */
|
||||
} ft5x06_params_t;
|
||||
|
||||
/**
|
||||
* @brief Device descriptor for the driver
|
||||
*/
|
||||
typedef struct {
|
||||
#ifdef MODULE_TOUCH_DEV
|
||||
touch_dev_t *dev; /**< Pointer to the generic touch device */
|
||||
#endif
|
||||
ft5x06_params_t params; /**< Initialization parameters */
|
||||
} ft5x06_t;
|
||||
|
||||
/**
|
||||
* @brief Initialize the given device
|
||||
*
|
||||
* @param[inout] dev Device descriptor of the driver
|
||||
* @param[in] params Initialization parameters
|
||||
* @param[in] cb Callback function called on touch interrupts
|
||||
* @param[in] arg Context argument used in callback function
|
||||
*
|
||||
* @return 0 on success
|
||||
* @return -ENODEV when no valid device
|
||||
* @return -EPROTO on any bus error
|
||||
*/
|
||||
int ft5x06_init(ft5x06_t *dev, const ft5x06_params_t *params,
|
||||
ft5x06_event_cb_t cb, void *arg);
|
||||
|
||||
/**
|
||||
* @brief Read the touch positions
|
||||
*
|
||||
* @param[in] dev Device descriptor of the FT5x06
|
||||
* @param[out] positions Touch positions
|
||||
* @param[in] len Number of touch positions to read
|
||||
*
|
||||
* @return 0 on success
|
||||
* @return -EPROTO on any bus error
|
||||
*/
|
||||
int ft5x06_read_touch_positions(const ft5x06_t *dev, ft5x06_touch_position_t *positions, size_t len);
|
||||
|
||||
/**
|
||||
* @brief Read the number of touch
|
||||
*
|
||||
* @param[in] dev Device descriptor of the FT5x06
|
||||
* @param[out] count Number of touch detected
|
||||
*
|
||||
* @return 0 on success
|
||||
* @return -EPROTO on any bus error
|
||||
*/
|
||||
int ft5x06_read_touch_count(const ft5x06_t *dev, uint8_t *count);
|
||||
|
||||
/**
|
||||
* @brief Read the gesture detected
|
||||
*
|
||||
* @param[in] dev Device descriptor of the FT5X06
|
||||
* @param[out] gesture Gesture ID
|
||||
*
|
||||
* @return 0 on success
|
||||
* @return -EPROTO on any bus error
|
||||
*/
|
||||
int ft5x06_read_touch_gesture(const ft5x06_t *dev, ft5x06_touch_gesture_t *gesture);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* FT5X06_H */
|
||||
/** @} */
|
||||
52
sys/auto_init/screen/auto_init_ft5x06.c
Normal file
52
sys/auto_init/screen/auto_init_ft5x06.c
Normal file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Inria
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup sys_auto_init
|
||||
* @{
|
||||
* @file
|
||||
* @brief initializes ft5x06 touch panel device
|
||||
*
|
||||
* @author Alexandre Abadie <alexandre.abadie@inria.fr>
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include "log.h"
|
||||
|
||||
#include "touch_dev.h"
|
||||
|
||||
#include "ft5x06.h"
|
||||
#include "ft5x06_params.h"
|
||||
#include "ft5x06_touch_dev.h"
|
||||
|
||||
#define FT5X06_NUMOF ARRAY_SIZE(ft5x06_params)
|
||||
|
||||
ft5x06_t ft5x06_devs[FT5X06_NUMOF];
|
||||
static touch_dev_reg_t touch_dev_entries[FT5X06_NUMOF];
|
||||
|
||||
void auto_init_ft5x06(void)
|
||||
{
|
||||
assert(FT5X06_NUMOF == ARRAY_SIZE(ft5x06_screen_ids));
|
||||
|
||||
for (size_t i = 0; i < FT5X06_NUMOF; i++) {
|
||||
LOG_DEBUG("[auto_init_screen] initializing ft5x06 #%u\n", i);
|
||||
if (ft5x06_init(&ft5x06_devs[i], &ft5x06_params[i], NULL, NULL) < 0) {
|
||||
LOG_ERROR("[auto_init_screen] error initializing ft5x06 #%u\n", i);
|
||||
continue;
|
||||
}
|
||||
|
||||
touch_dev_entries[i].dev = (touch_dev_t *)&ft5x06_devs[i];
|
||||
touch_dev_entries[i].screen_id = ft5x06_screen_ids[i];
|
||||
touch_dev_entries[i].dev->driver = &ft5x06_touch_dev_driver;
|
||||
|
||||
/* add to touch_dev registry */
|
||||
touch_dev_reg_add(&(touch_dev_entries[i]));
|
||||
}
|
||||
}
|
||||
@ -18,7 +18,7 @@
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#define ENABLE_DEBUG (0)
|
||||
#define ENABLE_DEBUG 0
|
||||
#include "debug.h"
|
||||
|
||||
void auto_init_screen(void)
|
||||
@ -41,6 +41,10 @@ void auto_init_screen(void)
|
||||
extern void auto_init_stmpe811(void);
|
||||
auto_init_stmpe811();
|
||||
}
|
||||
if (IS_USED(MODULE_FT5X06)) {
|
||||
extern void auto_init_ft5x06(void);
|
||||
auto_init_ft5x06();
|
||||
}
|
||||
}
|
||||
|
||||
if (IS_USED(MODULE_LVGL)) {
|
||||
|
||||
7
tests/driver_ft5x06/Makefile
Normal file
7
tests/driver_ft5x06/Makefile
Normal file
@ -0,0 +1,7 @@
|
||||
BOARD ?= stm32f746g-disco
|
||||
include ../Makefile.tests_common
|
||||
|
||||
DRIVER ?= ft5336
|
||||
USEMODULE += $(DRIVER)
|
||||
|
||||
include $(RIOTBASE)/Makefile.include
|
||||
3
tests/driver_ft5x06/Makefile.ci
Normal file
3
tests/driver_ft5x06/Makefile.ci
Normal file
@ -0,0 +1,3 @@
|
||||
BOARD_INSUFFICIENT_MEMORY := \
|
||||
nucleo-l011k4 \
|
||||
#
|
||||
3
tests/driver_ft5x06/app.config.test
Normal file
3
tests/driver_ft5x06/app.config.test
Normal file
@ -0,0 +1,3 @@
|
||||
# this file enables modules defined in Kconfig. Do not use this file for
|
||||
# application configuration. This is only needed during migration.
|
||||
CONFIG_MODULE_FT5336=y
|
||||
89
tests/driver_ft5x06/main.c
Normal file
89
tests/driver_ft5x06/main.c
Normal file
@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Inria
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup tests
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Test application for the ft5x06 touch driver
|
||||
*
|
||||
* @author Alexandre Abadie <alexandre.abadie@inria.fr>
|
||||
*
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "mutex.h"
|
||||
|
||||
#include "ft5x06.h"
|
||||
#include "ft5x06_params.h"
|
||||
|
||||
static void _touch_event_cb(void *arg)
|
||||
{
|
||||
mutex_unlock(arg);
|
||||
}
|
||||
|
||||
static ft5x06_touch_position_t positions[FT5X06_TOUCHES_COUNT_MAX];
|
||||
|
||||
int main(void)
|
||||
{
|
||||
mutex_t lock = MUTEX_INIT_LOCKED;
|
||||
ft5x06_t dev;
|
||||
|
||||
puts("FT5x06 test application\n");
|
||||
|
||||
printf("+------------Initializing------------+\n");
|
||||
int ret = ft5x06_init(&dev, &ft5x06_params[0], _touch_event_cb, &lock);
|
||||
if (ret != 0) {
|
||||
puts("[Error] Initialization failed");
|
||||
return 1;
|
||||
}
|
||||
|
||||
puts("Initialization successful");
|
||||
|
||||
uint8_t current_touch_count = 0;
|
||||
ft5x06_read_touch_count(&dev, ¤t_touch_count);
|
||||
uint8_t last_touch_count = current_touch_count;
|
||||
|
||||
while (1) {
|
||||
|
||||
/* wait for touch event */
|
||||
mutex_lock(&lock);
|
||||
|
||||
ft5x06_read_touch_count(&dev, ¤t_touch_count);
|
||||
|
||||
if (current_touch_count != last_touch_count) {
|
||||
if (current_touch_count) {
|
||||
printf("%d touch detected\n", current_touch_count);
|
||||
}
|
||||
if (!current_touch_count) {
|
||||
puts("Released!");
|
||||
}
|
||||
last_touch_count = current_touch_count;
|
||||
}
|
||||
|
||||
ft5x06_touch_gesture_t gesture;
|
||||
ft5x06_read_touch_gesture(&dev, &gesture);
|
||||
if (gesture != FT5X06_TOUCH_NO_GESTURE) {
|
||||
printf("Gesture detected: %d\n", gesture);
|
||||
}
|
||||
|
||||
/* Display touch positions if there are some */
|
||||
if (current_touch_count > 0) {
|
||||
ft5x06_read_touch_positions(&dev, positions, current_touch_count);
|
||||
for (uint8_t touch = 0; touch < current_touch_count; touch++) {
|
||||
printf("Touch %d - X: %i, Y:%i\n",
|
||||
touch + 1, positions[touch].x, positions[touch].y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user