Difference between revisions of "Unit MCP230XX"

From Ultibo.org
Jump to: navigation, search
 
(One intermediate revision by the same user not shown)
Line 5: Line 5:
 
----
 
----
  
'''Microchip MCP230XX I/O expander Driver unit'''
+
'''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'''
+
! I2C
 
| The I2C device this MCP23008 is connected to
 
| The I2C device this MCP23008 is connected to
 
|-
 
|-
! '''Address'''
+
! Address
 
| The I2C address for this MCP23008
 
| The I2C address for this MCP23008
 
|-
 
|-
! '''Return'''
+
! 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'''
+
! I2C
 
| The I2C device this MCP23017 is connected to
 
| The I2C device this MCP23017 is connected to
 
|-
 
|-
! '''Address'''
+
! Address
 
| The I2C address for this MCP23017
 
| The I2C address for this MCP23017
 
|-
 
|-
! '''Return'''
+
! 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'''
+
! GPIO
 
| The GPIO device to destroy
 
| The GPIO device to destroy
 
|-
 
|-
! '''Return'''
+
! 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'''
+
! 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'''
+
! 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'''
+
! 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'''
+
! 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'''
+
! 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'''
+
! 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'''
+
! 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'''
+
! 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'''
+
! 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'''
+
! 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


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



[Expand]
MCP230XX specific constants MCP23008_*


[Expand]
MCP230XX chip MCP230XX_CHIP_*


[Expand]
MCP230XX I2C MCP230XX_I2C_*


Type definitions



MCP230XX GPIO types

[Expand]

PMCP230XXGPIO = ^TMCP230XXGPIO;

TMCP230XXGPIO = record


Public variables


None defined

Function declarations



MCP230XX functions

[Expand]
function MCP23008GPIOCreate(I2C:PI2CDevice; Address:Word):PGPIODevice;
Description: Create, register and start a new MCP23008 GPIO device connected to the specified I2C device


[Expand]
function MCP23017GPIOCreate(I2C:PI2CDevice; Address:Word):PGPIODevice;
Description: Create, register and start a new MCP23017 GPIO device connected to the specified I2C device


[Expand]
function MCP230XXGPIODestroy(GPIO:PGPIODevice):LongWord;
Description: Stop, deregister and destroy an MCP230XX GPIO device created by this driver


MCP230XX GPIO functions

[Expand]
function MCP230XXGPIOStart(GPIO:PGPIODevice):LongWord;
Description: Implementation of GPIODeviceStart API for MCP230XX


[Expand]
function MCP230XXGPIOStop(GPIO:PGPIODevice):LongWord; 
Description: Implementation of GPIODeviceStop API for MCP230XX


[Expand]
function MCP230XXGPIORead(GPIO:PGPIODevice; Reg:LongWord):LongWord;
Description: Implementation of GPIODeviceRead API for MCP230XX


[Expand]
procedure MCP230XXGPIOWrite(GPIO:PGPIODevice; Reg,Value:LongWord);
Description: Implementation of GPIODeviceWrite API for MCP230XX


[Expand]
function MCP230XXGPIOInputGet(GPIO:PGPIODevice; Pin:LongWord):LongWord;
Description: Implementation of GPIODeviceInputGet API for MCP230XX


[Expand]
function MCP230XXGPIOOutputSet(GPIO:PGPIODevice; Pin,Level:LongWord):LongWord;
Description: Implementation of GPIODeviceOutputSet API for MCP230XX


[Expand]
function MCP230XXGPIOPullGet(GPIO:PGPIODevice; Pin:LongWord):LongWord;
Description: Implementation of GPIODevicePullGet API for MCP230XX


[Expand]
function MCP230XXGPIOPullSelect(GPIO:PGPIODevice; Pin,Mode:LongWord):LongWord;
Description: Implementation of GPIODevicePullSelect API for MCP230XX


[Expand]
function MCP230XXGPIOFunctionGet(GPIO:PGPIODevice; Pin:LongWord):LongWord;
Description: Implementation of GPIODeviceFunctionGet API for MCP230XX


[Expand]
function MCP230XXGPIOFunctionSelect(GPIO:PGPIODevice; Pin,Mode:LongWord):LongWord;
Description: Implementation of GPIODeviceFunctionSelect API for MCP230XX


Return to Unit Reference