cmem7_gpio.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /**
  2. *****************************************************************************
  3. * @file cmem7_gpio.h
  4. *
  5. * @brief CMEM7 GPIO header file
  6. *
  7. *
  8. * @version V1.0
  9. * @date 3. September 2013
  10. *
  11. * @note
  12. *
  13. *****************************************************************************
  14. * @attention
  15. *
  16. * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
  17. * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
  18. * TIME. AS A RESULT, CAPITAL-MICRO SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
  19. * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
  20. * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
  21. * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
  22. *
  23. * <h2><center>&copy; COPYRIGHT 2013 Capital-micro </center></h2>
  24. *****************************************************************************
  25. */
  26. #ifndef __CMEM7_GPIO_H
  27. #define __CMEM7_GPIO_H
  28. #ifdef __cplusplus
  29. extern "C" {
  30. #endif
  31. #include "cmem7.h"
  32. #include "cmem7_conf.h"
  33. /** @defgroup GPIO_GROUP
  34. * @{
  35. */
  36. typedef enum {
  37. GPIO_GROUP_GPIO,
  38. } GPIO_GROUP;
  39. #define IS_GPIO_GROUP(GROUP) (((GROUP) == GPIO_GROUP_GPIO))
  40. /**
  41. * @}
  42. */
  43. /** @defgroup GPIO_PWM_CHANNEL
  44. * @{
  45. */
  46. typedef enum {
  47. GPIO_PWM_CHANNEL_GPIO_31,
  48. } GPIO_PWM_CHANNEL;
  49. #define IS_GPIO_PWM_CHANNEL(CHANNEL) (((CHANNEL) == GPIO_PWM_CHANNEL_GPIO_31))
  50. /**
  51. * @}
  52. */
  53. /**
  54. * @brief GPIO initialization
  55. * @note This function should be called at first before any other interfaces.
  56. * @param[in] Group GPIO group, which is a value of @ref GPIO_GROUP
  57. * @param[in] PositiveTrigger Positive edge interrupt trigger if true, or negative edge
  58. * @retval None
  59. */
  60. void GPIO_Init(uint8_t Group, uint32_t PositiveTrigger);
  61. /**
  62. * @brief Enable or disable GPIO output in the specific group.
  63. * @param[in] Group GPIO group, which is a value of @ref GPIO_GROUP
  64. * @param[in] Enable each bit indicates if the corresponding GPIO pin
  65. * in the specific GPIO group is enable or not
  66. * @retval None
  67. */
  68. void GPIO_EnableOutput(uint8_t Group, uint32_t Enable);
  69. /**
  70. * @brief Enable or disable GPIO interrupt in the specific group.
  71. * @param[in] Group GPIO group, which is a value of @ref GPIO_GROUP
  72. * @param[in] Enable each bit indicates if the corresponding GPIO pin interrupt
  73. * in the specific GPIO group is enable or not
  74. * @retval None
  75. */
  76. void GPIO_EnableInt(uint8_t Group, uint32_t Enable);
  77. /**
  78. * @brief Check specific interrupts are set or not
  79. * @param[in] Group GPIO group, which is a value of @ref GPIO_GROUP
  80. * @retval uint32_t each bit indicates if the corresponding GPIO pin interrupt
  81. * in the specific GPIO group is set or not
  82. */
  83. uint32_t GPIO_GetIntStatus(uint8_t Group);
  84. /**
  85. * @brief Clear GPIO interrupt in the specific group.
  86. * @param[in] Group GPIO group, which is a value of @ref GPIO_GROUP
  87. * @param[in] Clear each bit indicates if the corresponding GPIO pin interrupt
  88. * in the specific GPIO group is clear or not
  89. * @retval None
  90. */
  91. void GPIO_ClearInt(uint8_t Group, uint32_t Clear);
  92. /**
  93. * @brief Get value of each GPIO pin in the specific group
  94. * @param[in] Group GPIO group, which is a value of @ref GPIO_GROUP
  95. * @retval uint32_t each bit indicates value of the corresponding GPIO pin
  96. * in the specific GPIO group
  97. */
  98. uint32_t GPIO_Read(uint8_t Group);
  99. /**
  100. * @brief Set value of each GPIO pin in the specific group
  101. * @param[in] Group GPIO group, which is a value of @ref GPIO_GROUP
  102. * @param[in] Unmask each bit indicates value of the corresponding GPIO pin
  103. * in the specific GPIO group is set or not
  104. * @param[in] data each bit indicates value of the corresponding GPIO pin
  105. * in the specific GPIO group to be set
  106. * @retval None
  107. */
  108. void GPIO_Write(uint8_t Group, uint32_t Unmask, uint32_t data);
  109. /**
  110. * @brief Initialize PWM for the specific GPIO pin
  111. * @note It can work before call GPIO_EnableOutput for the specific GPIO pin
  112. * @param[in] Channel PWM channel, which is a value of @ref GPIO_PWM_CHANNEL
  113. * @param[in] HighLevelNanoSecond Nanosecond which high level lasts
  114. * @param[in] LowLevelNanoSecond Nanosecond which low level lasts
  115. * @retval None
  116. * @see GPIO_EnableOutput
  117. */
  118. void GPIO_InitPwm(uint8_t Channel, uint32_t HighLevelNanoSecond, uint32_t LowLevelNanoSecond);
  119. /**
  120. * @brief Enable or disable GPIO PWM in the specific channel.
  121. * @param[in] Channel PWM channel, which is a value of @ref GPIO_PWM_CHANNEL
  122. * @param[in] Enable The bit indicates if the specific channel is enable or not
  123. * @retval None
  124. */
  125. void GPIO_EnablePwm(uint8_t Channel, BOOL Enable);
  126. /**
  127. xjf 20150324
  128. **/
  129. void GPIO_SetBits(uint32_t mask);
  130. void GPIO_clrBits(uint32_t mask);
  131. uint32_t GPIO_getBits(uint32_t mask);
  132. #ifdef __cplusplus
  133. }
  134. #endif
  135. #endif /* __CMEM7_GPIO_H */