@@ -6,7 +6,7 @@ The `gpio(general purpose input/output)` IP is a fully parameterised soft IP rec
6
6
### Feature
7
7
* 1~ 32 channels support
8
8
* Input and output direction control
9
- * Pin multiplexer with one alternate ouput function
9
+ * Pin multiplexer with two alternate ouput function
10
10
* Three configurable modes
11
11
* input pull-down with schmitt trigger
12
12
* ouput push-pull
@@ -41,7 +41,8 @@ The `gpio(general purpose input/output)` IP is a fully parameterised soft IP rec
41
41
| [ INTTYPE0] ( #interrupt-type0-register ) | 0x10 | 4 | interrupt type0 register |
42
42
| [ INTTYPE1] ( #interrupt-type1-register ) | 0x14 | 4 | interrupt type1 register |
43
43
| [ INTSTAT] ( #interrupt-state-register ) | 0x18 | 4 | interrupt state register |
44
- | [ IOCFG] ( ) | 0x1C | 4 | io configuration register |
44
+ | [ IOCFG] ( # ) | 0x1C | 4 | io configuration register |
45
+ | [ PINMUX] ( #pin-mux-register ) | 0x1C | 4 | io configuration register |
45
46
46
47
#### PAD Direction Register
47
48
| bit | access | description |
@@ -122,26 +123,57 @@ reset value: `0x0000_0000`
122
123
123
124
* INTSTAT: interrupt state
124
125
126
+ #### IO Config Register
127
+ | bit | access | description |
128
+ | :---:| :-------:| :---------: |
129
+ | ` [31:GPIO_NUM] ` | none | reserved |
130
+ | ` [GPIO_NUM-1:0] ` | RW | IOCFG |
131
+
132
+ reset value: ` 0x0000_0000 `
133
+
134
+ * IOCFG: io control mode config
135
+ * ` IOCFG[i] = 1'b0 ` : software control mode
136
+ * ` IOCFG[i] = 1'b1 ` : alternate control mode
137
+
138
+ #### Pin Mux Register
139
+ | bit | access | description |
140
+ | :---:| :-------:| :---------: |
141
+ | ` [31:GPIO_NUM] ` | none | reserved |
142
+ | ` [GPIO_NUM-1:0] ` | RW | PINMUX |
143
+
144
+ reset value: ` 0x0000_0000 `
145
+
146
+ * PINMUX: alternate io select
147
+ * ` IOCFG[i] = 1'b0 ` : alternate 0 io select
148
+ * ` IOCFG[i] = 1'b1 ` : alternate 1 io select
149
+
125
150
### Program Guide
126
151
These registers can be accessed by 4-byte aligned read and write. C-like pseudocode output operation:
127
152
``` c
128
- gpio.PADDIR[i] = (uint32_t )0 // set Ith gpio ouput mode
129
- gpio.PADOUT[i] = DATA_1_bit // set Ith gpio output data
153
+ // software control
154
+ gpio.IOCFG[i] = (uint32_t )0 // set to software control mode
155
+ gpio.PADDIR[i] = (uint32_t )0 // set Ith gpio ouput mode
156
+ gpio.PADOUT[i] = DATA_1_bit // set Ith gpio output data
157
+ // alternate io
158
+ gpio.IOCFG[i] = (uint32_t )1 // set to alternate io control mode
159
+ gpio.PINMUX[i] = (uint32_t )[0 , 1 ] // set the alter data io signals
160
+ ... // specific IP function config...
130
161
```
131
162
input operation:
132
163
``` c
133
- gpio.PADDIR[i] = (uint32_t )1 // set Ith gpio ouput mode
134
- gpio.INTEN[i] = (uint32_t )1 // enable Ith gpio irq
135
- gpio.INTTYPE0[i] = (uint32_t )0 // set Ith gpio rise edge trigger
136
- gpio.INTTYPE1[i] = (uint32_t )1 // set Ith gpio rise edge trigger
164
+ gpio.IOCFG = (uint32_t )0 // set to software control mode
165
+ gpio.PADDIR[i] = (uint32_t )1 // set Ith gpio ouput mode
166
+ gpio.INTEN[i] = (uint32_t )1 // enable Ith gpio irq
167
+ gpio.INTTYPE0[i] = (uint32_t )0 // set Ith gpio rise edge trigger
168
+ gpio.INTTYPE1[i] = (uint32_t )1 // set Ith gpio rise edge trigger
137
169
138
170
// polling mode
139
171
while (gpio.PADDIN[i] == 1 ) {}
140
172
141
173
// irq mode
142
174
...
143
175
gpio_handle (){
144
- irq_val = gpio.STAT // read and clear irq flag
176
+ irq_val = gpio.STAT // read and clear irq flag
145
177
}
146
178
```
147
179
complete driver and test codes in [ driver] ( ../driver/ ) dir.
0 commit comments