Difference between revisions of "Unit GPIO"
Line 43: | Line 43: | ||
|- | |- | ||
! '''Note''' | ! '''Note''' | ||
− | | | + | | None documented |
|- | |- | ||
|} | |} | ||
Line 58: | Line 58: | ||
|- | |- | ||
! '''Note''' | ! '''Note''' | ||
− | | | + | | None documented |
|- | |- | ||
|} | |} | ||
Line 70: | Line 70: | ||
|- | |- | ||
! '''Note''' | ! '''Note''' | ||
− | | | + | | None documented |
|- | |- | ||
|} | |} | ||
Line 82: | Line 82: | ||
|- | |- | ||
! '''Note''' | ! '''Note''' | ||
− | | | + | | None documented |
|- | |- | ||
|} | |} | ||
Line 94: | Line 94: | ||
|- | |- | ||
! '''Note''' | ! '''Note''' | ||
− | | | + | | None documented |
|- | |- | ||
|} | |} | ||
Line 106: | Line 106: | ||
|- | |- | ||
! '''Note''' | ! '''Note''' | ||
− | | | + | | None documented |
|- | |- | ||
|} | |} | ||
Line 118: | Line 118: | ||
|- | |- | ||
! '''Note''' | ! '''Note''' | ||
− | | | + | | None documented |
|- | |- | ||
|} | |} | ||
Line 130: | Line 130: | ||
|- | |- | ||
! '''Note''' | ! '''Note''' | ||
− | | | + | | None documented |
|- | |- | ||
|} | |} | ||
Line 142: | Line 142: | ||
|- | |- | ||
! '''Note''' | ! '''Note''' | ||
− | | | + | | None documented |
|- | |- | ||
|} | |} | ||
Line 154: | Line 154: | ||
|- | |- | ||
! '''Note''' | ! '''Note''' | ||
− | | | + | | None documented |
|- | |- | ||
|} | |} | ||
Line 166: | Line 166: | ||
|- | |- | ||
! '''Note''' | ! '''Note''' | ||
− | | | + | | None documented |
|- | |- | ||
|} | |} | ||
Line 178: | Line 178: | ||
|- | |- | ||
! '''Note''' | ! '''Note''' | ||
− | | | + | | None documented |
|- | |- | ||
|} | |} | ||
Line 190: | Line 190: | ||
|- | |- | ||
! '''Note''' | ! '''Note''' | ||
− | | | + | | None documented |
|- | |- | ||
|} | |} | ||
Line 202: | Line 202: | ||
|- | |- | ||
! '''Note''' | ! '''Note''' | ||
− | | | + | | None documented |
|- | |- | ||
|} | |} | ||
Line 214: | Line 214: | ||
|- | |- | ||
! '''Note''' | ! '''Note''' | ||
− | | | + | | None documented |
|- | |- | ||
|} | |} | ||
Line 253: | Line 253: | ||
|- | |- | ||
! '''Note''' | ! '''Note''' | ||
− | | | + | | None documented |
|- | |- | ||
|} | |} | ||
Line 265: | Line 265: | ||
|- | |- | ||
! '''Note''' | ! '''Note''' | ||
− | | | + | | None documented |
|- | |- | ||
|} | |} | ||
Line 277: | Line 277: | ||
|- | |- | ||
! '''Note''' | ! '''Note''' | ||
− | | | + | | None documented |
|- | |- | ||
|} | |} | ||
Line 289: | Line 289: | ||
|- | |- | ||
! '''Note''' | ! '''Note''' | ||
− | | | + | | None documented |
|- | |- | ||
|} | |} | ||
Line 301: | Line 301: | ||
|- | |- | ||
! '''Note''' | ! '''Note''' | ||
− | | | + | | None documented |
|- | |- | ||
|} | |} | ||
Line 313: | Line 313: | ||
|- | |- | ||
! '''Note''' | ! '''Note''' | ||
− | | | + | | None documented |
|- | |- | ||
|} | |} | ||
Line 325: | Line 325: | ||
|- | |- | ||
! '''Note''' | ! '''Note''' | ||
− | | | + | | None documented |
|- | |- | ||
|} | |} | ||
Line 337: | Line 337: | ||
|- | |- | ||
! '''Note''' | ! '''Note''' | ||
− | | | + | | None documented |
|- | |- | ||
|} | |} | ||
Line 352: | Line 352: | ||
|- | |- | ||
! '''Note''' | ! '''Note''' | ||
− | | | + | | None documented |
|- | |- | ||
|} | |} | ||
Line 517: | Line 517: | ||
|- | |- | ||
! '''Note''' | ! '''Note''' | ||
− | | | + | | None documented |
|- | |- | ||
|} | |} | ||
Line 529: | Line 529: | ||
|- | |- | ||
! '''Note''' | ! '''Note''' | ||
− | | | + | | None documented |
|- | |- | ||
|} | |} | ||
Line 541: | Line 541: | ||
|- | |- | ||
! '''Note''' | ! '''Note''' | ||
− | | | + | | None documented |
|- | |- | ||
|} | |} | ||
Line 553: | Line 553: | ||
|- | |- | ||
! '''Note''' | ! '''Note''' | ||
− | | | + | | None documented |
|- | |- | ||
|} | |} | ||
Line 613: | Line 613: | ||
|- | |- | ||
! '''Note''' | ! '''Note''' | ||
− | | | + | | None documented |
|- | |- | ||
|} | |} | ||
Line 625: | Line 625: | ||
|- | |- | ||
! '''Note''' | ! '''Note''' | ||
− | | | + | | None documented |
|- | |- | ||
|} | |} | ||
Line 637: | Line 637: | ||
|- | |- | ||
! '''Note''' | ! '''Note''' | ||
− | | | + | | None documented |
|- | |- | ||
|} | |} | ||
Line 649: | Line 649: | ||
|- | |- | ||
! '''Note''' | ! '''Note''' | ||
− | | | + | | None documented |
|- | |- | ||
|} | |} | ||
Line 661: | Line 661: | ||
|- | |- | ||
! '''Note''' | ! '''Note''' | ||
− | | | + | | None documented |
|- | |- | ||
|} | |} | ||
Line 673: | Line 673: | ||
|- | |- | ||
! '''Note''' | ! '''Note''' | ||
− | | | + | | None documented |
|- | |- | ||
|} | |} | ||
Line 685: | Line 685: | ||
|- | |- | ||
! '''Note''' | ! '''Note''' | ||
− | | | + | | None documented |
|- | |- | ||
|} | |} | ||
Line 697: | Line 697: | ||
|- | |- | ||
! '''Note''' | ! '''Note''' | ||
− | | | + | | None documented |
|- | |- | ||
|} | |} | ||
Line 709: | Line 709: | ||
|- | |- | ||
! '''Note''' | ! '''Note''' | ||
− | | | + | | None documented |
|- | |- | ||
|} | |} |
Revision as of 05:29, 27 September 2016
Return to Unit Reference
Description
GPIO devices represent the external or internal pins available on most system on chip (SoC) devices to provide control and interfacing capabilities for both hardware and software.
This unit maintains pin numbering exactly as per the SoC documentation but abstracts other features such as alternate function selects to avoid exposing chip specific values via the API.
Not all GPIO devices support the same feature set so the GPIODeviceProperties function returns a structure which describes the number of pins as well as minimum and maximum pin numbers along with a set of flags that indicate what functionality is supported by the device.
Multiple GPIO devices can be accomodated, each one is registered with this unit when the driver for the device is loaded and initialized. This unit includes functions for enumerating the devices that are available and each function takes a GPIODevice parameter to allow specifying the exact device to control.
Simplified versions of many of the functions in this unit are provided in the Platform unit to allow control of the default GPIO device and in cases where there is only one device registered these functions will provide most of the capability required.
Constants
To be documented
Type definitions
To be documented
Public variables
To be documented
Function declarations
Initialization functions
procedure GPIOInit;
Note | None documented |
---|
GPIO functions
function GPIODeviceStart(GPIO:PGPIODevice):LongWord;
Note | None documented |
---|
function GPIODeviceStop(GPIO:PGPIODevice):LongWord;
Note | None documented |
---|
function GPIODeviceRead(GPIO:PGPIODevice; Reg:LongWord):LongWord;
Note | None documented |
---|
procedure GPIODeviceWrite(GPIO:PGPIODevice; Reg,Value:LongWord);
Note | None documented |
---|
function GPIODeviceInputGet(GPIO:PGPIODevice; Pin:LongWord):LongWord;
Note | None documented |
---|
function GPIODeviceInputWait(GPIO:PGPIODevice; Pin,Trigger,Timeout:LongWord):LongWord;
Note | None documented |
---|
function GPIODeviceInputEvent(GPIO:PGPIODevice; Pin,Trigger,Flags,Timeout:LongWord; Callback:TGPIOCallback; Data:Pointer):LongWord;
Note | None documented |
---|
function GPIODeviceInputCancel(GPIO:PGPIODevice; Pin:LongWord):LongWord;
Note | None documented |
---|
function GPIODeviceOutputSet(GPIO:PGPIODevice; Pin,Level:LongWord):LongWord;
Note | None documented |
---|
function GPIODevicePullGet(GPIO:PGPIODevice;Pin:LongWord):LongWord;
Note | None documented |
---|
function GPIODevicePullSelect(GPIO:PGPIODevice; Pin,Mode:LongWord):LongWord;
Note | None documented |
---|
function GPIODeviceFunctionGet(GPIO:PGPIODevice; Pin:LongWord):LongWord;
Note | None documented |
---|
function GPIODeviceFunctionSelect(GPIO:PGPIODevice; Pin,Mode:LongWord):LongWord;
Note | None documented |
---|
function GPIODeviceProperties(GPIO:PGPIODevice; Properties:PGPIOProperties):LongWord;
Note | None documented |
---|
function GPIODeviceCreate:PGPIODevice;
Return | Pointer to new GPIO entry or nil if GPIO could not be created |
---|
function GPIODeviceCreateEx(Size:LongWord):PGPIODevice;
Size | Size in bytes to allocate for new GPIO (Including the GPIO entry) |
---|---|
Return | Pointer to new GPIO entry or nil if GPIO could not be created |
function GPIODeviceDestroy(GPIO:PGPIODevice):LongWord;
Note | None documented |
---|
function GPIODeviceRegister(GPIO:PGPIODevice):LongWord;
Note | None documented |
---|
function GPIODeviceDeregister(GPIO:PGPIODevice):LongWord;
Note | None documented |
---|
function GPIODeviceFind(GPIOId:LongWord):PGPIODevice;
Note | None documented |
---|
function GPIODeviceFindByName(const Name:String):PGPIODevice; inline;
Note | None documented |
---|
function GPIODeviceFindByDescription(const Description:String):PGPIODevice; inline;
Note | None documented |
---|
function GPIODeviceEnumerate(Callback:TGPIOEnumerate; Data:Pointer):LongWord;
Note | None documented |
---|
function GPIODeviceNotification(GPIO:PGPIODevice; Callback:TGPIONotification; Data:Pointer; Notification,Flags:LongWord):LongWord;
Note | None documented |
---|
RTL GPIO functions
function SysGPIOAvailable:Boolean;
Note | None documented |
---|
function SysGPIOInputGet(Pin:LongWord):LongWord;
Pin | The pin to get the state for (eg GPIO_PIN_1) |
---|---|
Return | The current state (eg GPIO_LEVEL_HIGH) or GPIO_LEVEL_UNKNOWN on failure |
function SysGPIOInputWait(Pin,Trigger,Timeout:LongWord):LongWord;
Pin | The pin to wait for the state to change (eg GPIO_PIN_1) |
---|---|
Trigger | The trigger event to wait for (eg GPIO_TRIGGER_HIGH) |
Timeout | Number of milliseconds to wait for the change (INFINITE to wait forever) |
Return | The state after the change (eg GPIO_LEVEL_HIGH) or GPIO_LEVEL_UNKNOWN on failure or timeout |
function SysGPIOInputEvent(Pin,Trigger,Timeout:LongWord; Callback:TGPIOCallback; Data:Pointer):LongWord;
Pin | The pin to schedule the state change for (eg GPIO_PIN_1) |
---|---|
Trigger | The trigger event which will cause the function to be called (eg GPIO_TRIGGER_HIGH) |
Timeout | The number of milliseconds before the scheduled trigger expires (INFINITE to never expire) |
Callback | The function to be called when the trigger occurs |
Data | A pointer to be pass to the function when the trigger occurs (Optional) |
Return | ERROR_SUCCESS if the trigger was scheduled successfully or another error code on failure |
Note | The pin and trigger that caused the event will be passed to the callback function |
function SysGPIOOutputSet(Pin,Level:LongWord):LongWord;
Pin | The pin to set the state for (eg GPIO_PIN_1) |
---|---|
Level | The state to set the pin to (eg GPIO_LEVEL_HIGH) |
Return | ERROR_SUCCESS if completed successfully or another error code on failure |
function SysGPIOPullGet(Pin:LongWord):LongWord;
Pin | The pin to get the pull state for (eg GPIO_PIN_1) |
---|---|
Return | The current pull state of the pin (eg GPIO_PULL_UP) or GPIO_PULL_UNKNOWN on failure |
function SysGPIOPullSelect(Pin,Mode:LongWord):LongWord;
Pin | The pin to change the pull state for (eg GPIO_PIN_1) |
---|---|
Mode | The pull state to set for the pin (eg GPIO_PULL_UP) |
Return | ERROR_SUCCESS if completed successfully or another error code on failure |
function SysGPIOFunctionGet(Pin:LongWord):LongWord;
Pin | The pin to get the function for (eg GPIO_PIN_1) |
---|---|
Return | The current function of the pin (eg GPIO_FUNCTION_IN) or GPIO_FUNCTION_UNKNOWN on failure |
function SysGPIOFunctionSelect(Pin,Mode:LongWord):LongWord;
Pin | The pin to change the function for (eg GPIO_PIN_1) |
---|---|
Mode | The function to set for the pin (eg GPIO_FUNCTION_OUT) |
Return | ERROR_SUCCESS if completed successfully or another error code on failure |
GPIO helper functions
function GPIOGetCount:LongWord; inline;
Note | None documented |
---|
function GPIODeviceGetDefault:PGPIODevice; inline;
Note | None documented |
---|
function GPIODeviceSetDefault(GPIO:PGPIODevice):LongWord;
Note | None documented |
---|
function GPIODeviceCheck(GPIO:PGPIODevice):PGPIODevice;
Note | None documented |
---|
function GPIODeviceCreateEvent(GPIO:PGPIODevice; Pin:PGPIOPin; Callback:TGPIOCallback; Data:Pointer; Timeout:LongWord):PGPIOEvent;
Note | Event must be registered by calling GPIODeviceRegisterEvent. Caller must hold the GPIO device lock. |
---|
function GPIODeviceDestroyEvent(GPIO:PGPIODevice; Event:PGPIOEvent):LongWord;
Note | Event must be deregistered first by calling GPIODeviceDeregisterEvent. Caller must hold the GPIO device lock. |
---|
function GPIODeviceRegisterEvent(GPIO:PGPIODevice; Pin:PGPIOPin; Event:PGPIOEvent):LongWord;
Note | Event must be created by calling GPIODeviceCreateEvent. Caller must hold the GPIO device lock. |
---|
function GPIODeviceDeregisterEvent(GPIO:PGPIODevice;Pin:PGPIOPin;Event:PGPIOEvent):LongWord;
Note | Event must be destroyed by calling GPIODeviceDestroyEvent. Caller must hold the GPIO device lock. |
---|
procedure GPIOLog(Level:LongWord; GPIO:PGPIODevice; const AText:String);
Note | None documented |
---|
procedure GPIOLogInfo(GPIO:PGPIODevice; const AText:String);
Note | None documented |
---|
procedure GPIOLogError(GPIO:PGPIODevice; const AText:String);
Note | None documented |
---|
procedure GPIOLogDebug(GPIO:PGPIODevice; const AText:String);
Note | None documented |
---|
function GPIOPinToString(Pin:LongWord):String;
Note | None documented |
---|
function GPIOLevelToString(Level:LongWord):String;
Note | None documented |
---|
function GPIOTriggerToString(Trigger:LongWord):String;
Note | None documented |
---|
function GPIOPullToString(Value:LongWord):String;
Note | None documented |
---|
function GPIOFunctionToString(Value:LongWord):String;
Note | None documented |
---|
Return to Unit Reference