ioswm_8xx.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601
  1. /*
  2. * @brief LPC8xx IOCON register block and driver
  3. *
  4. * @note
  5. * Copyright(C) NXP Semiconductors, 2012
  6. * All rights reserved.
  7. *
  8. * @par
  9. * Software that is described herein is for illustrative purposes only
  10. * which provides customers with programming information regarding the
  11. * LPC products. This software is supplied "AS IS" without any warranties of
  12. * any kind, and NXP Semiconductors and its licenser disclaim any and
  13. * all warranties, express or implied, including all implied warranties of
  14. * merchantability, fitness for a particular purpose and non-infringement of
  15. * intellectual property rights. NXP Semiconductors assumes no responsibility
  16. * or liability for the use of the software, conveys no license or rights under any
  17. * patent, copyright, mask work right, or any other intellectual property rights in
  18. * or to any products. NXP Semiconductors reserves the right to make changes
  19. * in the software without notification. NXP Semiconductors also makes no
  20. * representation or warranty that such application will be suitable for the
  21. * specified use without further testing or modification.
  22. *
  23. * @par
  24. * Permission to use, copy, modify, and distribute this software and its
  25. * documentation is hereby granted, under NXP Semiconductors' and its
  26. * licensor's relevant copyrights in the software, without fee, provided that it
  27. * is used in conjunction with NXP Semiconductors microcontrollers. This
  28. * copyright, permission, and disclaimer notice must appear in all copies of
  29. * this code.
  30. */
  31. #ifndef __IOCON_8XX_H_
  32. #define __IOCON_8XX_H_
  33. #ifdef __cplusplus
  34. extern "C" {
  35. #endif
  36. /** @defgroup IOCON_8XX CHIP: LPC8xx IOCON register block and driver
  37. * @ingroup CHIP_8XX_Drivers
  38. * @{
  39. */
  40. #define NUM_IOCON_PIO (29)
  41. /**
  42. * @brief Array of IOCON pin definitions passed to Chip_IOCON_SetPinMuxing() must be in this format
  43. */
  44. typedef struct {
  45. uint32_t pin:8; /* Pin number */
  46. uint32_t modefunc:24; /* Function and mode */
  47. } PINMUX_GRP_T;
  48. /**
  49. * @brief IOCON register block structure
  50. * @note When accessing this register structure, use the PIOn enumeration
  51. * as the array index as the pin assignments are not mapped 1-1 with the
  52. * IOCON structure.<br>
  53. * Incorrect: LPC_IOCON->PIO0[0] = 0x1; // Index 0 does not map to pin 0!<br>
  54. * Correct: LPC_IOCON->PIO0[IOCON_PIO0] = 0x1; // Enumeration PIO0 maps to pin 0
  55. */
  56. typedef struct { /*!< (@ 0x40044000) IOCONFIG Structure */
  57. __IO uint32_t PIO0[NUM_IOCON_PIO + 2]; /* 2 added for reserved register */
  58. } LPC_IOCON_T;
  59. /**
  60. * @brief IOCON Register bit definitions
  61. */
  62. /* Pin Mode mask */
  63. #define PIN_MODE_MASK (0x3 << 3)
  64. #define PIN_MODE_BITNUM (3)
  65. /* Pin Hysteresis mask */
  66. #define PIN_HYS_MASK (0x1 << 5)
  67. #define PIN_HYS_BITNUM (5)
  68. /* Pin invert input mask */
  69. #define PIN_INV_MASK (0x1 << 6)
  70. #define PIN_INV_BITNUM (6)
  71. /* Pin open drain mode mask */
  72. #define PIN_OD_MASK (0x1 << 10)
  73. #define PIN_OD_BITNUM (10)
  74. /* Pin digital filter sample mode mask */
  75. #define PIN_SMODE_MASK (0x3 << 11)
  76. #define PIN_SMODE_BITNUM (11)
  77. /* Pin clock divider mask */
  78. #define PIN_CLKDIV_MASK (0x7 << 13)
  79. #define PIN_CLKDIV_BITNUM (13)
  80. /* Pin I2C mode mask - valid for PIO10 & PIO11 only */
  81. #define PIN_I2CMODE_MASK (0x3 << 8)
  82. #define PIN_I2CMODE_BITNUM (8)
  83. /**
  84. * @brief IOCON Pin Numbers enum
  85. * Maps a pin number to an IOCON (register) array index. IOCON indexes
  86. * are not mapped 1-1 with pin numbers. When access the PIO0 array in
  87. * the LPC_IOCON_T structure, the array should be indexed with one of
  88. * these enumerations based on the pin that will have it's settings
  89. * changed.<br>
  90. * Example: LPC_IOCON->PIO0[IOCON_PIO0] = 0x1; // Enumeration PIO0 maps to pin 0
  91. */
  92. typedef enum CHIP_PINx {
  93. IOCON_PIO0 = 0x11, /*!< PIN 0 */
  94. IOCON_PIO1 = 0x0B, /*!< PIN 1 */
  95. IOCON_PIO2 = 0x06, /*!< PIN 2 */
  96. IOCON_PIO3 = 0x05, /*!< PIN 3 */
  97. IOCON_PIO4 = 0x04, /*!< PIN 4 */
  98. IOCON_PIO5 = 0x03, /*!< PIN 5 */
  99. /* The following pins are not present in DIP8 packages */
  100. IOCON_PIO6 = 0x10, /*!< PIN 6 */
  101. IOCON_PIO7 = 0x0F, /*!< PIN 7 */
  102. IOCON_PIO8 = 0x0E, /*!< PIN 8 */
  103. IOCON_PIO9 = 0x0D, /*!< PIN 9 */
  104. IOCON_PIO10 = 0x08, /*!< PIN 10 */
  105. IOCON_PIO11 = 0x07, /*!< PIN 11 */
  106. IOCON_PIO12 = 0x02, /*!< PIN 12 */
  107. IOCON_PIO13 = 0x01, /*!< PIN 13 */
  108. /* The following pins are not present in DIP8 & TSSOP16 packages */
  109. IOCON_PIO14 = 0x12, /*!< PIN 14 */
  110. IOCON_PIO15 = 0x0A, /*!< PIN 15 */
  111. IOCON_PIO16 = 0x09, /*!< PIN 16 */
  112. IOCON_PIO17 = 0x00, /*!< PIN 17 */
  113. IOCON_PIO_NUL0 = 0x0C, /*!< PIN NULL */
  114. /* The following pins are not present in DIP8, TSSOP16 & TSSOP20 packages */
  115. IOCON_PIO18 = 0x1E, /*!< PIN 18 */
  116. IOCON_PIO19 = 0x1D, /*!< PIN 19 */
  117. IOCON_PIO20 = 0x1C, /*!< PIN 20 */
  118. IOCON_PIO21 = 0x1B, /*!< PIN 21 */
  119. IOCON_PIO22 = 0x1A, /*!< PIN 22 */
  120. IOCON_PIO23 = 0x19, /*!< PIN 23 */
  121. IOCON_PIO24 = 0x18, /*!< PIN 24 */
  122. IOCON_PIO25 = 0x17, /*!< PIN 25 */
  123. IOCON_PIO26 = 0x16, /*!< PIN 26 */
  124. IOCON_PIO27 = 0x15, /*!< PIN 27 */
  125. IOCON_PIO28 = 0x14, /*!< PIN 28 */
  126. IOCON_PIO_NUL1 = 0x13, /*!< PIN NULL */
  127. } CHIP_PINx_T;
  128. /**
  129. * @brief IOCON Pin Modes enum
  130. */
  131. typedef enum CHIP_PIN_MODE {
  132. PIN_MODE_INACTIVE = 0, /*!< Inactive mode */
  133. PIN_MODE_PULLDN = 1, /*!< Pull Down mode */
  134. PIN_MODE_PULLUP = 2, /*!< Pull up mode */
  135. PIN_MODE_REPEATER = 3 /*!< Repeater mode */
  136. } CHIP_PIN_MODE_T;
  137. /**
  138. * @brief IOCON Digital Filter Sample modes enum
  139. */
  140. typedef enum CHIP_PIN_SMODE {
  141. PIN_SMODE_BYPASS = 0, /*!< Bypass input filter */
  142. PIN_SMODE_CYC1 = 1, /*!< Input pulses shorter than 1 filter clock cycle are rejected */
  143. PIN_SMODE_CYC2 = 2, /*!< Input pulses shorter than 2 filter clock cycles are rejected */
  144. PIN_SMODE_CYC3 = 3 /*!< Input pulses shorter than 3 filter clock cycles are rejected */
  145. } CHIP_PIN_SMODE_T;
  146. /**
  147. * @brief IOCON I2C Modes enum (Only for I2C pins PIO0_10 and PIO0_11)
  148. */
  149. typedef enum CHIP_PIN_I2CMODE {
  150. PIN_I2CMODE_STDFAST = 0, /*!< I2C standard mode/Fast mode */
  151. PIN_I2CMODE_GPIO = 1, /*!< Standard I/O functionality */
  152. PIN_I2CMODE_FASTPLUS = 2 /*!< I2C Fast plus mode */
  153. } CHIP_PIN_I2CMODE_T;
  154. /**
  155. * @brief Sets I/O Control pin mux
  156. * @param pIOCON : The base of IOCON peripheral on the chip
  157. * @param pin : GPIO pin to mux
  158. * @param modefunc : OR'ed values or type IOCON_*
  159. * @return Nothing
  160. */
  161. STATIC INLINE void Chip_IOCON_PinMuxSet(LPC_IOCON_T *pIOCON, uint8_t pin, uint32_t modefunc)
  162. {
  163. pIOCON->PIO0[pin] = modefunc;
  164. }
  165. /**
  166. * @brief Set all I/O Control pin muxing
  167. * @param pIOCON : The base of IOCON peripheral on the chip
  168. * @param pinArray : Pointer to array of pin mux selections
  169. * @param arrayLength : Number of entries in pinArray
  170. * @return Nothing
  171. */
  172. void Chip_IOCON_SetPinMuxing(LPC_IOCON_T *pIOCON, const PINMUX_GRP_T* pinArray, uint32_t arrayLength);
  173. /**
  174. * @brief Sets pull-up or pull-down mode for a pin
  175. * @param pIOCON : The base of IOCON peripheral on the chip
  176. * @param pin : Pin number
  177. * @param mode : Mode (Pull-up/Pull-down mode)
  178. * @return Nothing
  179. * @note Do not use with pins PIO10 and PIO11.
  180. */
  181. void Chip_IOCON_PinSetMode(LPC_IOCON_T *pIOCON, CHIP_PINx_T pin, CHIP_PIN_MODE_T mode);
  182. /**
  183. * @brief Enable or disable hysteresis for a pin
  184. * @param pIOCON : The base of IOCON peripheral on the chip
  185. * @param pin : Pin number
  186. * @param enable : true to enable, false to disable
  187. * @return Nothing
  188. * @note Do not use with pins PIO10 and PIO11.
  189. */
  190. void Chip_IOCON_PinSetHysteresis(LPC_IOCON_T *pIOCON, CHIP_PINx_T pin, bool enable);
  191. /**
  192. * @brief Enable hysteresis for a pin
  193. * @param pIOCON : The base of IOCON peripheral on the chip
  194. * @param pin : Pin number
  195. * @return Nothing
  196. * @note Do not use with pins PIO10 and PIO11.
  197. */
  198. STATIC INLINE void Chip_IOCON_PinEnableHysteresis(LPC_IOCON_T *pIOCON, CHIP_PINx_T pin)
  199. {
  200. pIOCON->PIO0[pin] |= PIN_HYS_MASK;
  201. }
  202. /**
  203. * @brief Disable hysteresis for a pin
  204. * @param pIOCON : The base of IOCON peripheral on the chip
  205. * @param pin : Pin number
  206. * @return Nothing
  207. * @note Do not use with pins PIO10 and PIO11.
  208. */
  209. STATIC INLINE void Chip_IOCON_PinDisableHysteresis(LPC_IOCON_T *pIOCON, CHIP_PINx_T pin)
  210. {
  211. pIOCON->PIO0[pin] &= ~PIN_HYS_MASK;
  212. }
  213. /**
  214. * @brief Enable or disable invert input for a pin
  215. * @param pIOCON : The base of IOCON peripheral on the chip
  216. * @param pin : Pin number
  217. * @param invert : true to invert, false to not to invert
  218. * @return Nothing
  219. */
  220. void Chip_IOCON_PinSetInputInverted(LPC_IOCON_T *pIOCON, CHIP_PINx_T pin, bool invert);
  221. /**
  222. * @brief Enable invert input for a pin
  223. * @param pIOCON : The base of IOCON peripheral on the chip
  224. * @param pin : Pin number
  225. * @return Nothing
  226. */
  227. STATIC INLINE void Chip_IOCON_PinEnableInputInverted(LPC_IOCON_T *pIOCON, CHIP_PINx_T pin)
  228. {
  229. pIOCON->PIO0[pin] |= PIN_INV_MASK;
  230. }
  231. /**
  232. * @brief Disable invert input for a pin
  233. * @param pIOCON : The base of IOCON peripheral on the chip
  234. * @param pin : Pin number
  235. * @return Nothing
  236. */
  237. STATIC INLINE void Chip_IOCON_PinDisableInputInverted(LPC_IOCON_T *pIOCON, CHIP_PINx_T pin)
  238. {
  239. pIOCON->PIO0[pin] &= ~PIN_INV_MASK;
  240. }
  241. /**
  242. * @brief Enables or disables open-drain mode for a pin
  243. * @param pIOCON : The base of IOCON peripheral on the chip
  244. * @param pin : Pin number
  245. * @param open_drain : true to enable open-drain mode,
  246. * false to disable open-drain mode
  247. * @return Nothing
  248. */
  249. void Chip_IOCON_PinSetOpenDrainMode(LPC_IOCON_T *pIOCON, CHIP_PINx_T pin, bool open_drain);
  250. /**
  251. * @brief Enables open-drain mode for a pin
  252. * @param pIOCON : The base of IOCON peripheral on the chip
  253. * @param pin : Pin number
  254. * @return Nothing
  255. */
  256. STATIC INLINE void Chip_IOCON_PinEnableOpenDrainMode(LPC_IOCON_T *pIOCON, CHIP_PINx_T pin)
  257. {
  258. pIOCON->PIO0[pin] |= PIN_OD_MASK;
  259. }
  260. /**
  261. * @brief Disables open-drain mode for a pin
  262. * @param pIOCON : The base of IOCON peripheral on the chip
  263. * @param pin : Pin number
  264. * @return Nothing
  265. */
  266. STATIC INLINE void Chip_IOCON_PinDisableOpenDrainMode(LPC_IOCON_T *pIOCON, CHIP_PINx_T pin)
  267. {
  268. pIOCON->PIO0[pin] &= ~PIN_OD_MASK;
  269. }
  270. /**
  271. * @brief Set pin mode to default after reset
  272. * @param pIOCON : The base of IOCON peripheral on the chip
  273. * @param pin : Pin number
  274. * @return Nothing
  275. */
  276. STATIC INLINE void Chip_IOCON_PinSetToDefault(LPC_IOCON_T *pIOCON, CHIP_PINx_T pin)
  277. {
  278. if (pin == IOCON_PIO10 || pin == IOCON_PIO11)
  279. pIOCON->PIO0[pin] = 0x80;
  280. else
  281. pIOCON->PIO0[pin] = 0x90;
  282. }
  283. /**
  284. * @brief Sets the digital filter sampling mode for a pin
  285. * @param pIOCON : The base of IOCON peripheral on the chip
  286. * @param pin : Pin number
  287. * @param smode : 0x0 = bypass, 0x[1..3] = 1 to 3 clock cycles.
  288. * @return Nothing
  289. */
  290. void Chip_IOCON_PinSetSampleMode(LPC_IOCON_T *pIOCON, CHIP_PINx_T pin, CHIP_PIN_SMODE_T smode);
  291. /**
  292. * @brief Select peripheral clock divider for input filter sampling clock
  293. * @param pIOCON : The base of IOCON peripheral on the chip
  294. * @param pin : Pin number
  295. * @param clkdiv : 0 = no divisor, 1...6 = PCLK/clkdiv
  296. * @return Nothing
  297. */
  298. void Chip_IOCON_PinSetClockDivisor(LPC_IOCON_T *pIOCON, CHIP_PINx_T pin, CHIP_PIN_CLKDIV_T clkdiv);
  299. /**
  300. * @brief Set I2C mode for a pin
  301. * @param pIOCON : The base of IOCON peripheral on the chip
  302. * @param pin : Pin number
  303. * @param mode : 0:Standard/Fast I2C 1: GPIO 2: Fast Plus
  304. * @return Nothing
  305. * @note Valid for pins PIO0_10 and PIO0_11 only.
  306. */
  307. void Chip_IOCON_PinSetI2CMode(LPC_IOCON_T *pIOCON, CHIP_PINx_T pin, CHIP_PIN_I2CMODE_T mode);
  308. /**
  309. * @}
  310. */
  311. /** @defgroup SWM_8XX CHIP: LPC8xx Switch Matrix Driver
  312. * @ingroup CHIP_8XX_Drivers
  313. * @{
  314. */
  315. /**
  316. * @brief LPC8XX Switch Matrix register block structure
  317. */
  318. typedef struct {
  319. #if defined(CHIP_LPC82X)
  320. __IO uint32_t PINASSIGN[12]; /*!< Pin Assign register array */
  321. __I uint32_t RESERVED0[100];
  322. #else
  323. __IO uint32_t PINASSIGN[9]; /*!< Pin Assign register array */
  324. __I uint32_t RESERVED0[103];
  325. #endif
  326. __IO uint32_t PINENABLE0; /*!< Pin Enable register */
  327. } LPC_SWM_T;
  328. #if defined(CHIP_LPC82X)
  329. #define SWM_PINENABLE0_RESERVED (~0x1ffffff)
  330. #else
  331. #define SWM_PINENABLE0_RESERVED (~0x1ff)
  332. #endif
  333. /**
  334. * @brief LPC8XX Switch Matrix Movable pins
  335. */
  336. #if defined(CHIP_LPC82X)
  337. typedef enum CHIP_SWM_PIN_MOVABLE {
  338. SWM_U0_TXD_O, /*!< PINASSIGN0 - UART0 TXD Output */
  339. SWM_U0_RXD_I, /*!< PINASSIGN0 - UART0 RXD Input */
  340. SWM_U0_RTS_O, /*!< PINASSIGN0 - UART0 RTS Output */
  341. SWM_U0_CTS_I, /*!< PINASSIGN0 - UART0 CTS Input */
  342. SWM_U0_SCLK_IO = 0x10, /*!< PINASSIGN1 - UART0 SCLK I/O */
  343. SWM_U1_TXD_O, /*!< PINASSIGN1 - UART1 TXD Output */
  344. SWM_U1_RXD_I, /*!< PINASSIGN1 - UART1 RXD Input */
  345. SWM_U1_RTS_O, /*!< PINASSIGN1 - UART1 RTS Output */
  346. SWM_U1_CTS_I = 0x20, /*!< PINASSIGN2 - UART1 CTS Input */
  347. SWM_U1_SCLK_IO, /*!< PINASSIGN2 - UART1 SCLK I/O */
  348. SWM_U2_TXD_O, /*!< PINASSIGN2 - UART2 TXD Output */
  349. SWM_U2_RXD_I, /*!< PINASSIGN2 - UART2 RXD Input */
  350. SWM_U2_RTS_O = 0x30, /*!< PINASSIGN3 - UART2 RTS Output */
  351. SWM_U2_CTS_I, /*!< PINASSIGN3 - UART2 CTS Input */
  352. SWM_U2_SCLK_IO, /*!< PINASSIGN3 - UART2 SCLK I/O */
  353. SWM_SPI0_SCK_IO, /*!< PINASSIGN3 - SPI0 SCK I/O */
  354. SWM_SPI0_MOSI_IO = 0x40, /*!< PINASSIGN4 - SPI0 MOSI I/O */
  355. SWM_SPI0_MISO_IO, /*!< PINASSIGN4 - SPI0 MISO I/O */
  356. SWM_SPI0_SSEL0_IO, /*!< PINASSIGN4 - SPI0 SSEL0 I/O */
  357. SWM_SPI0_SSEL1_IO, /*!< PINASSIGN4 - SPI0 SSEL1 I/O */
  358. SWM_SPI0_SSEL2_IO = 0x50, /*!< PINASSIGN5 - SPI0 SSEL2 I/O */
  359. SWM_SPI0_SSEL3_IO, /*!< PINASSIGN5 - SPI0 SSEL3 I/O */
  360. SWM_SPI1_SCK_IO, /*!< PINASSIGN5 - SPI1 SCK I/O */
  361. SWM_SPI1_MOSI_IO, /*!< PINASSIGN5 - SPI1 MOSI I/O */
  362. SWM_SPI1_MISO_IO = 0x60, /*!< PINASSIGN6 - SPI1 MISO I/O */
  363. SWM_SPI1_SSEL0_IO, /*!< PINASSIGN6 - SPI1 SSEL0 I/O */
  364. SWM_SPI1_SSEL1_IO, /*!< PINASSIGN6 - SPI1 SSEL1 I/O */
  365. SWM_SCT_IN0_I, /*!< PINASSIGN6 - SCT INPUT_0 Input */
  366. SWM_SCT_IN1_I = 0x70, /*!< PINASSIGN7 - SCT INPUT_1 Input */
  367. SWM_SCT_IN2_I, /*!< PINASSIGN7 - SCT INPUT_2 Input */
  368. SWM_SCT_IN3_I, /*!< PINASSIGN7 - SCT INPUT_3 Input */
  369. SWM_SCT_OUT0_O, /*!< PINASSIGN7 - SCT OUTPUT_0 Output */
  370. SWM_SCT_OUT1_O = 0x80, /*!< PINASSIGN8 - SCT OUTPUT_1 Output */
  371. SWM_SCT_OUT2_O, /*!< PINASSIGN8 - SCT OUTPUT_2 Output */
  372. SWM_SCT_OUT3_O, /*!< PINASSIGN8 - SCT OUTPUT_3 Output */
  373. SWM_SCT_OUT4_O, /*!< PINASSIGN8 - SCT OUTPUT_4 Output */
  374. SWM_SCT_OUT5_O = 0x90, /*!< PINASSIGN9 - SCT OUTPUT_5 Output */
  375. SWM_I2C1_SDA_IO, /*!< PINASSIGN9 - I2C1 SDA I/O */
  376. SWM_I2C1_SCL_IO, /*!< PINASSIGN9 - I2C1 SCL I/O */
  377. SWM_I2C2_SDA_IO, /*!< PINASSIGN9 - I2C2 SDA I/O */
  378. SWM_I2C2_SCL_IO = 0xA0, /*!< PINASSIGN10 - I2C2 SCL I/O */
  379. SWM_I2C3_SDA_IO, /*!< PINASSIGN10 - I2C3 SDA I/O */
  380. SWM_I2C3_SCL_IO, /*!< PINASSIGN10 - I2C3 SCL I/O */
  381. SWM_ADC_PINTRIG0_I, /*!< PINASSIGN10 - ADC PIN TRIGGER-0 Input */
  382. SWM_ADC_PINTRIG1_I = 0xB0, /*!< PINASSIGN11 - ADC PIN TRIGGER-1 Input */
  383. SWM_ACMP_O_O, /*!< PINASSIGN11 - ACMP OUT Output */
  384. SWM_CLKOUT_O, /*!< PINASSIGN11 - CLKOUT Output */
  385. SWM_GPIO_INT_BMAT_O, /*!< PINASSIGN11 - GPIO INT BMAT Output */
  386. } CHIP_SWM_PIN_MOVABLE_T;
  387. #else
  388. typedef enum CHIP_SWM_PIN_MOVABLE {
  389. SWM_U0_TXD_O = 0x00, /*!< PINASSIGN0 - UART0 TXD Output */
  390. SWM_U0_RXD_I = 0x01, /*!< PINASSIGN0 - UART0 RXD Input */
  391. SWM_U0_RTS_O = 0x02, /*!< PINASSIGN0 - UART0 RTS Output */
  392. SWM_U0_CTS_I = 0x03, /*!< PINASSIGN0 - UART0 CTS Input */
  393. SWM_U0_SCLK_IO = 0x10, /*!< PINASSIGN1 - UART0 SCLK I/O */
  394. SWM_U1_TXD_O = 0x11, /*!< PINASSIGN1 - UART1 TXD Output */
  395. SWM_U1_RXD_I = 0x12, /*!< PINASSIGN1 - UART1 RXD Input */
  396. SWM_U1_RTS_O = 0x13, /*!< PINASSIGN1 - UART1 RTS Output */
  397. SWM_U1_CTS_I = 0x20, /*!< PINASSIGN2 - UART1 CTS Input */
  398. SWM_U1_SCLK_IO = 0x21, /*!< PINASSIGN2 - UART1 SCLK I/O */
  399. SWM_U2_TXD_O = 0x22, /*!< PINASSIGN2 - UART2 TXD Output */
  400. SWM_U2_RXD_I = 0x23, /*!< PINASSIGN2 - UART2 RXD Input */
  401. SWM_U2_RTS_O = 0x30, /*!< PINASSIGN3 - UART2 RTS Output */
  402. SWM_U2_CTS_I = 0x31, /*!< PINASSIGN3 - UART2 CTS Input */
  403. SWM_U2_SCLK_IO = 0x32, /*!< PINASSIGN3 - UART2 SCLK I/O */
  404. SWM_SPI0_SCK_IO = 0x33, /*!< PINASSIGN3 - SPI0 SCK I/O */
  405. SWM_SPI0_MOSI_IO = 0x40, /*!< PINASSIGN4 - SPI0 MOSI I/O */
  406. SWM_SPI0_MISO_IO = 0x41, /*!< PINASSIGN4 - SPI0 MISO I/O */
  407. SWM_SPI0_SSEL_IO = 0x42, /*!< PINASSIGN4 - SPI0 SSEL I/O */
  408. SWM_SPI1_SCK_IO = 0x43, /*!< PINASSIGN4 - SPI1 SCK I/O */
  409. SWM_SPI1_MOSI_IO = 0x50, /*!< PINASSIGN5 - SPI1 MOSI I/O */
  410. SWM_SPI1_MISO_IO = 0x51, /*!< PINASSIGN5 - SPI1 MISO I/O */
  411. SWM_SPI1_SSEL_IO = 0x52, /*!< PINASSIGN5 - SPI1 SSEL I/O */
  412. SWM_CTIN_0_I = 0x53, /*!< PINASSIGN5 - CTIN0 Input */
  413. SWM_CTIN_1_I = 0x60, /*!< PINASSIGN6 - CTIN1 Input */
  414. SWM_CTIN_2_I = 0x61, /*!< PINASSIGN6 - CTIN2 Input */
  415. SWM_CTIN_3_I = 0x62, /*!< PINASSIGN6 - CTIN3 Input */
  416. SWM_CTOUT_0_O = 0x63, /*!< PINASSIGN6 - CTOUT0 Output */
  417. SWM_CTOUT_1_O = 0x70, /*!< PINASSIGN7 - CTOUT1 Output */
  418. SWM_CTOUT_2_O = 0x71, /*!< PINASSIGN7 - CTOUT2 Output */
  419. SWM_CTOUT_3_O = 0x72, /*!< PINASSIGN7 - CTOUT3 Output */
  420. SWM_I2C_SDA_IO = 0x73, /*!< PINASSIGN7 - I2C SDA I/O */
  421. SWM_I2C_SCL_IO = 0x80, /*!< PINASSIGN8 - I2C SCL I/O */
  422. SWM_ACMP_O_O = 0x81, /*!< PINASSIGN8 - I2C ACMP Output */
  423. SWM_CLKOUT_O = 0x82, /*!< PINASSIGN8 - I2C CLKOUT Output */
  424. SWM_GPIO_INT_BMAT_O = 0x83, /*!< PINASSIGN8 - I2C GPIO INT BMAT Output */
  425. } CHIP_SWM_PIN_MOVABLE_T;
  426. #endif
  427. /**
  428. * @brief LPC8XX Switch Matrix Fixed pins
  429. */
  430. #if defined(CHIP_LPC82X)
  431. typedef enum CHIP_SWM_PIN_FIXED {
  432. SWM_FIXED_ACMP_I1 = 0, /*!< ACMP I1 */
  433. SWM_FIXED_ACMP_I2 = 1, /*!< ACMP I2 */
  434. SWM_FIXED_ACMP_I3 = 2, /*!< ACMP I3 */
  435. SWM_FIXED_ACMP_I4 = 3, /*!< ACMP I4 */
  436. SWM_FIXED_SWCLK = 4, /*!< SWCLK */
  437. SWM_FIXED_SWDIO = 5, /*!< SWDIO */
  438. SWM_FIXED_XTALIN = 6, /*!< XTALIN */
  439. SWM_FIXED_XTALOUT = 7, /*!< XTALOUT */
  440. SWM_FIXED_RST = 8, /*!< Reset */
  441. SWM_FIXED_CLKIN = 9, /*!< Clock Input */
  442. SWM_FIXED_VDDCMP = 10, /*!< VDD */
  443. SWM_FIXED_I2C0_SDA = 11, /*!< I2C0 SDA */
  444. SWM_FIXED_I2C0_SCL = 12, /*!< I2C0 SCL */
  445. SWM_FIXED_ADC0 = 13, /*!< ADC0 */
  446. SWM_FIXED_ADC1 = 14, /*!< ADC1 */
  447. SWM_FIXED_ADC2 = 15, /*!< ADC2 */
  448. SWM_FIXED_ADC3 = 16, /*!< ADC3 */
  449. SWM_FIXED_ADC4 = 17, /*!< ADC4 */
  450. SWM_FIXED_ADC5 = 18, /*!< ADC5 */
  451. SWM_FIXED_ADC6 = 19, /*!< ADC6 */
  452. SWM_FIXED_ADC7 = 20, /*!< ADC7 */
  453. SWM_FIXED_ADC8 = 21, /*!< ADC8 */
  454. SWM_FIXED_ADC9 = 22, /*!< ADC9 */
  455. SWM_FIXED_ADC10 = 23, /*!< ADC10 */
  456. SWM_FIXED_ADC11 = 24, /*!< ADC11 */
  457. } CHIP_SWM_PIN_FIXED_T;
  458. #else
  459. typedef enum CHIP_SWM_PIN_FIXED {
  460. SWM_FIXED_ACMP_I1 = 0, /*!< ACMP I1 */
  461. SWM_FIXED_ACMP_I2 = 1, /*!< ACMP I2 */
  462. SWM_FIXED_SWCLK = 2, /*!< SWCLK */
  463. SWM_FIXED_SWDIO = 3, /*!< SWDIO */
  464. SWM_FIXED_XTALIN = 4, /*!< XTALIN */
  465. SWM_FIXED_XTALOUT = 5, /*!< XTALOUT */
  466. SWM_FIXED_RST = 6, /*!< Reset */
  467. SWM_FIXED_CLKIN = 7, /*!< Clock Input */
  468. SWM_FIXED_VDDCMP = 8 /*!< VDD */
  469. } CHIP_SWM_PIN_FIXED_T;
  470. #endif
  471. /**
  472. * @brief Initialise the SWM module
  473. * @return Nothing
  474. * @note This function only enables the SWM clock.
  475. */
  476. STATIC INLINE void Chip_SWM_Init(void)
  477. {
  478. Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_SWM);
  479. }
  480. /**
  481. * @brief Deinitialise the SWM module
  482. * @return Nothing
  483. * @note This function only disables the SWM clock.
  484. */
  485. STATIC INLINE void Chip_SWM_Deinit(void)
  486. {
  487. Chip_Clock_DisablePeriphClock(SYSCTL_CLOCK_SWM);
  488. }
  489. /**
  490. * @brief Assign movable pin function to physical pin in Switch Matrix
  491. * @param movable : Movable pin function
  492. * @param assign : Physical pin to be assigned
  493. * @return Nothing
  494. */
  495. void Chip_SWM_MovablePinAssign(CHIP_SWM_PIN_MOVABLE_T movable, uint8_t assign);
  496. /**
  497. * @brief Enables or Disable Fixed Function Pin in the Switch Matrix
  498. * @param pin : Pin to be enabled or disabled
  499. * @param enable : True to enable the pin, False to disable the pin
  500. * @return Nothing
  501. */
  502. void Chip_SWM_FixedPinEnable(CHIP_SWM_PIN_FIXED_T pin, bool enable);
  503. /**
  504. * @brief Enables a Fixed Function Pin in the Switch Matrix
  505. * @param pin : Pin to be enabled
  506. * @return Nothing
  507. */
  508. STATIC INLINE void Chip_SWM_EnableFixedPin(CHIP_SWM_PIN_FIXED_T pin)
  509. {
  510. LPC_SWM->PINENABLE0 &= ~((1 << (uint32_t) pin) | SWM_PINENABLE0_RESERVED);
  511. }
  512. /**
  513. * @brief Disables a Fixed Function Pin in the Switch Matrix
  514. * @param pin : Pin to be disabled
  515. * @return Nothing
  516. */
  517. STATIC INLINE void Chip_SWM_DisableFixedPin(CHIP_SWM_PIN_FIXED_T pin)
  518. {
  519. LPC_SWM->PINENABLE0 = (1 << (uint32_t) pin) | (LPC_SWM->PINENABLE0 & ~SWM_PINENABLE0_RESERVED);
  520. }
  521. /**
  522. * @brief Tests whether a fixed pin is enabled or disabled in the Switch Matrix
  523. * @param pin : The pin to test whether it is enabled or disabled
  524. * @return True if the pin is enabled, False if disabled
  525. */
  526. STATIC INLINE bool Chip_SWM_IsEnabled(CHIP_SWM_PIN_FIXED_T pin)
  527. {
  528. return (bool) ((LPC_SWM->PINENABLE0 & (1 << (uint32_t) pin)) == 0);
  529. }
  530. /**
  531. * @}
  532. */
  533. #ifdef __cplusplus
  534. }
  535. #endif
  536. #endif /* __IOCON_8XX_H_ */