Difference between revisions of "Unit PCF857X"
Line 95: | Line 95: | ||
---- | ---- | ||
− | '' | + | |
+ | '''PCF857X GPIO''' | ||
+ | |||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;"> | ||
+ | <code>PPCF857XGPIO = ^TPCF857XGPIO;</code> | ||
+ | |||
+ | <code>TPCF857XGPIO = record</code> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | |colspan="2"|''GPIO Properties'' | ||
+ | |- | ||
+ | | <code>GPIO:TGPIODevice;</code> | ||
+ | | style="width: 50%;"| | ||
+ | |- | ||
+ | |colspan="2"|''PCF857X Properties'' | ||
+ | |- | ||
+ | | <code>I2C:PI2CDevice;</code> | ||
+ | | The I2C device this GPIO is connected to | ||
+ | |- | ||
+ | | <code>Address:Word;</code> | ||
+ | | The I2C address of the device | ||
+ | |- | ||
+ | | <code>Chip:LongWord;</code> | ||
+ | | The chip type (eg PCF857X_CHIP_PCF8574) | ||
+ | |- | ||
+ | | <code>Size:LongWord;</code> | ||
+ | | Size of an I2C read/write for the device | ||
+ | |- | ||
+ | | <code>Rate:LongWord;</code> | ||
+ | | Clock rate for this device | ||
+ | |- | ||
+ | | <code>GPIOValues:array[0..PCF857X_I2C_MAX_SIZE - 1] of Byte;</code> | ||
+ | | Buffer for GPIO port values (Output only) | ||
+ | |- | ||
+ | | <code>GPPUValues:array[0..PCF857X_I2C_MAX_SIZE - 1] of Byte;</code> | ||
+ | | Buffer for GPPU pull up values | ||
+ | |- | ||
+ | | <code>IODIRValues:array[0..PCF857X_I2C_MAX_SIZE - 1] of Byte;</code> | ||
+ | | Buffer for IODIR I/O direction values | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
=== Public variables === | === Public variables === |
Revision as of 06:25, 21 July 2021
Return to Unit Reference
Contents
[hide]Description
NXP PCF857X I/O expander Driver
The NXP PCF8574 is an 8 bit I/O expander that provides 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 PCF857X 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 PCF8574GPIOCreate and pass an I2C device and address. The function 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.
Note: This unit does not currently implement the interrupt capabilities of the PCF857X 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 PCF857X chips.
Constants
PCF8574_GPIO_*
PCF857X_CHIP_*
PCF8574_I2C_*
Type definitions
PCF857X GPIO
Public variables
None defined
Function declarations
PCF857X functions
function PCF8574GPIOCreate(I2C:PI2CDevice; Address:Word):PGPIODevice;
function PCF857XGPIODestroy(GPIO:PGPIODevice):LongWord;
PCF857X GPIO functions
function PCF857XGPIOStart(GPIO:PGPIODevice):LongWord;
function PCF857XGPIOStop(GPIO:PGPIODevice):LongWord;
function PCF857XGPIORead(GPIO:PGPIODevice; Reg:LongWord):LongWord;
procedure PCF857XGPIOWrite(GPIO:PGPIODevice; Reg,Value:LongWord);
function PCF857XGPIOInputGet(GPIO:PGPIODevice; Pin:LongWord):LongWord;
function PCF857XGPIOOutputSet(GPIO:PGPIODevice; Pin,Level:LongWord):LongWord;
function PCF857XGPIOPullGet(GPIO:PGPIODevice; Pin:LongWord):LongWord;
function PCF857XGPIOFunctionGet(GPIO:PGPIODevice; Pin:LongWord):LongWord;
function PCF857XGPIOFunctionSelect(GPIO:PGPIODevice; Pin,Mode:LongWord):LongWord;
Return to Unit Reference