aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorTectu <joel@unormal.org>2012-08-16 03:26:02 -0700
committerTectu <joel@unormal.org>2012-08-16 03:26:02 -0700
commitdf680e6d6e6b791534c970dee313b492e829b6e4 (patch)
treef7413c4ef23867e5679a96aab63d7b44e6883274 /include
parent2d8c4a825de421f1d045433478e65da31d551d06 (diff)
parent0b8c95ab207a474e9b1c28c89c8848e6d0992974 (diff)
downloaduGFX-df680e6d6e6b791534c970dee313b492e829b6e4.tar.gz
uGFX-df680e6d6e6b791534c970dee313b492e829b6e4.tar.bz2
uGFX-df680e6d6e6b791534c970dee313b492e829b6e4.zip
Merge pull request #43 from abhishek-kakkar/master
Touchpad Updates
Diffstat (limited to 'include')
-rw-r--r--include/touchpad.h2
-rw-r--r--include/touchpad_lld.h65
2 files changed, 51 insertions, 16 deletions
diff --git a/include/touchpad.h b/include/touchpad.h
index 445d3202..55a83a9d 100644
--- a/include/touchpad.h
+++ b/include/touchpad.h
@@ -70,7 +70,7 @@ struct cal {
extern "C" {
#endif
-void tpInit(TOUCHPADDriver *tp);
+void tpInit(const TOUCHPADDriver *tp);
uint16_t tpReadX(void);
uint16_t tpReadY(void);
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);