swm.h 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. /*
  2. * lpc8xx_swm.h
  3. *
  4. * Created on: March 28, 2017
  5. *
  6. */
  7. #ifndef LPC8XX_SWM_H_
  8. #define LPC8XX_SWM_H_
  9. #include "LPC8xx.h"
  10. // Port pin number equates
  11. #define P0_0 0
  12. #define P0_1 1
  13. #define P0_2 2
  14. #define P0_3 3
  15. #define P0_4 4
  16. #define P0_5 5
  17. #define P0_6 6
  18. #define P0_7 7
  19. #define P0_8 8
  20. #define P0_9 9
  21. #define P0_10 10
  22. #define P0_11 11
  23. #define P0_12 12
  24. #define P0_13 13
  25. #define P0_14 14
  26. #define P0_15 15
  27. #define P0_16 16
  28. #define P0_17 17
  29. #define P0_18 18
  30. #define P0_19 19
  31. #define P0_20 20
  32. #define P0_21 21
  33. #define P0_22 22
  34. #define P0_23 23
  35. #define P0_24 24
  36. #define P0_25 25
  37. #define P0_26 26
  38. #define P0_27 27
  39. #define P0_28 28
  40. #define P0_29 29
  41. #define P0_30 30
  42. #define P0_31 31
  43. #define P1_0 32
  44. #define P1_1 33
  45. #define P1_2 34
  46. #define P1_3 35
  47. #define P1_4 36
  48. #define P1_5 37
  49. #define P1_6 38
  50. #define P1_7 39
  51. #define P1_8 40
  52. #define P1_9 41
  53. #define P1_10 42
  54. #define P1_11 43
  55. #define P1_12 44
  56. #define P1_13 45
  57. #define P1_14 46
  58. #define P1_15 47
  59. #define P1_16 48
  60. #define P1_17 49
  61. #define P1_18 50
  62. #define P1_19 51
  63. #define P1_20 52
  64. #define P1_21 53
  65. #define P1_22 54
  66. #define P1_23 55
  67. #define P1_24 56
  68. #define P1_25 57
  69. #define P1_26 58
  70. #define P1_27 59
  71. #define P1_28 60
  72. #define P1_29 61
  73. #define P1_30 62
  74. #define P1_31 63
  75. #define NO_PIN 0xFF
  76. // Function name equates (for normal people)
  77. #define U0_TXD 0
  78. #define U0_RXD 1
  79. #define U0_RTS 2
  80. #define U0_CTS 3
  81. #define U0_SCLK 4
  82. #define U1_TXD 5
  83. #define U1_RXD 6
  84. #define U1_SCLK 7
  85. #define SPI0_SCK 8
  86. #define SPI0_MOSI 9
  87. #define SPI0_MISO 10
  88. #define SPI0_SSEL0 11
  89. #define SPI0_SSEL1 12
  90. #define T0_CAP0 13
  91. #define T0_CAP1 14
  92. #define T0_CAP2 15
  93. #define T0_MAT0 16
  94. #define T0_MAT1 17
  95. #define T0_MAT2 18
  96. #define T0_MAT3 19
  97. #define I2C0_SDA 20
  98. #define I2C0_SCL 21
  99. #define COMP0_OUT 22
  100. #define ACOMP 22
  101. #define CLKOUT 23
  102. #define GPIO_INT_BMAT 24
  103. #define LVLSHFT_IN0 25
  104. #define LVLSHFT_IN1 26
  105. #define LVLSHFT_OUT0 27
  106. #define LVLSHFT_OUT1 28
  107. #define I2C1_SDA 29
  108. #define I2C1_SCL 30
  109. #define PLU_CLKIN 31
  110. #define CAPT_X0 32
  111. #define CAPT_X1 33
  112. #define CAPT_X2 34
  113. #define CAPT_X3 35
  114. #define CAPT_X4 36
  115. #define CAPT_YL 37
  116. #define CAPT_YH 38
  117. #define num_funcs 39
  118. // Function name equates for the PINASSIGN_4PIN register
  119. #define min_4pin_func 100
  120. #define PLU_IN0 100
  121. #define PLU_IN1 101
  122. #define PLU_IN2 102
  123. #define PLU_IN3 103
  124. #define PLU_IN4 104
  125. #define PLU_IN5 105
  126. #define PLU_OUT0 106
  127. #define PLU_OUT1 107
  128. #define PLU_OUT2 108
  129. #define PLU_OUT3 109
  130. #define PLU_OUT4 110
  131. #define PLU_OUT5 111
  132. #define PLU_OUT6 112
  133. #define PLU_OUT7 113
  134. #define max_4pin_func 113
  135. // PINENABLE0 register defines
  136. #define ACMP_I1 (1<<0)
  137. #define ACMP_I2 (1<<1)
  138. #define ACMP_I3 (1<<2)
  139. #define ACMP_I4 (1<<3)
  140. #define SWCLK (1<<4)
  141. #define SWDIO (1<<5)
  142. #define RESETN (1<<6)
  143. #define CLKIN (1<<7)
  144. #define WKTCLKIN (1<<8)
  145. #define VDDCMP (1<<9)
  146. #define ADC_0 (1<<10)
  147. #define ADC_1 (1<<11)
  148. #define ADC_2 (1<<12)
  149. #define ADC_3 (1<<13)
  150. #define ADC_4 (1<<14)
  151. #define ADC_5 (1<<15)
  152. #define ADC_6 (1<<16)
  153. #define ADC_7 (1<<17)
  154. #define ADC_8 (1<<18)
  155. #define ADC_9 (1<<19)
  156. #define ADC_10 (1<<20)
  157. #define ADC_11 (1<<21)
  158. #define ACMP_I5 (1<<22)
  159. #define DACOUT0 (1<<23)
  160. /**
  161. * @brief LPC8XX Switch Matrix PLU Movable pins (works for LPC804 with PLU)
  162. */
  163. typedef enum CHIP_SWM_PLU_MOVABLE {
  164. PLU_INPUT0_PIO0_0 = 0x00 << 0, /*!< PLU_INPUT0 - PIO0_0 */
  165. PLU_INPUT0_PIO0_8 = 0x01 << 0, /*!< PLU_INPUT0 - PIO0_8 */
  166. PLU_INPUT0_PIO0_17 = 0x02 << 0, /*!< PLU_INPUT0 - PIO0_17 */
  167. PLU_INPUT0_NONE = 0x03 << 0, /*!< PLU_INPUT0 - NONE */
  168. PLU_INPUT1_PIO0_1 = 0x00 << 2, /*!< PLU_INPUT1 - PIO0_1 */
  169. PLU_INPUT1_PIO0_9 = 0x01 << 2, /*!< PLU_INPUT1 - PIO0_9 */
  170. PLU_INPUT1_PIO0_18 = 0x02 << 2, /*!< PLU_INPUT1 - PIO0_18 */
  171. PLU_INPUT1_NONE = 0x03 << 2, /*!< PLU_INPUT1 - NONE */
  172. PLU_INPUT2_PIO0_2 = 0x00 << 4, /*!< PLU_INPUT2 - PIO0_2 */
  173. PLU_INPUT2_PIO0_10 = 0x01 << 4, /*!< PLU_INPUT2 - PIO0_10 */
  174. PLU_INPUT2_PIO0_19 = 0x02 << 4, /*!< PLU_INPUT2 - PIO0_19 */
  175. PLU_INPUT2_NONE = 0x03 << 4, /*!< PLU_INPUT2 - NONE */
  176. PLU_INPUT3_PIO0_3 = 0x00 << 6, /*!< PLU_INPUT3 - PIO0_3 */
  177. PLU_INPUT3_PIO0_11 = 0x01 << 6, /*!< PLU_INPUT3 - PIO0_11 */
  178. PLU_INPUT3_PIO0_20 = 0x02 << 6, /*!< PLU_INPUT3 - PIO0_20 */
  179. PLU_INPUT3_NONE = 0x03 << 6, /*!< PLU_INPUT3 - NONE */
  180. PLU_INPUT4_PIO0_4 = 0x00 << 8, /*!< PLU_INPUT4 - PIO0_4 */
  181. PLU_INPUT4_PIO0_12 = 0x01 << 8, /*!< PLU_INPUT4 - PIO0_12 */
  182. PLU_INPUT4_PIO0_21 = 0x02 << 8, /*!< PLU_INPUT4 - PIO0_21 */
  183. PLU_INPUT4_NONE = 0x03 << 8, /*!< PLU_INPUT4 - NONE */
  184. PLU_INPUT5_PIO0_5 = 0x00 << 10, /*!< PLU_INPUT5 - PIO0_5 */
  185. PLU_INPUT5_PIO0_13 = 0x01 << 10, /*!< PLU_INPUT5 - PIO0_13 */
  186. PLU_INPUT5_PIO0_22 = 0x02 << 10, /*!< PLU_INPUT5 - PIO0_22 */
  187. PLU_INPUT5_NONE = 0x03 << 10, /*!< PLU_INPUT5 - NONE */
  188. PLU_OUTPUT0_PIO0_7 = 0x00 << 12, /*!< PLU_OUTPUT0 - PIO0_7 */
  189. PLU_OUTPUT0_PIO0_14 = 0x01 << 12, /*!< PLU_OUTPUT0 - PIO0_14 */
  190. PLU_OUTPUT0_PIO0_23 = 0x02 << 12, /*!< PLU_OUTPUT0 - PIO0_23 */
  191. PLU_OUTPUT0_NONE = 0x03 << 12, /*!< PLU_OUTPUT0 - NONE */
  192. PLU_OUTPUT1_PIO0_8 = 0x00 << 14, /*!< PLU_OUTPUT1 - PIO0_8 */
  193. PLU_OUTPUT1_PIO0_15 = 0x01 << 14, /*!< PLU_OUTPUT1 - PIO0_15 */
  194. PLU_OUTPUT1_PIO0_24 = 0x02 << 14, /*!< PLU_OUTPUT1 - PIO0_24 */
  195. PLU_OUTPUT1_NONE = 0x03 << 14, /*!< PLU_OUTPUT1 - NONE */
  196. PLU_OUTPUT2_PIO0_9 = 0x00 << 16, /*!< PLU_OUTPUT2 - PIO0_9 */
  197. PLU_OUTPUT2_PIO0_16 = 0x01 << 16, /*!< PLU_OUTPUT2 - PIO0_16 */
  198. PLU_OUTPUT2_PIO0_25 = 0x02 << 16, /*!< PLU_OUTPUT2 - PIO0_25 */
  199. PLU_OUTPUT2_NONE = 0x03 << 16, /*!< PLU_OUTPUT2 - NONE */
  200. PLU_OUTPUT3_PIO0_10 = 0x00 << 18, /*!< PLU_OUTPUT3 - PIO0_10 */
  201. PLU_OUTPUT3_PIO0_17 = 0x01 << 18, /*!< PLU_OUTPUT3 - PIO0_17 */
  202. PLU_OUTPUT3_PIO0_26 = 0x02 << 18, /*!< PLU_OUTPUT3 - PIO0_26 */
  203. PLU_OUTPUT3_NONE = 0x03 << 18, /*!< PLU_OUTPUT3 - NONE */
  204. PLU_OUTPUT4_PIO0_11 = 0x00 << 20, /*!< PLU_OUTPUT4 - PIO0_11 */
  205. PLU_OUTPUT4_PIO0_18 = 0x01 << 20, /*!< PLU_OUTPUT4 - PIO0_18 */
  206. PLU_OUTPUT4_PIO0_27 = 0x02 << 20, /*!< PLU_OUTPUT4 - PIO0_27 */
  207. PLU_OUTPUT4_NONE = 0x03 << 20, /*!< PLU_OUTPUT4 - NONE */
  208. PLU_OUTPUT5_PIO0_12 = 0x00 << 22, /*!< PLU_OUTPUT5 - PIO0_12 */
  209. PLU_OUTPUT5_PIO0_19 = 0x01 << 22, /*!< PLU_OUTPUT5 - PIO0_19 */
  210. PLU_OUTPUT5_PIO0_28 = 0x02 << 22, /*!< PLU_OUTPUT5 - PIO0_28 */
  211. PLU_OUTPUT5_NONE = 0x03 << 22, /*!< PLU_OUTPUT5 - NONE */
  212. PLU_OUTPUT6_PIO0_13 = 0x00 << 24, /*!< PLU_OUTPUT6 - PIO0_13 */
  213. PLU_OUTPUT6_PIO0_20 = 0x01 << 24, /*!< PLU_OUTPUT6 - PIO0_20 */
  214. PLU_OUTPUT6_PIO0_29 = 0x02 << 24, /*!< PLU_OUTPUT6 - PIO0_29 */
  215. PLU_OUTPUT6_NONE = 0x03 << 24, /*!< PLU_OUTPUT6 - NONE */
  216. PLU_OUTPUT7_PIO0_14 = 0x00 << 26, /*!< PLU_OUTPUT7 - PIO0_14 */
  217. PLU_OUTPUT7_PIO0_21 = 0x01 << 26, /*!< PLU_OUTPUT7 - PIO0_21 */
  218. PLU_OUTPUT7_PIO0_30 = 0x02 << 26, /*!< PLU_OUTPUT7 - PIO0_30 */
  219. PLU_OUTPUT7_NONE = 0x03 << 26, /*!< PLU_OUTPUT7 - NONE */
  220. } CHIP_SWM_PLU_MOVABLE_T;
  221. // Function prototypes
  222. void ConfigSWM(uint32_t func, uint32_t port_pin);
  223. void EnableFixedPinFunc(uint32_t func);
  224. void DisableFixedPinFunc(uint32_t func);
  225. #endif /* LPC8XX_SWM_H_ */