Difference between revisions of "Unit GPIO"

From Ultibo.org
Jump to: navigation, search
Line 338: Line 338:
 
! '''Note'''
 
! '''Note'''
 
| To be documented
 
| To be documented
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
 +
'''RTL GPIO functions'''
 +
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 +
<pre style="border: 0; padding-bottom:0px;">function SysGPIOInputGet(Pin:LongWord):LongWord;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Get the current state of a GPIO input pin</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! '''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
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 +
<pre style="border: 0; padding-bottom:0px;">function SysGPIOInputWait(Pin,Trigger,Timeout:LongWord):LongWord;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Wait for the state of a GPIO input pin to change</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! '''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
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 +
<pre style="border: 0; padding-bottom:0px;">function SysGPIOInputEvent(Pin,Trigger,Timeout:LongWord; Callback:TGPIOCallback; Data:Pointer):LongWord;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Schedule a function to be called when the state of a GPIO input pin changes</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! '''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
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 +
<pre style="border: 0; padding-bottom:0px;">function SysGPIOOutputSet(Pin,Level:LongWord):LongWord; </pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Set the state of a GPIO output pin</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! '''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
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 +
<pre style="border: 0; padding-bottom:0px;">function SysGPIOPullGet(Pin:LongWord):LongWord;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Get the current pull state of a GPIO pin</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! '''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
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 +
<pre style="border: 0; padding-bottom:0px;">function SysGPIOPullSelect(Pin,Mode:LongWord):LongWord;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Change the pull state of a GPIO pin</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! '''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
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 +
<pre style="border: 0; padding-bottom:0px;">function SysGPIOFunctionGet(Pin:LongWord):LongWord;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Get the current function of a GPIO pin</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! '''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
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 +
<pre style="border: 0; padding-bottom:0px;">function SysGPIOFunctionSelect(Pin,Mode:LongWord):LongWord;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Change the function of a GPIO pin</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! '''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
 
|-
 
|-
 
|}
 
|}

Revision as of 06:42, 28 July 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

[Expand]
procedure GPIOInit;
Description: To be documented


GPIO functions

[Expand]
function GPIODeviceStart(GPIO:PGPIODevice):LongWord;
Description: To be documented


[Expand]
function GPIODeviceStop(GPIO:PGPIODevice):LongWord;
Description: To be documented


[Expand]
function GPIODeviceRead(GPIO:PGPIODevice; Reg:LongWord):LongWord;
Description: To be documented


[Expand]
procedure GPIODeviceWrite(GPIO:PGPIODevice; Reg,Value:LongWord);
Description: To be documented


[Expand]
function GPIODeviceInputGet(GPIO:PGPIODevice; Pin:LongWord):LongWord;
Description: To be documented


[Expand]
function GPIODeviceInputWait(GPIO:PGPIODevice; Pin,Trigger,Timeout:LongWord):LongWord;
Description: To be documented


[Expand]
function GPIODeviceInputEvent(GPIO:PGPIODevice; Pin,Trigger,Flags,Timeout:LongWord; Callback:TGPIOCallback; Data:Pointer):LongWord;
Description: To be documented


[Expand]
function GPIODeviceInputCancel(GPIO:PGPIODevice; Pin:LongWord):LongWord;
Description: To be documented


[Expand]
function GPIODeviceOutputSet(GPIO:PGPIODevice; Pin,Level:LongWord):LongWord;
Description: To be documented


[Expand]
function GPIODevicePullGet(GPIO:PGPIODevice;Pin:LongWord):LongWord;
Description: To be documented


[Expand]
function GPIODevicePullSelect(GPIO:PGPIODevice; Pin,Mode:LongWord):LongWord;
Description: To be documented


[Expand]
function GPIODeviceFunctionGet(GPIO:PGPIODevice; Pin:LongWord):LongWord;
Description: To be documented


[Expand]
function GPIODeviceFunctionSelect(GPIO:PGPIODevice; Pin,Mode:LongWord):LongWord;
Description: To be documented


[Expand]
function GPIODeviceProperties(GPIO:PGPIODevice; Properties:PGPIOProperties):LongWord;
Description: To be documented


[Expand]
function GPIODeviceCreate:PGPIODevice;
Description: Create a new GPIO entry


[Expand]
function GPIODeviceCreateEx(Size:LongWord):PGPIODevice;
Description: Create a new GPIO entry


[Expand]
function GPIODeviceDestroy(GPIO:PGPIODevice):LongWord;
Description: Destroy an existing GPIO entry


[Expand]
function GPIODeviceRegister(GPIO:PGPIODevice):LongWord;
Description: Register a new GPIO in the GPIO table


[Expand]
function GPIODeviceDeregister(GPIO:PGPIODevice):LongWord;
Description: Deregister a GPIO in the GPIO table


[Expand]
function GPIODeviceFind(GPIOId:LongWord):PGPIODevice;
Description: To be documented


[Expand]
function GPIODeviceFindByName(const Name:String):PGPIODevice; inline;
Description: To be documented


[Expand]
function GPIODeviceFindByDescription(const Description:String):PGPIODevice; inline;
Description: To be documented


[Expand]
function GPIODeviceEnumerate(Callback:TGPIOEnumerate; Data:Pointer):LongWord;
Description: To be documented


[Expand]
function GPIODeviceNotification(GPIO:PGPIODevice; Callback:TGPIONotification; Data:Pointer; Notification,Flags:LongWord):LongWord;
Description: To be documented


RTL GPIO functions

[Expand]
function SysGPIOInputGet(Pin:LongWord):LongWord;
Description: Get the current state of a GPIO input pin


[Expand]
function SysGPIOInputWait(Pin,Trigger,Timeout:LongWord):LongWord;
Description: Wait for the state of a GPIO input pin to change


[Expand]
function SysGPIOInputEvent(Pin,Trigger,Timeout:LongWord; Callback:TGPIOCallback; Data:Pointer):LongWord;
Description: Schedule a function to be called when the state of a GPIO input pin changes


[Expand]
function SysGPIOOutputSet(Pin,Level:LongWord):LongWord; 
Description: Set the state of a GPIO output pin


[Expand]
function SysGPIOPullGet(Pin:LongWord):LongWord;
Description: Get the current pull state of a GPIO pin


[Expand]
function SysGPIOPullSelect(Pin,Mode:LongWord):LongWord;
Description: Change the pull state of a GPIO pin


[Expand]
function SysGPIOFunctionGet(Pin:LongWord):LongWord;
Description: Get the current function of a GPIO pin


[Expand]
function SysGPIOFunctionSelect(Pin,Mode:LongWord):LongWord;
Description: Change the function of a GPIO pin



Return to Unit Reference