Skip to content

Commit c6e4b86

Browse files
committed
docs: add iocfg and pinmux use guide
1 parent 541b7a0 commit c6e4b86

File tree

2 files changed

+42
-10
lines changed

2 files changed

+42
-10
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## Features
44
* 1~32 channels support
55
* Input and output direction control
6-
* Pin multiplexer with one alternate ouput function
6+
* Pin multiplexer with two alternate ouput function
77
* Three configurable modes
88
* input pull-down with schmitt trigger
99
* ouput push-pull

doc/datasheet.md

Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ The `gpio(general purpose input/output)` IP is a fully parameterised soft IP rec
66
### Feature
77
* 1~32 channels support
88
* Input and output direction control
9-
* Pin multiplexer with one alternate ouput function
9+
* Pin multiplexer with two alternate ouput function
1010
* Three configurable modes
1111
* input pull-down with schmitt trigger
1212
* ouput push-pull
@@ -41,7 +41,8 @@ The `gpio(general purpose input/output)` IP is a fully parameterised soft IP rec
4141
| [INTTYPE0](#interrupt-type0-register) | 0x10 | 4 | interrupt type0 register |
4242
| [INTTYPE1](#interrupt-type1-register) | 0x14 | 4 | interrupt type1 register |
4343
| [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 |
4546

4647
#### PAD Direction Register
4748
| bit | access | description |
@@ -122,26 +123,57 @@ reset value: `0x0000_0000`
122123

123124
* INTSTAT: interrupt state
124125

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+
125150
### Program Guide
126151
These registers can be accessed by 4-byte aligned read and write. C-like pseudocode output operation:
127152
```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...
130161
```
131162
input operation:
132163
```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
137169

138170
// polling mode
139171
while(gpio.PADDIN[i] == 1) {}
140172

141173
// irq mode
142174
...
143175
gpio_handle(){
144-
irq_val = gpio.STAT // read and clear irq flag
176+
irq_val = gpio.STAT // read and clear irq flag
145177
}
146178
```
147179
complete driver and test codes in [driver](../driver/) dir.

0 commit comments

Comments
 (0)