wm_gpio.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. /**
  2. * @file wm_gpio.h
  3. *
  4. * @brief GPIO Driver Module
  5. *
  6. * @author dave
  7. *
  8. * Copyright (c) 2014 Winner Microelectronics Co., Ltd.
  9. */
  10. #ifndef WM_GPIO_H
  11. #define WM_GPIO_H
  12. #include "wm_type_def.h"
  13. #include "wm_io.h"
  14. /** gpio interrupte callback function */
  15. typedef void (*tls_gpio_irq_callback)(void *arg);
  16. /** Indicating gpio direction */
  17. enum tls_gpio_dir {
  18. WM_GPIO_DIR_OUTPUT, /**< output */
  19. WM_GPIO_DIR_INPUT /**< input */
  20. };
  21. /** Indicating gpio attribute */
  22. enum tls_gpio_attr {
  23. WM_GPIO_ATTR_FLOATING, /**< floating status */
  24. WM_GPIO_ATTR_PULLHIGH, /**< pull high */
  25. WM_GPIO_ATTR_PULLLOW /**< pull low */
  26. };
  27. /** Indicating gpio interrupt trigger type */
  28. enum tls_gpio_irq_trig {
  29. WM_GPIO_IRQ_TRIG_RISING_EDGE, /**< rising edge arises the interrupt */
  30. WM_GPIO_IRQ_TRIG_FALLING_EDGE, /**< falling edge arises the interrupt */
  31. WM_GPIO_IRQ_TRIG_DOUBLE_EDGE, /**< both rising edge and falling edge arise the interrupt */
  32. WM_GPIO_IRQ_TRIG_HIGH_LEVEL, /**< high power level arises the interrupt */
  33. WM_GPIO_IRQ_TRIG_LOW_LEVEL /**< low power level arises the interrupt */
  34. };
  35. /**
  36. * @defgroup Driver_APIs Driver APIs
  37. * @brief Driver APIs
  38. */
  39. /**
  40. * @addtogroup Driver_APIs
  41. * @{
  42. */
  43. /**
  44. * @defgroup GPIO_Driver_APIs GPIO Driver APIs
  45. * @brief GPIO driver APIs
  46. */
  47. /**
  48. * @addtogroup GPIO_Driver_APIs
  49. * @{
  50. */
  51. /**
  52. * @brief This function is used to config gpio function
  53. *
  54. * @param[in] gpio_pin gpio pin num
  55. * @param[in] dir gpio direction
  56. * @param[in] attr gpio attribute
  57. *
  58. * @return None
  59. *
  60. * @note None
  61. */
  62. void tls_gpio_cfg(enum tls_io_name gpio_pin, enum tls_gpio_dir dir, enum tls_gpio_attr attr);
  63. /**
  64. * @brief This function is used to read gpio status
  65. *
  66. * @param[in] gpio_pin gpio pin num
  67. *
  68. * @retval 0 power level is low
  69. * @retval 1 power level is high
  70. *
  71. * @note None
  72. */
  73. u8 tls_gpio_read(enum tls_io_name gpio_pin);
  74. /**
  75. * @brief This function is used to modify gpio status
  76. *
  77. * @param[in] gpio_pin gpio pin num
  78. * @param[in] value power level
  79. * 0: low power level
  80. * 1: high power level
  81. *
  82. * @return None
  83. *
  84. * @note None
  85. */
  86. void tls_gpio_write(enum tls_io_name gpio_pin, u8 value);
  87. //hyj
  88. void tls_gpio_pulse(enum tls_io_name gpio_pin,u8* level,u16 len,u16 delay);
  89. /**
  90. * @brief This function is used to config gpio interrupt
  91. *
  92. * @param[in] gpio_pin gpio pin num
  93. * @param[in] mode interrupt trigger type
  94. *
  95. * @return None
  96. *
  97. * @note None
  98. */
  99. void tls_gpio_irq_enable(enum tls_io_name gpio_pin, enum tls_gpio_irq_trig mode);
  100. /**
  101. * @brief This function is used to disable gpio interrupt
  102. *
  103. * @param[in] gpio_pin gpio pin num
  104. *
  105. * @return None
  106. *
  107. * @note None
  108. */
  109. void tls_gpio_irq_disable(enum tls_io_name gpio_pin);
  110. /**
  111. * @brief This function is used to get gpio interrupt status
  112. *
  113. * @param[in] gpio_pin gpio pin num
  114. *
  115. * @retval 0 no interrupt happened
  116. * @retval 1 interrupt happened
  117. *
  118. * @note None
  119. */
  120. u8 tls_get_gpio_irq_status(enum tls_io_name gpio_pin);
  121. /**
  122. * @brief This function is used to clear gpio interrupt flag
  123. *
  124. * @param[in] gpio_pin gpio pin num
  125. *
  126. * @return None
  127. *
  128. * @note None
  129. */
  130. void tls_clr_gpio_irq_status(enum tls_io_name gpio_pin);
  131. /**
  132. * @brief This function is used to register gpio interrupt
  133. *
  134. * @param[in] gpio_pin gpio pin num
  135. * @param[in] callback the gpio interrupt call back function
  136. * @param[in] arg parammeter for the callback
  137. *
  138. * @return None
  139. *
  140. * @note
  141. * gpio callback function is called in interrupt,
  142. * so can not operate the critical data in the callback fuuction,
  143. * recommendation to send messages to other tasks to operate it.
  144. */
  145. void tls_gpio_isr_register(enum tls_io_name gpio_pin,
  146. tls_gpio_irq_callback callback,
  147. void *arg);
  148. /**
  149. * @}
  150. */
  151. /**
  152. * @}
  153. */
  154. #endif /* end of WM_GPIO_H */