STM32 fixes for DM9161 PHY; Enhancements for ADS7843e touchscreen controller
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5199 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
6a744b77a0
commit
8a0899a695
11
ChangeLog
11
ChangeLog
@ -3425,4 +3425,13 @@
|
||||
that samples the position.
|
||||
* drivers/lcd/ssd1289.c: On some platforms we are unable to
|
||||
read the device ID -- reason unknown; workaround in place.
|
||||
|
||||
* drivers/input/ads7843.c: Add thresholding options and an
|
||||
option to swap X and Y positions. Fix some logic errors in
|
||||
the SPI locking/selecting logic.
|
||||
* arch/arm/src/armv7-m/up_systemreset.c: Add logic to reset
|
||||
the Cortex-Mx using the AIRCR register. Contributed by Darcy
|
||||
Gong.
|
||||
* arch/arm/src/stm32/up_eth.c: Add logic specifically for the
|
||||
DM9161 PHY. If the DM9161 failed to initialize, then use the
|
||||
up_sysemreset() logic to reset the MCU. Contributed by Darcy
|
||||
Gong.
|
||||
|
@ -175,7 +175,7 @@
|
||||
#define NVIC_CPUID_BASE_OFFSET 0x0d00 /* CPUID base register */
|
||||
#define NVIC_INTCTRL_OFFSET 0x0d04 /* Interrupt control state register */
|
||||
#define NVIC_VECTAB_OFFSET 0x0d08 /* Vector table offset register */
|
||||
#define NVIC_AIRC_OFFSET 0x0d0c /* Application interrupt/reset contol registr */
|
||||
#define NVIC_AIRCR_OFFSET 0x0d0c /* Application interrupt/reset contol registr */
|
||||
#define NVIC_SYSCON_OFFSET 0x0d10 /* System control register */
|
||||
#define NVIC_CFGCON_OFFSET 0x0d14 /* Configuration control register */
|
||||
#define NVIC_SYSH_PRIORITY_OFFSET(n) (0x0d14 + 4*((n) >> 2))
|
||||
@ -348,7 +348,7 @@
|
||||
#define NVIC_CPUID_BASE (ARMV7M_NVIC_BASE + NVIC_CPUID_BASE_OFFSET)
|
||||
#define NVIC_INTCTRL (ARMV7M_NVIC_BASE + NVIC_INTCTRL_OFFSET)
|
||||
#define NVIC_VECTAB (ARMV7M_NVIC_BASE + NVIC_VECTAB_OFFSET)
|
||||
#define NVIC_AIRC (ARMV7M_NVIC_BASE + NVIC_AIRC_OFFSET)
|
||||
#define NVIC_AIRCR (ARMV7M_NVIC_BASE + NVIC_AIRCR_OFFSET)
|
||||
#define NVIC_SYSCON (ARMV7M_NVIC_BASE + NVIC_SYSCON_OFFSET)
|
||||
#define NVIC_CFGCON (ARMV7M_NVIC_BASE + NVIC_CFGCON_OFFSET)
|
||||
#define NVIC_SYSH_PRIORITY(n) (ARMV7M_NVIC_BASE + NVIC_SYSH_PRIORITY_OFFSET(n))
|
||||
@ -501,12 +501,18 @@
|
||||
#define NVIC_SYSHCON_USGFAULTENA (1 << 18) /* Bit 18: UsageFault enabled */
|
||||
|
||||
/* Application Interrupt and Reset Control Register (AIRCR) */
|
||||
/* Bit 0: Reserved */
|
||||
#define NVIC_AIRC_VECTCLRACTIVE (1 << 1) /* Bit 1: Reserved for debug use */
|
||||
#define NVIC_AIRC_SYSRESETREQ (1 << 2) /* Bit 2: System reset */
|
||||
/* Bits 3-14: Reserved */
|
||||
#define NVIC_AIRC_ENDIANNESS (1 << 15) /* Bit 15: 1=Big endian */
|
||||
/* Bits 16-31: Reserved */
|
||||
|
||||
#define NVIC_AIRCR_VECTRESET (1 << 0) /* Bit 0: VECTRESET */
|
||||
#define NVIC_AIRCR_VECTCLRACTIVE (1 << 1) /* Bit 1: Reserved for debug use */
|
||||
#define NVIC_AIRCR_SYSRESETREQ (1 << 2) /* Bit 2: System reset */
|
||||
/* Bits 2-7: Reserved */
|
||||
#define NVIC_AIRCR_PRIGROUP_SHIFT (8) /* Bits 8-14: PRIGROUP */
|
||||
#define NVIC_AIRCR_PRIGROUP_MASK (7 << NVIC_AIRCR_PRIGROUP_SHIFT)
|
||||
#define NVIC_AIRCR_ENDIANNESS (1 << 15) /* Bit 15: 1=Big endian */
|
||||
#define NVIC_AIRCR_VECTKEY_SHIFT (16) /* Bits 16-31: VECTKEY */
|
||||
#define NVIC_AIRCR_VECTKEY_MASK (0xffff << NVIC_AIRCR_VECTKEY_SHIFT)
|
||||
#define NVIC_AIRCR_VECTKEYSTAT_SHIFT (16) /* Bits 16-31: VECTKEYSTAT */
|
||||
#define NVIC_AIRCR_VECTKEYSTAT_MASK (0xffff << NVIC_AIRCR_VECTKEYSTAT_SHIFT)
|
||||
|
||||
/* Debug Exception and Monitor Control Register (DEMCR) */
|
||||
|
||||
|
79
arch/arm/src/armv7-m/up_systemreset.c
Normal file
79
arch/arm/src/armv7-m/up_systemreset.c
Normal file
@ -0,0 +1,79 @@
|
||||
/****************************************************************************
|
||||
* arch/arm/src/armv7-m/up_systemreset.c
|
||||
*
|
||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
* Darcy Gong
|
||||
*
|
||||
* 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 <stdint.h>
|
||||
|
||||
#include "up_arch.h"
|
||||
#include "nvic.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public functions
|
||||
****************************************************************************/
|
||||
|
||||
void up_systemreset(void)
|
||||
{
|
||||
uint32_t regval;
|
||||
|
||||
/* Set up for the system reset, retaining the priority group from the
|
||||
* the AIRCR register.
|
||||
*/
|
||||
|
||||
regval = getreg32(NVIC_AIRCR) & NVIC_AIRCR_PRIGROUP_MASK;
|
||||
regval |= ((0x5fa << NVIC_AIRCR_VECTKEY_SHIFT) | NVIC_AIRCR_SYSRESETREQ);
|
||||
putreg32(regval, NVIC_AIRCR);
|
||||
|
||||
/* Ensure completion of memory accesses */
|
||||
|
||||
__asm volatile ("dsb");
|
||||
|
||||
/* Wait for the reset */
|
||||
|
||||
for (;;);
|
||||
}
|
@ -241,6 +241,10 @@ extern void up_pminitialize(void);
|
||||
# define up_pminitialize()
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_ARCH_CORTEXM3) || defined(CONFIG_ARCH_CORTEXM4)
|
||||
extern void up_systemreset(void) noreturn_function;
|
||||
#endif
|
||||
|
||||
/* Interrupt handling *******************************************************/
|
||||
|
||||
extern void up_irqinitialize(void);
|
||||
|
@ -269,6 +269,7 @@ config STM32_ETHMAC
|
||||
bool "Ethernet MAC"
|
||||
default n
|
||||
depends on STM32_CONNECTIVITYLINE || STM32_STM32F20XX || STM32_STM32F40XX
|
||||
select ARCH_HAVE_PHY
|
||||
|
||||
config STM32_FSMC
|
||||
bool "FSMC"
|
||||
|
@ -45,8 +45,8 @@ CMN_CSRCS = up_assert.c up_blocktask.c up_copystate.c \
|
||||
up_initialize.c up_initialstate.c up_interruptcontext.c \
|
||||
up_memfault.c up_modifyreg8.c up_modifyreg16.c up_modifyreg32.c \
|
||||
up_releasepending.c up_releasestack.c up_reprioritizertr.c \
|
||||
up_schedulesigaction.c up_sigdeliver.c up_unblocktask.c \
|
||||
up_usestack.c up_doirq.c up_hardfault.c up_svcall.c
|
||||
up_schedulesigaction.c up_sigdeliver.c up_systemreset.c \
|
||||
up_unblocktask.c up_usestack.c up_doirq.c up_hardfault.c up_svcall.c
|
||||
|
||||
ifeq ($(CONFIG_ARMV7M_CMNVECTOR),y)
|
||||
CMN_ASRCS += up_exception.S
|
||||
|
@ -664,6 +664,9 @@ static void stm32_rxdescinit(FAR struct stm32_ethmac_s *priv);
|
||||
|
||||
static int stm32_phyread(uint16_t phydevaddr, uint16_t phyregaddr, uint16_t *value);
|
||||
static int stm32_phywrite(uint16_t phydevaddr, uint16_t phyregaddr, uint16_t value);
|
||||
#ifdef CONFIG_PHY_DM9161
|
||||
static inline int stm32_dm9161(FAR struct stm32_ethmac_s *priv);
|
||||
#endif
|
||||
static int stm32_phyinit(FAR struct stm32_ethmac_s *priv);
|
||||
|
||||
/* MAC/DMA Initialization */
|
||||
@ -2479,6 +2482,72 @@ static int stm32_phywrite(uint16_t phydevaddr, uint16_t phyregaddr, uint16_t val
|
||||
return -ETIMEDOUT;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Function: stm32_dm9161
|
||||
*
|
||||
* Description:
|
||||
* Special workaround for the Davicom DM9161 PHY is required. On power,
|
||||
* up, the PHY is not usually configured correctly but will work after
|
||||
* a powered-up reset. This is really a workaround for some more
|
||||
* fundamental issue with the PHY clocking initialization, but the
|
||||
* root cause has not been studied (nor will it be with this workaround).
|
||||
*
|
||||
* Parameters:
|
||||
* priv - A reference to the private driver state structure
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_PHY_DM9161
|
||||
static inline int stm32_dm9161(FAR struct stm32_ethmac_s *priv)
|
||||
{
|
||||
uint16_t phyval;
|
||||
int ret;
|
||||
|
||||
/* Read the PHYID1 register; A failure to read the PHY ID is one
|
||||
* indication that check if the DM9161 PHY CHIP is not ready.
|
||||
*/
|
||||
|
||||
ret = stm32_phyread(CONFIG_STM32_PHYADDR, MII_PHYID1, &phyval);
|
||||
if (ret < 0)
|
||||
{
|
||||
ndbg("Failed to read the PHY ID1: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* If we failed to read the PHY ID1 register, the reset the MCU to recover */
|
||||
|
||||
else if (phyval == 0xffff)
|
||||
{
|
||||
up_systemreset();
|
||||
}
|
||||
|
||||
nvdbg("PHY ID1: 0x%04X\n", phyval);
|
||||
|
||||
/* Now check the "DAVICOM Specified Configuration Register (DSCR)", Register 16 */
|
||||
|
||||
ret = stm32_phyread(CONFIG_STM32_PHYADDR, 16, &phyval);
|
||||
if (ret < 0)
|
||||
{
|
||||
ndbg("Failed to read the PHY Register 0x10: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Bit 8 of the DSCR register is zero, the the DM9161 has not selected RMII.
|
||||
* If RMII is not selected, then reset the MCU to recover.
|
||||
*/
|
||||
|
||||
else if ((phyval & (1 << 8)) == 0)
|
||||
{
|
||||
up_systemreset();
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Function: stm32_phyinit
|
||||
*
|
||||
@ -2524,6 +2593,16 @@ static int stm32_phyinit(FAR struct stm32_ethmac_s *priv)
|
||||
}
|
||||
up_mdelay(PHY_RESET_DELAY);
|
||||
|
||||
/* Special workaround for the Davicom DM9161 PHY is required. */
|
||||
|
||||
#ifdef CONFIG_PHY_DM9161
|
||||
ret = stm32_dm9161(priv);
|
||||
if (ret < 0)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Perform auto-negotion if so configured */
|
||||
|
||||
#ifdef CONFIG_STM32_AUTONEG
|
||||
|
@ -377,6 +377,11 @@ CONFIG_USART2_2STOP=0
|
||||
# Networking Support
|
||||
#
|
||||
CONFIG_NET=y
|
||||
CONFIG_ARCH_HAVE_PHY=y
|
||||
# CONFIG_PHY_KS8721 is not set
|
||||
# CONFIG_PHY_DP83848C is not set
|
||||
# CONFIG_PHY_LAN8720 is not set
|
||||
CONFIG_PHY_DM9161=y
|
||||
# CONFIG_NET_NOINTS is not set
|
||||
CONFIG_NET_MULTIBUFFER=y
|
||||
# CONFIG_NET_IPv6 is not set
|
||||
|
@ -359,6 +359,13 @@ CONFIG_RTC=y
|
||||
CONFIG_INPUT=y
|
||||
# CONFIG_INPUT_TSC2007 is not set
|
||||
CONFIG_INPUT_ADS7843E=y
|
||||
# CONFIG_ADS7843E_MULTIPLE is not set
|
||||
CONFIG_ADS7843E_SPIMODE=0
|
||||
CONFIG_ADS7843E_FREQUENCY=100000
|
||||
# CONFIG_ADS7843E_SWAPXY is not set
|
||||
CONFIG_ADS7843E_THRESHX=12
|
||||
CONFIG_ADS7843E_THRESHY=12
|
||||
# CONFIG_INPUT_STMPE811 is not set
|
||||
CONFIG_LCD=y
|
||||
# CONFIG_LCD_NOGETRUN is not set
|
||||
CONFIG_LCD_MAXCONTRAST=1
|
||||
@ -418,6 +425,11 @@ CONFIG_USART2_2STOP=0
|
||||
# Networking Support
|
||||
#
|
||||
CONFIG_NET=y
|
||||
CONFIG_ARCH_HAVE_PHY=y
|
||||
# CONFIG_PHY_KS8721 is not set
|
||||
# CONFIG_PHY_DP83848C is not set
|
||||
# CONFIG_PHY_LAN8720 is not set
|
||||
CONFIG_PHY_DM9161=y
|
||||
# CONFIG_NET_NOINTS is not set
|
||||
CONFIG_NET_MULTIBUFFER=y
|
||||
# CONFIG_NET_IPv6 is not set
|
||||
|
@ -201,9 +201,17 @@ static void tsc_clear(FAR struct ads7843e_config_s *state)
|
||||
static bool tsc_busy(FAR struct ads7843e_config_s *state)
|
||||
{
|
||||
/* Hmmm... The ADS7843E BUSY pin is not brought out on the Shenzhou board.
|
||||
* We will most certainly have to revisit this.
|
||||
* We will most certainly have to revisit this. There is this cryptic
|
||||
* statement in the XPT2046 spec: "No DCLK delay required with dedicated
|
||||
* serial port."
|
||||
*
|
||||
* The busy state is used by the ADS7843E driver to control the delay
|
||||
* between sending the command, then reading the returned data.
|
||||
*/
|
||||
|
||||
#if 0
|
||||
up_udelay(1600); /* 1.6MS */
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
# For a description of the syntax of this configuration file,
|
||||
# see misc/tools/kconfig-language.txt.
|
||||
#
|
||||
|
||||
config INPUT_TSC2007
|
||||
bool "TI TSC2007 touchscreen controller"
|
||||
default n
|
||||
@ -9,7 +10,29 @@ config INPUT_TSC2007
|
||||
---help---
|
||||
Enable support for the TI TSC2007 touchscreen controller
|
||||
|
||||
|
||||
if INPUT_TSC2007
|
||||
|
||||
config TSC2007_8BIT
|
||||
bool "8-bit Conversions"
|
||||
default n
|
||||
---help---
|
||||
Use faster, but less accurate, 8-bit conversions. Default: 12-bit conversions.
|
||||
|
||||
config TSC2007_MULTIPLE
|
||||
bool "Multiple TSC2007 Devices"
|
||||
default n
|
||||
---help---
|
||||
Can be defined to support multiple TSC2007 devices on board.
|
||||
|
||||
config TSC2007_NPOLLWAITERS
|
||||
int "Number poll waiters"
|
||||
default 4
|
||||
depends on !DISABLE_POLL
|
||||
---help---
|
||||
Maximum number of threads that can be waiting on poll()
|
||||
|
||||
endif
|
||||
|
||||
config INPUT_ADS7843E
|
||||
bool "TI ADS7843/TSC2046 touchscreen controller"
|
||||
default n
|
||||
@ -18,3 +41,169 @@ config INPUT_ADS7843E
|
||||
Enable support for the TI/Burr-Brown ADS7842 touchscreen controller. I believe
|
||||
that driver should be compatibile with the TI/Burr-Brown TSC2046 and XPT2046
|
||||
touchscreen controllers as well.
|
||||
|
||||
if INPUT_ADS7843E
|
||||
|
||||
config ADS7843E_MULTIPLE
|
||||
bool "Multiple ADS7843E Devices"
|
||||
default n
|
||||
---help---
|
||||
Can be defined to support multiple ADS7843E devices on board.
|
||||
|
||||
config ADS7843E_NPOLLWAITERS
|
||||
int "Number poll waiters"
|
||||
default 4
|
||||
depends on !DISABLE_POLL
|
||||
---help---
|
||||
Maximum number of threads that can be waiting on poll()
|
||||
|
||||
config ADS7843E_SPIMODE
|
||||
int "SPI mode"
|
||||
default 0
|
||||
range 0,3
|
||||
---help---
|
||||
Controls the SPI mode. The device should work in mode 0, but sometimes
|
||||
you need to experiment.
|
||||
|
||||
config ADS7843E_FREQUENCY
|
||||
int "SPI frequency"
|
||||
default 100000
|
||||
---help---
|
||||
Define to use a different SPI bus frequency.
|
||||
|
||||
config ADS7843E_SWAPXY
|
||||
bool "Swap X/Y"
|
||||
default n
|
||||
---help---
|
||||
Reverse the meaning of X and Y to handle different LCD orientations.
|
||||
|
||||
config ADS7843E_THRESHX
|
||||
int "X threshold"
|
||||
default 12
|
||||
---help---
|
||||
New touch positions will only be reported when the X or Y data changes by these
|
||||
thresholds. This trades reduces data rate for some loss in dragging accuracy. For
|
||||
12-bit values so the raw ranges are 0-4095. So for example, if your display is
|
||||
320x240, then THRESHX=13 and THRESHY=17 would correspond to one pixel. Default: 12
|
||||
|
||||
config ADS7843E_THRESHY
|
||||
int "Y threshold"
|
||||
default 12
|
||||
---help---
|
||||
New touch positions will only be reported when the X or Y data changes by these
|
||||
thresholds. This trades reduces data rate for some loss in dragging accuracy. For
|
||||
12-bit values so the raw ranges are 0-4095. So for example, if your display is
|
||||
320x240, then THRESHX=13 and THRESHY=17 would correspond to one pixel. Default: 12
|
||||
|
||||
endif
|
||||
|
||||
config INPUT_STMPE811
|
||||
bool "STMicro STMPE811 Driver"
|
||||
default n
|
||||
---help---
|
||||
Enables support for the STMPE811 driver
|
||||
|
||||
if INPUT_STMPE811
|
||||
|
||||
choice
|
||||
prompt "STMPE Interface"
|
||||
default STMPE811_I2C
|
||||
|
||||
config STMPE811_SPI
|
||||
bool "SPI Interface"
|
||||
select SPI
|
||||
---help---
|
||||
Enables support for the SPI interface (not currently supported)
|
||||
|
||||
config STMPE811_I2C
|
||||
bool "STMPE811 I2C Interface"
|
||||
select I2C
|
||||
---help---
|
||||
Enables support for the I2C interface
|
||||
|
||||
endchoice
|
||||
|
||||
config STMPE811_MULTIPLE
|
||||
bool "Multiple STMPE811 Devices"
|
||||
default n
|
||||
---help---
|
||||
Can be defined to support multiple STMPE811 devices on board.
|
||||
|
||||
config STMPE811_NPOLLWAITERS
|
||||
int "Number poll waiters"
|
||||
default 4
|
||||
depends on !DISABLE_POLL
|
||||
---help---
|
||||
Maximum number of threads that can be waiting on poll()
|
||||
|
||||
config STMPE811_TSC_DISABLE
|
||||
bool "Disable STMPE811 Touchscreen Support"
|
||||
default n
|
||||
---help---
|
||||
Disable driver touchscreen functionality.
|
||||
|
||||
config STMPE811_SWAPXY
|
||||
bool "Swap X/Y"
|
||||
default n
|
||||
depends on !STMPE811_TSC_DISABLE
|
||||
---help---
|
||||
Reverse the meaning of X and Y to handle different LCD orientations.
|
||||
|
||||
config STMPE811_THRESHX
|
||||
int "X threshold"
|
||||
default 12
|
||||
depends on !STMPE811_TSC_DISABLE
|
||||
---help---
|
||||
STMPE811 touchscreen data comes in a a very high rate. New touch positions
|
||||
will only be reported when the X or Y data changes by these thresholds.
|
||||
This trades reduces data rate for some loss in dragging accuracy. The
|
||||
STMPE811 is configure for 12-bit values so the raw ranges are 0-4095. So
|
||||
for example, if your display is 320x240, then THRESHX=13 and THRESHY=17
|
||||
would correspond to one pixel. Default: 12
|
||||
|
||||
config STMPE811_THRESHY
|
||||
int "Y threshold"
|
||||
default 12
|
||||
depends on !STMPE811_TSC_DISABLE
|
||||
---help---
|
||||
STMPE811 touchscreen data comes in a a very high rate. New touch positions
|
||||
will only be reported when the X or Y data changes by these thresholds.
|
||||
This trades reduces data rate for some loss in dragging accuracy. The
|
||||
STMPE811 is configure for 12-bit values so the raw ranges are 0-4095. So
|
||||
for example, if your display is 320x240, then THRESHX=13 and THRESHY=17
|
||||
would correspond to one pixel. Default: 12
|
||||
|
||||
config STMPE811_ADC_DISABLE
|
||||
bool "Disable STMPE811 ADC Support"
|
||||
default y
|
||||
---help---
|
||||
Disable driver ADC functionality.
|
||||
|
||||
config STMPE811_GPIO_DISABLE
|
||||
bool "Disable STMPE811 GPIO Support"
|
||||
default y
|
||||
---help---
|
||||
Disable driver GPIO functionality.
|
||||
|
||||
config STMPE811_GPIOINT_DISABLE
|
||||
bool "Disable STMPE811 GPIO Interrupt Support"
|
||||
default y
|
||||
depends on !STMPE811_GPIO_DISABLE
|
||||
---help---
|
||||
Disable driver GPIO interrupt functionlality (ignored if GPIO functionality is
|
||||
disabled).
|
||||
|
||||
config STMPE811_TEMP_DISABLE
|
||||
bool "Disable STMPE811 Temperature Sensor Support"
|
||||
default y
|
||||
---help---
|
||||
Disable driver temperature sensor functionality.
|
||||
|
||||
config STMPE811_REGDEBUG
|
||||
bool "Enable Register-Level STMPE811 Debug"
|
||||
default n
|
||||
depends on DEBUG
|
||||
---help---
|
||||
Enable very low register-level debug output.
|
||||
|
||||
endif
|
||||
|
@ -79,6 +79,12 @@
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* This is a value for the threshold that guantees a big difference on the
|
||||
* first pendown (but can't overflow).
|
||||
*/
|
||||
|
||||
#define INVALID_THRESHOLD 0x1000
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
@ -88,13 +94,14 @@
|
||||
****************************************************************************/
|
||||
/* Low-level SPI helpers */
|
||||
|
||||
static inline void ads7843e_configspi(FAR struct spi_dev_s *spi);
|
||||
#ifdef CONFIG_SPI_OWNBUS
|
||||
static inline void ads7843e_select(FAR struct spi_dev_s *spi);
|
||||
static inline void ads7843e_deselect(FAR struct spi_dev_s *spi);
|
||||
static inline void ads7843e_configspi(FAR struct spi_dev_s *spi);
|
||||
# define ads7843e_lock(spi)
|
||||
# define ads7843e_unlock(spi)
|
||||
#else
|
||||
static void ads7843e_select(FAR struct spi_dev_s *spi);
|
||||
static void ads7843e_deselect(FAR struct spi_dev_s *spi);
|
||||
# define ads7843e_configspi(spi);
|
||||
static void ads7843e_lock(FAR struct spi_dev_s *spi);
|
||||
static void ads7843e_unlock(FAR struct spi_dev_s *spi);
|
||||
#endif
|
||||
|
||||
static inline void ads7843e_waitbusy(FAR struct ads7843e_dev_s *priv);
|
||||
@ -157,13 +164,12 @@ static struct ads7843e_dev_s *g_ads7843elist;
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Function: ads7843e_select
|
||||
* Function: ads7843e_lock
|
||||
*
|
||||
* Description:
|
||||
* Select the SPI, locking and re-configuring if necessary. This function
|
||||
* must be called before initiating any sequence of SPI operations. If we
|
||||
* are sharing the SPI bus with other devices (CONFIG_SPI_OWNBUS undefined)
|
||||
* then we need to lock and configure the SPI bus for each transfer.
|
||||
* Lock the SPI bus and re-configure as necessary. This function must be
|
||||
* to assure: (1) exclusive access to the SPI bus, and (2) to assure that
|
||||
* the shared bus is properly configured for the touchscreen controller.
|
||||
*
|
||||
* Parameters:
|
||||
* spi - Reference to the SPI driver structure
|
||||
@ -175,42 +181,35 @@ static struct ads7843e_dev_s *g_ads7843elist;
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_SPI_OWNBUS
|
||||
static inline void ads7843e_select(FAR struct spi_dev_s *spi)
|
||||
#ifndef CONFIG_SPI_OWNBUS
|
||||
static void ads7843e_lock(FAR struct spi_dev_s *spi)
|
||||
{
|
||||
/* We own the SPI bus, so just select the chip */
|
||||
|
||||
SPI_SELECT(spi, SPIDEV_TOUCHSCREEN, true);
|
||||
}
|
||||
#else
|
||||
static void ads7843e_select(FAR struct spi_dev_s *spi)
|
||||
{
|
||||
/* Select ADS7843 chip (locking the SPI bus in case there are multiple
|
||||
* devices competing for the SPI bus
|
||||
/* Lock the SPI bus because there are multiple devices competing for the
|
||||
* SPI bus
|
||||
*/
|
||||
|
||||
(void)SPI_LOCK(spi, true);
|
||||
SPI_SELECT(spi, SPIDEV_TOUCHSCREEN, true);
|
||||
|
||||
/* Now make sure that the SPI bus is configured for the ADS7843 (it
|
||||
* might have gotten configured for a different device while unlocked)
|
||||
/* We have the lock. Now make sure that the SPI bus is configured for the
|
||||
* ADS7843 (it might have gotten configured for a different device while
|
||||
* unlocked)
|
||||
*/
|
||||
|
||||
SPI_SELECT(spi, SPIDEV_TOUCHSCREEN, true);
|
||||
SPI_SETMODE(spi, CONFIG_ADS7843E_SPIMODE);
|
||||
SPI_SETBITS(spi, 8);
|
||||
SPI_SETFREQUENCY(spi, CONFIG_ADS7843E_FREQUENCY);
|
||||
SPI_SELECT(spi, SPIDEV_TOUCHSCREEN, false);
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Function: ads7843e_deselect
|
||||
* Function: ads7843e_unlock
|
||||
*
|
||||
* Description:
|
||||
* De-select the SPI, unlocking as necessary. This function must be
|
||||
* after completing a sequence of SPI operations. If we are sharing the SPI
|
||||
* bus with other devices (CONFIG_SPI_OWNBUS undefined) then we need to
|
||||
* un-lock the SPI bus for each transfer, possibly losing the current
|
||||
* configuration.
|
||||
* If we are sharing the SPI bus with other devices (CONFIG_SPI_OWNBUS
|
||||
* undefined) then we need to un-lock the SPI bus for each transfer,
|
||||
* possibly losing the current configuration.
|
||||
*
|
||||
* Parameters:
|
||||
* spi - Reference to the SPI driver structure
|
||||
@ -222,19 +221,11 @@ static void ads7843e_select(FAR struct spi_dev_s *spi)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_SPI_OWNBUS
|
||||
static inline void ads7843e_deselect(FAR struct spi_dev_s *spi)
|
||||
#ifndef CONFIG_SPI_OWNBUS
|
||||
static void ads7843e_unlock(FAR struct spi_dev_s *spi)
|
||||
{
|
||||
/* We own the SPI bus, so just de-select the chip */
|
||||
/* Relinquish the SPI bus. */
|
||||
|
||||
SPI_SELECT(spi, SPIDEV_TOUCHSCREEN, false);
|
||||
}
|
||||
#else
|
||||
static void ads7843e_deselect(FAR struct spi_dev_s *spi)
|
||||
{
|
||||
/* De-select ADS7843 chip and relinquish the SPI bus. */
|
||||
|
||||
SPI_SELECT(spi, SPIDEV_TOUCHSCREEN, false);
|
||||
(void)SPI_LOCK(spi, false);
|
||||
}
|
||||
#endif
|
||||
@ -258,23 +249,20 @@ static void ads7843e_deselect(FAR struct spi_dev_s *spi)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_SPI_OWNBUS
|
||||
static inline void ads7843e_configspi(FAR struct spi_dev_s *spi)
|
||||
{
|
||||
idbg("Mode: %d Bits: 8 Frequency: %d\n",
|
||||
CONFIG_ADS7843E_SPIMODE, CONFIG_ADS7843E_FREQUENCY);
|
||||
|
||||
/* Configure SPI for the ADS7843. But only if we own the SPI bus. Otherwise, don't
|
||||
* bother because it might change.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_SPI_OWNBUS
|
||||
SPI_SELECT(spi, SPIDEV_TOUCHSCREEN, true);
|
||||
SPI_SETMODE(spi, CONFIG_ADS7843E_SPIMODE);
|
||||
SPI_SETBITS(spi, 8);
|
||||
SPI_SETFREQUENCY(spi, CONFIG_ADS7843E_FREQUENCY);
|
||||
SPI_SELECT(spi, SPIDEV_TOUCHSCREEN, false);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ads7843e_waitbusy
|
||||
@ -296,7 +284,7 @@ static uint16_t ads7843e_sendcmd(FAR struct ads7843e_dev_s *priv, uint8_t cmd)
|
||||
|
||||
/* Select the ADS7843E */
|
||||
|
||||
ads7843e_select(priv->spi);
|
||||
SPI_SELECT(priv->spi, SPIDEV_TOUCHSCREEN, true);
|
||||
|
||||
/* Send the command */
|
||||
|
||||
@ -306,7 +294,7 @@ static uint16_t ads7843e_sendcmd(FAR struct ads7843e_dev_s *priv, uint8_t cmd)
|
||||
/* Read the data */
|
||||
|
||||
SPI_RECVBLOCK(priv->spi, buffer, 2);
|
||||
ads7843e_deselect(priv->spi);
|
||||
SPI_SELECT(priv->spi, SPIDEV_TOUCHSCREEN, false);
|
||||
|
||||
result = ((uint16_t)buffer[0] << 8) | (uint16_t)buffer[1];
|
||||
result = result >> 4;
|
||||
@ -554,6 +542,10 @@ static void ads7843e_worker(FAR void *arg)
|
||||
{
|
||||
FAR struct ads7843e_dev_s *priv = (FAR struct ads7843e_dev_s *)arg;
|
||||
FAR struct ads7843e_config_s *config;
|
||||
uint16_t x;
|
||||
uint16_t y;
|
||||
uint16_t xdiff;
|
||||
uint16_t ydiff;
|
||||
bool pendown;
|
||||
int ret;
|
||||
|
||||
@ -572,6 +564,10 @@ static void ads7843e_worker(FAR void *arg)
|
||||
|
||||
wd_cancel(priv->wdog);
|
||||
|
||||
/* Lock the SPI bus so that we have exclusive access */
|
||||
|
||||
ads7843e_lock(priv->spi);
|
||||
|
||||
/* Get exclusive access to the driver data structure */
|
||||
|
||||
do
|
||||
@ -594,13 +590,20 @@ static void ads7843e_worker(FAR void *arg)
|
||||
|
||||
if (!pendown)
|
||||
{
|
||||
/* Ignore the interrupt if the pen was already up (CONTACT_NONE == pen up and
|
||||
* already reported. CONTACT_UP == pen up, but not reported)
|
||||
/* The pen is up.. reset thresholding variables. */
|
||||
|
||||
priv->threshx = INVALID_THRESHOLD;
|
||||
priv->threshy = INVALID_THRESHOLD;
|
||||
|
||||
/* Ignore the interrupt if the pen was already up (CONTACT_NONE == pen up
|
||||
* and already reported; CONTACT_UP == pen up, but not reported)
|
||||
*/
|
||||
|
||||
if (priv->sample.contact == CONTACT_NONE)
|
||||
if (priv->sample.contact == CONTACT_NONE ||
|
||||
priv->sample.contact == CONTACT_UP)
|
||||
|
||||
{
|
||||
goto errout;
|
||||
goto ignored;
|
||||
}
|
||||
|
||||
/* The pen is up. NOTE: We know from a previous test, that this is a
|
||||
@ -618,14 +621,57 @@ static void ads7843e_worker(FAR void *arg)
|
||||
|
||||
else if (priv->sample.contact == CONTACT_UP)
|
||||
{
|
||||
goto errout;
|
||||
/* If we have not yet processed the last pen up event, then we
|
||||
* cannot handle this pen down event. We will have to discard it. That
|
||||
* should be okay because we will set the timer to to sample again
|
||||
* later.
|
||||
*/
|
||||
|
||||
wd_start(priv->wdog, ADS7843E_WDOG_DELAY, ads7843e_wdog, 1, (uint32_t)priv);
|
||||
goto ignored;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Handle pen down events. First, sample positional values. */
|
||||
|
||||
priv->sample.x = ads7843e_sendcmd(priv, ADS7843_CMD_XPOSITION);
|
||||
priv->sample.y = ads7843e_sendcmd(priv, ADS7843_CMD_YPOSITION);
|
||||
#ifdef CONFIG_ADS7843E_SWAPXY
|
||||
x = ads7843e_sendcmd(priv, ADS7843_CMD_YPOSITION);
|
||||
y = ads7843e_sendcmd(priv, ADS7843_CMD_XPOSITION);
|
||||
#else
|
||||
x = ads7843e_sendcmd(priv, ADS7843_CMD_XPOSITION);
|
||||
y = ads7843e_sendcmd(priv, ADS7843_CMD_YPOSITION);
|
||||
#endif
|
||||
|
||||
/* Perform a thresholding operation so that the results will be more stable.
|
||||
* If the difference from the last sample is small, then ignore the event.
|
||||
* REVISIT: Should a large change in pressure also generate a event?
|
||||
*/
|
||||
|
||||
xdiff = x > priv->threshx ? (x - priv->threshx) : (priv->threshx - x);
|
||||
ydiff = y > priv->threshy ? (y - priv->threshy) : (priv->threshy - y);
|
||||
|
||||
/* Continue to sample the position while the pen is down */
|
||||
|
||||
wd_start(priv->wdog, ADS7843E_WDOG_DELAY, ads7843e_wdog, 1, (uint32_t)priv);
|
||||
|
||||
/* Check the thresholds. Bail if there is no significant difference */
|
||||
|
||||
if (xdiff < CONFIG_ADS7843E_THRESHX && ydiff < CONFIG_ADS7843E_THRESHY)
|
||||
{
|
||||
/* Little or no change in either direction ... don't report anything. */
|
||||
|
||||
goto ignored;
|
||||
}
|
||||
|
||||
/* When we see a big difference, snap to the new x/y thresholds */
|
||||
|
||||
priv->threshx = x;
|
||||
priv->threshy = y;
|
||||
|
||||
/* Update the x/y position in the sample data */
|
||||
|
||||
priv->sample.x = priv->threshx;
|
||||
priv->sample.y = priv->threshy;
|
||||
|
||||
/* The X/Y positional data is now valid */
|
||||
|
||||
@ -642,10 +688,6 @@ static void ads7843e_worker(FAR void *arg)
|
||||
|
||||
priv->sample.contact = CONTACT_DOWN;
|
||||
}
|
||||
|
||||
/* Continue to sample the position while the pen is down */
|
||||
|
||||
wd_start(priv->wdog, ADS7843E_WDOG_DELAY, ads7843e_wdog, 1, (uint32_t)priv);
|
||||
}
|
||||
|
||||
/* Indicate the availability of new sample data for this ID */
|
||||
@ -659,13 +701,15 @@ static void ads7843e_worker(FAR void *arg)
|
||||
|
||||
/* Exit, re-enabling ADS7843E interrupts */
|
||||
|
||||
errout:
|
||||
ignored:
|
||||
|
||||
(void)ads7843e_sendcmd(priv, ADS7843_CMD_ENABPINIRQ);
|
||||
config->enable(config, true);
|
||||
|
||||
/* Release our lock on the state structure */
|
||||
/* Release our lock on the state structure and unlock the SPI bus */
|
||||
|
||||
sem_post(&priv->devsem);
|
||||
ads7843e_unlock(priv->spi);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -1119,7 +1163,7 @@ errout:
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int ads7843e_register(FAR struct spi_dev_s *dev,
|
||||
int ads7843e_register(FAR struct spi_dev_s *spi,
|
||||
FAR struct ads7843e_config_s *config, int minor)
|
||||
{
|
||||
FAR struct ads7843e_dev_s *priv;
|
||||
@ -1129,11 +1173,11 @@ int ads7843e_register(FAR struct spi_dev_s *dev,
|
||||
#endif
|
||||
int ret;
|
||||
|
||||
ivdbg("dev: %p minor: %d\n", dev, minor);
|
||||
ivdbg("spi: %p minor: %d\n", spi, minor);
|
||||
|
||||
/* Debug-only sanity checks */
|
||||
|
||||
DEBUGASSERT(dev != NULL && config != NULL && minor >= 0 && minor < 100);
|
||||
DEBUGASSERT(spi != NULL && config != NULL && minor >= 0 && minor < 100);
|
||||
|
||||
/* Create and initialize a ADS7843E device driver instance */
|
||||
|
||||
@ -1151,11 +1195,14 @@ int ads7843e_register(FAR struct spi_dev_s *dev,
|
||||
/* Initialize the ADS7843E device driver instance */
|
||||
|
||||
memset(priv, 0, sizeof(struct ads7843e_dev_s));
|
||||
priv->spi = dev; /* Save the SPI device handle */
|
||||
priv->config = config; /* Save the board configuration */
|
||||
priv->wdog = wd_create(); /* Create a watchdog timer */
|
||||
sem_init(&priv->devsem, 0, 1); /* Initialize device structure semaphore */
|
||||
sem_init(&priv->waitsem, 0, 0); /* Initialize pen event wait semaphore */
|
||||
priv->spi = spi; /* Save the SPI device handle */
|
||||
priv->config = config; /* Save the board configuration */
|
||||
priv->wdog = wd_create(); /* Create a watchdog timer */
|
||||
priv->threshx = INVALID_THRESHOLD; /* Initialize thresholding logic */
|
||||
priv->threshy = INVALID_THRESHOLD; /* Initialize thresholding logic */
|
||||
|
||||
sem_init(&priv->devsem, 0, 1); /* Initialize device structure semaphore */
|
||||
sem_init(&priv->waitsem, 0, 0); /* Initialize pen event wait semaphore */
|
||||
|
||||
/* Make sure that interrupts are disabled */
|
||||
|
||||
@ -1171,14 +1218,25 @@ int ads7843e_register(FAR struct spi_dev_s *dev,
|
||||
goto errout_with_priv;
|
||||
}
|
||||
|
||||
idbg("Mode: %d Bits: 8 Frequency: %d\n",
|
||||
CONFIG_ADS7843E_SPIMODE, CONFIG_ADS7843E_FREQUENCY);
|
||||
|
||||
/* Lock the SPI bus so that we have exclusive access */
|
||||
|
||||
ads7843e_lock(spi);
|
||||
|
||||
/* Configure the SPI interface */
|
||||
|
||||
ads7843e_configspi(dev);
|
||||
ads7843e_configspi(spi);
|
||||
|
||||
/* Enable the PEN IRQ */
|
||||
|
||||
ads7843e_sendcmd(priv, ADS7843_CMD_ENABPINIRQ);
|
||||
|
||||
/* Unlock the bus */
|
||||
|
||||
ads7843e_unlock(spi);
|
||||
|
||||
/* Register the device as an input device */
|
||||
|
||||
(void)snprintf(devname, DEV_NAMELEN, DEV_FORMAT, minor);
|
||||
|
@ -139,6 +139,8 @@ struct ads7843e_dev_s
|
||||
uint8_t nwaiters; /* Number of threads waiting for ADS7843E data */
|
||||
uint8_t id; /* Current touch point ID */
|
||||
volatile bool penchange; /* An unreported event is buffered */
|
||||
uint16_t threshx; /* Thresholding X value */
|
||||
uint16_t threshy; /* Thresholding Y value */
|
||||
sem_t devsem; /* Manages exclusive access to this structure */
|
||||
sem_t waitsem; /* Used to wait for the availability of data */
|
||||
|
||||
|
@ -70,6 +70,16 @@
|
||||
# define CONFIG_ADS7843E_SPIMODE SPIDEV_MODE0
|
||||
#endif
|
||||
|
||||
/* Thresholds */
|
||||
|
||||
#ifndef CONFIG_ADS7843E_THRESHX
|
||||
# define CONFIG_ADS7843E_THRESHX 12
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_ADS7843E_THRESHY
|
||||
# define CONFIG_ADS7843E_THRESHY 12
|
||||
#endif
|
||||
|
||||
/* Check for some required settings. This can save the user a lot of time
|
||||
* in getting the right configuration.
|
||||
*/
|
||||
@ -149,7 +159,7 @@ extern "C" {
|
||||
* number
|
||||
*
|
||||
* Input Parameters:
|
||||
* dev - An SPI driver instance
|
||||
* spi - An SPI driver instance
|
||||
* config - Persistent board configuration data
|
||||
* minor - The input device minor number
|
||||
*
|
||||
@ -159,7 +169,7 @@ extern "C" {
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
EXTERN int ads7843e_register(FAR struct spi_dev_s *dev,
|
||||
EXTERN int ads7843e_register(FAR struct spi_dev_s *spi,
|
||||
FAR struct ads7843e_config_s *config,
|
||||
int minor);
|
||||
|
||||
|
@ -85,7 +85,7 @@
|
||||
* CONFIG_STMPE811_TEMP_DISABLE
|
||||
* Disable driver temperature sensor functionality.
|
||||
* CONFIG_STMPE811_REGDEBUG
|
||||
* Enabled very low register-level debug output. Requires CONFIG_DEBUG.
|
||||
* Enable very low register-level debug output. Requires CONFIG_DEBUG.
|
||||
* CONFIG_STMPE811_THRESHX and CONFIG_STMPE811_THRESHY
|
||||
* STMPE811 touchscreen data comes in a a very high rate. New touch positions
|
||||
* will only be reported when the X or Y data changes by these thresholds.
|
||||
|
@ -18,6 +18,9 @@ choice
|
||||
prompt "Board PHY Selection"
|
||||
depends on ARCH_HAVE_PHY
|
||||
default PHY_KS8721
|
||||
---help---
|
||||
Identify the PHY on your board. This setting is not used by all Ethernet
|
||||
drivers no do all Ethernet drivers support all PHYs.
|
||||
|
||||
config PHY_KS8721
|
||||
bool "Micrel KS8721 PHY"
|
||||
@ -28,6 +31,9 @@ config PHY_DP83848C
|
||||
config PHY_LAN8720
|
||||
bool "SMSC LAN8720 PHY"
|
||||
|
||||
config PHY_DM9161
|
||||
bool "Davicom DM9161 PHY"
|
||||
|
||||
endchoice
|
||||
|
||||
config NET_NOINTS
|
||||
|
Loading…
x
Reference in New Issue
Block a user