Difference between revisions of "Unit GPIO"
(64 intermediate revisions by the same user not shown) | |||
Line 4: | Line 4: | ||
=== Description === | === Description === | ||
---- | ---- | ||
+ | |||
+ | '''Ultibo GPIO Interface unit''' | ||
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. | 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. | ||
Line 9: | Line 11: | ||
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. | 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 | + | Not all GPIO devices support the same feature set so the GPIODeviceGetProperties 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 | + | Multiple GPIO devices can be accommodated, 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. | 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. | ||
Line 18: | Line 20: | ||
---- | ---- | ||
− | '' | + | |
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;"> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''GPIO specific constants''' <code> GPIO_* </code></div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | | <code>GPIO_NAME_PREFIX = 'GPIO';</code> | ||
+ | | Name prefix for GPIO Devices | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;"> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''GPIO device type''' <code> GPIO_TYPE_* </code></div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | | <code>GPIO_TYPE_NONE = 0;</code> | ||
+ | | style="width: 50%;"| | ||
+ | |- | ||
+ | | <code>GPIO_TYPE_MAX = 0;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"|''GPIO device type name'' | ||
+ | |- | ||
+ | |colspan="2"|<code>GPIO_TYPE_NAMES:array[GPIO_TYPE_NONE..GPIO_TYPE_MAX] of String = ('GPIO_TYPE_NONE');</code> | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;"> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''GPIO device state''' <code> GPIO_STATE_* </code></div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | | <code>GPIO_STATE_DISABLED = 0;</code> | ||
+ | | style="width: 50%;"| | ||
+ | |- | ||
+ | | <code>GPIO_STATE_ENABLED = 1;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>GPIO_STATE_MAX = 1;</code> | ||
+ | | | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;"> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''GPIO device flag''' <code> GPIO_FLAG_* </code></div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | | <code>GPIO_FLAG_NONE = $00000000;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>GPIO_FLAG_PULL_UP = $00000001;</code> | ||
+ | | Device supports Pull Up on a pin | ||
+ | |- | ||
+ | | <code>GPIO_FLAG_PULL_DOWN = $00000002;</code> | ||
+ | | Device supports Pull Down on a pin | ||
+ | |- | ||
+ | | <code>GPIO_FLAG_TRIGGER_LOW = $00000004;</code> | ||
+ | | Device supports Trigger on Low level on a pin | ||
+ | |- | ||
+ | | <code>GPIO_FLAG_TRIGGER_HIGH = $00000008;</code> | ||
+ | | Device supports Trigger on High level on a pin | ||
+ | |- | ||
+ | | <code>GPIO_FLAG_TRIGGER_RISING = $00000010;</code> | ||
+ | | Device supports Trigger on Rising edge on a pin | ||
+ | |- | ||
+ | | <code>GPIO_FLAG_TRIGGER_FALLING = $00000020;</code> | ||
+ | | Device supports Trigger on Falling edge on a pin | ||
+ | |- | ||
+ | | <code>GPIO_FLAG_TRIGGER_EDGE = $00000040;</code> | ||
+ | | Device supports Trigger on any edge (Rising or Falling) on a pin | ||
+ | |- | ||
+ | | <code>GPIO_FLAG_TRIGGER_ASYNC = $00000080;</code> | ||
+ | | Device supports Trigger on Asynchronous Rising/Falling edge on a pin | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;"> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''GPIO event flag''' <code> GPIO_EVENT_FLAG_* </code></div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | | <code>GPIO_EVENT_FLAG_NONE = $00000000;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>GPIO_EVENT_FLAG_REPEAT = $00000001;</code> | ||
+ | | Event will be repeated until cancelled | ||
+ | |- | ||
+ | | <code>GPIO_EVENT_FLAG_INTERRUPT = $00000002;</code> | ||
+ | | Event will be dispatched by interrupt handler (If applicable) | ||
+ | Caution: Events called by the interrupt handler must obey interrupt rules with regard to locks, memory allocation and latency | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;"> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''GPIO logging''' <code> GPIO_LOG_* </code></div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | | <code>GPIO_LOG_LEVEL_DEBUG = LOG_LEVEL_DEBUG;</code> | ||
+ | | GPIO debugging messages | ||
+ | |- | ||
+ | | <code>GPIO_LOG_LEVEL_INFO = LOG_LEVEL_INFO;</code> | ||
+ | | GPIO informational messages, such as a device being attached or detached | ||
+ | |- | ||
+ | | <code>GPIO_LOG_LEVEL_WARN = LOG_LEVEL_WARN;</code> | ||
+ | | GPIO warning messages | ||
+ | |- | ||
+ | | <code>GPIO_LOG_LEVEL_ERROR = LOG_LEVEL_ERROR;</code> | ||
+ | | GPIO error messages | ||
+ | |- | ||
+ | | <code>GPIO_LOG_LEVEL_NONE = LOG_LEVEL_NONE;</code> | ||
+ | | No GPIO messages | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
=== Type definitions === | === Type definitions === | ||
---- | ---- | ||
− | '' | + | |
+ | '''GPIO properties''' | ||
+ | |||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;"> | ||
+ | <code>PGPIOProperties = ^TGPIOProperties;</code> | ||
+ | |||
+ | <code>TGPIOProperties = record</code> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | | <code>Flags:LongWord;</code> | ||
+ | | Device flags (eg GPIO_FLAG_TRIGGER_HIGH) | ||
+ | |- | ||
+ | | <code>PinMin:LongWord;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>PinMax:LongWord;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>PinCount:LongWord;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>FunctionMin:LongWord;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>FunctionMax:LongWord;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>FunctionCount:LongWord;</code> | ||
+ | | | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | |||
+ | '''GPIO event''' | ||
+ | |||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;"> | ||
+ | <code>PGPIOEvent = ^TGPIOEvent;</code> | ||
+ | |||
+ | <code>TGPIOEvent = record</code> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | | <code>Pin:PGPIOPin;</code> | ||
+ | | GPIO Pin this event belongs to | ||
+ | |- | ||
+ | | <code>Callback:TGPIOCallback;</code> | ||
+ | | Callback function to call when trigger occurs | ||
+ | |- | ||
+ | | <code>Data:Pointer;</code> | ||
+ | | Pointer to pass to the callback function when trigger occurs | ||
+ | |- | ||
+ | | <code>Timeout:LongWord;</code> | ||
+ | | Timeout in milliseconds for this callback (or INFINITE for no timeout) | ||
+ | |- | ||
+ | | <code>Prev:PGPIOEvent;</code> | ||
+ | | Previous event in the list | ||
+ | |- | ||
+ | | <code>Next:PGPIOEvent;</code> | ||
+ | | Next event in the list | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | |||
+ | '''GPIO pin''' | ||
+ | |||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;"> | ||
+ | <code>PGPIOPin = ^TGPIOPin;</code> | ||
+ | |||
+ | <code>TGPIOPin = record</code> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | |colspan="2"|Note: Forward declared for GPIOEvent | ||
+ | |- | ||
+ | | <code>GPIO:PGPIODevice;</code> | ||
+ | | GPIO device this pin belongs to | ||
+ | |- | ||
+ | | <code>Pin:LongWord;</code> | ||
+ | | Pin number of this pin on the device (May be used by drivers for internal numbering) | ||
+ | |- | ||
+ | | <code>Flags:LongWord;</code> | ||
+ | | Current flags for this pin (eg GPIO_EVENT_FLAG_REPEAT) | ||
+ | |- | ||
+ | | <code>Trigger:LongWord;</code> | ||
+ | | Current trigger value for this pin (or GPIO_TRIGGER_NONE if no triggers current) | ||
+ | |- | ||
+ | | <code>Count:LongWord;</code> | ||
+ | | Count of threads and events waiting for the trigger | ||
+ | |- | ||
+ | | <code>Event:TEventHandle;</code> | ||
+ | | Event for threads waiting for the trigger | ||
+ | |- | ||
+ | | <code>Events:PGPIOEvent;</code> | ||
+ | | List of events waiting for the trigger | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | |||
+ | '''GPIO enumeration callback''' | ||
+ | |||
+ | {| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;" | ||
+ | |- | ||
+ | | <code>TGPIOEnumerate = function(GPIO:PGPIODevice; Data:Pointer):LongWord;</code> | ||
+ | | style="width: 40%;"| | ||
+ | |- | ||
+ | |} | ||
+ | |||
+ | '''GPIO notification callback''' | ||
+ | |||
+ | {| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;" | ||
+ | |- | ||
+ | | <code>TGPIONotification = function(Device:PDevice; Data:Pointer; Notification:LongWord):LongWord;</code> | ||
+ | | style="width: 40%;"| | ||
+ | |- | ||
+ | |} | ||
+ | |||
+ | '''GPIO device start''' | ||
+ | |||
+ | {| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;" | ||
+ | |- | ||
+ | | <code>TGPIODeviceStart = function(GPIO:PGPIODevice):LongWord;</code> | ||
+ | | style="width: 40%;"| | ||
+ | |- | ||
+ | |} | ||
+ | |||
+ | '''GPIO device stop''' | ||
+ | |||
+ | {| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;" | ||
+ | |- | ||
+ | | <code>TGPIODeviceStop = function(GPIO:PGPIODevice):LongWord;</code> | ||
+ | | style="width: 40%;"| | ||
+ | |- | ||
+ | |} | ||
+ | |||
+ | '''GPIO device read''' | ||
+ | |||
+ | {| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;" | ||
+ | |- | ||
+ | | <code>TGPIODeviceRead = function(GPIO:PGPIODevice; Reg:LongWord):LongWord;</code> | ||
+ | | style="width: 40%;"| | ||
+ | |- | ||
+ | |} | ||
+ | |||
+ | '''GPIO device write''' | ||
+ | |||
+ | {| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;" | ||
+ | |- | ||
+ | | <code>TGPIODeviceWrite = procedure(GPIO:PGPIODevice; Reg,Value:LongWord);</code> | ||
+ | | style="width: 40%;"| | ||
+ | |- | ||
+ | |} | ||
+ | |||
+ | '''GPIO device input get''' | ||
+ | |||
+ | {| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;" | ||
+ | |- | ||
+ | | <code>TGPIODeviceInputGet = function(GPIO:PGPIODevice; Pin:LongWord):LongWord;</code> | ||
+ | | style="width: 40%;"| | ||
+ | |- | ||
+ | |} | ||
+ | |||
+ | '''GPIO device input wait''' | ||
+ | |||
+ | {| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;" | ||
+ | |- | ||
+ | | <code>TGPIODeviceInputWait = function(GPIO:PGPIODevice; Pin,Trigger,Timeout:LongWord):LongWord;</code> | ||
+ | | style="width: 40%;"| | ||
+ | |- | ||
+ | |} | ||
+ | |||
+ | '''GPIO device input event''' | ||
+ | |||
+ | {| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;" | ||
+ | |- | ||
+ | | <code>TGPIODeviceInputEvent = function(GPIO:PGPIODevice; Pin,Trigger,Flags,Timeout:LongWord; Callback:TGPIOCallback; Data:Pointer):LongWord;</code> | ||
+ | | style="width: 40%;"| | ||
+ | |- | ||
+ | |} | ||
+ | |||
+ | '''GPIO device input cancel''' | ||
+ | |||
+ | {| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;" | ||
+ | |- | ||
+ | | <code>TGPIODeviceInputCancel = function(GPIO:PGPIODevice; Pin:LongWord):LongWord;</code> | ||
+ | | style="width: 40%;"| | ||
+ | |- | ||
+ | |} | ||
+ | |||
+ | '''GPIO device output set''' | ||
+ | |||
+ | {| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;" | ||
+ | |- | ||
+ | | <code>TGPIODeviceOutputSet = function(GPIO:PGPIODevice; Pin,Level:LongWord):LongWord;</code> | ||
+ | | style="width: 40%;"| | ||
+ | |- | ||
+ | |} | ||
+ | |||
+ | '''GPIO device pull get''' | ||
+ | |||
+ | {| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;" | ||
+ | |- | ||
+ | | <code>TGPIODevicePullGet = function(GPIO:PGPIODevice; Pin:LongWord):LongWord;</code> | ||
+ | | style="width: 40%;"| | ||
+ | |- | ||
+ | |} | ||
+ | |||
+ | '''GPIO device pull select''' | ||
+ | |||
+ | {| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;" | ||
+ | |- | ||
+ | | <code>TGPIODevicePullSelect = function(GPIO:PGPIODevice; Pin,Mode:LongWord):LongWord;</code> | ||
+ | | style="width: 40%;"| | ||
+ | |- | ||
+ | |} | ||
+ | |||
+ | '''GPIO device function get''' | ||
+ | |||
+ | {| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;" | ||
+ | |- | ||
+ | | <code>TGPIODeviceFunctionGet = function(GPIO:PGPIODevice; Pin:LongWord):LongWord;</code> | ||
+ | | style="width: 40%;"| | ||
+ | |- | ||
+ | |} | ||
+ | |||
+ | '''GPIO device function select''' | ||
+ | |||
+ | {| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;" | ||
+ | |- | ||
+ | | <code>TGPIODeviceFunctionSelect = function(GPIO:PGPIODevice; Pin,Mode:LongWord):LongWord;</code> | ||
+ | | style="width: 40%;"| | ||
+ | |- | ||
+ | |} | ||
+ | |||
+ | '''GPIO device get properties''' | ||
+ | |||
+ | {| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;" | ||
+ | |- | ||
+ | | <code>TGPIODeviceGetProperties = function(GPIO:PGPIODevice; Properties:PGPIOProperties):LongWord;</code> | ||
+ | | style="width: 40%;"| | ||
+ | |- | ||
+ | |} | ||
+ | |||
+ | '''GPIO device''' | ||
+ | |||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;"> | ||
+ | <code>PGPIODevice = ^TGPIODevice;</code> | ||
+ | |||
+ | <code>TGPIODevice = record</code> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | |colspan="2"|Note: Forward declared for GPIOPin | ||
+ | |- | ||
+ | |colspan="2"|''Device Properties'' | ||
+ | |- | ||
+ | | <code>Device:TDevice;</code> | ||
+ | | The Device entry for this GPIO | ||
+ | |- | ||
+ | |colspan="2"|''GPIO Properties'' | ||
+ | |- | ||
+ | | <code>GPIOId:LongWord;</code> | ||
+ | | Unique Id of this GPIO in the GPIO table | ||
+ | |- | ||
+ | | <code>GPIOState:LongWord;</code> | ||
+ | | GPIO state (eg GPIO_STATE_ENABLED) | ||
+ | |- | ||
+ | | <code>DeviceStart:TGPIODeviceStart;</code> | ||
+ | | A Device specific DeviceStart method implementing the standard GPIO device interface (Mandatory) | ||
+ | |- | ||
+ | | <code>DeviceStop:TGPIODeviceStop;</code> | ||
+ | | A Device specific DeviceStop method implementing the standard GPIO device interface (Mandatory) | ||
+ | |- | ||
+ | | <code>DeviceRead:TGPIODeviceRead;</code> | ||
+ | | A Device specific DeviceRead method implementing the standard GPIO device interface (Or nil if the default method is suitable) | ||
+ | |- | ||
+ | | <code>DeviceWrite:TGPIODeviceWrite;</code> | ||
+ | | A Device specific DeviceWrite method implementing the standard GPIO device interface (Or nil if the default method is suitable) | ||
+ | |- | ||
+ | | <code>DeviceInputGet:TGPIODeviceInputGet;</code> | ||
+ | | A Device specific DeviceInputGet method implementing the standard GPIO device interface (Mandatory) | ||
+ | |- | ||
+ | | <code>DeviceInputWait:TGPIODeviceInputWait;</code> | ||
+ | | A Device specific DeviceInputWait method implementing the standard GPIO device interface (Or nil if the operation is not supported) | ||
+ | |- | ||
+ | | <code>DeviceInputEvent:TGPIODeviceInputEvent;</code> | ||
+ | | A Device specific DeviceInputEvent method implementing the standard GPIO device interface (Or nil if the operation is not supported) | ||
+ | |- | ||
+ | | <code>DeviceInputCancel:TGPIODeviceInputCancel;</code> | ||
+ | | A Device specific DeviceInputCancel method implementing the standard GPIO device interface (Or nil if the operation is not supported) | ||
+ | |- | ||
+ | | <code>DeviceOutputSet:TGPIODeviceOutputSet;</code> | ||
+ | | A Device specific DeviceOutputSet method implementing the standard GPIO device interface (Mandatory) | ||
+ | |- | ||
+ | | <code>DevicePullGet:TGPIODevicePullGet;</code> | ||
+ | | A Device specific DevicePullGet method implementing the standard GPIO device interface (Or nil if the operation is not supported) | ||
+ | |- | ||
+ | | <code>DevicePullSelect:TGPIODevicePullSelect;</code> | ||
+ | | A Device specific DevicePullSelect method implementing the standard GPIO device interface (Or nil if the operation is not supported) | ||
+ | |- | ||
+ | | <code>DeviceFunctionGet:TGPIODeviceFunctionGet;</code> | ||
+ | | A Device specific DeviceFunctionGet method implementing the standard GPIO device interface (Or nil if the operation is not supported) | ||
+ | |- | ||
+ | | <code>DeviceFunctionSelect:TGPIODeviceFunctionSelect;</code> | ||
+ | | A Device specific DeviceFunctionSelect method implementing the standard GPIO device interface (Or nil if the operation is not supported) | ||
+ | |- | ||
+ | | <code>DeviceGetProperties:TGPIODeviceGetProperties;</code> | ||
+ | | A Device specific DeviceGetProperties method implementing the standard GPIO device interface (Or nil if the default method is suitable) | ||
+ | |- | ||
+ | |colspan="2"|''Driver Properties'' | ||
+ | |- | ||
+ | | <code>Lock:TMutexHandle;</code> | ||
+ | | Device lock | ||
+ | |- | ||
+ | | <code>Address:Pointer;</code> | ||
+ | | Device register base address | ||
+ | |- | ||
+ | | <code>Pins:array of TGPIOPin;</code> | ||
+ | | Device pins | ||
+ | |- | ||
+ | | <code>Properties:TGPIOProperties;</code> | ||
+ | | Device properties | ||
+ | |- | ||
+ | |colspan="2"|''Statistics Properties'' | ||
+ | |- | ||
+ | | <code>GetCount:LongWord;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>SetCount:LongWord;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>WaitCount:LongWord;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>EventCount:LongWord;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"|''Internal Properties'' | ||
+ | |- | ||
+ | | <code>Prev:PGPIODevice;</code> | ||
+ | | Previous entry in GPIO table | ||
+ | |- | ||
+ | | <code>Next:PGPIODevice;</code> | ||
+ | | Next entry in GPIO table | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | |||
+ | '''GPIO pin information''' | ||
+ | |||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;"> | ||
+ | <code>PGPIOInfo = ^TGPIOInfo;</code> | ||
+ | |||
+ | <code>TGPIOInfo = record</code> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | |colspan="2"|Note: Used by other units to pass complete details of a GPIO pin | ||
+ | |- | ||
+ | | <code>GPIO:PGPIODevice;</code> | ||
+ | | Device for this GPIO pin | ||
+ | |- | ||
+ | | <code>Pin:LongWord;</code> | ||
+ | | Pin number (eg GPIO_PIN_59) | ||
+ | |- | ||
+ | | <code>Func:LongWord;</code> | ||
+ | | Function value (or GPIO_FUNCTION_UNKNOWN) | ||
+ | |- | ||
+ | | <code>Pull:LongWord;</code> | ||
+ | | Pull Up/Down value (or GPIO_PULL_UNKNOWN) | ||
+ | |- | ||
+ | | <code>Trigger:LongWord;</code> | ||
+ | | Trigger value (or GPIO_TRIGGER_UNKNOWN) | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
=== Public variables === | === Public variables === | ||
---- | ---- | ||
− | '' | + | |
+ | '''GPIO logging''' | ||
+ | |||
+ | {| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;" | ||
+ | |- | ||
+ | | <code>GPIO_DEFAULT_LOG_LEVEL:LongWord = GPIO_LOG_LEVEL_DEBUG;</code> | ||
+ | | style="width: 40%;"|Minimum level for GPIO messages. Only messages with level greater than or equal to this will be printed. | ||
+ | |- | ||
+ | |} | ||
+ | {| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;" | ||
+ | |- | ||
+ | | <code>GPIO_LOG_ENABLED:Boolean;</code> | ||
+ | | style="width: 40%;"| | ||
+ | |- | ||
+ | |} | ||
+ | <br /> | ||
=== Function declarations === | === Function declarations === | ||
---- | ---- | ||
− | + | ||
'''Initialization functions''' | '''Initialization functions''' | ||
Line 42: | Line 559: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
− | | | + | | None documented |
|- | |- | ||
|} | |} | ||
Line 53: | Line 570: | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | <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 GPIODeviceStart(GPIO:PGPIODevice):LongWord;</pre> | <pre style="border: 0; padding-bottom:0px;">function GPIODeviceStart(GPIO:PGPIODevice):LongWord;</pre> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' | + | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Start the specified GPIO device and enable access</div> |
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! GPIO |
− | | | + | | The GPIO device to start |
+ | |- | ||
+ | ! Return | ||
+ | | ERROR_SUCCESS if completed or another error code on failure | ||
|- | |- | ||
|} | |} | ||
Line 65: | Line 585: | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | <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 GPIODeviceStop(GPIO:PGPIODevice):LongWord;</pre> | <pre style="border: 0; padding-bottom:0px;">function GPIODeviceStop(GPIO:PGPIODevice):LongWord;</pre> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' | + | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Stop the specified GPIO device and disable access</div> |
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! GPIO |
− | | | + | | The GPIO device to stop |
+ | |- | ||
+ | ! Return | ||
+ | | ERROR_SUCCESS if completed or another error code on failure | ||
|- | |- | ||
|} | |} | ||
Line 77: | Line 600: | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | <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 GPIODeviceRead(GPIO:PGPIODevice; Reg:LongWord):LongWord;</pre> | <pre style="border: 0; padding-bottom:0px;">function GPIODeviceRead(GPIO:PGPIODevice; Reg:LongWord):LongWord;</pre> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' | + | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Perform a direct read from a register of the specified GPIO device</div> |
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! GPIO |
− | | | + | | The GPIO device to read from |
+ | |- | ||
+ | ! Reg | ||
+ | | The memory register to read from | ||
+ | |- | ||
+ | ! Return | ||
+ | | The value of the memory register | ||
|- | |- | ||
|} | |} | ||
Line 89: | Line 618: | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | <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;">procedure GPIODeviceWrite(GPIO:PGPIODevice; Reg,Value:LongWord);</pre> | <pre style="border: 0; padding-bottom:0px;">procedure GPIODeviceWrite(GPIO:PGPIODevice; Reg,Value:LongWord);</pre> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' | + | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Perform a direct write to a register of the specified GPIO device</div> |
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! GPIO |
− | | | + | | The GPIO device to write to |
+ | |- | ||
+ | ! Reg | ||
+ | | The memory register to write to | ||
+ | |- | ||
+ | ! Return | ||
+ | | The value to write to the register | ||
|- | |- | ||
|} | |} | ||
Line 101: | Line 636: | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | <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 GPIODeviceInputGet(GPIO:PGPIODevice; Pin:LongWord):LongWord;</pre> | <pre style="border: 0; padding-bottom:0px;">function GPIODeviceInputGet(GPIO:PGPIODevice; Pin:LongWord):LongWord;</pre> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' | + | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Get the current state of an input pin on the specified GPIO device</div> |
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! GPIO |
− | | | + | | The GPIO device to get from |
+ | |- | ||
+ | ! 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 | ||
|- | |- | ||
|} | |} | ||
Line 113: | Line 654: | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | <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 GPIODeviceInputWait(GPIO:PGPIODevice; Pin,Trigger,Timeout:LongWord):LongWord;</pre> | <pre style="border: 0; padding-bottom:0px;">function GPIODeviceInputWait(GPIO:PGPIODevice; Pin,Trigger,Timeout:LongWord):LongWord;</pre> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' | + | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Wait for the state of a input pin to change on the specified GPIO device</div> |
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! GPIO |
− | | | + | | The GPIO device to wait for |
+ | |- | ||
+ | ! 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 | ||
|- | |- | ||
|} | |} | ||
Line 125: | Line 678: | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | <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 GPIODeviceInputEvent(GPIO:PGPIODevice; Pin,Trigger,Flags,Timeout:LongWord; Callback:TGPIOCallback; Data:Pointer):LongWord;</pre> | <pre style="border: 0; padding-bottom:0px;">function GPIODeviceInputEvent(GPIO:PGPIODevice; Pin,Trigger,Flags,Timeout:LongWord; Callback:TGPIOCallback; Data:Pointer):LongWord;</pre> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' | + | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Schedule a function to be called when the state of a input pin changes on the specified GPIO device</div> |
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! GPIO |
− | | | + | | The GPIO device to schedule the callback for |
+ | |- | ||
+ | ! 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) | ||
+ | |- | ||
+ | ! Flags | ||
+ | | The flags to control the event (eg GPIO_EVENT_FLAG_REPEAT) | ||
+ | |- | ||
+ | ! 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 | ||
|- | |- | ||
|} | |} | ||
Line 137: | Line 714: | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | <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 GPIODeviceInputCancel(GPIO:PGPIODevice; Pin:LongWord):LongWord;</pre> | <pre style="border: 0; padding-bottom:0px;">function GPIODeviceInputCancel(GPIO:PGPIODevice; Pin:LongWord):LongWord;</pre> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' | + | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Cancel a previously scheduled event callback function for an input pin on the specified GPIO device</div> |
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! GPIO |
− | | | + | | The GPIO device to cancel the callback for |
+ | |- | ||
+ | ! Pin | ||
+ | | The pin to cancel the state change for (eg GPIO_PIN_1) | ||
+ | |- | ||
+ | ! Return | ||
+ | | ERROR_SUCCESS if the callback was cancelled successfully or another error code on failure | ||
|- | |- | ||
|} | |} | ||
Line 149: | Line 732: | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | <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 GPIODeviceOutputSet(GPIO:PGPIODevice; Pin,Level:LongWord):LongWord;</pre> | <pre style="border: 0; padding-bottom:0px;">function GPIODeviceOutputSet(GPIO:PGPIODevice; Pin,Level:LongWord):LongWord;</pre> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' | + | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Set the state of a output pin on the specified GPIO device</div> |
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! '''Note''' | + | ! GPIO |
− | | | + | | The GPIO device to set for |
+ | |- | ||
+ | ! 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 GPIODeviceLevelGet(GPIO:PGPIODevice; Pin:LongWord):LongWord;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Get the current level (state) of a pin on the specified GPIO device</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! GPIO | ||
+ | | The GPIO device to get from | ||
+ | |- | ||
+ | ! Pin | ||
+ | | The pin to get the level for (eg GPIO_PIN_1) | ||
+ | |- | ||
+ | ! Return | ||
+ | | The current level (eg GPIO_LEVEL_HIGH) or GPIO_LEVEL_UNKNOWN on failure | ||
+ | |- | ||
+ | ! Note | ||
+ | | This function is a synonym for GPIODeviceInputGet as in many cases the level can be read from a pin regardless of input or output mode. This may help to make code clearer or easier to understand in some cases. | ||
+ | |- | ||
+ | |} | ||
+ | </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 GPIODeviceLevelSet(GPIO:PGPIODevice; Pin,Level:LongWord):LongWord;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Set the level (state) of a pin on the specified GPIO device</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! GPIO | ||
+ | | The GPIO device to set for | ||
+ | |- | ||
+ | ! Pin | ||
+ | | The pin to set the level for (eg GPIO_PIN_1) | ||
+ | |- | ||
+ | ! Level | ||
+ | | The level to set the pin to (eg GPIO_LEVEL_HIGH) | ||
+ | |- | ||
+ | ! Return | ||
+ | | ERROR_SUCCESS if completed successfully or another error code on failure | ||
+ | |- | ||
+ | ! Note | ||
+ | | This function is a synonym for GPIODeviceOutputSet as in many cases the level can be set for a pin regardless of input or output mode. This may help to make code clearer or easier to understand in some cases. | ||
|- | |- | ||
|} | |} | ||
Line 161: | Line 798: | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | <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 GPIODevicePullGet(GPIO:PGPIODevice;Pin:LongWord):LongWord;</pre> | <pre style="border: 0; padding-bottom:0px;">function GPIODevicePullGet(GPIO:PGPIODevice;Pin:LongWord):LongWord;</pre> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' | + | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Get the current pull state of a pin on the specified GPIO device</div> |
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! GPIO |
− | | | + | | The GPIO device to get from |
+ | |- | ||
+ | ! 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 | ||
|- | |- | ||
|} | |} | ||
Line 173: | Line 816: | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | <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 GPIODevicePullSelect(GPIO:PGPIODevice; Pin,Mode:LongWord):LongWord;</pre> | <pre style="border: 0; padding-bottom:0px;">function GPIODevicePullSelect(GPIO:PGPIODevice; Pin,Mode:LongWord):LongWord;</pre> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' | + | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Change the pull state of a pin on the specified GPIO device</div> |
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! GPIO |
− | | | + | | The GPIO device to set for |
+ | |- | ||
+ | ! 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 | ||
|- | |- | ||
|} | |} | ||
Line 185: | Line 837: | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | <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 GPIODeviceFunctionGet(GPIO:PGPIODevice; Pin:LongWord):LongWord;</pre> | <pre style="border: 0; padding-bottom:0px;">function GPIODeviceFunctionGet(GPIO:PGPIODevice; Pin:LongWord):LongWord;</pre> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' | + | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Get the current function of a pin on the specified GPIO device</div> |
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! GPIO |
− | | | + | | The GPIO device to get from |
+ | |- | ||
+ | ! 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 | ||
|- | |- | ||
|} | |} | ||
Line 197: | Line 855: | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | <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 GPIODeviceFunctionSelect(GPIO:PGPIODevice; Pin,Mode:LongWord):LongWord;</pre> | <pre style="border: 0; padding-bottom:0px;">function GPIODeviceFunctionSelect(GPIO:PGPIODevice; Pin,Mode:LongWord):LongWord;</pre> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' | + | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Change the function of a pin on the specified GPIO device</div> |
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! GPIO |
− | | | + | | The GPIO device to set for |
+ | |- | ||
+ | ! 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 | ||
|- | |- | ||
|} | |} | ||
Line 208: | Line 875: | ||
<br /> | <br /> | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | <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 GPIODeviceProperties(GPIO:PGPIODevice; Properties:PGPIOProperties):LongWord;</pre> | + | <pre style="border: 0; padding-bottom:0px;">function GPIODeviceProperties(GPIO:PGPIODevice; Properties:PGPIOProperties):LongWord; inline;</pre> |
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' | + | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Get the properties for the specified GPIO device</div> |
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! ''' | + | ! GPIO |
− | | | + | | The GPIO device to get properties from |
+ | |- | ||
+ | ! Properties | ||
+ | | Pointer to a TGPIOProperties structure to fill in | ||
+ | |- | ||
+ | ! Return | ||
+ | | ERROR_SUCCESS if completed or another error code on failure | ||
+ | |- | ||
+ | ! Note | ||
+ | | Replaced by GPIODeviceGetProperties for consistency | ||
+ | |- | ||
+ | |} | ||
+ | </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 GPIODeviceGetProperties(GPIO:PGPIODevice; Properties:PGPIOProperties):LongWord;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Get the properties for the specified GPIO device</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! GPIO | ||
+ | | The GPIO device to get properties from | ||
+ | |- | ||
+ | ! Properties | ||
+ | | Pointer to a TGPIOProperties structure to fill in | ||
+ | |- | ||
+ | ! Return | ||
+ | | ERROR_SUCCESS if completed or another error code on failure | ||
|- | |- | ||
|} | |} | ||
Line 225: | Line 919: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Return |
| Pointer to new GPIO entry or nil if GPIO could not be created | | Pointer to new GPIO entry or nil if GPIO could not be created | ||
|- | |- | ||
Line 237: | Line 931: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Size |
| Size in bytes to allocate for new GPIO (Including the GPIO entry) | | 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 | | Pointer to new GPIO entry or nil if GPIO could not be created | ||
|- | |- | ||
Line 252: | Line 946: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! GPIO |
− | | | + | | The GPIO device to destroy |
+ | |- | ||
+ | ! Return | ||
+ | | ERROR_SUCCESS if completed or another error code on failure | ||
|- | |- | ||
|} | |} | ||
Line 264: | Line 961: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! GPIO |
− | | | + | | The GPIO device to register |
+ | |- | ||
+ | ! Return | ||
+ | | ERROR_SUCCESS if completed or another error code on failure | ||
|- | |- | ||
|} | |} | ||
Line 276: | Line 976: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! GPIO |
− | | | + | | The GPIO device to deregister |
+ | |- | ||
+ | ! Return | ||
+ | | ERROR_SUCCESS if completed or another error code on failure | ||
|- | |- | ||
|} | |} | ||
Line 284: | Line 987: | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | <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 GPIODeviceFind(GPIOId:LongWord):PGPIODevice;</pre> | <pre style="border: 0; padding-bottom:0px;">function GPIODeviceFind(GPIOId:LongWord):PGPIODevice;</pre> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' | + | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Find a GPIO device by ID in the GPIO table</div> |
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! GPIOId |
− | | | + | | The ID number of the GPIO device to find |
+ | |- | ||
+ | ! Return | ||
+ | | Pointer to GPIO device entry or nil if not found | ||
|- | |- | ||
|} | |} | ||
Line 296: | Line 1,002: | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | <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 GPIODeviceFindByName(const Name:String):PGPIODevice; inline;</pre> | <pre style="border: 0; padding-bottom:0px;">function GPIODeviceFindByName(const Name:String):PGPIODevice; inline;</pre> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' | + | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Find a GPIO device by name in the GPIO table</div> |
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Name |
− | | | + | | The name of the GPIO to find (eg GPIO0) |
+ | |- | ||
+ | ! Return | ||
+ | | Pointer to GPIO device entry or nil if not found | ||
|- | |- | ||
|} | |} | ||
Line 308: | Line 1,017: | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | <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 GPIODeviceFindByDescription(const Description:String):PGPIODevice; inline;</pre> | <pre style="border: 0; padding-bottom:0px;">function GPIODeviceFindByDescription(const Description:String):PGPIODevice; inline;</pre> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' | + | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Find a GPIO device by description in the GPIO table</div> |
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Description |
− | | | + | | The description of the GPIO to find (eg BCM2836 GPIO) |
+ | |- | ||
+ | ! Return | ||
+ | | Pointer to GPIO device entry or nil if not found | ||
|- | |- | ||
|} | |} | ||
Line 320: | Line 1,032: | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | <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 GPIODeviceEnumerate(Callback:TGPIOEnumerate; Data:Pointer):LongWord;</pre> | <pre style="border: 0; padding-bottom:0px;">function GPIODeviceEnumerate(Callback:TGPIOEnumerate; Data:Pointer):LongWord;</pre> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' | + | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Enumerate all GPIO devices in the GPIO table</div> |
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Callback |
− | | | + | | The callback function to call for each GPIO in the table |
+ | |- | ||
+ | ! Data | ||
+ | | A private data pointer to pass to callback for each GPIO in the table | ||
+ | |- | ||
+ | ! Note | ||
+ | | ERROR_SUCCESS if completed or another error code on failure | ||
|- | |- | ||
|} | |} | ||
Line 332: | Line 1,050: | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | <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 GPIODeviceNotification(GPIO:PGPIODevice; Callback:TGPIONotification; Data:Pointer; Notification,Flags:LongWord):LongWord;</pre> | <pre style="border: 0; padding-bottom:0px;">function GPIODeviceNotification(GPIO:PGPIODevice; Callback:TGPIONotification; Data:Pointer; Notification,Flags:LongWord):LongWord;</pre> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' | + | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Register a notification for GPIO device changes</div> |
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! GPIO |
− | | | + | | The GPIO device to notify changes for (Optional, pass nil for all GPIO devices) |
+ | |- | ||
+ | ! Callback | ||
+ | | The function to call when a notification event occurs | ||
+ | |- | ||
+ | ! Data | ||
+ | | A private data pointer to pass to callback when a notification event occurs | ||
+ | |- | ||
+ | ! Notification | ||
+ | | The events to register for notification of (eg DEVICE_NOTIFICATION_REGISTER) | ||
+ | |- | ||
+ | ! Flags | ||
+ | | The flags to control the notification (eg NOTIFIER_FLAG_WORKER) | ||
|- | |- | ||
|} | |} | ||
Line 343: | Line 1,073: | ||
<br /> | <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 SysGPIOAvailable:Boolean;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Check if a GPIO device is available</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Note | ||
+ | | None documented | ||
+ | |- | ||
+ | |} | ||
+ | </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 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 | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | |||
+ | '''GPIO helper 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 GPIOGetCount:LongWord;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Get the current GPIO count</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Note | ||
+ | | None documented | ||
+ | |- | ||
+ | |} | ||
+ | </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 GPIODeviceGetDefault:PGPIODevice;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Get the current default GPIO device</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Note | ||
+ | | None documented | ||
+ | |- | ||
+ | |} | ||
+ | </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 GPIODeviceSetDefault(GPIO:PGPIODevice):LongWord;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Set the current default GPIO device</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Note | ||
+ | | None documented | ||
+ | |- | ||
+ | |} | ||
+ | </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 GPIODeviceCheck(GPIO:PGPIODevice):PGPIODevice;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Check if the supplied GPIO is in the GPIO table</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Note | ||
+ | | None documented | ||
+ | |- | ||
+ | |} | ||
+ | </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 GPIOTypeToString(GPIOType:LongWord):String;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Convert a GPIO type value to a string</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Note | ||
+ | | None documented | ||
+ | |- | ||
+ | |} | ||
+ | </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 GPIOStateToString(GPIOState:LongWord):String;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Convert a GPIO state value to a string</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Note | ||
+ | | None documented | ||
+ | |- | ||
+ | |} | ||
+ | </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 GPIODeviceCreateEvent(GPIO:PGPIODevice; Pin:PGPIOPin; Callback:TGPIOCallback; Data:Pointer; Timeout:LongWord):PGPIOEvent;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Create a new event using the supplied parameters</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Note | ||
+ | | Event must be registered by calling GPIODeviceRegisterEvent | ||
+ | Caller must hold the GPIO device lock | ||
+ | |- | ||
+ | |} | ||
+ | </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 GPIODeviceDestroyEvent(GPIO:PGPIODevice; Event:PGPIOEvent):LongWord;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Destroy an existing event</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Note | ||
+ | | Event must be deregistered first by calling GPIODeviceDeregisterEvent | ||
+ | Caller must hold the GPIO device lock | ||
+ | |- | ||
+ | |} | ||
+ | </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 GPIODeviceRegisterEvent(GPIO:PGPIODevice; Pin:PGPIOPin; Event:PGPIOEvent):LongWord;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Register an event in the event list of the supplied Pin</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Note | ||
+ | | Event must be created by calling GPIODeviceCreateEvent | ||
+ | Caller must hold the GPIO device lock | ||
+ | |- | ||
+ | |} | ||
+ | </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 GPIODeviceDeregisterEvent(GPIO:PGPIODevice;Pin:PGPIOPin;Event:PGPIOEvent):LongWord;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Deregister an event in the event list of the supplied Pin</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Note | ||
+ | | Event must be destroyed by calling GPIODeviceDestroyEvent | ||
+ | Caller must hold the GPIO device lock | ||
+ | |- | ||
+ | |} | ||
+ | </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;">procedure GPIOLog(Level:LongWord; GPIO:PGPIODevice; const AText:String);</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Note | ||
+ | | None documented | ||
+ | |- | ||
+ | |} | ||
+ | </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;">procedure GPIOLogInfo(GPIO:PGPIODevice; const AText:String); inline;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Note | ||
+ | | None documented | ||
+ | |- | ||
+ | |} | ||
+ | </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;">procedure GPIOLogWarn(GPIO:PGPIODevice; const AText:String); inline;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Note | ||
+ | | None documented | ||
+ | |- | ||
+ | |} | ||
+ | </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;">procedure GPIOLogError(GPIO:PGPIODevice; const AText:String); inline;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Note | ||
+ | | None documented | ||
+ | |- | ||
+ | |} | ||
+ | </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;">procedure GPIOLogDebug(GPIO:PGPIODevice; const AText:String); inline;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Note | ||
+ | | None documented | ||
+ | |- | ||
+ | |} | ||
+ | </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 GPIOPinToString(Pin:LongWord):String;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Note | ||
+ | | None documented | ||
+ | |- | ||
+ | |} | ||
+ | </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 GPIOLevelToString(Level:LongWord):String;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Note | ||
+ | | None documented | ||
+ | |- | ||
+ | |} | ||
+ | </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 GPIOTriggerToString(Trigger:LongWord):String;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Note | ||
+ | | None documented | ||
+ | |- | ||
+ | |} | ||
+ | </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 GPIOPullToString(Value:LongWord):String;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Note | ||
+ | | None documented | ||
+ | |- | ||
+ | |} | ||
+ | </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 GPIOFunctionToString(Value:LongWord):String;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Note | ||
+ | | None documented | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
Return to [[Unit_Reference|Unit Reference]] | Return to [[Unit_Reference|Unit Reference]] |
Latest revision as of 04:40, 12 September 2023
Return to Unit Reference
Description
Ultibo GPIO Interface unit
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 GPIODeviceGetProperties 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 accommodated, 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
GPIO_*
GPIO_NAME_PREFIX = 'GPIO';
|
Name prefix for GPIO Devices |
GPIO_TYPE_*
GPIO_TYPE_NONE = 0;
|
|
GPIO_TYPE_MAX = 0;
|
|
GPIO device type name | |
GPIO_TYPE_NAMES:array[GPIO_TYPE_NONE..GPIO_TYPE_MAX] of String = ('GPIO_TYPE_NONE');
|
GPIO_STATE_*
GPIO_STATE_DISABLED = 0;
|
|
GPIO_STATE_ENABLED = 1;
|
|
GPIO_STATE_MAX = 1;
|
GPIO_FLAG_*
GPIO_FLAG_NONE = $00000000;
|
|
GPIO_FLAG_PULL_UP = $00000001;
|
Device supports Pull Up on a pin |
GPIO_FLAG_PULL_DOWN = $00000002;
|
Device supports Pull Down on a pin |
GPIO_FLAG_TRIGGER_LOW = $00000004;
|
Device supports Trigger on Low level on a pin |
GPIO_FLAG_TRIGGER_HIGH = $00000008;
|
Device supports Trigger on High level on a pin |
GPIO_FLAG_TRIGGER_RISING = $00000010;
|
Device supports Trigger on Rising edge on a pin |
GPIO_FLAG_TRIGGER_FALLING = $00000020;
|
Device supports Trigger on Falling edge on a pin |
GPIO_FLAG_TRIGGER_EDGE = $00000040;
|
Device supports Trigger on any edge (Rising or Falling) on a pin |
GPIO_FLAG_TRIGGER_ASYNC = $00000080;
|
Device supports Trigger on Asynchronous Rising/Falling edge on a pin |
GPIO_EVENT_FLAG_*
GPIO_EVENT_FLAG_NONE = $00000000;
|
|
GPIO_EVENT_FLAG_REPEAT = $00000001;
|
Event will be repeated until cancelled |
GPIO_EVENT_FLAG_INTERRUPT = $00000002;
|
Event will be dispatched by interrupt handler (If applicable)
Caution: Events called by the interrupt handler must obey interrupt rules with regard to locks, memory allocation and latency |
GPIO_LOG_*
GPIO_LOG_LEVEL_DEBUG = LOG_LEVEL_DEBUG;
|
GPIO debugging messages |
GPIO_LOG_LEVEL_INFO = LOG_LEVEL_INFO;
|
GPIO informational messages, such as a device being attached or detached |
GPIO_LOG_LEVEL_WARN = LOG_LEVEL_WARN;
|
GPIO warning messages |
GPIO_LOG_LEVEL_ERROR = LOG_LEVEL_ERROR;
|
GPIO error messages |
GPIO_LOG_LEVEL_NONE = LOG_LEVEL_NONE;
|
No GPIO messages |
Type definitions
GPIO properties
PGPIOProperties = ^TGPIOProperties;
TGPIOProperties = record
Flags:LongWord;
|
Device flags (eg GPIO_FLAG_TRIGGER_HIGH) |
PinMin:LongWord;
|
|
PinMax:LongWord;
|
|
PinCount:LongWord;
|
|
FunctionMin:LongWord;
|
|
FunctionMax:LongWord;
|
|
FunctionCount:LongWord;
|
GPIO event
PGPIOEvent = ^TGPIOEvent;
TGPIOEvent = record
Pin:PGPIOPin;
|
GPIO Pin this event belongs to |
Callback:TGPIOCallback;
|
Callback function to call when trigger occurs |
Data:Pointer;
|
Pointer to pass to the callback function when trigger occurs |
Timeout:LongWord;
|
Timeout in milliseconds for this callback (or INFINITE for no timeout) |
Prev:PGPIOEvent;
|
Previous event in the list |
Next:PGPIOEvent;
|
Next event in the list |
GPIO pin
PGPIOPin = ^TGPIOPin;
TGPIOPin = record
Note: Forward declared for GPIOEvent | |
GPIO:PGPIODevice;
|
GPIO device this pin belongs to |
Pin:LongWord;
|
Pin number of this pin on the device (May be used by drivers for internal numbering) |
Flags:LongWord;
|
Current flags for this pin (eg GPIO_EVENT_FLAG_REPEAT) |
Trigger:LongWord;
|
Current trigger value for this pin (or GPIO_TRIGGER_NONE if no triggers current) |
Count:LongWord;
|
Count of threads and events waiting for the trigger |
Event:TEventHandle;
|
Event for threads waiting for the trigger |
Events:PGPIOEvent;
|
List of events waiting for the trigger |
GPIO enumeration callback
TGPIOEnumerate = function(GPIO:PGPIODevice; Data:Pointer):LongWord;
|
GPIO notification callback
TGPIONotification = function(Device:PDevice; Data:Pointer; Notification:LongWord):LongWord;
|
GPIO device start
TGPIODeviceStart = function(GPIO:PGPIODevice):LongWord;
|
GPIO device stop
TGPIODeviceStop = function(GPIO:PGPIODevice):LongWord;
|
GPIO device read
TGPIODeviceRead = function(GPIO:PGPIODevice; Reg:LongWord):LongWord;
|
GPIO device write
TGPIODeviceWrite = procedure(GPIO:PGPIODevice; Reg,Value:LongWord);
|
GPIO device input get
TGPIODeviceInputGet = function(GPIO:PGPIODevice; Pin:LongWord):LongWord;
|
GPIO device input wait
TGPIODeviceInputWait = function(GPIO:PGPIODevice; Pin,Trigger,Timeout:LongWord):LongWord;
|
GPIO device input event
TGPIODeviceInputEvent = function(GPIO:PGPIODevice; Pin,Trigger,Flags,Timeout:LongWord; Callback:TGPIOCallback; Data:Pointer):LongWord;
|
GPIO device input cancel
TGPIODeviceInputCancel = function(GPIO:PGPIODevice; Pin:LongWord):LongWord;
|
GPIO device output set
TGPIODeviceOutputSet = function(GPIO:PGPIODevice; Pin,Level:LongWord):LongWord;
|
GPIO device pull get
TGPIODevicePullGet = function(GPIO:PGPIODevice; Pin:LongWord):LongWord;
|
GPIO device pull select
TGPIODevicePullSelect = function(GPIO:PGPIODevice; Pin,Mode:LongWord):LongWord;
|
GPIO device function get
TGPIODeviceFunctionGet = function(GPIO:PGPIODevice; Pin:LongWord):LongWord;
|
GPIO device function select
TGPIODeviceFunctionSelect = function(GPIO:PGPIODevice; Pin,Mode:LongWord):LongWord;
|
GPIO device get properties
TGPIODeviceGetProperties = function(GPIO:PGPIODevice; Properties:PGPIOProperties):LongWord;
|
GPIO device
PGPIODevice = ^TGPIODevice;
TGPIODevice = record
Note: Forward declared for GPIOPin | |
Device Properties | |
Device:TDevice;
|
The Device entry for this GPIO |
GPIO Properties | |
GPIOId:LongWord;
|
Unique Id of this GPIO in the GPIO table |
GPIOState:LongWord;
|
GPIO state (eg GPIO_STATE_ENABLED) |
DeviceStart:TGPIODeviceStart;
|
A Device specific DeviceStart method implementing the standard GPIO device interface (Mandatory) |
DeviceStop:TGPIODeviceStop;
|
A Device specific DeviceStop method implementing the standard GPIO device interface (Mandatory) |
DeviceRead:TGPIODeviceRead;
|
A Device specific DeviceRead method implementing the standard GPIO device interface (Or nil if the default method is suitable) |
DeviceWrite:TGPIODeviceWrite;
|
A Device specific DeviceWrite method implementing the standard GPIO device interface (Or nil if the default method is suitable) |
DeviceInputGet:TGPIODeviceInputGet;
|
A Device specific DeviceInputGet method implementing the standard GPIO device interface (Mandatory) |
DeviceInputWait:TGPIODeviceInputWait;
|
A Device specific DeviceInputWait method implementing the standard GPIO device interface (Or nil if the operation is not supported) |
DeviceInputEvent:TGPIODeviceInputEvent;
|
A Device specific DeviceInputEvent method implementing the standard GPIO device interface (Or nil if the operation is not supported) |
DeviceInputCancel:TGPIODeviceInputCancel;
|
A Device specific DeviceInputCancel method implementing the standard GPIO device interface (Or nil if the operation is not supported) |
DeviceOutputSet:TGPIODeviceOutputSet;
|
A Device specific DeviceOutputSet method implementing the standard GPIO device interface (Mandatory) |
DevicePullGet:TGPIODevicePullGet;
|
A Device specific DevicePullGet method implementing the standard GPIO device interface (Or nil if the operation is not supported) |
DevicePullSelect:TGPIODevicePullSelect;
|
A Device specific DevicePullSelect method implementing the standard GPIO device interface (Or nil if the operation is not supported) |
DeviceFunctionGet:TGPIODeviceFunctionGet;
|
A Device specific DeviceFunctionGet method implementing the standard GPIO device interface (Or nil if the operation is not supported) |
DeviceFunctionSelect:TGPIODeviceFunctionSelect;
|
A Device specific DeviceFunctionSelect method implementing the standard GPIO device interface (Or nil if the operation is not supported) |
DeviceGetProperties:TGPIODeviceGetProperties;
|
A Device specific DeviceGetProperties method implementing the standard GPIO device interface (Or nil if the default method is suitable) |
Driver Properties | |
Lock:TMutexHandle;
|
Device lock |
Address:Pointer;
|
Device register base address |
Pins:array of TGPIOPin;
|
Device pins |
Properties:TGPIOProperties;
|
Device properties |
Statistics Properties | |
GetCount:LongWord;
|
|
SetCount:LongWord;
|
|
WaitCount:LongWord;
|
|
EventCount:LongWord;
|
|
Internal Properties | |
Prev:PGPIODevice;
|
Previous entry in GPIO table |
Next:PGPIODevice;
|
Next entry in GPIO table |
GPIO pin information
PGPIOInfo = ^TGPIOInfo;
TGPIOInfo = record
Note: Used by other units to pass complete details of a GPIO pin | |
GPIO:PGPIODevice;
|
Device for this GPIO pin |
Pin:LongWord;
|
Pin number (eg GPIO_PIN_59) |
Func:LongWord;
|
Function value (or GPIO_FUNCTION_UNKNOWN) |
Pull:LongWord;
|
Pull Up/Down value (or GPIO_PULL_UNKNOWN) |
Trigger:LongWord;
|
Trigger value (or GPIO_TRIGGER_UNKNOWN) |
Public variables
GPIO logging
GPIO_DEFAULT_LOG_LEVEL:LongWord = GPIO_LOG_LEVEL_DEBUG;
|
Minimum level for GPIO messages. Only messages with level greater than or equal to this will be printed. |
GPIO_LOG_ENABLED:Boolean;
|
Function declarations
Initialization functions
procedure GPIOInit;
Note | None documented |
---|
GPIO functions
function GPIODeviceStart(GPIO:PGPIODevice):LongWord;
GPIO | The GPIO device to start |
---|---|
Return | ERROR_SUCCESS if completed or another error code on failure |
function GPIODeviceStop(GPIO:PGPIODevice):LongWord;
GPIO | The GPIO device to stop |
---|---|
Return | ERROR_SUCCESS if completed or another error code on failure |
function GPIODeviceRead(GPIO:PGPIODevice; Reg:LongWord):LongWord;
GPIO | The GPIO device to read from |
---|---|
Reg | The memory register to read from |
Return | The value of the memory register |
procedure GPIODeviceWrite(GPIO:PGPIODevice; Reg,Value:LongWord);
GPIO | The GPIO device to write to |
---|---|
Reg | The memory register to write to |
Return | The value to write to the register |
function GPIODeviceInputGet(GPIO:PGPIODevice; Pin:LongWord):LongWord;
GPIO | The GPIO device to get from |
---|---|
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 GPIODeviceInputWait(GPIO:PGPIODevice; Pin,Trigger,Timeout:LongWord):LongWord;
GPIO | The GPIO device to wait for |
---|---|
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 GPIODeviceInputEvent(GPIO:PGPIODevice; Pin,Trigger,Flags,Timeout:LongWord; Callback:TGPIOCallback; Data:Pointer):LongWord;
GPIO | The GPIO device to schedule the callback for |
---|---|
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) |
Flags | The flags to control the event (eg GPIO_EVENT_FLAG_REPEAT) |
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 GPIODeviceInputCancel(GPIO:PGPIODevice; Pin:LongWord):LongWord;
GPIO | The GPIO device to cancel the callback for |
---|---|
Pin | The pin to cancel the state change for (eg GPIO_PIN_1) |
Return | ERROR_SUCCESS if the callback was cancelled successfully or another error code on failure |
function GPIODeviceOutputSet(GPIO:PGPIODevice; Pin,Level:LongWord):LongWord;
GPIO | The GPIO device to set for |
---|---|
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 GPIODeviceLevelGet(GPIO:PGPIODevice; Pin:LongWord):LongWord;
GPIO | The GPIO device to get from |
---|---|
Pin | The pin to get the level for (eg GPIO_PIN_1) |
Return | The current level (eg GPIO_LEVEL_HIGH) or GPIO_LEVEL_UNKNOWN on failure |
Note | This function is a synonym for GPIODeviceInputGet as in many cases the level can be read from a pin regardless of input or output mode. This may help to make code clearer or easier to understand in some cases. |
function GPIODeviceLevelSet(GPIO:PGPIODevice; Pin,Level:LongWord):LongWord;
GPIO | The GPIO device to set for |
---|---|
Pin | The pin to set the level for (eg GPIO_PIN_1) |
Level | The level to set the pin to (eg GPIO_LEVEL_HIGH) |
Return | ERROR_SUCCESS if completed successfully or another error code on failure |
Note | This function is a synonym for GPIODeviceOutputSet as in many cases the level can be set for a pin regardless of input or output mode. This may help to make code clearer or easier to understand in some cases. |
function GPIODevicePullGet(GPIO:PGPIODevice;Pin:LongWord):LongWord;
GPIO | The GPIO device to get from |
---|---|
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 GPIODevicePullSelect(GPIO:PGPIODevice; Pin,Mode:LongWord):LongWord;
GPIO | The GPIO device to set for |
---|---|
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 GPIODeviceFunctionGet(GPIO:PGPIODevice; Pin:LongWord):LongWord;
GPIO | The GPIO device to get from |
---|---|
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 GPIODeviceFunctionSelect(GPIO:PGPIODevice; Pin,Mode:LongWord):LongWord;
GPIO | The GPIO device to set for |
---|---|
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 |
function GPIODeviceProperties(GPIO:PGPIODevice; Properties:PGPIOProperties):LongWord; inline;
GPIO | The GPIO device to get properties from |
---|---|
Properties | Pointer to a TGPIOProperties structure to fill in |
Return | ERROR_SUCCESS if completed or another error code on failure |
Note | Replaced by GPIODeviceGetProperties for consistency |
function GPIODeviceGetProperties(GPIO:PGPIODevice; Properties:PGPIOProperties):LongWord;
GPIO | The GPIO device to get properties from |
---|---|
Properties | Pointer to a TGPIOProperties structure to fill in |
Return | ERROR_SUCCESS if completed or another error code on failure |
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;
GPIO | The GPIO device to destroy |
---|---|
Return | ERROR_SUCCESS if completed or another error code on failure |
function GPIODeviceRegister(GPIO:PGPIODevice):LongWord;
GPIO | The GPIO device to register |
---|---|
Return | ERROR_SUCCESS if completed or another error code on failure |
function GPIODeviceDeregister(GPIO:PGPIODevice):LongWord;
GPIO | The GPIO device to deregister |
---|---|
Return | ERROR_SUCCESS if completed or another error code on failure |
function GPIODeviceFind(GPIOId:LongWord):PGPIODevice;
GPIOId | The ID number of the GPIO device to find |
---|---|
Return | Pointer to GPIO device entry or nil if not found |
function GPIODeviceFindByName(const Name:String):PGPIODevice; inline;
Name | The name of the GPIO to find (eg GPIO0) |
---|---|
Return | Pointer to GPIO device entry or nil if not found |
function GPIODeviceFindByDescription(const Description:String):PGPIODevice; inline;
Description | The description of the GPIO to find (eg BCM2836 GPIO) |
---|---|
Return | Pointer to GPIO device entry or nil if not found |
function GPIODeviceEnumerate(Callback:TGPIOEnumerate; Data:Pointer):LongWord;
Callback | The callback function to call for each GPIO in the table |
---|---|
Data | A private data pointer to pass to callback for each GPIO in the table |
Note | ERROR_SUCCESS if completed or another error code on failure |
function GPIODeviceNotification(GPIO:PGPIODevice; Callback:TGPIONotification; Data:Pointer; Notification,Flags:LongWord):LongWord;
GPIO | The GPIO device to notify changes for (Optional, pass nil for all GPIO devices) |
---|---|
Callback | The function to call when a notification event occurs |
Data | A private data pointer to pass to callback when a notification event occurs |
Notification | The events to register for notification of (eg DEVICE_NOTIFICATION_REGISTER) |
Flags | The flags to control the notification (eg NOTIFIER_FLAG_WORKER) |
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;
Note | None documented |
---|
function GPIODeviceGetDefault:PGPIODevice;
Note | None documented |
---|
function GPIODeviceSetDefault(GPIO:PGPIODevice):LongWord;
Note | None documented |
---|
function GPIODeviceCheck(GPIO:PGPIODevice):PGPIODevice;
Note | None documented |
---|
function GPIOTypeToString(GPIOType:LongWord):String;
Note | None documented |
---|
function GPIOStateToString(GPIOState:LongWord):String;
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); inline;
Note | None documented |
---|
procedure GPIOLogWarn(GPIO:PGPIODevice; const AText:String); inline;
Note | None documented |
---|
procedure GPIOLogError(GPIO:PGPIODevice; const AText:String); inline;
Note | None documented |
---|
procedure GPIOLogDebug(GPIO:PGPIODevice; const AText:String); inline;
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