Skip to content

Commit 1db8671

Browse files
gpio: Add get_type function
Signed-off-by: Francois Berder <francois.berder@imgtec.com>
1 parent 0cb903d commit 1db8671

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

letmecreate/core/gpio.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,21 @@ def get_pin(mikrobus_index, pin_type):
7171
return pin.value
7272

7373

74+
def get_type(gpio_pin):
75+
"""Returns the type of the GPIO
76+
77+
Some GPIO's on the Mikrobus has some type (AN, PWM, INT, RST or CS). Other
78+
GPIO's don't have a type.
79+
80+
Note: An exception is thrown if the type of the gpio cannot be found.
81+
"""
82+
pin_type = ctypes.c_uint8(0)
83+
ret = _LIB.gpio_get_type(gpio_pin, ctypes.byref(pin_type))
84+
if ret < 0:
85+
raise Exception("gpio get type failed")
86+
return pin_type.value
87+
88+
7489
def set_direction(gpio_pin, direction):
7590
"""Configure GPIO as an input or an output.
7691

0 commit comments

Comments
 (0)