lpc177x_8x_pinsel.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. /**********************************************************************
  2. * $Id$ lpc177x_8x_pinsel.h 2011-06-02
  3. *//**
  4. * @file lpc177x_8x_pinsel.h
  5. * @brief Contains all macro definitions and function prototypes
  6. * support for Pin-connection block firmware library on LPC177x_8x
  7. * @version 1.0
  8. * @date 02. June. 2011
  9. * @author NXP MCU SW Application Team
  10. *
  11. * Copyright(C) 2011, NXP Semiconductor
  12. * All rights reserved.
  13. *
  14. ***********************************************************************
  15. * Software that is described herein is for illustrative purposes only
  16. * which provides customers with programming information regarding the
  17. * products. This software is supplied "AS IS" without any warranties.
  18. * NXP Semiconductors assumes no responsibility or liability for the
  19. * use of the software, conveys no license or title under any patent,
  20. * copyright, or mask work right to the product. NXP Semiconductors
  21. * reserves the right to make changes in the software without
  22. * notification. NXP Semiconductors also make no representation or
  23. * warranty that such application will be suitable for the specified
  24. * use without further testing or modification.
  25. **********************************************************************/
  26. /* Peripheral group ----------------------------------------------------------- */
  27. /** @defgroup PINSEL Pin Selection
  28. * @ingroup LPC177x_8xCMSIS_FwLib_Drivers
  29. * @{
  30. */
  31. #ifndef __LPC177X_8X_PINSEL_H
  32. #define __LPC177X_8X_PINSEL_H
  33. /* Includes ------------------------------------------------------------------- */
  34. #include "LPC177x_8x.h"
  35. #include "lpc_types.h"
  36. /* Public Macros -------------------------------------------------------------- */
  37. /** @defgroup PINSEL_Public_Macros
  38. * @{
  39. */
  40. /* Macros define IOCON bits */
  41. #define IOCON_MODE_PLAIN ((0<<3))
  42. #define IOCON_MODE_PULLDOWN ((1<<3))
  43. #define IOCON_MODE_PULLUP ((2<<3))
  44. #define IOCON_MODE_REPEATER ((3<<3))
  45. #define IOCON_HYS ((1<<5))
  46. #define IOCON_SLEW ((1<<6))
  47. #define IOCON_INBUF ((1<<7))
  48. #define IOCON_I2CMODE_FAST ((0<<8))
  49. #define IOCON_I2CMODE_OPENDRAIN ((1<<8))
  50. #define IOCON_I2CMODE_FASTPLUS ((2<<8))
  51. #define IOCON_I2CMODE_HIGHOPENDRAIN ((3<<8))
  52. #define IOCON_ODMODE ((1<<10))
  53. /* Macros define for LOC registers */
  54. #define LOC_CAN_RD_1_P0_0 ((0)) /**< Input for CAN_RD_1 comes from P0.0 */
  55. #define LOC_CAN_RD_1_P0_21 ((1)) /**< Input for CAN_RD_1 comes from P0.21 */
  56. #define LOC_CAN_RD_2_P2_7 ((0)) /**< Input for CAN_RD_2 comes from P2.7 */
  57. #define LOC_CAN_RD_2_P0_4 ((1)) /**< Input for CAN_RD_2 comes from P0.4 */
  58. #define LOC_ENET_MDIO_P2_9 ((0)) /**< Input for ENET_MDIO comes from P2.9 */
  59. #define LOC_ENET_MDIO_P1_17 ((1)) /**< Input for ENET_MDIO comes from P1.17 */
  60. #define LOC_EINT_0_P0_29 ((0)) /**< Input for EINT_0 comes from P0.29 */
  61. #define LOC_EINT_0_P2_10 ((1)) /**< Input for EINT_0 comes from P2.10 */
  62. #define LOC_EINT_1_P0_30 ((0)) /**< Input for EINT_1 comes from P0.30 */
  63. #define LOC_EINT_1_P2_11 ((1)) /**< Input for EINT_1 comes from P2.11 */
  64. #define LOC_I2C0_SCL_P1_31 ((0)) /**< Input for I2C0_SCL comes from P1.31 */
  65. #define LOC_I2C0_SCL_P0_28 ((1)) /**< Input for I2C0_SCL comes from P0.28 */
  66. #define LOC_I2C0_SCL_P5_3 ((2)) /**< Input for I2C0_SCL comes from P5.3 */
  67. #define LOC_I2C0_SDA_P1_30 ((0)) /**< Input for I2C0_SDA comes from P1.30 */
  68. #define LOC_I2C0_SDA_P0_27 ((1)) /**< Input for I2C0_SDA comes from P0.27 */
  69. #define LOC_I2C0_SDA_P5_2 ((2)) /**< Input for I2C0_SDA comes from P5.2 */
  70. #define LOC_I2C1_SCL_P0_1 ((0)) /**< Input for I2C1_SCL comes from P0.1 */
  71. #define LOC_I2C1_SCL_P2_15 ((1)) /**< Input for I2C1_SCL comes from P2.15 */
  72. #define LOC_I2C1_SCL_P0_20 ((2)) /**< Input for I2C1_SCL comes from P0.20 */
  73. #define LOC_I2C1_SDA_P2_14 ((0)) /**< Input for I2C1_SDA comes from P2.14 */
  74. #define LOC_I2C1_SDA_P0_0 ((1)) /**< Input for I2C1_SDA comes from P0.0 */
  75. #define LOC_I2C1_SDA_P0_19 ((2)) /**< Input for I2C1_SDA comes from P0.19 */
  76. #define LOC_I2C2_SCL_P2_31 ((0)) /**< Input for I2C2_SCL comes from P2.31 */
  77. #define LOC_I2C2_SCL_P0_11 ((1)) /**< Input for I2C2_SCL comes from P0.11 */
  78. #define LOC_I2C2_SCL_P4_21 ((2)) /**< Input for I2C2_SCL comes from P4.21 */
  79. #define LOC_I2C2_SCL_P4_29 ((3)) /**< Input for I2C2_SCL comes from P4.29 */
  80. #define LOC_I2C2_SDA_P2_30 ((0)) /**< Input for I2C2_SDA comes from P2.30 */
  81. #define LOC_I2C2_SDA_P0_10 ((1)) /**< Input for I2C2_SDA comes from P0.10 */
  82. #define LOC_I2C2_SDA_P4_20 ((2)) /**< Input for I2C2_SDA comes from P4.20 */
  83. #define LOC_I2C2_SDA_P1_15 ((3)) /**< Input for I2C2_SDA comes from P1.15 */
  84. #define LOC_I2S_RX_SCK_P0_23 ((0)) /**< Input for I2S_RX_SCK comes from P0.23 */
  85. #define LOC_I2S_RX_SCK_P0_4 ((1)) /**< Input for I2S_RX_SCK comes from P0.4 */
  86. #define LOC_I2S_RX_SDA_P0_25 ((0)) /**< Input for I2S_RX_SDA comes from P0.25 */
  87. #define LOC_I2S_RX_SDA_P0_6 ((1)) /**< Input for I2S_RX_SDA comes from P0.6 */
  88. #define LOC_I2S_RX_WS_P0_24 ((0)) /**< Input for I2S_RX_WS comes from P0.24 */
  89. #define LOC_I2S_RX_WS_P0_5 ((1)) /**< Input for I2S_RX_WS comes from P0.5 */
  90. #define LOC_I2S_TX_SCK_P2_11 ((0)) /**< Input for I2S_TX_SCK comes from P2.11 */
  91. #define LOC_I2S_TX_SCK_P0_7 ((1)) /**< Input for I2S_TX_SCK comes from P0.7 */
  92. #define LOC_I2S_TX_WS_P2_12 ((0)) /**< Input for I2S_TX_WS comes from P2.12 */
  93. #define LOC_I2S_TX_WS_P0_8 ((1)) /**< Input for I2S_TX_WS comes from P0.8 */
  94. #define LOC_PWM0_CAP_0_P1_12 ((0)) /**< Input for PWM0_CAP_0 comes from P1.12 */
  95. #define LOC_PWM0_CAP_0_P3_22 ((1)) /**< Input for PWM0_CAP_0 comes from P3.22 */
  96. #define LOC_PWM1_CAP_0_P3_23 ((0)) /**< Input for PWM1_CAP_0 comes from P3.23 */
  97. #define LOC_PWM1_CAP_0_P1_28 ((1)) /**< Input for PWM1_CAP_0 comes from P1.28 */
  98. #define LOC_PWM1_CAP_0_P2_6 ((2)) /**< Input for PWM1_CAP_0 comes from P2.6 */
  99. #define LOC_SD_CMD_P0_20 ((0)) /**< Input for SD_CMD comes from P0.20 */
  100. #define LOC_SD_CMD_P1_3 ((1)) /**< Input for SD_CMD comes from P1.3 */
  101. #define LOC_SD_DAT_0_P0_22 ((0)) /**< Input for SD_DAT_0 comes from P0.22 */
  102. #define LOC_SD_DAT_0_P1_6 ((1)) /**< Input for SD_DAT_0 comes from P1.6 */
  103. #define LOC_SD_DAT_1_P2_11 ((0)) /**< Input for SD_DAT_1 comes from P2.11 */
  104. #define LOC_SD_DAT_1_P1_7 ((1)) /**< Input for SD_DAT_1 comes from P1.7 */
  105. #define LOC_SD_DAT_2_P2_12 ((0)) /**< Input for SD_DAT_2 comes from P2.12 */
  106. #define LOC_SD_DAT_2_P1_11 ((1)) /**< Input for SD_DAT_2 comes from P1.11 */
  107. #define LOC_SD_DAT_3_P2_13 ((0)) /**< Input for SD_DAT_3 comes from P2.13 */
  108. #define LOC_SD_DAT_3_P1_12 ((1)) /**< Input for SD_DAT_3 comes from P1.12 */
  109. #define LOC_SSP0_MISO_P2_26 ((0)) /**< Input for SSP0_MISO comes from P2.26 */
  110. #define LOC_SSP0_MISO_P1_23 ((1)) /**< Input for SSP0_MISO comes from P1_23 */
  111. #define LOC_SSP0_MISO_P0_17 ((2)) /**< Input for SSP0_MISO comes from P0_17 */
  112. #define LOC_SSP0_MOSI_P2_27 ((0)) /**< Input for SSP0_MOSI comes from P2.27 */
  113. #define LOC_SSP0_MOSI_P1_24 ((1)) /**< Input for SSP0_MOSI comes from P1.24 */
  114. #define LOC_SSP0_MOSI_P0_18 ((2)) /**< Input for SSP0_MOSI comes from P0.18 */
  115. #define LOC_SSP0_SCK_P1_20 ((0)) /**< Input for SSP0_SCK comes from P1.20 */
  116. #define LOC_SSP0_SCK_P2_22 ((1)) /**< Input for SSP0_SCK comes from P2.22 */
  117. #define LOC_SSP0_SCK_P0_15 ((2)) /**< Input for SSP0_SCK comes from P0_15 */
  118. #define LOC_SSP0_SSEL_P2_23 ((0)) /**< Input for SSP0_SSEL comes from P2.23 */
  119. #define LOC_SSP0_SSEL_P1_21 ((1)) /**< Input for SSP0_SSEL comes from P1.21 */
  120. #define LOC_SSP0_SSEL_P1_28 ((2)) /**< Input for SSP0_SSEL comes from P1.28 */
  121. #define LOC_SSP0_SSEL_P0_16 ((3)) /**< Input for SSP0_SSEL comes from P0.16 */
  122. #define LOC_SSP1_MISO_P0_12 ((0)) /**< Input for SSP1_MISO comes from P0.12 */
  123. #define LOC_SSP1_MISO_P1_18 ((1)) /**< Input for SSP1_MISO comes from P1.18 */
  124. #define LOC_SSP1_MISO_P4_22 ((2)) /**< Input for SSP1_MISO comes from P4_22 */
  125. #define LOC_SSP1_MISO_P0_8 ((3)) /**< Input for SSP1_MISO comes from P0.8 */
  126. #define LOC_SSP1_MOSI_P0_13 ((0)) /**< Input for SSP1_MOSI comes from P0.13 */
  127. #define LOC_SSP1_MOSI_P1_22 ((1)) /**< Input for SSP1_MOSI comes from P1.22 */
  128. #define LOC_SSP1_MOSI_P4_23 ((2)) /**< Input for SSP1_MOSI comes from P4.23 */
  129. #define LOC_SSP1_MOSI_P0_9 ((3)) /**< Input for SSP1_MOSI comes from P0.9 */
  130. #define LOC_SSP1_SCK_P1_31 ((0)) /**< Input for SSP1_SCK comes from P1.31 */
  131. #define LOC_SSP1_SCK_P1_19 ((1)) /**< Input for SSP1_SCK comes from P1.19 */
  132. #define LOC_SSP1_SCK_P4_20 ((2)) /**< Input for SSP1_SCK comes from P4_20 */
  133. #define LOC_SSP1_SCK_P0_7 ((3)) /**< Input for SSP1_SCK comes from P0_7 */
  134. #define LOC_SSP1_SSEL_P0_14 ((0)) /**< Input for SSP1_SSEL comes from P0.14 */
  135. #define LOC_SSP1_SSEL_P1_26 ((1)) /**< Input for SSP1_SSEL comes from P1.26 */
  136. #define LOC_SSP1_SSEL_P4_21 ((2)) /**< Input for SSP1_SSEL comes from P4.21 */
  137. #define LOC_SSP1_SSEL_P0_6 ((3)) /**< Input for SSP1_SSEL comes from P0.6 */
  138. #define LOC_SSP2_MISO_P1_4 ((1)) /**< Input for SSP2_MISO comes from P1.4 */
  139. #define LOC_SSP2_MOSI_P1_1 ((1)) /**< Input for SSP2_MOSI comes from P1.1 */
  140. #define LOC_SSP2_SCK_P1_0 ((1)) /**< Input for SSP2_SCK comes from P1.0 */
  141. #define LOC_SSP2_SSEL_P1_8 ((1)) /**< Input for SSP2_SSEL comes from P1.8 */
  142. #define LOC_T0_CAP_0_P3_23 ((0)) /**< Input for T0_CAP_0 comes from P3.23 */
  143. #define LOC_T0_CAP_0_P1_26 ((1)) /**< Input for T0_CAP_0 comes from P1.26 */
  144. #define LOC_T0_CAP_1_P3_24 ((0)) /**< Input for T0_CAP_1 comes from P3.24 */
  145. #define LOC_T0_CAP_1_P1_27 ((1)) /**< Input for T0_CAP_1 comes from P1.27 */
  146. #define LOC_T1_CAP_0_P1_18 ((0)) /**< Input for T1_CAP_0 comes from P1.18 */
  147. #define LOC_T1_CAP_0_P3_27 ((1)) /**< Input for T1_CAP_0 comes from P3.27 */
  148. #define LOC_T1_CAP_1_P3_28 ((0)) /**< Input for T1_CAP_1 comes from P3.28 */
  149. #define LOC_T1_CAP_1_P1_19 ((1)) /**< Input for T1_CAP_1 comes from P1.19 */
  150. #define LOC_T2_CAP_0_P2_14 ((0)) /**< Input for T2_CAP_0 comes from P2.14 */
  151. #define LOC_T2_CAP_0_P2_6 ((1)) /**< Input for T2_CAP_0 comes from P2.6 */
  152. #define LOC_T2_CAP_0_P0_4 ((2)) /**< Input for T2_CAP_0 comes from P0.4 */
  153. #define LOC_T2_CAP_0_P1_14 ((3)) /**< Input for T2_CAP_0 comes from P1.14 */
  154. #define LOC_T2_CAP_1_P2_15 ((0)) /**< Input for T2_CAP_1 comes from P2.15 */
  155. #define LOC_T2_CAP_1_P0_5 ((1)) /**< Input for T2_CAP_1 comes from P0.5 */
  156. #define LOC_T3_CAP_0_P0_23 ((0)) /**< Input for T3_CAP_0 comes from P0.23 */
  157. #define LOC_T3_CAP_0_P2_22 ((1)) /**< Input for T3_CAP_0 comes from P2.22 */
  158. #define LOC_T3_CAP_0_P1_10 ((2)) /**< Input for T3_CAP_0 comes from P1.10 */
  159. #define LOC_T3_CAP_1_P0_24 ((0)) /**< Input for T3_CAP_1 comes from P0.24 */
  160. #define LOC_T3_CAP_1_P2_23 ((1)) /**< Input for T3_CAP_1 comes from P2.23 */
  161. #define LOC_T3_CAP_1_P1_0 ((2)) /**< Input for T3_CAP_1 comes from P1.0 */
  162. #define LOC_U0_RXD_P0_1 ((0)) /**< Input for U0_RXD comes from P0.1 */
  163. #define LOC_U0_RXD_P0_3 ((1)) /**< Input for U0_RXD comes from P0.3 */
  164. #define LOC_U1_CTS_P0_17 ((0)) /**< Input for U1_CTS comes from P0.17 */
  165. #define LOC_U1_CTS_P2_8 ((1)) /**< Input for U1_CTS comes from P2.8 */
  166. #define LOC_U1_CTS_P2_2 ((2)) /**< Input for U1_CTS comes from P2.2 */
  167. #define LOC_U1_CTS_P3_18 ((3)) /**< Input for U1_CTS comes from P3.18 */
  168. #define LOC_U1_DCD_P0_18 ((0)) /**< Input for U1_DCD comes from P0.18 */
  169. #define LOC_U1_DCD_P2_3 ((1)) /**< Input for U1_DCD comes from P2.3 */
  170. #define LOC_U1_DCD_P3_19 ((2)) /**< Input for U1_DCD comes from P3_19 */
  171. #define LOC_U1_DSR_P0_19 ((0)) /**< Input for U1_DSR comes from P0.19 */
  172. #define LOC_U1_DSR_P2_4 ((1)) /**< Input for U1_DSR comes from P2.4 */
  173. #define LOC_U1_DSR_P3_20 ((2)) /**< Input for U1_DSR comes from P0.19 */
  174. #define LOC_U1_RI_P0_21 ((0)) /**< Input for U1_RI comes from P0.21 */
  175. #define LOC_U1_RI_P2_6 ((1)) /**< Input for U1_RI comes from P2.6 */
  176. #define LOC_U1_RI_P3_22 ((2)) /**< Input for U1_RI comes from P3.22 */
  177. #define LOC_U1_RXD_P0_16 ((0)) /**< Input for U1_RXD comes from P0.16 */
  178. #define LOC_U1_RXD_P3_17 ((1)) /**< Input for U1_RXD comes from P3.17 */
  179. #define LOC_U1_RXD_P2_1 ((2)) /**< Input for U1_RXD comes from P2.1 */
  180. #define LOC_U2_RXD_P0_11 ((0)) /**< Input for U2_RXD comes from P0.11 */
  181. #define LOC_U2_RXD_P4_23 ((1)) /**< Input for U2_RXD comes from P4.23 */
  182. #define LOC_U2_RXD_P2_9 ((2)) /**< Input for U2_RXD comes from P2.9 */
  183. #define LOC_U3_RXD_P0_26 ((0)) /**< Input for U3_RXD comes from P0.26 */
  184. #define LOC_U3_RXD_P0_1 ((1)) /**< Input for U3_RXD comes from P0.1 */
  185. #define LOC_U3_RXD_P4_29 ((2)) /**< Input for U3_RXD comes from P4.29 */
  186. #define LOC_U3_RXD_P0_3 ((3)) /**< Input for U3_RXD comes from P0.3 */
  187. #define LOC_U4_RXD_P2_9 ((0)) /**< Input for U4_RXD comes from P2.9 */
  188. #define LOC_U4_RXD_P5_3 ((1)) /**< Input for U4_RXD comes from P5.3 */
  189. #define LOC_USB_SCL_P0_28 ((0)) /**< Input for USB_SCL comes from P0.28 */
  190. #define LOC_USB_SCL_P1_28 ((1)) /**< Input for USB_SCL comes from P1.28 */
  191. #define LOC_USB_SDA_P0_27 ((0)) /**< Input for USB_SDA comes from P0.27 */
  192. #define LOC_USB_SDA_P1_29 ((1)) /**< Input for USB_SDA comes from P1.29 */
  193. /**
  194. * @}
  195. */
  196. /** @defgroup PINSEL_Public_Types PINSEL Public Types
  197. * @{
  198. */
  199. typedef enum
  200. {
  201. PINSEL_BASICMODE_PLAINOUT = 0, /**< Plain output */
  202. PINSEL_BASICMODE_PULLDOWN, /**< Pull-down enabled */
  203. PINSEL_BASICMODE_PULLUP, /**< Pull-up enabled (default) */
  204. PINSEL_BASICMODE_REPEATER /**< Repeater mode */
  205. }PinSel_BasicMode;
  206. typedef enum
  207. {
  208. /** Fast mode (400 kHz clock rate) and standard (100 kHz clock rate) */
  209. PINSEL_I2CMODE_FAST_STANDARD = 0,
  210. /** Open drain I/O (not I2C). No glitch filter, 3 mA typical output drive */
  211. PINSEL_I2CMODE_OPENDRAINIO,
  212. /** Fast Mode Plus I2C. This includes a filter for <50 ns glitches */
  213. PINSEL_I2CMODE_FASTMODEPLUS,
  214. /** High drive open drain I/O (not I2C). No glitch filter, 20 mA typical output drive */
  215. PINSEL_I2CMODE_HIDRIVE_OPENDRAIN
  216. }PinSel_I2cMode;
  217. /**
  218. * @}
  219. */
  220. /* Public Functions ----------------------------------------------------------- */
  221. /** @defgroup PINSEL_Public_Functions
  222. * @{
  223. */
  224. void PINSEL_ConfigPin(uint8_t portnum, uint8_t pinnum, uint8_t funcnum);
  225. void PINSEL_SetPinMode(uint8_t portnum, uint8_t pinnum, PinSel_BasicMode modenum);
  226. void PINSEL_SetHysMode(uint8_t portnum, uint8_t pinnum, FunctionalState NewState);
  227. void PINSEL_SetSlewMode(uint8_t portnum, uint8_t pinnum, FunctionalState NewState);
  228. void PINSEL_SetInBufMode(uint8_t portnum, uint8_t pinnum, FunctionalState NewState);
  229. void PINSEL_SetI2CMode(uint8_t portnum, uint8_t pinnum, PinSel_I2cMode I2CMode);
  230. void PINSEL_SetOpenDrainMode(uint8_t portnum, uint8_t pinnum, FunctionalState NewState);
  231. void PINSEL_SetAnalogPinMode (uint8_t portnum, uint8_t pinnum, uint8_t enable);
  232. void PINSEL_DacEnable (uint8_t portnum, uint8_t pinnum, uint8_t enable);
  233. void PINSEL_SetFilter (uint8_t portnum, uint8_t pinnum, uint8_t enable);
  234. /**
  235. * @}
  236. */
  237. #endif /* LPC177x_8x_PINSEL_H */
  238. /**
  239. * @}
  240. */
  241. /* --------------------------------- End Of File ------------------------------ */