GPIO
You can use this module to perform operations on a GPIO pin, including setting the input/output direction, reading/writing the level value, and setting the interrupt service routine (ISR) function.
Since:
1.0
Summary
Files
Typedefs
Defines the function type of a GPIO interrupt service routine (ISR). |
Enumerations
GpioValue { = 0, GPIO_VAL_HIGH = 1, } |
|
GpioDirType { = 0, GPIO_DIR_OUT = 1, } |
Functions
GpioRead (uint16_t gpio, uint16_t val) |
|
GpioSetDir (uint16_t gpio, uint16_t dir) |
|
GpioSetIrq (uint16_t gpio, uint16_t mode, func, void *arg) |
|
GpioUnSetIrq (uint16_t gpio) |
|
GpioDisableIrq (uint16_t gpio) |
Details
GpioIrqFunc
Defines the function type of a GPIO interrupt service routine (ISR).
This function is used when you call to register the ISR for a GPIO pin.
Parameters:
gpio | Indicates the GPIO number of the ISR. |
data | Indicates the pointer to the private data passed to this ISR (The data is specified when the ISR is registered). |
Returns:
Returns 0 if the ISR function type is successfully defined; returns a negative value otherwise.
See also:
Enumeration Type Documentation
GpioDirType
Description:
Enumerates GPIO directions.
GpioValue
enum [GpioValue]($api-api-SmartVision-Devices-GPIO.md#ga6a25a3efddf2301c7b01a7f0af44fb11)
Description:
Enumerates GPIO level values.
GPIO_VAL_LOW | |
GPIO_VAL_HIGH | |
GPIO_VAL_ERR |
Function Documentation
GpioDisableIrq()
Description:
Disables a GPIO pin interrupt.
You can call this function when you need to temporarily mask a GPIO pin interrupt or cancel an ISR function.
Parameters:
gpio | Indicates the GPIO pin number. |
Returns:
Returns 0 if the GPIO pin interrupt is successfully disabled; returns a negative value otherwise.
Description:
Enables a GPIO pin interrupt.
Before enabling the interrupt, you must call GpioSetIrq to set the ISR function for the GPIO pin.
Parameters:
gpio | Indicates the GPIO pin number. |
Returns:
Returns 0 if the GPIO pin interrupt is successfully enabled; returns a negative value otherwise.
GpioGetDir()
int32_t GpioGetDir (uint16_t gpio, uint16_t * dir )
Description:
Obtains the input/output direction of a GPIO pin.
Parameters:
gpio | Indicates the GPIO pin number. |
dir | Indicates the pointer to the obtained input/output direction. For details, see GpioDirType. |
Returns:
Returns 0 if the GPIO pin direction is successfully obtained; returns a negative value otherwise.
GpioRead()
Description:
Reads the level value of a GPIO pin.
Before using this function, you need to call GpioSetDir to set the GPIO pin direction to input.
Parameters:
Returns:
Returns 0 if the GPIO pin level value is successfully read; returns a negative value otherwise.
GpioSetDir()
Description:
Sets the input/output direction for a GPIO pin.
Generally, you can set the direction to input when external level signals need to be read, and set the direction to output when the level signals need to be sent externally.
Parameters:
gpio | Indicates the GPIO pin number. |
dir | Indicates the direction to set. For details, see GpioDirType. |
Returns:
Returns 0 if the GPIO pin direction is successfully set; returns a negative value otherwise.
GpioSetIrq()
Description:
Sets the ISR function for a GPIO pin.
Before using a GPIO pin as an interrupt, you must call this function to set an ISR function for this GPIO pin, including the ISR parameters and the interrupt trigger mode. After the setting is successful, you also need to call GpioEnableIrq to enable the interrupt, so that the ISR function can respond correctly.
Parameters:
gpio | Indicates the GPIO pin number. |
mode | Indicates the interrupt trigger mode. For details, see OSAL_IRQF_TRIGGER_RISING. |
func | Indicates the ISR function to set, which is specified by . |
arg | Indicates the pointer to the parameters passed to the ISR function. |
Returns:
Returns 0 if the ISR function of the GPIO pin is successfully set; returns a negative value otherwise.
GpioUnSetIrq()
Description:
Cancels the setting of the ISR function for a GPIO pin.
If you do not need the GPIO pin as an interrupt, call this function to cancel the ISR function set via . Since this ISR function is no longer valid, you are advised to use GpioDisableIrq to disable the GPIO pin interrupt.
Parameters:
gpio | Indicates the GPIO pin number. |
Returns:
Returns 0 if the ISR function of the GPIO pin is successfully cancelled; returns a negative value otherwise.
GpioWrite()
Description:
Writes the level value for a GPIO pin.
Before using this function, you need to call to set the GPIO pin direction to output.
Parameters:
gpio | Indicates the GPIO pin number. |
val | Indicates the level value to be written. For details, see . |
Returns:
Returns 0 if the GPIO pin level value is successfully written; returns a negative value otherwise.