drv_keypad.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /* Copyright (C) 2018 RDA Technologies Limited and/or its affiliates("RDA").
  2. * All rights reserved.
  3. *
  4. * This software is supplied "AS IS" without any warranties.
  5. * RDA assumes no responsibility or liability for the use of the software,
  6. * conveys no license or title under any patent, copyright, or mask work
  7. * right to the product. RDA reserves the right to make changes in the
  8. * software without notification. RDA also make no representation or
  9. * warranty that such application will be suitable for the specified use
  10. * without further testing or modification.
  11. */
  12. #ifndef _DRV_KEYPAD_H_
  13. #define _DRV_KEYPAD_H_
  14. #include <stdint.h>
  15. #include "quec_proj_config.h"
  16. #ifdef __cplusplus
  17. extern "C" {
  18. #endif
  19. /**
  20. * \brief keypad logic definition
  21. */
  22. #ifdef CONFIG_QUEC_PROJECT_FEATURE_KEYPAD
  23. typedef enum
  24. {
  25. KEY_MAP_POWER = 0, ///< power key
  26. KEY_MAP_0, ///< '0'
  27. KEY_MAP_1, ///< '1'
  28. KEY_MAP_2, ///< '2'
  29. KEY_MAP_3, ///< '3'
  30. KEY_MAP_4, ///< '4'
  31. KEY_MAP_5, ///< '5'
  32. KEY_MAP_6, ///< '6'
  33. KEY_MAP_7, ///< '7'
  34. KEY_MAP_8, ///< '8'
  35. KEY_MAP_9, ///< '9'
  36. KEY_MAP_STAR, ///< '*'
  37. KEY_MAP_SHARP, ///< '#'
  38. KEY_MAP_LEFT, ///< left
  39. KEY_MAP_RIGHT, ///< right
  40. KEY_MAP_UP, ///< up
  41. KEY_MAP_DOWN, ///< down
  42. KEY_MAP_OK, ///< ok
  43. KEY_MAP_CANCLE, ///< cancel
  44. KEY_MAP_SOFT_L, ///< left soft key
  45. KEY_MAP_SOFT_R, ///< rigfht soft key
  46. KEY_MAP_SIM1, ///< customized
  47. KEY_MAP_SIM2, ///< customized
  48. KEY_MAP_22,
  49. KEY_MAP_23,
  50. KEY_MAP_24,
  51. KEY_MAP_25,
  52. KEY_MAP_26,
  53. KEY_MAP_27,
  54. KEY_MAP_28,
  55. KEY_MAP_29,
  56. KEY_MAP_30,
  57. KEY_MAP_31,
  58. KEY_MAP_32,
  59. KEY_MAP_33,
  60. KEY_MAP_34,
  61. KEY_MAP_MAX_COUNT ///< total count
  62. } keyMap_t;
  63. #else
  64. typedef enum
  65. {
  66. KEY_MAP_POWER = 0, ///< power key
  67. KEY_MAP_0, ///< '0'
  68. KEY_MAP_1, ///< '1'
  69. KEY_MAP_2, ///< '2'
  70. KEY_MAP_3, ///< '3'
  71. KEY_MAP_4, ///< '4'
  72. KEY_MAP_5, ///< '5'
  73. KEY_MAP_6, ///< '6'
  74. KEY_MAP_7, ///< '7'
  75. KEY_MAP_8, ///< '8'
  76. KEY_MAP_9, ///< '9'
  77. KEY_MAP_STAR, ///< '*'
  78. KEY_MAP_SHARP, ///< '#'
  79. KEY_MAP_LEFT, ///< left
  80. KEY_MAP_RIGHT, ///< right
  81. KEY_MAP_UP, ///< up
  82. KEY_MAP_DOWN, ///< down
  83. KEY_MAP_OK, ///< ok
  84. KEY_MAP_CANCLE, ///< cancel
  85. KEY_MAP_SOFT_L, ///< left soft key
  86. KEY_MAP_SOFT_R, ///< rigfht soft key
  87. KEY_MAP_SIM1, ///< customized
  88. KEY_MAP_SIM2, ///< customized
  89. KEY_MAP_MAX_COUNT ///< total count
  90. } keyMap_t;
  91. #endif
  92. /**
  93. * @brief the key state
  94. */
  95. typedef enum
  96. {
  97. KEY_STATE_PRESS = (1 << 0),
  98. KEY_STATE_RELEASE = (1 << 1),
  99. } keyState_t;
  100. /**
  101. * @brief function type, key event handler
  102. */
  103. typedef void (*keyEventCb_t)(keyMap_t key, keyState_t evt, void *p);
  104. /**
  105. * @brief init the keypad driver
  106. */
  107. void drvKeypadInit();
  108. /**
  109. * @brief set key event handler
  110. *
  111. * @param evtmsk the event mask caller care about
  112. * @param cb the handler
  113. * @param ctx caller context
  114. */
  115. void drvKeypadSetCB(keyEventCb_t cb, uint32_t mask, void *ctx);
  116. /**
  117. * @brief get key current state
  118. *
  119. * @param key the key indicator
  120. * @return
  121. * - (-1) fail
  122. * - KEY_STATE_PRESS the key is pressed
  123. * - KEY_STATE_RELEASE the key is released
  124. */
  125. int drvKeypadState(keyMap_t key);
  126. /**
  127. * @brief Get all press keys code from register,values can not more than 10 .
  128. * Provided for bbat autotest use.
  129. *
  130. * @param key array pointer
  131. * @param count variable addr
  132. * @return
  133. * - (-1) fail
  134. * 1 pass
  135. */
  136. int bbatGetAllScanKeyId(uint8_t *key, int *count);
  137. /**
  138. * @brief reconfig keypad gpio
  139. *
  140. * @param fun_pad function and pad
  141. */
  142. void drvKeypadGpioReconfig(unsigned fun_pad);
  143. #ifdef __cplusplus
  144. }
  145. #endif
  146. #endif