Skip to content

Commit

Permalink
gpio: Add get_type function
Browse files Browse the repository at this point in the history
Signed-off-by: Francois Berder <[email protected]>
  • Loading branch information
francois-berder committed Feb 14, 2017
1 parent 0cb903d commit 1db8671
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions letmecreate/core/gpio.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,21 @@ def get_pin(mikrobus_index, pin_type):
return pin.value


def get_type(gpio_pin):
"""Returns the type of the GPIO
Some GPIO's on the Mikrobus has some type (AN, PWM, INT, RST or CS). Other
GPIO's don't have a type.
Note: An exception is thrown if the type of the gpio cannot be found.
"""
pin_type = ctypes.c_uint8(0)
ret = _LIB.gpio_get_type(gpio_pin, ctypes.byref(pin_type))
if ret < 0:
raise Exception("gpio get type failed")
return pin_type.value


def set_direction(gpio_pin, direction):
"""Configure GPIO as an input or an output.
Expand Down

0 comments on commit 1db8671

Please sign in to comment.