1
0
Fork 0
forked from nuttx/nuttx-update

Merged in plwm/nuttx/stm32f746g-disco-touchscreen (pull request #701)

stm32f746g-disco: touchscreen support

* fixed FT5x06 driver to correctly close (previously it unregistered interrupt handler during close)
* added LittlevGL demo for STM32F746G-DISCO

Approved-by: GregoryN <gnutt@nuttx.org>
This commit is contained in:
Marcin Wyrwas 2018-08-01 21:31:39 +00:00 committed by GregoryN
parent 5dec4a6763
commit 18ca531b40
9 changed files with 436 additions and 6 deletions

View file

@ -524,3 +524,18 @@ Configuration Directories
configuration. This configuration uses USART1 for the serial console.
USART1 is connected to the ST-link virtual com inside board.h to remove
the need of a extra serial connection to use this board.
lgvl
----
STM32F746G-DISCO LittlevGL demo example.
The LTDC is initialized during boot up.
This configuration uses USART1 for the serial console.
USART1 is connected to the ST-link virtual com inside board.h to remove
the need of a extra serial connection to use this board.
From the nsh comand line execute the lvgldemo example:
nsh> lvgldemo
The test will execute the calibration process and then run the
LittlevGL demo project.

View file

@ -29,7 +29,6 @@ CONFIG_HAVE_CXX=y
CONFIG_HAVE_CXXINITIALIZE=y
CONFIG_HOST_WINDOWS=y
CONFIG_INTELHEX_BINARY=y
CONFIG_LCD=y
CONFIG_MAX_TASKS=16
CONFIG_MAX_WDOGPARMS=2
CONFIG_MM_REGIONS=3

View file

@ -348,6 +348,15 @@
#define GPIO_USART1_RX GPIO_USART1_RX_2
#define GPIO_USART1_TX GPIO_USART1_TX_1
/* I2C - There is a FT5336 TouchPanel on I2C3 using these pins: */
#define GPIO_I2C3_SCL GPIO_I2C3_SCL_2
#define GPIO_I2C3_SDA GPIO_I2C3_SDA_2
#define GPIO_TP_INT (GPIO_INPUT|GPIO_FLOAT|GPIO_EXTI|GPIO_PORTI|GPIO_PIN13)
#define FT5x06_I2C_ADDRESS 0x38
/* The STM32 F7 connects to a SMSC LAN8742A PHY using these pins:
*
* STM32 F7 BOARD LAN8742A

View file

@ -0,0 +1,67 @@
# CONFIG_ARCH_FPU is not set
# CONFIG_NSH_DISABLE_IFCONFIG is not set
# CONFIG_NSH_DISABLE_PS is not set
# CONFIG_NX_DISABLE_16BPP is not set
# CONFIG_STM32F7_FB_CMAP is not set
# CONFIG_STM32F7_LTDC_L2 is not set
CONFIG_ARCH="arm"
CONFIG_ARCH_BOARD="stm32f746g-disco"
CONFIG_ARCH_BOARD_STM32F746G_DISCO=y
CONFIG_ARCH_BUTTONS=y
CONFIG_ARCH_CHIP_STM32F746NG=y
CONFIG_ARCH_CHIP_STM32F7=y
CONFIG_ARCH_STACKDUMP=y
CONFIG_ARMV7M_DCACHE=y
CONFIG_ARMV7M_DCACHE_WRITETHROUGH=y
CONFIG_ARMV7M_DTCM=y
CONFIG_ARMV7M_ICACHE=y
CONFIG_BOARD_INITIALIZE=y
CONFIG_BOARD_LOOPSPERMSEC=43103
CONFIG_BUILTIN=y
CONFIG_DEBUG_FULLOPT=y
CONFIG_DEBUG_SYMBOLS=y
CONFIG_DISABLE_POLL=y
CONFIG_DRIVERS_VIDEO=y
CONFIG_EXAMPLES_FB=y
CONFIG_EXAMPLES_LVGLDEMO=y
CONFIG_EXAMPLES_NSH=y
CONFIG_EXAMPLES_NSH_CXXINITIALIZE=y
CONFIG_EXAMPLES_TOUCHSCREEN=y
CONFIG_FT5X06_SINGLEPOINT=y
CONFIG_FT5X06_SWAPXY=y
CONFIG_GRAPHICS_LVGL=y
CONFIG_HAVE_CXX=y
CONFIG_HAVE_CXXINITIALIZE=y
CONFIG_INPUT=y
CONFIG_INPUT_FT5X06=y
CONFIG_INTELHEX_BINARY=y
CONFIG_LV_DPI=72
CONFIG_LV_HOR_RES=480
CONFIG_LV_VER_RES=272
CONFIG_MAX_TASKS=16
CONFIG_MAX_WDOGPARMS=2
CONFIG_MM_REGIONS=3
CONFIG_MQ_MAXMSGSIZE=256
CONFIG_NSH_BUILTIN_APPS=y
CONFIG_NSH_FILEIOSIZE=512
CONFIG_NSH_LINELEN=64
CONFIG_PREALLOC_MQ_MSGS=4
CONFIG_PREALLOC_TIMERS=4
CONFIG_PREALLOC_WDOGS=4
CONFIG_RAM_SIZE=245760
CONFIG_RAM_START=0x20010000
CONFIG_RAW_BINARY=y
CONFIG_RR_INTERVAL=200
CONFIG_SCHED_HPWORK=y
CONFIG_SCHED_WAITPID=y
CONFIG_SDCLONE_DISABLE=y
CONFIG_STM32F7_FMC=y
CONFIG_STM32F7_I2C3=y
CONFIG_STM32F7_LTDC=y
CONFIG_STM32F7_LTDC_FB_BASE=0xc0000000
CONFIG_STM32F7_LTDC_FB_SIZE=261120
CONFIG_STM32F7_USART1=y
CONFIG_USART1_SERIAL_CONSOLE=y
CONFIG_USER_ENTRYPOINT="nsh_main"
CONFIG_VIDEO_FB=y
CONFIG_WDOG_INTRESERVE=0

View file

@ -72,4 +72,8 @@ ifeq ($(CONFIG_STM32F7_FMC),y)
CSRCS += stm32_extmem.c
endif
ifeq ($(CONFIG_INPUT_FT5X06),y)
CSRCS += stm32_touchscreen.c
endif
include $(TOPDIR)/configs/Board.mk

View file

@ -129,5 +129,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;
}

View file

@ -0,0 +1,310 @@
/************************************************************************************
* configs/stm32f746g-disco/src/stm32_touchscreen.c
*
* Copyright (C) 2018 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
************************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <debug.h>
#include <errno.h>
#include <nuttx/input/ft5x06.h>
#include "stm32_gpio.h"
#include "stm32_i2c.h"
#include <arch/board/board.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#define FT5x06_FREQUENCY 100000 /* For now, will boost later */
#ifdef CONFIG_INPUT_FT5X06
#ifndef CONFIG_INPUT
# error "FT5x06 support requires CONFIG_INPUT"
#endif
#ifndef CONFIG_STM32F7_I2C3
# error "FT5x06 support requires CONFIG_STM32F7_I2C3"
#endif
#ifndef CONFIG_FT5X06_I2CDEV
# define CONFIG_FT5X06_I2CDEV 3
#endif
#if CONFIG_FT5X06_I2CDEV != 3
# error "CONFIG_FT5X06_I2CDEV must be three"
#endif
#ifndef CONFIG_FT5X06_DEVMINOR
# define CONFIG_FT5X06_DEVMINOR 0
#endif
/****************************************************************************
* Private Types
****************************************************************************/
struct stm32_ft5x06_config_s
{
xcpt_t handler; /* The FT5x06 interrupt handler */
FAR void *arg; /* Interrupt handler argument */
};
/****************************************************************************
* Private Function Ptototypes
****************************************************************************/
#ifndef CONFIG_FT5X06_POLLMODE
static int stm32_ft5x06_attach(FAR const struct ft5x06_config_s *config,
xcpt_t isr, FAR void *arg);
static void stm32_ft5x06_enable(FAR const struct ft5x06_config_s *config,
bool enable);
static void stm32_ft5x06_clear(FAR const struct ft5x06_config_s *config);
#endif
static void stm32_ft5x06_wakeup(FAR const struct ft5x06_config_s *config);
static void stm32_ft5x06_nreset(FAR const struct ft5x06_config_s *config,
bool state);
/****************************************************************************
* Private Data
****************************************************************************/
static const struct ft5x06_config_s g_ft5x06_config =
{
.address = FT5x06_I2C_ADDRESS,
.frequency = FT5x06_FREQUENCY,
#ifndef CONFIG_FT5X06_POLLMODE
.attach = stm32_ft5x06_attach,
.enable = stm32_ft5x06_enable,
.clear = stm32_ft5x06_clear,
#endif
.wakeup = stm32_ft5x06_wakeup,
.nreset = stm32_ft5x06_nreset
};
static struct stm32_ft5x06_config_s g_priv_config =
{
.handler = NULL,
.arg = NULL,
};
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: stm32_ft5x06_attach
*
* Description:
* Attach an FT5x06 interrupt handler to a GPIO interrupt
*
****************************************************************************/
#ifndef CONFIG_FT5X06_POLLMODE
static int stm32_ft5x06_attach(FAR const struct ft5x06_config_s *config,
xcpt_t isr, FAR void *arg)
{
iinfo("Saving handler %p\n", isr);
/* Just save the handler. We will use it when EXTI interruptsare enabled */
if (isr)
{
/* Just save the address of the handler for now. The new handler will
* be attached when the interrupt is next enabled.
*/
iinfo("Attaching %p\n", isr);
g_priv_config.handler = isr;
g_priv_config.arg = arg;
}
else
{
iinfo("Detaching %p\n", g_priv_config.handler);
stm32_ft5x06_enable(config, false);
g_priv_config.handler = NULL;
g_priv_config.arg = NULL;
}
return OK;
}
#endif
/****************************************************************************
* Name: stm32_ft5x06_enable
*
* Description:
* Enable or disable a GPIO interrupt
*
****************************************************************************/
#ifndef CONFIG_FT5X06_POLLMODE
static void stm32_ft5x06_enable(FAR const struct ft5x06_config_s *config,
bool enable)
{
irqstate_t flags;
/* Attach and enable, or detach and disable. Enabling and disabling GPIO
* interrupts is a multi-step process so the safest thing is to keep
* interrupts disabled during the reconfiguration.
*/
flags = enter_critical_section();
if (enable)
{
/* Configure the EXTI interrupt using the SAVED handler */
(void)stm32_gpiosetevent(GPIO_TP_INT, true, false, true,
g_priv_config.handler, g_priv_config.arg);
}
else
{
/* Configure the EXTI interrupt with a NULL handler to disable it */
(void)stm32_gpiosetevent(GPIO_TP_INT, false, false, false,
NULL, NULL);
}
leave_critical_section(flags);
}
#endif
/****************************************************************************
* Name: stm32_ft5x06_clear
*
* Description:
* Acknowledge/clear any pending GPIO interrupt
*
****************************************************************************/
#ifndef CONFIG_FT5X06_POLLMODE
static void stm32_ft5x06_clear(FAR const struct ft5x06_config_s *config)
{
/* Does nothing */
}
#endif
/****************************************************************************
* Name: stm32_ft5x06_wakeup
*
* Description:
* Issue WAKE interrupt to FT5x06 to change the FT5x06 from Hibernate to
* Active mode.
*
****************************************************************************/
static void stm32_ft5x06_wakeup(FAR const struct ft5x06_config_s *config)
{
/* We do not have access to the WAKE pin in the implementation */
}
/****************************************************************************
* Name: stm32_ft5x06_nreset
*
* Description:
* Control the chip reset pin
*
****************************************************************************/
static void stm32_ft5x06_nreset(FAR const struct ft5x06_config_s *config,
bool nstate)
{
/* We do not have access to the RESET pin in the implementation */
}
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* 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.
*
****************************************************************************/
int stm32_tsc_setup(int minor)
{
FAR struct i2c_master_s *dev;
int ret;
iinfo("minor %d\n", minor);
DEBUGASSERT(minor == CONFIG_FT5X06_DEVMINOR);
/* Check if we are already initialized */
iinfo("Initializing\n");
/* Configure the FT5X06 interrupt pin as an input */
(void)stm32_configgpio(GPIO_TP_INT);
/* Get an instance of the I2C interface */
dev = stm32_i2cbus_initialize(CONFIG_FT5X06_I2CDEV);
if (!dev)
{
ierr("ERROR: Failed to initialize I2C bus %d\n", CONFIG_FT5X06_I2CDEV);
return -ENODEV;
}
/* Initialize and register the I2C touchscreen device */
ret = ft5x06_register(dev, &g_ft5x06_config, CONFIG_FT5X06_DEVMINOR);
if (ret < 0)
{
ierr("ERROR: Failed to register FT5x06 driver: %d\n", ret);
stm32_i2cbus_uninitialize(dev);
return ret;
}
return OK;
}
#endif /* CONFIG_INPUT_FT5X06 */

View file

@ -173,7 +173,6 @@ void stm32_enablefmc(void);
#endif
/****************************************************************************
* Name: stm32_disablefmc
*
* Description:
@ -185,6 +184,27 @@ void stm32_enablefmc(void);
void stm32_disablefmc(void);
#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 /* __ASSEMBLY__ */
#endif /* __CONFIGS_STM32F746G_DISCO_SRC_STM32F746G_DISCO_H */

View file

@ -780,10 +780,6 @@ static void ft5x06_shutdown(FAR struct ft5x06_dev_s *priv)
config->clear(config);
config->enable(config, false);
/* Attach the interrupt handler */
(void)config->attach(config, NULL, NULL);
#endif
}