pinmux.h 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. /*
  2. * Copyright (C) 2017 C-SKY Microsystems Co., Ltd. All rights reserved.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. /******************************************************************************
  17. * @file pinmux.h
  18. * @brief Header file for the pinmux
  19. * @version V1.0
  20. * @date 02. June 2017
  21. ******************************************************************************/
  22. #ifndef PHOBOS_PINMUX_H
  23. #define PHOBOS_PINMUX_H
  24. #include <stdint.h>
  25. #include "pin_name.h"
  26. void phobos_ioreuse_initial(void);
  27. int32_t pin_mux(pin_name_t pin, uint16_t function);
  28. /* IOMUX0L function definition */
  29. #define PA0_UART0_TX 0x00000000
  30. #define PA0_PWM_CH0 0x00000001
  31. #define PA0_UART0_SIROUT 0x00000003
  32. #define PA1_UART0_RX 0x00000000
  33. #define PA1_PWM_CH1 0x00000004
  34. #define PA1_UART0_SIRIN 0x0000000C
  35. #define PA2_UART0_CTS 0x00000000
  36. #define PA2_PWM_CH2 0x00000010
  37. #define PA2_SPI0_CLK 0x00000020
  38. #define PA3_UART0_TRS 0x00000000
  39. #define PA3_PWM_CH3 0x00000040
  40. #define PA3_SPI0_TX 0x00000080
  41. #define PA4_I2C0_SCL 0x00000000
  42. #define PA4_PWM_CH4 0x00000100
  43. #define PA4_SPI0_RX 0x00000200
  44. #define PA5_I2C0_SDA 0x00000000
  45. #define PA5_PWM_CH5 0x00000400
  46. #define PA5_SPI0_CS 0x00000800
  47. #define PA6_SPI0_CLK 0x00000000
  48. #define PA6_ETB_TRIG0 0x00001000
  49. #define PA6_I2C0_SCL 0x00002000
  50. #define PA7_SPI_TX 0x00000000
  51. #define PA7_ETB_TRIG1 0x00004000
  52. #define PA7_I2C0_SDA 0x00008000
  53. #define PA8_SPI0_TX 0x00000000
  54. #define PA8_PWM_FAULT 0x00010000
  55. #define PA8_I2C1_SCL 0x00020000
  56. #define PA9_SPI0_CS 0x00000000
  57. #define PA9_PWM_CH0 0x00040000
  58. #define PA9_I2C1_SDA 0x00080000
  59. #define PA10_UART1_TX 0x00000000
  60. #define PA10_PWM_CH1 0x00100000
  61. #define PA10_UART1_SIROUT 0x00300000
  62. #define PA11_UART1_RX 0x00000000
  63. #define PA11_PWM_CH2 0x00400000
  64. #define PA11_UART1_SIRIN 0x00C00000
  65. #define PA12_UART1_CTS 0x00000000
  66. #define PA12_PWM_CH3 0x01000000
  67. #define PA12_SPI1_CLK 0x02000000
  68. #define PA13_UART1_RTS 0x00000000
  69. #define PA13_PWM_CH4 0x04000000
  70. #define PA13_SPI1_TX 0x08000000
  71. #define PA14_I2C1_SCL 0x00000000
  72. #define PA14_PWM_CH5 0x10000000
  73. #define PA14_SPI1_RX 0x20000000
  74. #define PA15_I2C1_SDA 0x00000000
  75. #define PA15_ETB_TRIG0 0x40000000
  76. #define PA15_SPI1_CS0 0x80000000
  77. /* IOMUX0H function definition */
  78. #define PA16_SPI1_CLK 0x00000000
  79. #define PA16_ETB_TRIG1 0x00000001
  80. #define PA17_SPI1_TX 0x00000000
  81. #define PA17_PWM_FAULT 0x00000004
  82. #define PA18_SPI1_RX 0x00000000
  83. #define PA18_PWM_CH0 0x00000010
  84. #define PA19_SPI1_CS0 0x00000000
  85. #define PA19_PWM_CH1 0x00000040
  86. #define PA20_UART2_RX 0x00000000
  87. #define PA20_PWM_CH2 0x00000100
  88. #define PA21_SPI1_CS2 0x00000000
  89. #define PA21_PWM_CH3 0x00000400
  90. #define PA22_UART2_RX 0x00000000
  91. #define PA22_PWM_CH4 0x00001000
  92. #define PA22_UART2_SIRI 0x00003000
  93. #define PA23_UART2_TX 0x00000000
  94. #define PA23_PWM_CH5 0x00004000
  95. #define PA23_UART2_SIROUT 0x0000C000
  96. #define PA24_UART2_CTS 0x00000000
  97. #define PA24_ETB_TRIG0 0x00010000
  98. #define PA24_SPI1_CS1 0x00020000
  99. #define PA25_UART2_RTS 0x00000000
  100. #define PA25_ETB_TRIG1 0x00040000
  101. #define PA25_SPI1_CS2 0x00080000
  102. #define PA26_UART3_TX 0x00000000
  103. #define PA26_PWM_FAULT 0x00100000
  104. #define PA26_UART3_SIROUT 0x00300000
  105. #define PA27_UART3_RX 0x00000000
  106. #define PA27_PWM_CH0 0x00400000
  107. #define PA27_UART3_SIRIN 0x00C00000
  108. #define PA28_I2S_MCLK 0x00000000
  109. #define PA28_PWM_CH1 0x01000000
  110. #define PA29_I2S_SCLK 0x00000000
  111. #define PA29_PWM_CH2 0x04000000
  112. #define PA30_I2S_WSCLK 0x00000000
  113. #define PA30_PWM_CH3 0x10000000
  114. #define PA31_I2S_SDA 0x00000000
  115. #define PA31_I2C0_SCL 0x40000000
  116. #define PA31_PWM_CH4 0x80000000
  117. /* IOMUX1L function definition */
  118. #define PB0_ADC0 0x00000000
  119. #define PB0_I2C0_SDA 0x00000001
  120. #define PB0_PWM_CH5 0x00000002
  121. #define PB1_ADC1 0x00000000
  122. #define PB1_I2C1_SCL 0x00000004
  123. #define PB1_USI_SCLK 0x00000008
  124. #define PB2_ADC2 0x00000000
  125. #define PB2_I2C1_SDA 0x00000010
  126. #define PB2_USI_SD0 0x00000020
  127. #define PB3_ADC3 0x00000000
  128. #define PB3_SPI1_CLK 0x00000040
  129. #define PB3_USI_SD1 0x00000080
  130. #define PB4_ADC4 0x00000000
  131. #define PB4_SPI1_TX 0x00000100
  132. #define PB4_USI_NSS 0x00000200
  133. #define PB5_ADC5 0x00000000
  134. #define PB5_SPI1_RX 0x00000400
  135. #define PB5_USI_SCLK 0x00000800
  136. #define PB6_ADC6 0x00000000
  137. #define PB6_SPI1_CS0 0x00001000
  138. #define PB6_USI_SD0 0x00002000
  139. #define PB7_ADC7 0x00000000
  140. #define PB7_SPI1_CS1 0x00004000
  141. #define PB7_USI_SD1 0x00008000
  142. #define PB8_ETB_TRIG0 0x00000000
  143. #define PB8_SPI1_CS2 0x00010000
  144. #define PB8_USI_NSS 0x00020000
  145. #define PB9_ETB_TRIG1 0x00000000
  146. #define PB9_UART3_CTS 0x00040000
  147. #define PB10_PWM_FAULT 0x00000000
  148. #define PB10_UART3_RTS 0x00100000
  149. /* flag as identification */
  150. #define GPIO_SET_BIT0 0x00000001
  151. #define GPIO_SET_BIT1 0x00000002
  152. #define GPIO_SET_BIT2 0x00000004
  153. #define GPIO_SET_BIT3 0x00000008
  154. #define GPIO_SET_BIT4 0x00000010
  155. #define GPIO_SET_BIT5 0x00000020
  156. #define GPIO_SET_BIT6 0x00000040
  157. #define GPIO_SET_BIT7 0x00000080
  158. #define GPIO_SET_BIT8 0x00000100
  159. #define GPIO_SET_BIT9 0x00000200
  160. #define GPIO_SET_BIT10 0x00000400
  161. #define GPIO_SET_BIT11 0x00000800
  162. #define GPIO_SET_BIT12 0x00001000
  163. #define GPIO_SET_BIT13 0x00002000
  164. #define GPIO_SET_BIT14 0x00004000
  165. #define GPIO_SET_BIT15 0x00008000
  166. #define GPIO_SET_BIT16 0x00010000
  167. #define GPIO_SET_BIT17 0x00020000
  168. #define GPIO_SET_BIT18 0x00040000
  169. #define GPIO_SET_BIT19 0x00080000
  170. #define GPIO_SET_BIT20 0x00100000
  171. #define GPIO_SET_BIT21 0x00200000
  172. #define GPIO_SET_BIT22 0x00400000
  173. #define GPIO_SET_BIT23 0x00800000
  174. #define GPIO_SET_BIT24 0x01000000
  175. #define GPIO_SET_BIT25 0x02000000
  176. #define GPIO_SET_BIT26 0x04000000
  177. #define GPIO_SET_BIT27 0x08000000
  178. #define GPIO_SET_BIT28 0x10000000
  179. #define GPIO_SET_BIT29 0x20000000
  180. #define GPIO_SET_BIT30 0x40000000
  181. #define GPIO_SET_BIT31 0x80000000
  182. /******************************************************************************
  183. * phobos gpio control and gpio reuse function
  184. * selecting regester adddress
  185. ******************************************************************************/
  186. #define PHOBOS_GIPO0_PORTCTL_REG 0x50018008
  187. #define PHOBOS_GIPO1_PORTCTL_REG 0x60018008
  188. #define PHOBOS_IOMUX0L_REG 0x50018100
  189. #define PHOBOS_IOMUX0H_REG 0x50018104
  190. #define PHOBOS_IOMUX1L_REG 0x50018108
  191. /*************basic gpio reuse v1.0********************************************
  192. * UART0(PA0,PA1)
  193. * UART1(PA10,PA11)
  194. * UART2(PA22,PA23)
  195. * UART3(PA26,PA27)
  196. * IIS(PA24,PA25,PA26,PA27)
  197. * SPI1(PA16,PA17,PA18)
  198. * IIC0(PA4,PA5)
  199. ******************************************************************************/
  200. #define GPIO0_REUSE_EN (GPIO_SET_BIT0|GPIO_SET_BIT1|GPIO_SET_BIT4|GPIO_SET_BIT5|GPIO_SET_BIT6|GPIO_SET_BIT9|GPIO_SET_BIT10|GPIO_SET_BIT11|GPIO_SET_BIT16|GPIO_SET_BIT17|GPIO_SET_BIT18|GPIO_SET_BIT22|GPIO_SET_BIT23|GPIO_SET_BIT26|GPIO_SET_BIT27)
  201. #define GPIO1_REUSE_EN (GPIO_SET_BIT0)
  202. #define IOMUX0L_FUNCTION_SEL (PA0_UART0_TX|PA1_UART0_RX|PA4_I2C0_SCL|PA5_I2C0_SDA|PA6_ETB_TRIG0|PA9_PWM_CH0|PA10_UART1_TX|PA11_UART1_RX)
  203. #define IOMUX0H_FUNCTION_SEL (PA16_SPI1_CLK|PA17_SPI1_TX|PA18_SPI1_RX|PA22_UART2_RX|PA23_UART2_TX|PA26_UART3_TX|PA27_UART3_RX)
  204. #define IOMUX1L_FUNCTION_SEL (PB0_ADC0)
  205. #define PWM_GPIO0_REUSE_EN (GPIO0_REUSE_EN|GPIO_SET_BIT0|GPIO_SET_BIT1|GPIO_SET_BIT2|GPIO_SET_BIT12|GPIO_SET_BIT13|GPIO_SET_BIT14)
  206. #define PWM_IOMUX0L_FUNCTION_SEL (IOMUX0L_FUNCTION_SEL|PA0_PWM_CH0|PA1_PWM_CH1|PA2_PWM_CH2|PA12_PWM_CH3|PA13_PWM_CH4|PA14_PWM_CH5)
  207. #endif /* PHOBOS_PINMUX_H */