gpio.h 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. //*****************************************************************************
  2. //
  3. // gpio.h - Defines and Macros for GPIO API.
  4. //
  5. // Copyright (c) 2005-2014 Texas Instruments Incorporated. All rights reserved.
  6. // Software License Agreement
  7. //
  8. // Redistribution and use in source and binary forms, with or without
  9. // modification, are permitted provided that the following conditions
  10. // are met:
  11. //
  12. // Redistributions of source code must retain the above copyright
  13. // notice, this list of conditions and the following disclaimer.
  14. //
  15. // Redistributions in binary form must reproduce the above copyright
  16. // notice, this list of conditions and the following disclaimer in the
  17. // documentation and/or other materials provided with the
  18. // distribution.
  19. //
  20. // Neither the name of Texas Instruments Incorporated nor the names of
  21. // its contributors may be used to endorse or promote products derived
  22. // from this software without specific prior written permission.
  23. //
  24. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  25. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  26. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  27. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  28. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  29. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  30. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  31. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  32. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  33. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  34. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  35. //
  36. // This is part of revision 2.1.0.12573 of the Tiva Peripheral Driver Library.
  37. //
  38. //*****************************************************************************
  39. #ifndef __DRIVERLIB_GPIO_H__
  40. #define __DRIVERLIB_GPIO_H__
  41. //*****************************************************************************
  42. //
  43. // If building with a C++ compiler, make all of the definitions in this header
  44. // have a C binding.
  45. //
  46. //*****************************************************************************
  47. #ifdef __cplusplus
  48. extern "C"
  49. {
  50. #endif
  51. //*****************************************************************************
  52. //
  53. // The following values define the bit field for the ui8Pins argument to
  54. // several of the APIs.
  55. //
  56. //*****************************************************************************
  57. #define GPIO_PIN_0 0x00000001 // GPIO pin 0
  58. #define GPIO_PIN_1 0x00000002 // GPIO pin 1
  59. #define GPIO_PIN_2 0x00000004 // GPIO pin 2
  60. #define GPIO_PIN_3 0x00000008 // GPIO pin 3
  61. #define GPIO_PIN_4 0x00000010 // GPIO pin 4
  62. #define GPIO_PIN_5 0x00000020 // GPIO pin 5
  63. #define GPIO_PIN_6 0x00000040 // GPIO pin 6
  64. #define GPIO_PIN_7 0x00000080 // GPIO pin 7
  65. //*****************************************************************************
  66. //
  67. // Values that can be passed to GPIODirModeSet as the ui32PinIO parameter, and
  68. // returned from GPIODirModeGet.
  69. //
  70. //*****************************************************************************
  71. #define GPIO_DIR_MODE_IN 0x00000000 // Pin is a GPIO input
  72. #define GPIO_DIR_MODE_OUT 0x00000001 // Pin is a GPIO output
  73. #define GPIO_DIR_MODE_HW 0x00000002 // Pin is a peripheral function
  74. //*****************************************************************************
  75. //
  76. // Values that can be passed to GPIOIntTypeSet as the ui32IntType parameter,
  77. // and returned from GPIOIntTypeGet.
  78. //
  79. //*****************************************************************************
  80. #define GPIO_FALLING_EDGE 0x00000000 // Interrupt on falling edge
  81. #define GPIO_RISING_EDGE 0x00000004 // Interrupt on rising edge
  82. #define GPIO_BOTH_EDGES 0x00000001 // Interrupt on both edges
  83. #define GPIO_LOW_LEVEL 0x00000002 // Interrupt on low level
  84. #define GPIO_HIGH_LEVEL 0x00000006 // Interrupt on high level
  85. #define GPIO_DISCRETE_INT 0x00010000 // Interrupt for individual pins
  86. //*****************************************************************************
  87. //
  88. // Values that can be passed to GPIOPadConfigSet as the ui32Strength parameter,
  89. // and returned by GPIOPadConfigGet in the *pui32Strength parameter.
  90. //
  91. //*****************************************************************************
  92. #define GPIO_STRENGTH_2MA 0x00000001 // 2mA drive strength
  93. #define GPIO_STRENGTH_4MA 0x00000002 // 4mA drive strength
  94. #define GPIO_STRENGTH_6MA 0x00000065 // 6mA drive strength
  95. #define GPIO_STRENGTH_8MA 0x00000066 // 8mA drive strength
  96. #define GPIO_STRENGTH_8MA_SC 0x0000006E // 8mA drive with slew rate control
  97. #define GPIO_STRENGTH_10MA 0x00000075 // 10mA drive strength
  98. #define GPIO_STRENGTH_12MA 0x00000077 // 12mA drive strength
  99. //*****************************************************************************
  100. //
  101. // Values that can be passed to GPIOPadConfigSet as the ui32PadType parameter,
  102. // and returned by GPIOPadConfigGet in the *pui32PadType parameter.
  103. //
  104. //*****************************************************************************
  105. #define GPIO_PIN_TYPE_STD 0x00000008 // Push-pull
  106. #define GPIO_PIN_TYPE_STD_WPU 0x0000000A // Push-pull with weak pull-up
  107. #define GPIO_PIN_TYPE_STD_WPD 0x0000000C // Push-pull with weak pull-down
  108. #define GPIO_PIN_TYPE_OD 0x00000009 // Open-drain
  109. #define GPIO_PIN_TYPE_ANALOG 0x00000000 // Analog comparator
  110. #define GPIO_PIN_TYPE_WAKE_HIGH 0x00000208 // Hibernate wake, high
  111. #define GPIO_PIN_TYPE_WAKE_LOW 0x00000108 // Hibernate wake, low
  112. //*****************************************************************************
  113. //
  114. // Values that can be passed to GPIOIntEnable() and GPIOIntDisable() functions
  115. // in the ui32IntFlags parameter.
  116. //
  117. //*****************************************************************************
  118. #define GPIO_INT_PIN_0 0x00000001
  119. #define GPIO_INT_PIN_1 0x00000002
  120. #define GPIO_INT_PIN_2 0x00000004
  121. #define GPIO_INT_PIN_3 0x00000008
  122. #define GPIO_INT_PIN_4 0x00000010
  123. #define GPIO_INT_PIN_5 0x00000020
  124. #define GPIO_INT_PIN_6 0x00000040
  125. #define GPIO_INT_PIN_7 0x00000080
  126. #define GPIO_INT_DMA 0x00000100
  127. //*****************************************************************************
  128. //
  129. // Prototypes for the APIs.
  130. //
  131. //*****************************************************************************
  132. extern void GPIODirModeSet(uint32_t ui32Port, uint8_t ui8Pins,
  133. uint32_t ui32PinIO);
  134. extern uint32_t GPIODirModeGet(uint32_t ui32Port, uint8_t ui8Pin);
  135. extern void GPIOIntTypeSet(uint32_t ui32Port, uint8_t ui8Pins,
  136. uint32_t ui32IntType);
  137. extern uint32_t GPIOIntTypeGet(uint32_t ui32Port, uint8_t ui8Pin);
  138. extern void GPIOPadConfigSet(uint32_t ui32Port, uint8_t ui8Pins,
  139. uint32_t ui32Strength, uint32_t ui32PadType);
  140. extern void GPIOPadConfigGet(uint32_t ui32Port, uint8_t ui8Pin,
  141. uint32_t *pui32Strength, uint32_t *pui32PadType);
  142. extern void GPIOIntEnable(uint32_t ui32Port, uint32_t ui32IntFlags);
  143. extern void GPIOIntDisable(uint32_t ui32Port, uint32_t ui32IntFlags);
  144. extern uint32_t GPIOIntStatus(uint32_t ui32Port, bool bMasked);
  145. extern void GPIOIntClear(uint32_t ui32Port, uint32_t ui32IntFlags);
  146. extern void GPIOIntRegister(uint32_t ui32Port, void (*pfnIntHandler)(void));
  147. extern void GPIOIntUnregister(uint32_t ui32Port);
  148. extern int32_t GPIOPinRead(uint32_t ui32Port, uint8_t ui8Pins);
  149. extern void GPIOPinWrite(uint32_t ui32Port, uint8_t ui8Pins, uint8_t ui8Val);
  150. extern void GPIOPinConfigure(uint32_t ui32PinConfig);
  151. extern void GPIOPinTypeADC(uint32_t ui32Port, uint8_t ui8Pins);
  152. extern void GPIOPinTypeCAN(uint32_t ui32Port, uint8_t ui8Pins);
  153. extern void GPIOPinTypeComparator(uint32_t ui32Port, uint8_t ui8Pins);
  154. extern void GPIOPinTypeEPI(uint32_t ui32Port, uint8_t ui8Pins);
  155. extern void GPIOPinTypeEthernetLED(uint32_t ui32Port, uint8_t ui8Pins);
  156. extern void GPIOPinTypeEthernetMII(uint32_t ui32Port, uint8_t ui8Pins);
  157. extern void GPIOPinTypeGPIOInput(uint32_t ui32Port, uint8_t ui8Pins);
  158. extern void GPIOPinTypeGPIOOutput(uint32_t ui32Port, uint8_t ui8Pins);
  159. extern void GPIOPinTypeGPIOOutputOD(uint32_t ui32Port, uint8_t ui8Pins);
  160. extern void GPIOPinTypeI2C(uint32_t ui32Port, uint8_t ui8Pins);
  161. extern void GPIOPinTypeI2CSCL(uint32_t ui32Port, uint8_t ui8Pins);
  162. extern void GPIOPinTypeLCD(uint32_t ui32Port, uint8_t ui8Pins);
  163. extern void GPIOPinTypePWM(uint32_t ui32Port, uint8_t ui8Pins);
  164. extern void GPIOPinTypeQEI(uint32_t ui32Port, uint8_t ui8Pins);
  165. extern void GPIOPinTypeSSI(uint32_t ui32Port, uint8_t ui8Pins);
  166. extern void GPIOPinTypeTimer(uint32_t ui32Port, uint8_t ui8Pins);
  167. extern void GPIOPinTypeUART(uint32_t ui32Port, uint8_t ui8Pins);
  168. extern void GPIOPinTypeUSBAnalog(uint32_t ui32Port, uint8_t ui8Pins);
  169. extern void GPIOPinTypeUSBDigital(uint32_t ui32Port, uint8_t ui8Pins);
  170. extern void GPIOPinTypeWakeHigh(uint32_t ui32Port, uint8_t ui8Pins);
  171. extern void GPIOPinTypeWakeLow(uint32_t ui32Port, uint8_t ui8Pins);
  172. extern uint32_t GPIOPinWakeStatus(uint32_t ui32Port);
  173. extern void GPIODMATriggerEnable(uint32_t ui32Port, uint8_t ui8Pins);
  174. extern void GPIODMATriggerDisable(uint32_t ui32Port, uint8_t ui8Pins);
  175. extern void GPIOADCTriggerEnable(uint32_t ui32Port, uint8_t ui8Pins);
  176. extern void GPIOADCTriggerDisable(uint32_t ui32Port, uint8_t ui8Pins);
  177. //*****************************************************************************
  178. //
  179. // Mark the end of the C bindings section for C++ compilers.
  180. //
  181. //*****************************************************************************
  182. #ifdef __cplusplus
  183. }
  184. #endif
  185. #endif // __DRIVERLIB_GPIO_H__