aboutsummaryrefslogtreecommitdiffstats
path: root/include/touchpad_lld.h
diff options
context:
space:
mode:
authorKumar Abhishek <abhishek.kakkar@hotmail.com>2012-08-16 15:14:16 +0530
committerKumar Abhishek <abhishek.kakkar@hotmail.com>2012-08-16 15:14:16 +0530
commita9beec902da2348e858dcd54550d99a40c1fbe87 (patch)
tree81e88faebe2d6922aff034c650be02958e52c0a3 /include/touchpad_lld.h
parent7334da9f7f7cd9ea03a80e9e85f62fe061455caf (diff)
downloaduGFX-a9beec902da2348e858dcd54550d99a40c1fbe87.tar.gz
uGFX-a9beec902da2348e858dcd54550d99a40c1fbe87.tar.bz2
uGFX-a9beec902da2348e858dcd54550d99a40c1fbe87.zip
XPT2046 LLD Major Update
Added 7 point median filtering to reduce noise TOUCHPADDriver structure now encapsulates the IRQ pin, so removed the TP_CS_ and TP_IRQ_ macros Added generic tp_lld_read_value method to read any ADC channel from the XPT2046, this includes on-chip temperature sensor and VBAT input Improved SPI bus sharing, with the optional TOUCHPAD_SPI_PROLOGUE and TOUCHPAD_SPI_EPILOGUE macros
Diffstat (limited to 'include/touchpad_lld.h')
-rw-r--r--include/touchpad_lld.h65
1 files changed, 50 insertions, 15 deletions
diff --git a/include/touchpad_lld.h b/include/touchpad_lld.h
index 45a561d3..a3a7489c 100644
--- a/include/touchpad_lld.h
+++ b/include/touchpad_lld.h
@@ -49,41 +49,76 @@
#define TOUCHPAD_HAS_PRESSURE FALSE
#endif
+#ifndef TOUCHPAD_SPI_PROLOGUE
+ #define TOUCHPAD_SPI_PROLOGUE()
+#endif
+
+#ifndef TOUCHPAD_SPI_EPILOGUE
+ #define TOUCHPAD_SPI_EPILOGUE()
+#endif
+
/*===========================================================================*/
/* Driver types. */
/*===========================================================================*/
-typedef struct TOUCHPADDriver TOUCHPADDriver;
+typedef struct _TOUCHPADDriver TOUCHPADDriver;
/**
* @brief Structure representing a Touchpad driver.
*/
-struct TOUCHPADDriver {
- /*
- * @brief Pointer to SPI driver.
- */
- SPIDriver *spid;
-
- /*
- * @brief SPI configuration.
- */
- SPIConfig *spicfg;
+struct _TOUCHPADDriver {
+ /*
+ * @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 tpIRQPort;
+
+ /*
+ * @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 tpIRQPin;
+
+ /*
+ * @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 TOUCHPAD_SPI_PROLOGUE() and TOUCHPAD_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;
};
+
/*===========================================================================*/
/* External declarations. */
/*===========================================================================*/
-#if !defined(__DOXYGEN__)
- extern TOUCHPADDriver Touchpad;
-#endif
#ifdef __cplusplus
extern "C" {
#endif
/* Core functions */
- void tp_lld_init(TOUCHPADDriver *tp);
+ void tp_lld_init(const TOUCHPADDriver *tp);
+
+ uint16_t tp_lld_read_value(uint8_t cmd);
uint16_t tp_lld_read_x(void);
uint16_t tp_lld_read_y(void);