gpio.h 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. //*****************************************************************************
  2. //
  3. // gpio.h - Defines and Macros for GPIO API.
  4. //
  5. // Copyright (c) 2005-2011 Texas Instruments Incorporated. All rights reserved.
  6. // Software License Agreement
  7. //
  8. // Texas Instruments (TI) is supplying this software for use solely and
  9. // exclusively on TI's microcontroller products. The software is owned by
  10. // TI and/or its suppliers, and is protected under applicable copyright
  11. // laws. You may not combine this software with "viral" open-source
  12. // software in order to form a larger program.
  13. //
  14. // THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
  15. // NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
  16. // NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  17. // A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
  18. // CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
  19. // DAMAGES, FOR ANY REASON WHATSOEVER.
  20. //
  21. // This is part of revision 8264 of the Stellaris Peripheral Driver Library.
  22. //
  23. //*****************************************************************************
  24. #ifndef __GPIO_H__
  25. #define __GPIO_H__
  26. //*****************************************************************************
  27. //
  28. // If building with a C++ compiler, make all of the definitions in this header
  29. // have a C binding.
  30. //
  31. //*****************************************************************************
  32. #ifdef __cplusplus
  33. extern "C"
  34. {
  35. #endif
  36. //*****************************************************************************
  37. //
  38. // The following values define the bit field for the ucPins argument to several
  39. // of the APIs.
  40. //
  41. //*****************************************************************************
  42. #define GPIO_PIN_0 0x00000001 // GPIO pin 0
  43. #define GPIO_PIN_1 0x00000002 // GPIO pin 1
  44. #define GPIO_PIN_2 0x00000004 // GPIO pin 2
  45. #define GPIO_PIN_3 0x00000008 // GPIO pin 3
  46. #define GPIO_PIN_4 0x00000010 // GPIO pin 4
  47. #define GPIO_PIN_5 0x00000020 // GPIO pin 5
  48. #define GPIO_PIN_6 0x00000040 // GPIO pin 6
  49. #define GPIO_PIN_7 0x00000080 // GPIO pin 7
  50. //*****************************************************************************
  51. //
  52. // Values that can be passed to GPIODirModeSet as the ulPinIO parameter, and
  53. // returned from GPIODirModeGet.
  54. //
  55. //*****************************************************************************
  56. #define GPIO_DIR_MODE_IN 0x00000000 // Pin is a GPIO input
  57. #define GPIO_DIR_MODE_OUT 0x00000001 // Pin is a GPIO output
  58. #define GPIO_DIR_MODE_HW 0x00000002 // Pin is a peripheral function
  59. //*****************************************************************************
  60. //
  61. // Values that can be passed to GPIOIntTypeSet as the ulIntType parameter, and
  62. // returned from GPIOIntTypeGet.
  63. //
  64. //*****************************************************************************
  65. #define GPIO_FALLING_EDGE 0x00000000 // Interrupt on falling edge
  66. #define GPIO_RISING_EDGE 0x00000004 // Interrupt on rising edge
  67. #define GPIO_BOTH_EDGES 0x00000001 // Interrupt on both edges
  68. #define GPIO_LOW_LEVEL 0x00000002 // Interrupt on low level
  69. #define GPIO_HIGH_LEVEL 0x00000007 // Interrupt on high level
  70. #define GPIO_DISCRETE_INT 0x00010000 // Interrupt for individual pins
  71. //*****************************************************************************
  72. //
  73. // Values that can be passed to GPIOPadConfigSet as the ulStrength parameter,
  74. // and returned by GPIOPadConfigGet in the *pulStrength parameter.
  75. //
  76. //*****************************************************************************
  77. #define GPIO_STRENGTH_2MA 0x00000001 // 2mA drive strength
  78. #define GPIO_STRENGTH_4MA 0x00000002 // 4mA drive strength
  79. #define GPIO_STRENGTH_8MA 0x00000004 // 8mA drive strength
  80. #define GPIO_STRENGTH_8MA_SC 0x0000000C // 8mA drive with slew rate control
  81. //*****************************************************************************
  82. //
  83. // Values that can be passed to GPIOPadConfigSet as the ulPadType parameter,
  84. // and returned by GPIOPadConfigGet in the *pulPadType parameter.
  85. //
  86. //*****************************************************************************
  87. #define GPIO_PIN_TYPE_STD 0x00000008 // Push-pull
  88. #define GPIO_PIN_TYPE_STD_WPU 0x0000000A // Push-pull with weak pull-up
  89. #define GPIO_PIN_TYPE_STD_WPD 0x0000000C // Push-pull with weak pull-down
  90. #define GPIO_PIN_TYPE_OD 0x00000009 // Open-drain
  91. #define GPIO_PIN_TYPE_OD_WPU 0x0000000B // Open-drain with weak pull-up
  92. #define GPIO_PIN_TYPE_OD_WPD 0x0000000D // Open-drain with weak pull-down
  93. #define GPIO_PIN_TYPE_ANALOG 0x00000000 // Analog comparator
  94. //*****************************************************************************
  95. //
  96. // Prototypes for the APIs.
  97. //
  98. //*****************************************************************************
  99. extern void GPIODirModeSet(unsigned long ulPort, unsigned char ucPins,
  100. unsigned long ulPinIO);
  101. extern unsigned long GPIODirModeGet(unsigned long ulPort, unsigned char ucPin);
  102. extern void GPIOIntTypeSet(unsigned long ulPort, unsigned char ucPins,
  103. unsigned long ulIntType);
  104. extern unsigned long GPIOIntTypeGet(unsigned long ulPort, unsigned char ucPin);
  105. extern void GPIOPadConfigSet(unsigned long ulPort, unsigned char ucPins,
  106. unsigned long ulStrength,
  107. unsigned long ulPadType);
  108. extern void GPIOPadConfigGet(unsigned long ulPort, unsigned char ucPin,
  109. unsigned long *pulStrength,
  110. unsigned long *pulPadType);
  111. extern void GPIOPinIntEnable(unsigned long ulPort, unsigned char ucPins);
  112. extern void GPIOPinIntDisable(unsigned long ulPort, unsigned char ucPins);
  113. extern long GPIOPinIntStatus(unsigned long ulPort, tBoolean bMasked);
  114. extern void GPIOPinIntClear(unsigned long ulPort, unsigned char ucPins);
  115. extern void GPIOPortIntRegister(unsigned long ulPort,
  116. void (*pfnIntHandler)(void));
  117. extern void GPIOPortIntUnregister(unsigned long ulPort);
  118. extern long GPIOPinRead(unsigned long ulPort, unsigned char ucPins);
  119. extern void GPIOPinWrite(unsigned long ulPort, unsigned char ucPins,
  120. unsigned char ucVal);
  121. extern void GPIOPinConfigure(unsigned long ulPinConfig);
  122. extern void GPIOPinTypeADC(unsigned long ulPort, unsigned char ucPins);
  123. extern void GPIOPinTypeCAN(unsigned long ulPort, unsigned char ucPins);
  124. extern void GPIOPinTypeComparator(unsigned long ulPort, unsigned char ucPins);
  125. extern void GPIOPinTypeEPI(unsigned long ulPort, unsigned char ucPins);
  126. extern void GPIOPinTypeEthernetLED(unsigned long ulPort, unsigned char ucPins);
  127. extern void GPIOPinTypeEthernetMII(unsigned long ulPort, unsigned char ucPins);
  128. extern void GPIOPinTypeFan(unsigned long ulPort, unsigned char ucPins);
  129. extern void GPIOPinTypeGPIOInput(unsigned long ulPort, unsigned char ucPins);
  130. extern void GPIOPinTypeGPIOOutput(unsigned long ulPort, unsigned char ucPins);
  131. extern void GPIOPinTypeGPIOOutputOD(unsigned long ulPort,
  132. unsigned char ucPins);
  133. extern void GPIOPinTypeI2C(unsigned long ulPort, unsigned char ucPins);
  134. extern void GPIOPinTypeI2CSCL(unsigned long ulPort, unsigned char ucPins);
  135. extern void GPIOPinTypeI2S(unsigned long ulPort, unsigned char ucPins);
  136. extern void GPIOPinTypeLPC(unsigned long ulPort, unsigned char ucPins);
  137. extern void GPIOPinTypePECIRx(unsigned long ulPort, unsigned char ucPins);
  138. extern void GPIOPinTypePECITx(unsigned long ulPort, unsigned char ucPins);
  139. extern void GPIOPinTypePWM(unsigned long ulPort, unsigned char ucPins);
  140. extern void GPIOPinTypeQEI(unsigned long ulPort, unsigned char ucPins);
  141. extern void GPIOPinTypeSSI(unsigned long ulPort, unsigned char ucPins);
  142. extern void GPIOPinTypeTimer(unsigned long ulPort, unsigned char ucPins);
  143. extern void GPIOPinTypeUART(unsigned long ulPort, unsigned char ucPins);
  144. extern void GPIOPinTypeUSBAnalog(unsigned long ulPort, unsigned char ucPins);
  145. extern void GPIOPinTypeUSBDigital(unsigned long ulPort, unsigned char ucPins);
  146. extern void GPIODMATriggerEnable(unsigned long ulPort, unsigned char ucPins);
  147. extern void GPIODMATriggerDisable(unsigned long ulPort, unsigned char ucPins);
  148. extern void GPIOADCTriggerEnable(unsigned long ulPort, unsigned char ucPins);
  149. extern void GPIOADCTriggerDisable(unsigned long ulPort, unsigned char ucPins);
  150. //****************************************************************************
  151. //
  152. // The definitions for GPIOPinConfigure previously resided in this file but
  153. // have been moved to pin_map.h and made part-specific (in other words, only
  154. // those definitions that are valid based on the selected part, as defined by
  155. // PART_<partnum>, will be made available). For backwards compatibility,
  156. // pin_map.h is included here so that the expected definitions will still be
  157. // available (though part-specific now, so some that were previously available
  158. // but inappropriate for the given part will not be available).
  159. //
  160. //*****************************************************************************
  161. #ifndef DEPRECATED
  162. #include "pin_map.h"
  163. #endif
  164. //*****************************************************************************
  165. //
  166. // Mark the end of the C bindings section for C++ compilers.
  167. //
  168. //*****************************************************************************
  169. #ifdef __cplusplus
  170. }
  171. #endif
  172. #endif // __GPIO_H__