pin.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. //*****************************************************************************
  2. //
  3. // pin.h
  4. //
  5. // Defines and Macros for the pin mux module
  6. //
  7. // Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
  8. //
  9. //
  10. // Redistribution and use in source and binary forms, with or without
  11. // modification, are permitted provided that the following conditions
  12. // are met:
  13. //
  14. // Redistributions of source code must retain the above copyright
  15. // notice, this list of conditions and the following disclaimer.
  16. //
  17. // Redistributions in binary form must reproduce the above copyright
  18. // notice, this list of conditions and the following disclaimer in the
  19. // documentation and/or other materials provided with the
  20. // distribution.
  21. //
  22. // Neither the name of Texas Instruments Incorporated nor the names of
  23. // its contributors may be used to endorse or promote products derived
  24. // from this software without specific prior written permission.
  25. //
  26. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  27. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  28. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  29. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  30. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  31. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  32. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  33. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  34. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  35. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  36. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  37. //
  38. //*****************************************************************************
  39. #ifndef __PIN_H__
  40. #define __PIN_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. // Macros Defining Pins
  53. //*****************************************************************************
  54. #define PIN_01 0x00000000
  55. #define PIN_02 0x00000001
  56. #define PIN_03 0x00000002
  57. #define PIN_04 0x00000003
  58. #define PIN_05 0x00000004
  59. #define PIN_06 0x00000005
  60. #define PIN_07 0x00000006
  61. #define PIN_08 0x00000007
  62. #define PIN_11 0x0000000A
  63. #define PIN_12 0x0000000B
  64. #define PIN_13 0x0000000C
  65. #define PIN_14 0x0000000D
  66. #define PIN_15 0x0000000E
  67. #define PIN_16 0x0000000F
  68. #define PIN_17 0x00000010
  69. #define PIN_18 0x00000011
  70. #define PIN_19 0x00000012
  71. #define PIN_20 0x00000013
  72. #define PIN_21 0x00000014
  73. #define PIN_45 0x0000002C
  74. #define PIN_46 0x0000002D
  75. #define PIN_47 0x0000002E
  76. #define PIN_48 0x0000002F
  77. #define PIN_49 0x00000030
  78. #define PIN_50 0x00000031
  79. #define PIN_52 0x00000033
  80. #define PIN_53 0x00000034
  81. #define PIN_55 0x00000036
  82. #define PIN_56 0x00000037
  83. #define PIN_57 0x00000038
  84. #define PIN_58 0x00000039
  85. #define PIN_59 0x0000003A
  86. #define PIN_60 0x0000003B
  87. #define PIN_61 0x0000003C
  88. #define PIN_62 0x0000003D
  89. #define PIN_63 0x0000003E
  90. #define PIN_64 0x0000003F
  91. //*****************************************************************************
  92. // Macros that can be used with PinConfigSet(), PinTypeGet(), PinStrengthGet()
  93. //*****************************************************************************
  94. #define PIN_MODE_0 0x00000000
  95. #define PIN_MODE_1 0x00000001
  96. #define PIN_MODE_2 0x00000002
  97. #define PIN_MODE_3 0x00000003
  98. #define PIN_MODE_4 0x00000004
  99. #define PIN_MODE_5 0x00000005
  100. #define PIN_MODE_6 0x00000006
  101. #define PIN_MODE_7 0x00000007
  102. #define PIN_MODE_8 0x00000008
  103. #define PIN_MODE_9 0x00000009
  104. #define PIN_MODE_10 0x0000000A
  105. #define PIN_MODE_11 0x0000000B
  106. #define PIN_MODE_12 0x0000000C
  107. #define PIN_MODE_13 0x0000000D
  108. #define PIN_MODE_14 0x0000000E
  109. #define PIN_MODE_15 0x0000000F
  110. // Note : PIN_MODE_255 is a dummy define for pinmux utility code generation
  111. // PIN_MODE_255 should never be used in any user code.
  112. #define PIN_MODE_255 0x000000FF
  113. //*****************************************************************************
  114. // Macros that can be used with PinDirModeSet() and returned from
  115. // PinDirModeGet().
  116. //*****************************************************************************
  117. #define PIN_DIR_MODE_IN 0x00000C00 // Pin is input
  118. #define PIN_DIR_MODE_OUT 0x00000800 // Pin is output
  119. #define PIN_DIR_MODE_HW 0x00000000 // Pin is peripheral function
  120. //*****************************************************************************
  121. // Macros that can be used with PinConfigSet()
  122. //*****************************************************************************
  123. #define PIN_STRENGTH_2MA 0x00000020
  124. #define PIN_STRENGTH_4MA 0x00000040
  125. #define PIN_STRENGTH_6MA 0x00000060
  126. #define PIN_TYPE_STD 0x00000000
  127. #define PIN_TYPE_STD_PU 0x00000100
  128. #define PIN_TYPE_STD_PD 0x00000200
  129. #define PIN_TYPE_OD 0x00000010
  130. #define PIN_TYPE_OD_PU 0x00000110
  131. #define PIN_TYPE_OD_PD 0x00000210
  132. #define PIN_TYPE_ANALOG 0x10000000
  133. //*****************************************************************************
  134. // Macros for mode and type
  135. //*****************************************************************************
  136. #define PAD_MODE_MASK 0x0000000F
  137. #define PAD_STRENGTH_MASK 0x000000E0
  138. #define PAD_TYPE_MASK 0x00000310
  139. #define PAD_CONFIG_BASE ((OCP_SHARED_BASE + OCP_SHARED_O_GPIO_PAD_CONFIG_0))
  140. //*****************************************************************************
  141. //
  142. // API Function prototypes
  143. //
  144. //*****************************************************************************
  145. extern void PinModeSet(unsigned long ulPin, unsigned long ulPinMode);
  146. extern void PinDirModeSet(unsigned long ulPin, unsigned long ulPinIO);
  147. extern unsigned long PinDirModeGet(unsigned long ulPin);
  148. extern unsigned long PinModeGet(unsigned long ulPin);
  149. extern void PinConfigGet(unsigned long ulPin,unsigned long *pulPinStrength,
  150. unsigned long *pulPinType);
  151. extern void PinConfigSet(unsigned long ulPin,unsigned long ulPinStrength,
  152. unsigned long ulPinType);
  153. extern void PinTypeUART(unsigned long ulPin,unsigned long ulPinMode);
  154. extern void PinTypeI2C(unsigned long ulPin,unsigned long ulPinMode);
  155. extern void PinTypeSPI(unsigned long ulPin,unsigned long ulPinMode);
  156. extern void PinTypeI2S(unsigned long ulPin,unsigned long ulPinMode);
  157. extern void PinTypeTimer(unsigned long ulPin,unsigned long ulPinMode);
  158. extern void PinTypeCamera(unsigned long ulPin,unsigned long ulPinMode);
  159. extern void PinTypeGPIO(unsigned long ulPin,unsigned long ulPinMode,
  160. tBoolean bOpenDrain);
  161. extern void PinTypeADC(unsigned long ulPin,unsigned long ulPinMode);
  162. extern void PinTypeSDHost(unsigned long ulPin,unsigned long ulPinMode);
  163. #ifdef __cplusplus
  164. }
  165. #endif
  166. #endif //__PIN_H__