STM32F429i Discovery: Add support for NxWM on STM32F429i-Disco board

This commit is contained in:
Alan Carvalho de Assis 2017-01-07 08:17:44 -06:00 committed by Gregory Nutt
parent feacfeae25
commit 530ec2e967
8 changed files with 2320 additions and 0 deletions

View File

@ -224,6 +224,11 @@
#define GPIO_TIM4_CH2OUT GPIO_TIM4_CH2OUT_2
/* I2C - There is a STMPE811 TouchPanel on I2C3 using these pins: */
#define GPIO_I2C3_SCL GPIO_I2C3_SCL_1
#define GPIO_I2C3_SDA GPIO_I2C3_SDA_1
/* SPI - There is a MEMS device on SPI5 using these pins: */
#define GPIO_SPI5_MISO GPIO_SPI5_MISO_1

View File

@ -0,0 +1,112 @@
############################################################################
# configs/stm32f429i-disco/nxwm/Make.defs
#
# Copyright (C) 2017 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.
#
############################################################################
include ${TOPDIR}/.config
include ${TOPDIR}/tools/Config.mk
include ${TOPDIR}/arch/arm/src/armv7-m/Toolchain.defs
LDSCRIPT = ld.script
ifeq ($(WINTOOL),y)
# Windows-native toolchains
DIRLINK = $(TOPDIR)/tools/copydir.sh
DIRUNLINK = $(TOPDIR)/tools/unlink.sh
MKDEP = $(TOPDIR)/tools/mkwindeps.sh
ARCHINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}"
ARCHXXINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}" -isystem "${shell cygpath -w $(TOPDIR)/include/cxx}"
ARCHSCRIPT = -T "${shell cygpath -w $(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/$(LDSCRIPT)}"
else
# Linux/Cygwin-native toolchain
MKDEP = $(TOPDIR)/tools/mkdeps$(HOSTEXEEXT)
ARCHINCLUDES = -I. -isystem $(TOPDIR)/include
ARCHXXINCLUDES = -I. -isystem $(TOPDIR)/include -isystem $(TOPDIR)/include/cxx
ARCHSCRIPT = -T$(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/$(LDSCRIPT)
endif
CC = $(CROSSDEV)gcc
CXX = $(CROSSDEV)g++
CPP = $(CROSSDEV)gcc -E
LD = $(CROSSDEV)ld
AR = $(ARCROSSDEV)ar rcs
NM = $(ARCROSSDEV)nm
OBJCOPY = $(CROSSDEV)objcopy
OBJDUMP = $(CROSSDEV)objdump
ARCHCCVERSION = ${shell $(CC) -v 2>&1 | sed -n '/^gcc version/p' | sed -e 's/^gcc version \([0-9\.]\)/\1/g' -e 's/[-\ ].*//g' -e '1q'}
ARCHCCMAJOR = ${shell echo $(ARCHCCVERSION) | cut -d'.' -f1}
ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
ARCHOPTIMIZATION = -g
endif
ifneq ($(CONFIG_DEBUG_NOOPT),y)
ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -fno-strength-reduce -fomit-frame-pointer
endif
ARCHCFLAGS = -fno-builtin
ARCHCXXFLAGS = -fno-builtin -fno-exceptions -fcheck-new -fno-rtti
ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef
ARCHWARNINGSXX = -Wall -Wshadow -Wundef
ARCHDEFINES =
ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10
CFLAGS = $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe
CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS)
CXXFLAGS = $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe
CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS)
CPPFLAGS = $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES)
AFLAGS = $(CFLAGS) -D__ASSEMBLY__
NXFLATLDFLAGS1 = -r -d -warn-common
NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections
LDNXFLATFLAGS = -e main -s 2048
ASMEXT = .S
OBJEXT = .o
LIBEXT = .a
EXEEXT =
ifneq ($(CROSSDEV),arm-nuttx-elf-)
LDFLAGS += -nostartfiles -nodefaultlibs
endif
ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
LDFLAGS += -g
endif
HOSTCC = gcc
HOSTINCLUDES = -I.
HOSTCFLAGS = -Wall -Wstrict-prototypes -Wshadow -Wundef -g -pipe
HOSTLDFLAGS =

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,80 @@
#!/bin/bash
# configs/stm32f429i-disco/nxwm/setenv.sh
#
# Copyright (C) 2017 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.
#
if [ "$_" = "$0" ] ; then
echo "You must source this script, not run it!" 1>&2
exit 1
fi
WD=`pwd`
if [ ! -x "setenv.sh" ]; then
echo "This script must be executed from the top-level NuttX build directory"
exit 1
fi
if [ -z "${PATH_ORIG}" ]; then
export PATH_ORIG="${PATH}"
fi
# This is the Cygwin path to the location where I installed the CodeSourcery
# toolchain under windows. You will also have to edit this if you install
# the CodeSourcery toolchain in any other location
#export TOOLCHAIN_BIN="/cygdrive/c/Program Files (x86)/CodeSourcery/Sourcery G++ Lite/bin"
# export TOOLCHAIN_BIN="/cygdrive/c/Program Files (x86)/CodeSourcery/Sourcery_CodeBench_Lite_for_ARM_EABI/bin"
#export TOOLCHAIN_BIN="/cygdrive/c/Users/MyName/MentorGraphics/Sourcery_CodeBench_Lite_for_ARM_EABI/bin"
# These are the Cygwin paths to the locations where I installed the Atollic
# toolchain under windows. You will also have to edit this if you install
# the Atollic toolchain in any other location. /usr/bin is added before
# the Atollic bin path because there is are binaries named gcc.exe and g++.exe
# at those locations as well.
#export TOOLCHAIN_BIN="/usr/bin:/cygdrive/c/Program Files (x86)/Atollic/TrueSTUDIO for ARM Pro 2.3.0/ARMTools/bin"
#export TOOLCHAIN_BIN="/usr/bin:/cygdrive/c/Program Files (x86)/Atollic/TrueSTUDIO for STMicroelectronics STM32 Lite 2.3.0/ARMTools/bin"
# This is the location where I installed the ARM "GNU Tools for ARM Embedded Processors"
# You can this free toolchain here https://launchpad.net/gcc-arm-embedded
export TOOLCHAIN_BIN="/cygdrive/c/Program Files (x86)/GNU Tools ARM Embedded/4.9 2015q2/bin"
# This is the path to the location where I installed the devkitARM toolchain
# You can get this free toolchain from http://devkitpro.org/ or http://sourceforge.net/projects/devkitpro/
#export TOOLCHAIN_BIN="/cygdrive/c/Program Files (x86)/devkitARM/bin"
# This is the Cygwin path to the location where I build the buildroot
# toolchain.
#export TOOLCHAIN_BIN="${WD}/../buildroot/build_arm_nofpu/staging_dir/bin"
# Add the path to the toolchain to the PATH varialble
export PATH="${TOOLCHAIN_BIN}:/sbin:/usr/sbin:${PATH_ORIG}"
echo "PATH : ${PATH}"

View File

@ -64,6 +64,10 @@ ifeq ($(CONFIG_STM32_OTGHS),y)
CSRCS += stm32_usb.c
endif
ifeq ($(CONFIG_INPUT_STMPE811),y)
CSRCS += stm32_stmpe811.c
endif
ifeq ($(CONFIG_STM32F429I_DISCO_ILI9341),y)
CSRCS += stm32_ili93414ws.c
endif

View File

@ -52,6 +52,77 @@
* Pre-processor Definitions
************************************************************************************/
/* Configuration ********************************************************************/
/* Should we initialize the NX server using nx_start? This is done for NxWidgets
* (CONFIG_NXWIDGETS=y) and if the NxWidget::CNxServer class expects the RTOS do the
* the NX initialization (CONFIG_NXWIDGET_SERVERINIT=n). This combination of
* settings is normally only used in the kernel build mode* (CONFIG_BUILD_PROTECTED)
* when NxWidgets is unable to initialize NX from user-space.
*/
#undef HAVE_NXSTART
#if !defined(CONFIG_NX_MULTIUSER)
# undef CONFIG_NX_START
#endif
#if defined(CONFIG_NXWIDGETS) && !defined(CONFIG_NXWIDGET_SERVERINIT)
# define HAVE_NXSTART
# include <nuttx/nx/nx.h>
#endif
/* Should we initialize the touchscreen for the NxWM (CONFIG_NXWM=y)? This
* is done if we have a touchscreen (CONFIG_INPUT_STMPE811=y), NxWM uses the
* touchscreen (CONFIG_NXWM_TOUCHSCREEN=y), and if we were asked to
* initialize the touchscreen for NxWM (NXWM_TOUCHSCREEN_DEVINIT=n). This
* combination of settings is normally only used in the kernel build mode
* (CONFIG_BUILD_PROTECTED) when NxWidgets is unable to initialize NX from
* user-space.
*/
#undef HAVE_TCINIT
#if defined(CONFIG_NXWM_TOUCHSCREEN)
# if !defined(CONFIG_NXWM_TOUCHSCREEN_DEVNO)
# error CONFIG_NXWM_TOUCHSCREEN_DEVNO is not defined
# elif defined(CONFIG_INPUT_STMPE811)
# if !defined(CONFIG_NXWM_TOUCHSCREEN_DEVINIT)
# define HAVE_TCINIT
# include <nuttx/input/touchscreen.h>
# endif
# else
# if !defined(CONFIG_NXWM_TOUCHSCREEN_DEVINIT) && defined(CONFIG_BUILD_PROTECTED)
# error CONFIG_INPUT_STMPE811=y is needed
# endif
# endif
#endif
/* Check if we will need to support the initialization kernel thread */
#undef HAVE_INITTHREAD
#ifdef CONFIG_BOARD_INITIALIZE
# if defined(CONFIG_NSH_LIBRARY) && !defined(CONFIG_LIB_BOARDCTL)
# define HAVE_INITTHREAD 1
# elif defined(HAVE_NXSTART)
# define HAVE_INITTHREAD 1
# elif defined(HAVE_TCINIT)
# define HAVE_INITTHREAD 1
# endif
#endif
#ifdef HAVE_INITTHREAD
# include <stdlib.h>
# include <assert.h>
# include <nuttx/kthread.h>
# ifndef CONFIG_STM32F429I_DISCO_BOARDINIT_PRIO
# define CONFIG_STM32F429I_DISCO_BOARDINIT_PRIO 196
# endif
# ifndef CONFIG_STM32F429I_DISCO_BOARDINIT_STACK
# define CONFIG_STM32F429I_DISCO_BOARDINIT_STACK 2048
# endif
#endif
/************************************************************************************
* Private Functions
************************************************************************************/
@ -131,6 +202,17 @@ void stm32_boardinitialize(void)
#ifdef CONFIG_BOARD_INITIALIZE
void board_initialize(void)
{
#ifdef HAVE_INITTHREAD
pid_t server;
/* Start the board initialization kernel thread */
server = kernel_thread("Board Init", CONFIG_STM32F429I_DISCO_BOARDINIT_PRIO,
CONFIG_STM32F429I_DISCO_BOARDINIT_STACK, board_initthread,
NULL);
ASSERT(server > 0);
#endif
#ifdef CONFIG_STM32F429I_DISCO_ILI9341_FBIFACE
/* Initialize the framebuffer driver */

View File

@ -0,0 +1,357 @@
/************************************************************************************
* configs/stm32f429i-disco/src/stm32_stmpe811.c
*
* Copyright (C) 2017 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 <stdbool.h>
#include <stdio.h>
#include <debug.h>
#include <errno.h>
#include <nuttx/board.h>
#include <nuttx/i2c/i2c_master.h>
#include <nuttx/input/touchscreen.h>
#include <nuttx/input/stmpe811.h>
#include <nuttx/irq.h>
#include "stm32.h"
#include "stm32f429i-disco.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Configuration ************************************************************/
#ifdef CONFIG_INPUT_STMPE811
#ifndef CONFIG_INPUT
# error "STMPE811 support requires CONFIG_INPUT"
#endif
#ifndef CONFIG_STM32_I2C3
# error "STMPE811 support requires CONFIG_STM32_I2C3"
#endif
#ifndef CONFIG_STMPE811_I2C
# error "Only the STMPE811 I2C interface is supported"
#endif
#ifdef CONFIG_STMPE811_SPI
# error "Only the STMPE811 SPI interface is supported"
#endif
#ifndef CONFIG_STMPE811_FREQUENCY
# define CONFIG_STMPE811_FREQUENCY 100000
#endif
#ifndef CONFIG_STMPE811_I2CDEV
# define CONFIG_STMPE811_I2CDEV 3
#endif
#if CONFIG_STMPE811_I2CDEV != 3
# error "CONFIG_STMPE811_I2CDEV must be three"
#endif
#ifndef CONFIG_STMPE811_DEVMINOR
# define CONFIG_STMPE811_DEVMINOR 0
#endif
/* Board definitions ********************************************************/
/* The STM3240G-EVAL has two STMPE811QTR I/O expanders on board both connected
* to the STM32 via I2C1. They share a common interrupt line: PI2.
*
* STMPE811 U24, I2C address 0x41 (7-bit)
* ------ ---- ---------------- --------------------------------------------
* STPE11 PIN BOARD SIGNAL BOARD CONNECTION
* ------ ---- ---------------- --------------------------------------------
* Y- TouchScreen_Y- LCD Connector XL
* X- TouchScreen_X- LCD Connector XR
* Y+ TouchScreen_Y+ LCD Connector XD
* X+ TouchScreen_X+ LCD Connector XU
* IN3 EXP_IO9
* IN2 EXP_IO10
* IN1 EXP_IO11
* IN0 EXP_IO12
*
* STMPE811 U29, I2C address 0x44 (7-bit)
* ------ ---- ---------------- --------------------------------------------
* STPE11 PIN BOARD SIGNAL BOARD CONNECTION
* ------ ---- ---------------- --------------------------------------------
* Y- EXP_IO1
* X- EXP_IO2
* Y+ EXP_IO3
* X+ EXP_IO4
* IN3 EXP_IO5
* IN2 EXP_IO6
* IN1 EXP_IO7
* IN0 EXP_IO8
*/
/****************************************************************************
* Private Types
****************************************************************************/
struct stm32_stmpe811config_s
{
/* Configuration structure as seen by the STMPE811 driver */
struct stmpe811_config_s config;
/* Additional private definitions only known to this driver */
STMPE811_HANDLE handle; /* The STMPE811 driver handle */
xcpt_t handler; /* The STMPE811 interrupt handler */
};
/****************************************************************************
* Static Function Prototypes
****************************************************************************/
/* IRQ/GPIO access callbacks. These operations all hidden behind callbacks
* to isolate the STMPE811 driver from differences in GPIO
* interrupt handling by varying boards and MCUs.* so that contact and loss-
* of-contact events can be detected.
*
* attach - Attach the STMPE811 interrupt handler to the GPIO interrupt
* enable - Enable or disable the GPIO interrupt
* clear - Acknowledge/clear any pending GPIO interrupt
*/
static int stmpe811_attach(FAR struct stmpe811_config_s *state, xcpt_t isr);
static void stmpe811_enable(FAR struct stmpe811_config_s *state, bool enable);
static void stmpe811_clear(FAR struct stmpe811_config_s *state);
/****************************************************************************
* Private Data
****************************************************************************/
/* A reference to a structure of this type must be passed to the STMPE811
* driver. This structure provides information about the configuration
* of the STMPE811 and provides some board-specific hooks.
*
* Memory for this structure is provided by the caller. It is not copied
* by the driver and is presumed to persist while the driver is active. The
* memory must be writable because, under certain circumstances, the driver
* may modify frequency or X plate resistance values.
*/
#ifndef CONFIG_STMPE811_TSC_DISABLE
static struct stm32_stmpe811config_s g_stmpe811config =
{
.config =
{
#ifdef CONFIG_STMPE811_I2C
.address = STMPE811_ADDR1,
#endif
.frequency = CONFIG_STMPE811_FREQUENCY,
#ifdef CONFIG_STMPE811_MULTIPLE
.irq = STM32_IRQ_EXTI2,
#endif
.ctrl1 = (ADC_CTRL1_SAMPLE_TIME_80 | ADC_CTRL1_MOD_12B),
.ctrl2 = ADC_CTRL2_ADC_FREQ_3p25,
.attach = stmpe811_attach,
.enable = stmpe811_enable,
.clear = stmpe811_clear,
},
.handler = NULL,
};
#endif
/****************************************************************************
* Private Functions
****************************************************************************/
/* IRQ/GPIO access callbacks. These operations all hidden behind
* callbacks to isolate the STMPE811 driver from differences in GPIO
* interrupt handling by varying boards and MCUs.
*
* attach - Attach the STMPE811 interrupt handler to the GPIO interrupt
* enable - Enable or disable the GPIO interrupt
* clear - Acknowledge/clear any pending GPIO interrupt
*/
static int stmpe811_attach(FAR struct stmpe811_config_s *state, xcpt_t isr)
{
FAR struct stm32_stmpe811config_s *priv =
(FAR struct stm32_stmpe811config_s *)state;
iinfo("Saving handler %p\n", isr);
DEBUGASSERT(priv);
/* Just save the handler. We will use it when EXTI interruptsare enabled */
priv->handler = isr;
return OK;
}
static void stmpe811_enable(FAR struct stmpe811_config_s *state, bool enable)
{
FAR struct stm32_stmpe811config_s *priv =
(FAR struct stm32_stmpe811config_s *)state;
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_IO_EXPANDER, true, true, true,
priv->handler);
}
else
{
/* Configure the EXTI interrupt with a NULL handler to disable it */
(void)stm32_gpiosetevent(GPIO_IO_EXPANDER, false, false, false, NULL);
}
leave_critical_section(flags);
}
static void stmpe811_clear(FAR struct stmpe811_config_s *state)
{
/* Does nothing */
}
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: board_tsc_setup
*
* Description:
* Each board that supports a touchscreen device must provide this function.
* This function is called by application-specific, setup 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 board_tsc_setup(int minor)
{
#ifndef CONFIG_STMPE811_TSC_DISABLE
FAR struct i2c_master_s *dev;
int ret;
iinfo("minor %d\n", minor);
DEBUGASSERT(minor == 0);
/* Check if we are already initialized */
if (!g_stmpe811config.handle)
{
iinfo("Initializing\n");
/* Configure the STMPE811 interrupt pin as an input */
(void)stm32_configgpio(GPIO_IO_EXPANDER);
/* Get an instance of the I2C interface */
dev = stm32_i2cbus_initialize(CONFIG_STMPE811_I2CDEV);
if (!dev)
{
ierr("ERROR: Failed to initialize I2C bus %d\n", CONFIG_STMPE811_I2CDEV);
return -ENODEV;
}
/* Instantiate the STMPE811 driver */
g_stmpe811config.handle =
stmpe811_instantiate(dev, (FAR struct stmpe811_config_s *)&g_stmpe811config);
if (!g_stmpe811config.handle)
{
ierr("ERROR: Failed to instantiate the STMPE811 driver\n");
return -ENODEV;
}
/* Initialize and register the I2C touchscreen device */
ret = stmpe811_register(g_stmpe811config.handle, CONFIG_STMPE811_DEVMINOR);
if (ret < 0)
{
ierr("ERROR: Failed to register STMPE driver: %d\n", ret);
/* stm32_i2cbus_uninitialize(dev); */
return -ENODEV;
}
}
return OK;
#else
return -ENOSYS;
#endif
}
/****************************************************************************
* Name: board_tsc_teardown
*
* Description:
* Each board that supports a touchscreen device must provide this function.
* This function is called by application-specific, setup logic to
* uninitialize the touchscreen device.
*
* Input Parameters:
* None
*
* Returned Value:
* None.
*
****************************************************************************/
void board_tsc_teardown(void)
{
/* No support for un-initializing the touchscreen STMPE811 device yet */
}
#endif /* CONFIG_INPUT_STMPE811 */

View File

@ -66,6 +66,16 @@
# undef CONFIG_STM32_SPI3
#endif
/* STMPE811 on I2C3 */
//#define GPIO_I2C3_SCL GPIO_I2C3_SCL_1
//#define GPIO_I2C3_SDA GPIO_I2C3_SDA_1
#define STMPE811_ADDR1 0x41
#define STMPE811_ADDR2 0x44
#define GPIO_IO_EXPANDER (GPIO_INPUT|GPIO_FLOAT|GPIO_EXTI|GPIO_PORTA|GPIO_PIN15)
/* STM32F429 Discovery GPIOs **************************************************************************/
/* LEDs */