summaryrefslogtreecommitdiff
path: root/bsp/phytium/libraries/standalone/doc/reference/sdk/fpinctrl.md
blob: 958156f69594fd25cc8a54c718506dda79936ff0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
# 芯片引脚控制

## 1. 概述

- 芯片引脚控制 (Pin Ctrl)用于引脚功能配置和引脚延迟配置,开发板上常存在某些 IO 之间存在共用同一物理引脚情况,即引脚复用,同时,通用 IO 引脚还可以配置引脚延迟
- FPinCtrl 支持芯片引脚控制功能,支持 FT2000/4、D2000 和 E2000

## 2. 功能

- FPinCtrl 主要提供引脚控制相关的功能配置,包括
- 1. 控制复用功能
- 2. 控制引脚驱动能力,只支持E2000平台
- 3. 配置引脚的上下拉电阻
- 4. 调节引脚的输入输出延迟

- 相关的源文件包括
```
fpinctrl.h
    fiopad.h  --> E2000
    fiopad.c

    fioctrl.h --> FT2000/4, D2000
    fioctrl.c
```

## 3. 配置方法

- 不需要特别配置

## 4. 应用示例

- 设置引脚的复用,驱动能力和上下拉电阻等

### [fpin_test](../../../baremetal/example/peripheral/pin/fioctrl_test)

- IO 引脚延时配置索引,参考 D2000/FT2000-4 数据手册的"表 5-32 通用 IO 引脚延时配置寄存

> 调用 FIOCTRL_INDEX 生成PAD对应的索引,e.g.

| 偏移    | 位域 |  说明 |
| -------- | ------- | ------- |
|0x0208  |  [27 : 26] | 控制 i2c_0_scl_pad 的上下拉 2'b10 |
|        |  [25 : 24] | 控制 i2c_0_scl_pad 的复用功能 2'b00 |

```c
    #define FIOCTRL_I2C0_SCL_PAD        (FPinIndex)FIOCTRL_INDEX(0x208, 24) /* i2c0-scl: func 0 */
```
> 定义控制域为 i2c0_scl_pad 的PAD,其中延时配置寄存器偏移量为0x208, 输入延时配置位从第24位开始

## 5. API参考

Note:

- FT2000/4 和 D2000 平台,使用FIOCTRL_INDEX 宏定义的 index 作为引脚索引
- E2000 平台,使用 FIOPAD_INDEX 宏定义的 index 作为引脚索引

#### FPinGetFunc

```c
FPinFunc FPinGetFunc(const FPinIndex pin);
```

Note:

- 获取IO引脚当前的复用功能

Input:

- {FPinIndex} pin IO引脚索引

Return:

- {FPinFunc} 当前的复用功能

#### FPinSetFunc

```c
void FPinSetFunc(const FPinIndex pin, FPinFunc func);
```

Note:

- 设置IO引脚复用功能

Input:

- {FPinIndex} pin IO引脚索引
- {FPinFunc} func IO复用功能

Return:

- 无

#### FPinGetPull

```c
FPinPull FPinGetPull(const FPinIndex pin);
```

Note:

- 获取IO引脚当前的上下拉设置

Input:

- {FPinIndex} pin IO引脚索引

Return:

- {FPinPull} 当前的上下拉设置

#### FPinSetPull

```c
void FPinSetPull(const FPinIndex pin, FPinPull pull);
```

Note:

- 设置IO引脚当前的上下拉

Input:

- {FPinIndex} pin IO引脚索引
- {FPinPull} pull 上下拉设置

Return:

- 无

#### FPinGetDelay

```c
FPinDelay FPinGetDelay(const FPinIndex pin, FPinDelayDir dir, FPinDelayType type);
```

Note:

- 获取IO引脚当前的延时设置

Input:

- {FPinIndex} pin IO引脚延时设置索引
- {FPinDelayDir} dir 输入/输出延时
- {FPinDelayType} type 精调/粗调延时

Return:

- {FPinDelay} 当前的延时设置

#### FPinGetDelayEn

```c
boolean FPinGetDelayEn(const FPinIndex pin, FPinDelayDir dir);
```

Note:

- 获取IO引脚当前的延时使能标志位

Input:

- {FPinIndex} pin IO引脚延时设置索引
- {FPinDelayDir} dir 输入/输出延时

Return:

- {boolean} TRUE: 使能延时, FALSE: 去使能延时

#### FPinSetDelay

```c
void FPinSetDelay(const FPinIndex pin, FPinDelayDir dir, FPinDelayType type, FPinDelay delay);
```

Note:

- 设置IO引脚延时

Input:

- {FPinIndex} pin IO引脚延时设置索引
- {FPinDelayDir} dir 输入/输出延时
- {FPinDelayType} type 精调/粗调延时
- {FPinDelay} delay 延时设置

Return:

- 无

#### FPinSetDelayEn

```c
void FPinSetDelayEn(const FPinIndex pin, FPinDelayDir dir, boolean enable);
```

Note:

- 使能/去使能IO引脚延时

Input:

- {FPinIndex} pin IO引脚延时设置索引
- {FPinDelayDir} dir 输入/输出延时
- {boolean} enable TRUE: 使能, FALSE: 去使能

Return:

- 无

#### FPinGetDrive

```c
FPinDrive FPinGetDrive(const FPinIndex pin);
```

Note:

- 获取IO引脚的驱动能力
- 只支持 E2000 平台

Input:

- {FPinIndex} pin IO引脚索引

Return:

- {FPinDrive} 引脚的当前的驱动能力

#### FPinSetDrive

```c
void FPinSetDrive(const FPinIndex pin, FPinDrive drive);
```

Note:

- 设置IO引脚的驱动能力
- 只支持 E2000 平台

Input:

- {FPinIndex} pin, IO引脚索引
- {FPinDrive} drive, 引脚驱动能力设置

Return:

- 无

#### 

```c

```

Note:

- 

Input:

- 

Return:

-