Difference between revisions of "Unit GPIO"
Line 537: | Line 537: | ||
=== Function declarations === | === Function declarations === | ||
---- | ---- | ||
− | |||
Line 548: | Line 547: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 563: | Line 562: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! GPIO |
| The GPIO device to start | | The GPIO device to start | ||
|- | |- | ||
− | ! | + | ! Return |
| ERROR_SUCCESS if completed or another error code on failure | | ERROR_SUCCESS if completed or another error code on failure | ||
|- | |- | ||
Line 578: | Line 577: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! GPIO |
| The GPIO device to stop | | The GPIO device to stop | ||
|- | |- | ||
− | ! | + | ! Return |
| ERROR_SUCCESS if completed or another error code on failure | | ERROR_SUCCESS if completed or another error code on failure | ||
|- | |- | ||
Line 593: | Line 592: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! GPIO |
| The GPIO device to read from | | The GPIO device to read from | ||
|- | |- | ||
− | ! | + | ! Reg |
| The memory register to read from | | The memory register to read from | ||
|- | |- | ||
− | ! | + | ! Return |
| The value of the memory register | | The value of the memory register | ||
|- | |- | ||
Line 611: | Line 610: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! GPIO |
| The GPIO device to write to | | The GPIO device to write to | ||
|- | |- | ||
− | ! | + | ! Reg |
| The memory register to write to | | The memory register to write to | ||
|- | |- | ||
− | ! | + | ! Return |
| The value to write to the register | | The value to write to the register | ||
|- | |- | ||
Line 629: | Line 628: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! GPIO |
| The GPIO device to get from | | The GPIO device to get from | ||
|- | |- | ||
− | ! | + | ! Pin |
| The pin to get the state for (eg GPIO_PIN_1) | | 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 | | The current state (eg GPIO_LEVEL_HIGH) or GPIO_LEVEL_UNKNOWN on failure | ||
|- | |- | ||
Line 647: | Line 646: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! GPIO |
| The GPIO device to wait for | | The GPIO device to wait for | ||
|- | |- | ||
− | ! | + | ! Pin |
| The pin to wait for the state to change (eg GPIO_PIN_1) | | The pin to wait for the state to change (eg GPIO_PIN_1) | ||
|- | |- | ||
− | ! | + | ! Trigger |
| The trigger event to wait for (eg GPIO_TRIGGER_HIGH) | | The trigger event to wait for (eg GPIO_TRIGGER_HIGH) | ||
|- | |- | ||
− | ! | + | ! Timeout |
| Number of milliseconds to wait for the change (INFINITE to wait forever) | | 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 | | The state after the change (eg GPIO_LEVEL_HIGH) or GPIO_LEVEL_UNKNOWN on failure or timeout | ||
|- | |- | ||
Line 671: | Line 670: | ||
{| 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 | | The GPIO device to schedule the callback for | ||
|- | |- | ||
− | ! | + | ! Pin |
| The pin to schedule the state change for (eg GPIO_PIN_1) | | 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) | | 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) | | The number of milliseconds before the scheduled trigger expires (INFINITE to never expire) | ||
|- | |- | ||
− | ! | + | ! Callback |
| The function to be called when the trigger occurs | | The function to be called when the trigger occurs | ||
|- | |- | ||
− | ! | + | ! Data |
| A pointer to be pass to the function when the trigger occurs (Optional) | | 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 | | 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 | | The pin and trigger that caused the event will be passed to the callback function | ||
|- | |- | ||
Line 704: | Line 703: | ||
{| 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 | | The GPIO device to cancel the callback for | ||
|- | |- | ||
− | ! | + | ! Pin |
| The pin to cancel the state change for (eg GPIO_PIN_1) | | 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 | | ERROR_SUCCESS if the callback was cancelled successfully or another error code on failure | ||
|- | |- | ||
Line 722: | Line 721: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! GPIO |
| The GPIO device to set for | | The GPIO device to set for | ||
|- | |- | ||
− | ! | + | ! Pin |
| The pin to set the state for (eg GPIO_PIN_1) | | The pin to set the state for (eg GPIO_PIN_1) | ||
|- | |- | ||
− | ! | + | ! Level |
| The state to set the pin to (eg GPIO_LEVEL_HIGH) | | The state to set the pin to (eg GPIO_LEVEL_HIGH) | ||
|- | |- | ||
− | ! | + | ! Return |
| ERROR_SUCCESS if completed successfully or another error code on failure | | ERROR_SUCCESS if completed successfully or another error code on failure | ||
|- | |- | ||
Line 743: | Line 742: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! GPIO |
| The GPIO device to get from | | The GPIO device to get from | ||
|- | |- | ||
− | ! | + | ! Pin |
| The pin to get the pull state for (eg GPIO_PIN_1) | | 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 | | The current pull state of the pin (eg GPIO_PULL_UP) or GPIO_PULL_UNKNOWN on failure | ||
|- | |- | ||
Line 761: | Line 760: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! GPIO |
| The GPIO device to set for | | The GPIO device to set for | ||
|- | |- | ||
− | ! | + | ! Pin |
| The pin to change the pull state for (eg GPIO_PIN_1) | | 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) | | The pull state to set for the pin (eg GPIO_PULL_UP) | ||
|- | |- | ||
− | ! | + | ! Return |
| ERROR_SUCCESS if completed successfully or another error code on failure | | ERROR_SUCCESS if completed successfully or another error code on failure | ||
|- | |- | ||
Line 782: | Line 781: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! GPIO |
| The GPIO device to get from | | The GPIO device to get from | ||
|- | |- | ||
− | ! | + | ! Pin |
| The pin to get the function for (eg GPIO_PIN_1) | | 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 | | The current function of the pin (eg GPIO_FUNCTION_IN) or GPIO_FUNCTION_UNKNOWN on failure | ||
|- | |- | ||
Line 800: | Line 799: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! GPIO |
| The GPIO device to set for | | The GPIO device to set for | ||
|- | |- | ||
− | ! | + | ! Pin |
| The pin to change the function for (eg GPIO_PIN_1) | | The pin to change the function for (eg GPIO_PIN_1) | ||
|- | |- | ||
− | ! | + | ! Mode |
| The function to set for the pin (eg GPIO_FUNCTION_OUT) | | The function to set for the pin (eg GPIO_FUNCTION_OUT) | ||
|- | |- | ||
− | ! | + | ! Return |
| ERROR_SUCCESS if completed successfully or another error code on failure | | ERROR_SUCCESS if completed successfully or another error code on failure | ||
|- | |- | ||
Line 821: | Line 820: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! GPIO |
| The GPIO device to get properties from | | The GPIO device to get properties from | ||
|- | |- | ||
− | ! | + | ! Properties |
| Pointer to a TGPIOProperties structure to fill in | | Pointer to a TGPIOProperties structure to fill in | ||
|- | |- | ||
− | ! | + | ! Return |
| ERROR_SUCCESS if completed or another error code on failure | | ERROR_SUCCESS if completed or another error code on failure | ||
|- | |- | ||
− | ! | + | ! Note |
| Replaced by GPIODeviceGetProperties for consistency | | Replaced by GPIODeviceGetProperties for consistency | ||
|- | |- | ||
Line 842: | Line 841: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! GPIO |
| The GPIO device to get properties from | | The GPIO device to get properties from | ||
|- | |- | ||
− | ! | + | ! Properties |
| Pointer to a TGPIOProperties structure to fill in | | Pointer to a TGPIOProperties structure to fill in | ||
|- | |- | ||
− | ! | + | ! Return |
| ERROR_SUCCESS if completed or another error code on failure | | ERROR_SUCCESS if completed or another error code on failure | ||
|- | |- | ||
Line 860: | Line 859: | ||
{| 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 872: | Line 871: | ||
{| 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 887: | Line 886: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! GPIO |
| The GPIO device to destroy | | The GPIO device to destroy | ||
|- | |- | ||
− | ! | + | ! Return |
| ERROR_SUCCESS if completed or another error code on failure | | ERROR_SUCCESS if completed or another error code on failure | ||
|- | |- | ||
Line 902: | Line 901: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! GPIO |
| The GPIO device to register | | The GPIO device to register | ||
|- | |- | ||
− | ! | + | ! Return |
| ERROR_SUCCESS if completed or another error code on failure | | ERROR_SUCCESS if completed or another error code on failure | ||
|- | |- | ||
Line 917: | Line 916: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! GPIO |
| The GPIO device to deregister | | The GPIO device to deregister | ||
|- | |- | ||
− | ! | + | ! Return |
| ERROR_SUCCESS if completed or another error code on failure | | ERROR_SUCCESS if completed or another error code on failure | ||
|- | |- | ||
Line 932: | Line 931: | ||
{| 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 | | The ID number of the GPIO device to find | ||
|- | |- | ||
− | ! | + | ! Return |
| Pointer to GPIO device entry or nil if not found | | Pointer to GPIO device entry or nil if not found | ||
|- | |- | ||
Line 947: | Line 946: | ||
{| 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) | | The name of the GPIO to find (eg GPIO0) | ||
|- | |- | ||
− | ! | + | ! Return |
| Pointer to GPIO device entry or nil if not found | | Pointer to GPIO device entry or nil if not found | ||
|- | |- | ||
Line 962: | Line 961: | ||
{| 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) | | The description of the GPIO to find (eg BCM2836 GPIO) | ||
|- | |- | ||
− | ! | + | ! Return |
| Pointer to GPIO device entry or nil if not found | | Pointer to GPIO device entry or nil if not found | ||
|- | |- | ||
Line 977: | Line 976: | ||
{| 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 | | 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 | | 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 | | ERROR_SUCCESS if completed or another error code on failure | ||
|- | |- | ||
Line 995: | Line 994: | ||
{| 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) | | The GPIO device to notify changes for (Optional, pass nil for all GPIO devices) | ||
|- | |- | ||
− | ! | + | ! Callback |
| The function to call when a notification event occurs | | The function to call when a notification event occurs | ||
|- | |- | ||
− | ! | + | ! Data |
| A private data pointer to pass to callback when a notification event occurs | | 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) | | The events to register for notification of (eg DEVICE_NOTIFICATION_REGISTER) | ||
|- | |- | ||
− | ! | + | ! Flags |
| The flags to control the notification (eg NOTIFIER_FLAG_WORKER) | | The flags to control the notification (eg NOTIFIER_FLAG_WORKER) | ||
|- | |- | ||
Line 1,022: | Line 1,021: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 1,034: | Line 1,033: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Pin |
| The pin to get the state for (eg GPIO_PIN_1) | | 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 | | The current state (eg GPIO_LEVEL_HIGH) or GPIO_LEVEL_UNKNOWN on failure | ||
|- | |- | ||
Line 1,049: | Line 1,048: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Pin |
| The pin to wait for the state to change (eg GPIO_PIN_1) | | The pin to wait for the state to change (eg GPIO_PIN_1) | ||
|- | |- | ||
− | ! | + | ! Trigger |
| The trigger event to wait for (eg GPIO_TRIGGER_HIGH) | | The trigger event to wait for (eg GPIO_TRIGGER_HIGH) | ||
|- | |- | ||
− | ! | + | ! Timeout |
| Number of milliseconds to wait for the change (INFINITE to wait forever) | | 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 | | The state after the change (eg GPIO_LEVEL_HIGH) or GPIO_LEVEL_UNKNOWN on failure or timeout | ||
|- | |- | ||
Line 1,070: | Line 1,069: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Pin |
| The pin to schedule the state change for (eg GPIO_PIN_1) | | 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) | | 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) | | The number of milliseconds before the scheduled trigger expires (INFINITE to never expire) | ||
|- | |- | ||
− | ! | + | ! Callback |
| The function to be called when the trigger occurs | | The function to be called when the trigger occurs | ||
|- | |- | ||
− | ! | + | ! Data |
| A pointer to be pass to the function when the trigger occurs (Optional) | | 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 | | 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 | | The pin and trigger that caused the event will be passed to the callback function | ||
|- | |- | ||
Line 1,100: | Line 1,099: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Pin |
| The pin to set the state for (eg GPIO_PIN_1) | | The pin to set the state for (eg GPIO_PIN_1) | ||
|- | |- | ||
− | ! | + | ! Level |
| The state to set the pin to (eg GPIO_LEVEL_HIGH) | | The state to set the pin to (eg GPIO_LEVEL_HIGH) | ||
|- | |- | ||
− | ! | + | ! Return |
| ERROR_SUCCESS if completed successfully or another error code on failure | | ERROR_SUCCESS if completed successfully or another error code on failure | ||
|- | |- | ||
Line 1,118: | Line 1,117: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Pin |
| The pin to get the pull state for (eg GPIO_PIN_1) | | 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 | | The current pull state of the pin (eg GPIO_PULL_UP) or GPIO_PULL_UNKNOWN on failure | ||
|- | |- | ||
Line 1,133: | Line 1,132: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Pin |
| The pin to change the pull state for (eg GPIO_PIN_1) | | 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) | | The pull state to set for the pin (eg GPIO_PULL_UP) | ||
|- | |- | ||
− | ! | + | ! Return |
| ERROR_SUCCESS if completed successfully or another error code on failure | | ERROR_SUCCESS if completed successfully or another error code on failure | ||
|- | |- | ||
Line 1,151: | Line 1,150: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Pin |
| The pin to get the function for (eg GPIO_PIN_1) | | 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 | | The current function of the pin (eg GPIO_FUNCTION_IN) or GPIO_FUNCTION_UNKNOWN on failure | ||
|- | |- | ||
Line 1,166: | Line 1,165: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Pin |
| The pin to change the function for (eg GPIO_PIN_1) | | The pin to change the function for (eg GPIO_PIN_1) | ||
|- | |- | ||
− | ! | + | ! Mode |
| The function to set for the pin (eg GPIO_FUNCTION_OUT) | | The function to set for the pin (eg GPIO_FUNCTION_OUT) | ||
|- | |- | ||
− | ! | + | ! Return |
| ERROR_SUCCESS if completed successfully or another error code on failure | | ERROR_SUCCESS if completed successfully or another error code on failure | ||
|- | |- | ||
Line 1,187: | Line 1,186: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 1,199: | Line 1,198: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 1,211: | Line 1,210: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 1,223: | Line 1,222: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 1,235: | Line 1,234: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
− | | Event must be registered by calling GPIODeviceRegisterEvent | + | | Event must be registered by calling GPIODeviceRegisterEvent |
+ | Caller must hold the GPIO device lock | ||
|- | |- | ||
|} | |} | ||
Line 1,247: | Line 1,247: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
− | | Event must be deregistered first by calling GPIODeviceDeregisterEvent | + | | Event must be deregistered first by calling GPIODeviceDeregisterEvent |
+ | Caller must hold the GPIO device lock | ||
|- | |- | ||
|} | |} | ||
Line 1,259: | Line 1,260: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
− | | Event must be created by calling GPIODeviceCreateEvent | + | | Event must be created by calling GPIODeviceCreateEvent |
+ | Caller must hold the GPIO device lock | ||
|- | |- | ||
|} | |} | ||
Line 1,271: | Line 1,273: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
− | | Event must be destroyed by calling GPIODeviceDestroyEvent | + | | Event must be destroyed by calling GPIODeviceDestroyEvent |
+ | Caller must hold the GPIO device lock | ||
|- | |- | ||
|} | |} | ||
Line 1,283: | Line 1,286: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 1,295: | Line 1,298: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 1,307: | Line 1,310: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 1,319: | Line 1,322: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 1,331: | Line 1,334: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 1,343: | Line 1,346: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 1,355: | Line 1,358: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 1,367: | Line 1,370: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 1,379: | Line 1,382: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 1,391: | Line 1,394: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- |
Revision as of 03:41, 20 April 2018
Return to Unit Reference
Contents
[hide]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_TYPE_*
GPIO_STATE_*
GPIO_FLAG_*
GPIO_EVENT_FLAG_*
GPIO_LOG_*
Type definitions
GPIO properties
GPIO event
GPIO pin
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
GPIO pin information
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
GPIO functions
function GPIODeviceStart(GPIO:PGPIODevice):LongWord;
function GPIODeviceStop(GPIO:PGPIODevice):LongWord;
function GPIODeviceRead(GPIO:PGPIODevice; Reg:LongWord):LongWord;
procedure GPIODeviceWrite(GPIO:PGPIODevice; Reg,Value:LongWord);
function GPIODeviceInputGet(GPIO:PGPIODevice; Pin:LongWord):LongWord;
function GPIODeviceInputWait(GPIO:PGPIODevice; Pin,Trigger,Timeout:LongWord):LongWord;
function GPIODeviceInputEvent(GPIO:PGPIODevice; Pin,Trigger,Flags,Timeout:LongWord; Callback:TGPIOCallback; Data:Pointer):LongWord;
function GPIODeviceInputCancel(GPIO:PGPIODevice; Pin:LongWord):LongWord;
function GPIODeviceOutputSet(GPIO:PGPIODevice; Pin,Level:LongWord):LongWord;
function GPIODevicePullGet(GPIO:PGPIODevice;Pin:LongWord):LongWord;
function GPIODevicePullSelect(GPIO:PGPIODevice; Pin,Mode:LongWord):LongWord;
function GPIODeviceFunctionGet(GPIO:PGPIODevice; Pin:LongWord):LongWord;
function GPIODeviceFunctionSelect(GPIO:PGPIODevice; Pin,Mode:LongWord):LongWord;
function GPIODeviceProperties(GPIO:PGPIODevice; Properties:PGPIOProperties):LongWord; inline;
function GPIODeviceGetProperties(GPIO:PGPIODevice; Properties:PGPIOProperties):LongWord;
function GPIODeviceCreateEx(Size:LongWord):PGPIODevice;
function GPIODeviceDestroy(GPIO:PGPIODevice):LongWord;
function GPIODeviceRegister(GPIO:PGPIODevice):LongWord;
function GPIODeviceDeregister(GPIO:PGPIODevice):LongWord;
function GPIODeviceFind(GPIOId:LongWord):PGPIODevice;
function GPIODeviceFindByName(const Name:String):PGPIODevice; inline;
function GPIODeviceFindByDescription(const Description:String):PGPIODevice; inline;
function GPIODeviceEnumerate(Callback:TGPIOEnumerate; Data:Pointer):LongWord;
function GPIODeviceNotification(GPIO:PGPIODevice; Callback:TGPIONotification; Data:Pointer; Notification,Flags:LongWord):LongWord;
RTL GPIO functions
function SysGPIOInputGet(Pin:LongWord):LongWord;
function SysGPIOInputWait(Pin,Trigger,Timeout:LongWord):LongWord;
function SysGPIOInputEvent(Pin,Trigger,Timeout:LongWord; Callback:TGPIOCallback; Data:Pointer):LongWord;
function SysGPIOOutputSet(Pin,Level:LongWord):LongWord;
function SysGPIOPullGet(Pin:LongWord):LongWord;
function SysGPIOPullSelect(Pin,Mode:LongWord):LongWord;
function SysGPIOFunctionGet(Pin:LongWord):LongWord;
function SysGPIOFunctionSelect(Pin,Mode:LongWord):LongWord;
GPIO helper functions
function GPIODeviceGetDefault:PGPIODevice; inline;
function GPIODeviceSetDefault(GPIO:PGPIODevice):LongWord;
function GPIODeviceCheck(GPIO:PGPIODevice):PGPIODevice;
function GPIODeviceCreateEvent(GPIO:PGPIODevice; Pin:PGPIOPin; Callback:TGPIOCallback; Data:Pointer; Timeout:LongWord):PGPIOEvent;
function GPIODeviceDestroyEvent(GPIO:PGPIODevice; Event:PGPIOEvent):LongWord;
function GPIODeviceRegisterEvent(GPIO:PGPIODevice; Pin:PGPIOPin; Event:PGPIOEvent):LongWord;
function GPIODeviceDeregisterEvent(GPIO:PGPIODevice;Pin:PGPIOPin;Event:PGPIOEvent):LongWord;
procedure GPIOLog(Level:LongWord; GPIO:PGPIODevice; const AText:String);
procedure GPIOLogInfo(GPIO:PGPIODevice; const AText:String); inline;
procedure GPIOLogWarn(GPIO:PGPIODevice; const AText:String); inline;
procedure GPIOLogError(GPIO:PGPIODevice; const AText:String); inline;
procedure GPIOLogDebug(GPIO:PGPIODevice; const AText:String); inline;
Return to Unit Reference