synaptics_touchpad.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /* Copyright (c) 2009 Nordic Semiconductor. All Rights Reserved.
  2. *
  3. * The information contained herein is property of Nordic Semiconductor ASA.
  4. * Terms and conditions of usage are described in detail in NORDIC
  5. * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
  6. *
  7. * Licensees are granted free, non-transferable use of the information. NO
  8. * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
  9. * the file.
  10. *
  11. */
  12. #ifndef SYNAPTICS_TOUCHPAD_H
  13. #define SYNAPTICS_TOUCHPAD_H
  14. /*lint ++flb "Enter library region" */
  15. #include <stdbool.h>
  16. #include <stdint.h>
  17. /** @file
  18. * @brief Synaptics Touchpad driver
  19. *
  20. *
  21. * @defgroup nrf_drivers_synaptics_touchpad Synaptics Touchpad driver.
  22. * @{
  23. * @ingroup nrf_drivers
  24. * @brief Synaptics Touchpad driver.
  25. */
  26. /**
  27. Touchpad register addresses.
  28. */
  29. #define TOUCHPAD_INT_STATUS 0x14 //!< Interrupt status register
  30. #define TOUCHPAD_BUTTON_STATUS 0x41 //!< Button status register
  31. #define TOUCHPAD_FINGER0_REL 0x30 //!< First register in finger delta block
  32. #define TOUCHPAD_GESTURE_FLAGS 0x3A //!< Gesture flags 0
  33. #define TOUCHPAD_SCROLL 0x3F //!< Scroll zone X / horizontal multifinger scroll
  34. #define TOUCHPAD_CONTROL 0x42 //!< Device control register
  35. #define TOUCHPAD_COMMAND 0x8F //!< Device command register
  36. #define TOUCHPAD_RESET 0x54 //!< Address of reset
  37. #define TOUCHPAD_PAGESELECT 0xFF //!< Address of page select (can be found in every page at the same address)
  38. #define TOUCHPAD_PRODUCT_ID 0xA2 //!< Address of product ID string
  39. /**
  40. Operational states
  41. */
  42. typedef enum
  43. {
  44. SleepmodeNormal = 0x00, //!< Normal operation
  45. SleepmodeSensorSleep = 0x01 //!< Low power operation
  46. } TouchpadSleepMode_t;
  47. /**
  48. @brief Function for Touchpad initialization.
  49. @param device_address TWI address of the device in bits [6:0]
  50. @retval true Touchpad was successfully identified and initialized
  51. @retval false Unexpected product ID or communication failure
  52. */
  53. bool touchpad_init(uint8_t device_address);
  54. /**
  55. @brief Function for attempting to soft-reset the device.
  56. @retval true Reset succeeded
  57. @retval false Reset failed
  58. */
  59. bool touchpad_reset(void);
  60. /**
  61. @brief Function for reading the interrupt status register of the device. This clears all interrupts.
  62. @param interrupt_status Address to store interrupt status to.
  63. @retval true Register contents read successfully to interrupt_status
  64. @retval false Reading failed
  65. */
  66. bool touchpad_interrupt_status_read(uint8_t *interrupt_status);
  67. /**
  68. @brief Function for sleep mode configuration.
  69. @note In low power mode the touchpad do not generate interrupts from touch sensing.
  70. @param[in] mode Operational mode
  71. @retval true Sleep mode set successfully
  72. @retval false Sleep mode setting failed
  73. */
  74. bool touchpad_set_sleep_mode(TouchpadSleepMode_t mode);
  75. /**
  76. @brief Function for reading a touchpad register contents over TWI.
  77. @param[in] register_address Register address
  78. @param[out] value Pointer to a data buffer where read data will be stored
  79. @retval true Register read succeeded
  80. @retval false Register read failed
  81. */
  82. bool touchpad_read_register(uint8_t register_address, uint8_t *value);
  83. /**
  84. @brief Function for writing a touchpad register contents over TWI.
  85. @param[in] register_address Register address
  86. @param[in] value Value to write to register
  87. @retval true Register write succeeded
  88. @retval false Register write failed
  89. */
  90. bool touchpad_write_register(uint8_t register_address, uint8_t value);
  91. /**
  92. @brief Function for writing touchpad register contents over TWI.
  93. Writes one or more consecutive registers.
  94. @param[out] product_id Pointer to a address to store product ID. Memory must be allocated for product_id_bytes number of bytes.
  95. @param[in] product_id_bytes Number of bytes to read
  96. @retval true Product ID read succeeded
  97. @retval false Product ID read failed
  98. */
  99. bool touchpad_product_id_read(uint8_t *product_id, uint8_t product_id_bytes);
  100. /**
  101. @brief Function for reading and verifying touchpad's product ID.
  102. @retval true Product ID is what was expected
  103. @retval false Product ID was not what was expected
  104. */
  105. bool touchpad_product_id_verify(void);
  106. /**
  107. *@}
  108. **/
  109. /*lint --flb "Leave library region" */
  110. #endif /* __TOUCHPAD_H__ */