From 8b51bcf46f97d7cd752f3b3d9b52b9f39051f60f Mon Sep 17 00:00:00 2001 From: Andrew Hannam Date: Sun, 11 Nov 2012 19:03:30 +1000 Subject: Touch Fixes. Deprecate Console Touch: - Move defines that may be altered by the touch config file to the lld header file. - Move the definition of the Touch driver structure to the lld config file. - Changed CONVERSIONS macro to TOUCHSCREEN_CONVERSIONS - Replaced references to GDISP_SCREEN_WIDTH with gdispGetWidth - Renamed TOUCHSCREEN_HAS_IRQ to TOUCHSCREEN_HAS_PRESSED to match new function name. - Added prototypes for calibration storage functions to touchscreen_lld.h so that either the lld driver or the application can define the function. Console: -Deprecated into "old" directory. Functionality replaced by gwin. --- drivers/touchscreen/ADS7843/touchscreen_lld.c | 2 +- .../touchscreen/ADS7843/touchscreen_lld_config.h | 41 +++++++++++++++++++++- drivers/touchscreen/XPT2046/touchscreen_lld.c | 2 +- .../touchscreen/XPT2046/touchscreen_lld_config.h | 41 +++++++++++++++++++++- 4 files changed, 82 insertions(+), 4 deletions(-) (limited to 'drivers/touchscreen') diff --git a/drivers/touchscreen/ADS7843/touchscreen_lld.c b/drivers/touchscreen/ADS7843/touchscreen_lld.c index 15b1d907..9b5d4aa0 100644 --- a/drivers/touchscreen/ADS7843/touchscreen_lld.c +++ b/drivers/touchscreen/ADS7843/touchscreen_lld.c @@ -211,7 +211,7 @@ uint16_t ts_lld_read_y(void) { } /* ---- Optional Routines ---- */ -#if TOUCHSCREEN_HAS_IRQ || defined(__DOXYGEN__) +#if TOUCHSCREEN_HAS_PRESSED || defined(__DOXYGEN__) /* * @brief for checking if touchscreen is pressed or not. * diff --git a/drivers/touchscreen/ADS7843/touchscreen_lld_config.h b/drivers/touchscreen/ADS7843/touchscreen_lld_config.h index 5769c288..056c8d7a 100644 --- a/drivers/touchscreen/ADS7843/touchscreen_lld_config.h +++ b/drivers/touchscreen/ADS7843/touchscreen_lld_config.h @@ -35,9 +35,48 @@ /* Driver hardware support. */ /*===========================================================================*/ -#define TOUCHSCREEN_HAS_IRQ TRUE +#define TOUCHSCREEN_HAS_PRESSED TRUE #define TOUCHSCREEN_HAS_PRESSURE FALSE +struct TouchscreenDriver { + /* + * @brief Pointer to SPI driver. + * @note SPI driver must be enabled in mcuconf.h and halconf.h + */ + SPIDriver *spip; + + /* + * @brief Pointer to the SPI configuration structure. + * @note The lowest possible speed ~ 1-2MHz is to be used, otherwise + * will result in a lot of noise + */ + const SPIConfig *spicfg; + + /* + * @brief Touchscreen controller TPIRQ pin GPIO port + */ + ioportid_t tsIRQPort; + + /* + * @brief Touchscreen controller TPIRQ GPIO pin + * @note The interface is polled as of now, interrupt support is + * to be implemented in the future. + */ + ioportmask_t tsIRQPin; + + /* + * @brief Initialize the SPI with the configuration struct given or not + * If TRUE, spiStart is called by the init, otherwise not + * @note This is provided in such a case when SPI port is being shared + * across multiple peripherals, so not to disturb the SPI bus. + * You can use TOUCHSCREEN_SPI_PROLOGUE() and TOUCHSCREEN_SPI_EPILOGUE() + * macros to change the SPI configuration or speed before and + * after using the touchpad. An example case would be sharing the + * bus with a fast flash memory chip. + */ + bool_t direct_init; +}; + #endif /* GFX_USE_TOUCHSCREEN */ #endif /* TOUCHSCREEN_LLD_CONFIG_H */ diff --git a/drivers/touchscreen/XPT2046/touchscreen_lld.c b/drivers/touchscreen/XPT2046/touchscreen_lld.c index ef410b0d..2d3689d4 100644 --- a/drivers/touchscreen/XPT2046/touchscreen_lld.c +++ b/drivers/touchscreen/XPT2046/touchscreen_lld.c @@ -211,7 +211,7 @@ uint16_t ts_lld_read_y(void) { } /* ---- Optional Routines ---- */ -#if TOUCHSCREEN_HAS_IRQ || defined(__DOXYGEN__) +#if TOUCHSCREEN_HAS_PRESSED || defined(__DOXYGEN__) /* * @brief for checking if touchscreen is pressed or not. * diff --git a/drivers/touchscreen/XPT2046/touchscreen_lld_config.h b/drivers/touchscreen/XPT2046/touchscreen_lld_config.h index 1bb8718e..3a030b5d 100644 --- a/drivers/touchscreen/XPT2046/touchscreen_lld_config.h +++ b/drivers/touchscreen/XPT2046/touchscreen_lld_config.h @@ -35,9 +35,48 @@ /* Driver hardware support. */ /*===========================================================================*/ -#define TOUCHSCREEN_HAS_IRQ TRUE +#define TOUCHSCREEN_HAS_PRESSED TRUE #define TOUCHSCREEN_HAS_PRESSURE TRUE +struct TouchscreenDriver { + /* + * @brief Pointer to SPI driver. + * @note SPI driver must be enabled in mcuconf.h and halconf.h + */ + SPIDriver *spip; + + /* + * @brief Pointer to the SPI configuration structure. + * @note The lowest possible speed ~ 1-2MHz is to be used, otherwise + * will result in a lot of noise + */ + const SPIConfig *spicfg; + + /* + * @brief Touchscreen controller TPIRQ pin GPIO port + */ + ioportid_t tsIRQPort; + + /* + * @brief Touchscreen controller TPIRQ GPIO pin + * @note The interface is polled as of now, interrupt support is + * to be implemented in the future. + */ + ioportmask_t tsIRQPin; + + /* + * @brief Initialize the SPI with the configuration struct given or not + * If TRUE, spiStart is called by the init, otherwise not + * @note This is provided in such a case when SPI port is being shared + * across multiple peripherals, so not to disturb the SPI bus. + * You can use TOUCHSCREEN_SPI_PROLOGUE() and TOUCHSCREEN_SPI_EPILOGUE() + * macros to change the SPI configuration or speed before and + * after using the touchpad. An example case would be sharing the + * bus with a fast flash memory chip. + */ + bool_t direct_init; +}; + #endif /* GFX_USE_TOUCHSCREEN */ #endif /* TOUCHSCREEN_LLD_CONFIG_H */ -- cgit v1.2.3