Difference between revisions of "Unit MCP230XX"
(One intermediate revision by the same user not shown) | |||
Line 5: | Line 5: | ||
---- | ---- | ||
− | '''Microchip MCP230XX I/O | + | '''Microchip MCP230XX I/O Expander Driver unit''' |
The Microchip MCP23008 and MCP23017 are 8 or 16 bit I/O expanders that provide GPIO pin control functions over an I2C connection. | The Microchip MCP23008 and MCP23017 are 8 or 16 bit I/O expanders that provide GPIO pin control functions over an I2C connection. | ||
Line 191: | Line 191: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! I2C |
| The I2C device this MCP23008 is connected to | | The I2C device this MCP23008 is connected to | ||
|- | |- | ||
− | ! | + | ! Address |
| The I2C address for this MCP23008 | | The I2C address for this MCP23008 | ||
|- | |- | ||
− | ! | + | ! Return |
| Pointer to the new GPIO device or nil on failure | | Pointer to the new GPIO device or nil on failure | ||
|- | |- | ||
Line 209: | Line 209: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! I2C |
| The I2C device this MCP23017 is connected to | | The I2C device this MCP23017 is connected to | ||
|- | |- | ||
− | ! | + | ! Address |
| The I2C address for this MCP23017 | | The I2C address for this MCP23017 | ||
|- | |- | ||
− | ! | + | ! Return |
| Pointer to the new GPIO device or nil on failure | | Pointer to the new GPIO device or nil on failure | ||
|- | |- | ||
Line 227: | Line 227: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! GPIO |
| The GPIO device to destroy | | The GPIO device to destroy | ||
|- | |- | ||
− | ! | + | ! Return |
| ERROR_SUCCESS if completed or another error code on failure | | ERROR_SUCCESS if completed or another error code on failure | ||
|- | |- | ||
Line 245: | Line 245: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
− | | Not intended to be called directly by applications, use GPIODeviceStart instead | + | | Not intended to be called directly by applications, use GPIODeviceStart instead. |
|- | |- | ||
|} | |} | ||
Line 257: | Line 257: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
− | | Not intended to be called directly by applications, use GPIODeviceStop instead | + | | Not intended to be called directly by applications, use GPIODeviceStop instead. |
|- | |- | ||
|} | |} | ||
Line 269: | Line 269: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
− | | Not intended to be called directly by applications, use GPIODeviceRead instead | + | | Not intended to be called directly by applications, use GPIODeviceRead instead. |
Will read only a single register byte | Will read only a single register byte | ||
|- | |- | ||
Line 282: | Line 282: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
− | | Not intended to be called directly by applications, use GPIODeviceWrite instead | + | | Not intended to be called directly by applications, use GPIODeviceWrite instead. |
Will write only a single register byte | Will write only a single register byte | ||
|- | |- | ||
Line 295: | Line 295: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
− | | Not intended to be called directly by applications, use GPIODeviceInputGet instead | + | | Not intended to be called directly by applications, use GPIODeviceInputGet instead. |
|- | |- | ||
|} | |} | ||
Line 307: | Line 307: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
− | | Not intended to be called directly by applications, use GPIODeviceOutputSet instead | + | | Not intended to be called directly by applications, use GPIODeviceOutputSet instead. |
|- | |- | ||
|} | |} | ||
Line 319: | Line 319: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
− | | Not intended to be called directly by applications, use GPIODevicePullGet instead | + | | Not intended to be called directly by applications, use GPIODevicePullGet instead. |
|- | |- | ||
|} | |} | ||
Line 331: | Line 331: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
− | | Not intended to be called directly by applications, use GPIODevicePullSelect instead | + | | Not intended to be called directly by applications, use GPIODevicePullSelect instead. |
|- | |- | ||
|} | |} | ||
Line 343: | Line 343: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
− | | Not intended to be called directly by applications, use GPIODeviceFunctionGet instead | + | | Not intended to be called directly by applications, use GPIODeviceFunctionGet instead. |
|- | |- | ||
|} | |} | ||
Line 355: | Line 355: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
− | | Not intended to be called directly by applications, use GPIODeviceFunctionSelect instead | + | | Not intended to be called directly by applications, use GPIODeviceFunctionSelect instead. |
|- | |- | ||
|} | |} |
Latest revision as of 05:44, 31 August 2021
Return to Unit Reference
Contents
[hide]Description
Microchip MCP230XX I/O Expander Driver unit
The Microchip MCP23008 and MCP23017 are 8 or 16 bit I/O expanders that provide GPIO pin control functions over an I2C connection.
The device can be represented in Ultibo as a standard GPIO device which is accessible via the GPIO unit functions. Because the MCP230XX is a chip that can be used and configured in multiple different scenarios this unit does not autocreate a GPIO device, instead you need to call the function MCP23008GPIOCreate or MCP23017GPIOCreate and pass an I2C device and address. The functions will create and return a GPIO device with the appropriate number of pins and other information for the specified chip, the returned devices will have been registered with the GPIO device unit and started ready for use.
Both devices also come in an SPI interface version, these are not currently supported by this unit.
Note: This unit does not currently implement the interrupt capabilities of the MCP230XX chips however it could be expanded to allow the interrupt pin to be connected to a GPIO pin on the SoC and use a trigger event from that to enable GPIOInputWait/GPIOInputEvent functions for the MCP230XX chips.
Constants
MCP23008_*
MCP230XX_CHIP_*
MCP230XX_I2C_*
Type definitions
MCP230XX GPIO types
Public variables
None defined
Function declarations
MCP230XX functions
function MCP23008GPIOCreate(I2C:PI2CDevice; Address:Word):PGPIODevice;
function MCP23017GPIOCreate(I2C:PI2CDevice; Address:Word):PGPIODevice;
function MCP230XXGPIODestroy(GPIO:PGPIODevice):LongWord;
MCP230XX GPIO functions
function MCP230XXGPIOStart(GPIO:PGPIODevice):LongWord;
function MCP230XXGPIOStop(GPIO:PGPIODevice):LongWord;
function MCP230XXGPIORead(GPIO:PGPIODevice; Reg:LongWord):LongWord;
procedure MCP230XXGPIOWrite(GPIO:PGPIODevice; Reg,Value:LongWord);
function MCP230XXGPIOInputGet(GPIO:PGPIODevice; Pin:LongWord):LongWord;
function MCP230XXGPIOOutputSet(GPIO:PGPIODevice; Pin,Level:LongWord):LongWord;
function MCP230XXGPIOPullGet(GPIO:PGPIODevice; Pin:LongWord):LongWord;
function MCP230XXGPIOPullSelect(GPIO:PGPIODevice; Pin,Mode:LongWord):LongWord;
function MCP230XXGPIOFunctionGet(GPIO:PGPIODevice; Pin:LongWord):LongWord;
function MCP230XXGPIOFunctionSelect(GPIO:PGPIODevice; Pin,Mode:LongWord):LongWord;
Return to Unit Reference