7.1.5 GPIO Controlling Procedure
This section describes the typical command sequence for using the MCP2222 GPIO functions.
Configure GPIO
Configuring an I/O pin as a normal output pin:
- Send the IO_SetConfiguration command through Endpoint 0x04 (OUT), with the following parameters:
| Parameter | Value | Description |
|---|---|---|
| Command | 0x60 | Configure I/O pin |
| I/O number | 0x00
...
| IO0 IO1 IO2 ... IO5 |
| I/O setting | 0x00 | Refer to the corresponding I/O Setting register for the setting value. |
- Read the response from Endpoint 0x84
(IN). The response can be one of the following:
Response Code Status Action 0x60Response to the I/O Set Configuration Continue reading 0x200x600x64The I/O pin is configured Invalid parameters.
Device configuration is locked.
Retry with valid parameters.
Unlock the device configuration and retry.
Configuring an I/O pin as an open-drain output pin:
- Send the IO_SetConfiguration command
through Endpoint 0x04 (OUT), with the following parameters:
Parameter Value Description Command 0x60Configure I/O pin I/O number 0x000x100x20...
0x50IO0 IO1
IO2
...
IO5
I/O setting 0x10Refer to the corresponding I/O setting register for the setting value - Read the response from Endpoint 0x84
(IN). The response can be one of the following:
Response Code Status Action 0x60Response to the I/O Set Configuration Continue reading 0x200x600x64I/O is configured. Invalid parameters.
Device configuration is locked.
Retry with valid parameters.
Unlock the device configuration and retry.
Configuring an I/O pin as a normal input pin:
- Send the IO_SetConfiguration command
through Endpoint 0x04 (OUT), with the following parameters:
Parameter Value Description Command 0x60Configure I/O pin I/O number 0x000x100x20...
0x50IO0 IO1
IO2
...
IO5
I/O setting 0x04Refer to the corresponding I/O setting register for the setting value - Read the response from Endpoint 0x84
(IN). The responses can be one of the following:
Response Code Status Action 0x60Response to the I/O Set Configuration Continue reading 0x200x600x64I/O is configured. Invalid parameters.
Device configuration is locked.
Retry with valid parameters.
Unlock the device configuration and retry.
Configuring an I/O pin as an internally pulled-up input pin
- Send the IO_SetConfiguration command
through Endpoint 0x04 (OUT), with the following parameters:
Parameter Value Description Command 0x60Configure I/O pin I/O number 0x000x100x20...
0x50IO0 IO1
IO2
...
IO5
I/O setting 0x0CRefer to the corresponding IO setting register for the setting value - Read the response from Endpoint 0x84
(IN). The response can be one of the following:
Response code Status Action 0x60Response to the I/O set configuration Continue reading 0x200x600x64The I/O is configured. Invalid parameters.
Device configuration is locked.
Retry with valid parameters.
Unlock the device configuration and retry.
Controlling a GPIO:
Setting or clearing an output pin:
- Send the GPIO_Write command through
Endpoint 0x04, OUT, with the following parameters:
Parameter Value Description Command 0x64Configure I/O pin I/O number and output state 0x000x010x100x11...
0x500x51IO0 Low IO0 High
IO1 Low
IO1 High
...
IO5 Low
IO5 High
- Read the response from Endpoint 0x84
(IN). The response can be one of the following:
Response Code Status Action 0x64Response to the I/O Set Configuration Continue reading 0x200x600x68The I/O is written. Invalid parameters.
Pin is not configured as a GPIO output.
Retry with valid parameters.
Reconfigure and retry.
Reading an input pin:
- Send the GPIO_Read command through
Endpoint 0x04 (OUT), with the following parameters:
Parameter Value Description Command 0x68Configure I/O pin The I/O number 0x000x10...
0x50IO0 IO1
...
IO5
- Read the response from Endpoint 0x84
(IN). The response can be one of the following:
Response Code Status Action 0x68Response to the I/O set configuration Continue reading 0x210x600x68The I/O is read. Invalid parameters.
The pin is not configures as a GPIO pin.
Retry with valid parameters.
Reconfigure and retry.
0x000x01The GPIO pin is at a logical LOW level.
GPIO pin is logical high.
Logical state of the pin
