From 03c27adb1c86d37548e695fd89937f01ed528954 Mon Sep 17 00:00:00 2001 From: Tectu Date: Thu, 9 Aug 2012 03:30:45 +0200 Subject: [PATCH] added tpIRQ() --- .../touchpad/touchpadXPT2046/touchpad_lld.c | 13 +++++++++++++ .../touchpadXPT2046/touchpad_lld_config.h | 1 + halext/include/touchpad.h | 5 ++++- halext/include/touchpad_lld.h | 10 +++++++++- halext/src/touchpad.c | 17 +++++++++++++++-- 5 files changed, 42 insertions(+), 4 deletions(-) diff --git a/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c b/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c index f85a68d9..d44d7212 100644 --- a/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c +++ b/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c @@ -134,6 +134,19 @@ uint16_t tp_lld_read_y(void) { } /* ---- Optional Routines ---- */ +#if TOUCHPAD_HAS_IRQ || defined(__DOXYGEN__) + /* + * @brief for checking if touchpad is pressed or not. + * + * @return 1 if pressed / 0 if not pressed + * + * @noapi + */ + uint8_t tp_lld_irq(void) { + return (!palReadPad(TP_IRQ_PORT, TP_IRQ)); + } +#endif + #if TOUCHPAD_HAS_PRESSURE || defined(__DOXYGEN__) /* * @brief Reads out the Z direction / pressure. diff --git a/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld_config.h b/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld_config.h index 17f33dd4..399117f9 100644 --- a/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld_config.h +++ b/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld_config.h @@ -35,6 +35,7 @@ /* Driver hardware support. */ /*===========================================================================*/ +#define TOUCHPAD_HAS_IRQ TRUE #define TOUCHPAD_HAS_PRESSURE TRUE #endif /* HAL_USE_TOUCHPAD */ diff --git a/halext/include/touchpad.h b/halext/include/touchpad.h index 4f9dce1a..445d3202 100644 --- a/halext/include/touchpad.h +++ b/halext/include/touchpad.h @@ -73,7 +73,10 @@ extern "C" { void tpInit(TOUCHPADDriver *tp); uint16_t tpReadX(void); uint16_t tpReadY(void); -void tpCalibrate(void); + +#if TOUCHPAD_HAS_IRQ + uint8_t tpIRQ(void); +#endif #if TOUCHPAD_HAS_PRESSURE uint16_t tpReadZ(void); diff --git a/halext/include/touchpad_lld.h b/halext/include/touchpad_lld.h index 7b33f366..c0339e05 100644 --- a/halext/include/touchpad_lld.h +++ b/halext/include/touchpad_lld.h @@ -41,6 +41,10 @@ /* Error checks. */ /*===========================================================================*/ +#ifndef TOUCHPAD_HAS_IRQ + #define TOUCHPAD_HAS_IRQ FALSE +#endif + #ifndef TOUCHPAD_HAS_PRESSURE #define TOUCHPAD_HAS_PRESSURE FALSE #endif @@ -79,7 +83,11 @@ extern "C" { uint16_t tp_lld_read_x(void); uint16_t tp_lld_read_y(void); - #if TOUCHPAD_PRESSURE + #if TOUCHPAD_HAS_IRQ + uint8_t tp_lld_irq(void); + #endif + + #if TOUCHPAD_HAS_PRESSURE uint16_t tp_lld_read_z(void); #endif diff --git a/halext/src/touchpad.c b/halext/src/touchpad.c index 7f7c87f6..2b51504a 100644 --- a/halext/src/touchpad.c +++ b/halext/src/touchpad.c @@ -107,7 +107,7 @@ static uint16_t _tpReadRealY(void) { * @note This function is NOT currently implicitly invoked by @p halInit(). * It must be called manually. * - * @init + * @api */ void tpInit(TOUCHPADDriver *tp) { /* Initialise Mutex */ @@ -177,7 +177,20 @@ uint16_t tpReadY(void) { return y; } -#if TOUCHPAD_PRESSURE || defined(__DOXYGEN__) +#if TOUCHPAD_HAS_IRQ || defined(__DOXYGEN__) + /** + * @brief returns if touchpad is pressed or not + * + * @return 1 if pressed, 0 otherwise + * + * @api + */ + uint8_t tpIRQ(void) { + return tp_lld_irq(); + } +#endif + +#if TOUCHPAD_HAS_PRESSURE || defined(__DOXYGEN__) /** * @brief Get the pressure. *