1
0
mirror of https://github.com/xtacocorex/CHIP_IO synced 2025-07-20 04:43:21 +00:00

Adding Python interface to get the base XIO numbers, fixes for gptest.py on the 4.4 kernel CHIPs

This commit is contained in:
Robert Wolterman
2016-07-03 11:49:17 -05:00
parent 92888aaca4
commit 9ee83c0b38
4 changed files with 19 additions and 3 deletions

View File

@ -20,7 +20,7 @@ classifiers = ['Development Status :: 3 - Alpha',
'Topic :: System :: Hardware']
setup(name = 'CHIP_IO',
version = '0.0.7',
version = '0.0.8',
author = 'Robert Wolterman',
author_email = 'robert.wolterman@gmail.com',
description = 'A module to control CHIP IO channels',

View File

@ -76,6 +76,6 @@ void define_constants(PyObject *module)
both_edge = Py_BuildValue("i", BOTH_EDGE);
PyModule_AddObject(module, "BOTH", both_edge);
version = Py_BuildValue("s", "0.0.7");
version = Py_BuildValue("s", "0.0.8");
PyModule_AddObject(module, "VERSION", version);
}

View File

@ -546,6 +546,19 @@ static PyObject *py_setwarnings(PyObject *self, PyObject *args)
Py_RETURN_NONE;
}
// python function base = get_xio_base()
static PyObject *py_gpio_base(PyObject *self, PyObject *args)
{
unsigned int value;
PyObject *py_value;
value = get_xio_base();
py_value = Py_BuildValue("i", value);
return py_value;
}
// Internal unit tests
extern int num_get_xio_base;
extern pins_t pins_info[];
@ -668,6 +681,7 @@ PyMethodDef gpio_methods[] = {
{"wait_for_edge", py_wait_for_edge, METH_VARARGS, "Wait for an edge.\ngpio - gpio channel\nedge - RISING, FALLING or BOTH"},
{"gpio_function", py_gpio_function, METH_VARARGS, "Return the current GPIO function (IN, OUT, ALT0)\ngpio - gpio channel"},
{"setwarnings", py_setwarnings, METH_VARARGS, "Enable or disable warning messages"},
{"get_gpio_base", py_gpio_base, METH_VARARGS, "Get the XIO base number for sysfs"},
{"selftest", py_selftest, METH_VARARGS, "Internal unit tests"},
{NULL, NULL, 0, NULL}
};

View File

@ -99,7 +99,9 @@ print "SETTING UP EDGE DETECTION ON XIO-P0"
GPIO.add_event_detect("XIO-P0", GPIO.FALLING, myfuncallback)
print "VERIFYING EDGE DETECT"
f = open("/sys/class/gpio/gpio408/edge", "r")
base = GPIO.get_gpio_base()
gfile = "/sys/class/gpio/gpio%d/edge" % base
f = open(gfile, "r")
edge = f.read()
f.close()
print "EDGE: %s" % edge