]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/T-HEAD_CB2201_CDK/csi/csi_driver/csky/phobos/include/pinmux.h
Introduce a port for T-HEAD CK802. A simple demo for T-HEAD CB2201 is also included.
[freertos] / FreeRTOS / Demo / T-HEAD_CB2201_CDK / csi / csi_driver / csky / phobos / include / pinmux.h
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 /******************************************************************************
18  * @file     pinmux.h
19  * @brief    Header file for the pinmux
20  * @version  V1.0
21  * @date     02. June 2017
22  ******************************************************************************/
23 #ifndef PHOBOS_PINMUX_H
24 #define PHOBOS_PINMUX_H
25
26 #include <stdint.h>
27 #include "pin_name.h"
28
29 void phobos_ioreuse_initial(void);
30 int32_t pin_mux(pin_name_t pin, uint16_t function);
31
32 /* IOMUX0L function definition */
33 #define PA0_UART0_TX      0x00000000
34 #define PA0_PWM_CH0       0x00000001
35 #define PA0_UART0_SIROUT  0x00000003
36 #define PA1_UART0_RX      0x00000000
37 #define PA1_PWM_CH1       0x00000004
38 #define PA1_UART0_SIRIN   0x0000000C
39 #define PA2_UART0_CTS     0x00000000
40 #define PA2_PWM_CH2       0x00000010
41 #define PA2_SPI0_CLK      0x00000020
42 #define PA3_UART0_TRS     0x00000000
43 #define PA3_PWM_CH3       0x00000040
44 #define PA3_SPI0_TX       0x00000080
45 #define PA4_I2C0_SCL      0x00000000
46 #define PA4_PWM_CH4       0x00000100
47 #define PA4_SPI0_RX       0x00000200
48 #define PA5_I2C0_SDA      0x00000000
49 #define PA5_PWM_CH5       0x00000400
50 #define PA5_SPI0_CS       0x00000800
51 #define PA6_SPI0_CLK      0x00000000
52 #define PA6_ETB_TRIG0     0x00001000
53 #define PA6_I2C0_SCL      0x00002000
54 #define PA7_SPI_TX        0x00000000
55 #define PA7_ETB_TRIG1     0x00004000
56 #define PA7_I2C0_SDA      0x00008000
57 #define PA8_SPI0_TX       0x00000000
58 #define PA8_PWM_FAULT     0x00010000
59 #define PA8_I2C1_SCL      0x00020000
60 #define PA9_SPI0_CS       0x00000000
61 #define PA9_PWM_CH0       0x00040000
62 #define PA9_I2C1_SDA      0x00080000
63 #define PA10_UART1_TX     0x00000000
64 #define PA10_PWM_CH1      0x00100000
65 #define PA10_UART1_SIROUT 0x00300000
66 #define PA11_UART1_RX     0x00000000
67 #define PA11_PWM_CH2      0x00400000
68 #define PA11_UART1_SIRIN  0x00C00000
69 #define PA12_UART1_CTS    0x00000000
70 #define PA12_PWM_CH3      0x01000000
71 #define PA12_SPI1_CLK     0x02000000
72 #define PA13_UART1_RTS    0x00000000
73 #define PA13_PWM_CH4      0x04000000
74 #define PA13_SPI1_TX      0x08000000
75 #define PA14_I2C1_SCL     0x00000000
76 #define PA14_PWM_CH5      0x10000000
77 #define PA14_SPI1_RX      0x20000000
78 #define PA15_I2C1_SDA     0x00000000
79 #define PA15_ETB_TRIG0    0x40000000
80 #define PA15_SPI1_CS0     0x80000000
81
82 /* IOMUX0H function definition */
83 #define PA16_SPI1_CLK     0x00000000
84 #define PA16_ETB_TRIG1    0x00000001
85 #define PA17_SPI1_TX      0x00000000
86 #define PA17_PWM_FAULT    0x00000004
87 #define PA18_SPI1_RX      0x00000000
88 #define PA18_PWM_CH0      0x00000010
89 #define PA19_SPI1_CS0     0x00000000
90 #define PA19_PWM_CH1      0x00000040
91 #define PA20_UART2_RX     0x00000000
92 #define PA20_PWM_CH2      0x00000100
93 #define PA21_SPI1_CS2     0x00000000
94 #define PA21_PWM_CH3      0x00000400
95 #define PA22_UART2_RX     0x00000000
96 #define PA22_PWM_CH4      0x00001000
97 #define PA22_UART2_SIRI   0x00003000
98 #define PA23_UART2_TX     0x00000000
99 #define PA23_PWM_CH5      0x00004000
100 #define PA23_UART2_SIROUT 0x0000C000
101 #define PA24_UART2_CTS    0x00000000
102 #define PA24_ETB_TRIG0    0x00010000
103 #define PA24_SPI1_CS1     0x00020000
104 #define PA25_UART2_RTS    0x00000000
105 #define PA25_ETB_TRIG1    0x00040000
106 #define PA25_SPI1_CS2     0x00080000
107 #define PA26_UART3_TX     0x00000000
108 #define PA26_PWM_FAULT    0x00100000
109 #define PA26_UART3_SIROUT 0x00300000
110 #define PA27_UART3_RX     0x00000000
111 #define PA27_PWM_CH0      0x00400000
112 #define PA27_UART3_SIRIN  0x00C00000
113 #define PA28_I2S_MCLK     0x00000000
114 #define PA28_PWM_CH1      0x01000000
115 #define PA29_I2S_SCLK     0x00000000
116 #define PA29_PWM_CH2      0x04000000
117 #define PA30_I2S_WSCLK    0x00000000
118 #define PA30_PWM_CH3      0x10000000
119 #define PA31_I2S_SDA      0x00000000
120 #define PA31_I2C0_SCL     0x40000000
121 #define PA31_PWM_CH4      0x80000000
122
123 /* IOMUX1L function definition */
124 #define PB0_ADC0       0x00000000
125 #define PB0_I2C0_SDA   0x00000001
126 #define PB0_PWM_CH5    0x00000002
127 #define PB1_ADC1       0x00000000
128 #define PB1_I2C1_SCL   0x00000004
129 #define PB1_USI_SCLK   0x00000008
130 #define PB2_ADC2       0x00000000
131 #define PB2_I2C1_SDA   0x00000010
132 #define PB2_USI_SD0    0x00000020
133 #define PB3_ADC3       0x00000000
134 #define PB3_SPI1_CLK   0x00000040
135 #define PB3_USI_SD1    0x00000080
136 #define PB4_ADC4       0x00000000
137 #define PB4_SPI1_TX    0x00000100
138 #define PB4_USI_NSS    0x00000200
139 #define PB5_ADC5       0x00000000
140 #define PB5_SPI1_RX    0x00000400
141 #define PB5_USI_SCLK   0x00000800
142 #define PB6_ADC6       0x00000000
143 #define PB6_SPI1_CS0   0x00001000
144 #define PB6_USI_SD0    0x00002000
145 #define PB7_ADC7       0x00000000
146 #define PB7_SPI1_CS1   0x00004000
147 #define PB7_USI_SD1    0x00008000
148 #define PB8_ETB_TRIG0  0x00000000
149 #define PB8_SPI1_CS2   0x00010000
150 #define PB8_USI_NSS    0x00020000
151 #define PB9_ETB_TRIG1  0x00000000
152 #define PB9_UART3_CTS  0x00040000
153 #define PB10_PWM_FAULT 0x00000000
154 #define PB10_UART3_RTS 0x00100000
155
156
157 /* flag as identification */
158 #define GPIO_SET_BIT0  0x00000001
159 #define GPIO_SET_BIT1  0x00000002
160 #define GPIO_SET_BIT2  0x00000004
161 #define GPIO_SET_BIT3  0x00000008
162 #define GPIO_SET_BIT4  0x00000010
163 #define GPIO_SET_BIT5  0x00000020
164 #define GPIO_SET_BIT6  0x00000040
165 #define GPIO_SET_BIT7  0x00000080
166 #define GPIO_SET_BIT8  0x00000100
167 #define GPIO_SET_BIT9  0x00000200
168 #define GPIO_SET_BIT10 0x00000400
169 #define GPIO_SET_BIT11 0x00000800
170 #define GPIO_SET_BIT12 0x00001000
171 #define GPIO_SET_BIT13 0x00002000
172 #define GPIO_SET_BIT14 0x00004000
173 #define GPIO_SET_BIT15 0x00008000
174 #define GPIO_SET_BIT16 0x00010000
175 #define GPIO_SET_BIT17 0x00020000
176 #define GPIO_SET_BIT18 0x00040000
177 #define GPIO_SET_BIT19 0x00080000
178 #define GPIO_SET_BIT20 0x00100000
179 #define GPIO_SET_BIT21 0x00200000
180 #define GPIO_SET_BIT22 0x00400000
181 #define GPIO_SET_BIT23 0x00800000
182 #define GPIO_SET_BIT24 0x01000000
183 #define GPIO_SET_BIT25 0x02000000
184 #define GPIO_SET_BIT26 0x04000000
185 #define GPIO_SET_BIT27 0x08000000
186 #define GPIO_SET_BIT28 0x10000000
187 #define GPIO_SET_BIT29 0x20000000
188 #define GPIO_SET_BIT30 0x40000000
189 #define GPIO_SET_BIT31 0x80000000
190
191 /******************************************************************************
192  * phobos gpio control and gpio reuse function
193  * selecting regester adddress
194  ******************************************************************************/
195
196 #define PHOBOS_GIPO0_PORTCTL_REG 0x50018008
197 #define PHOBOS_GIPO1_PORTCTL_REG 0x60018008
198 #define PHOBOS_IOMUX0L_REG       0x50018100
199 #define PHOBOS_IOMUX0H_REG       0x50018104
200 #define PHOBOS_IOMUX1L_REG       0x50018108
201
202 /*************basic gpio reuse v1.0********************************************
203  * UART0(PA0,PA1)
204  * UART1(PA10,PA11)
205  * UART2(PA22,PA23)
206  * UART3(PA26,PA27)
207  * IIS(PA24,PA25,PA26,PA27)
208  * SPI1(PA16,PA17,PA18)
209  * IIC0(PA4,PA5)
210  ******************************************************************************/
211 #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)
212 #define GPIO1_REUSE_EN                (GPIO_SET_BIT0)
213 #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)
214 #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)
215 #define IOMUX1L_FUNCTION_SEL          (PB0_ADC0)
216
217 #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)
218 #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)
219
220 #endif /* PHOBOS_PINMUX_H */
221