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:
2
setup.py
2
setup.py
@ -20,7 +20,7 @@ classifiers = ['Development Status :: 3 - Alpha',
|
|||||||
'Topic :: System :: Hardware']
|
'Topic :: System :: Hardware']
|
||||||
|
|
||||||
setup(name = 'CHIP_IO',
|
setup(name = 'CHIP_IO',
|
||||||
version = '0.0.7',
|
version = '0.0.8',
|
||||||
author = 'Robert Wolterman',
|
author = 'Robert Wolterman',
|
||||||
author_email = 'robert.wolterman@gmail.com',
|
author_email = 'robert.wolterman@gmail.com',
|
||||||
description = 'A module to control CHIP IO channels',
|
description = 'A module to control CHIP IO channels',
|
||||||
|
@ -76,6 +76,6 @@ void define_constants(PyObject *module)
|
|||||||
both_edge = Py_BuildValue("i", BOTH_EDGE);
|
both_edge = Py_BuildValue("i", BOTH_EDGE);
|
||||||
PyModule_AddObject(module, "BOTH", 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);
|
PyModule_AddObject(module, "VERSION", version);
|
||||||
}
|
}
|
||||||
|
@ -546,6 +546,19 @@ static PyObject *py_setwarnings(PyObject *self, PyObject *args)
|
|||||||
Py_RETURN_NONE;
|
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
|
// Internal unit tests
|
||||||
extern int num_get_xio_base;
|
extern int num_get_xio_base;
|
||||||
extern pins_t pins_info[];
|
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"},
|
{"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"},
|
{"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"},
|
{"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"},
|
{"selftest", py_selftest, METH_VARARGS, "Internal unit tests"},
|
||||||
{NULL, NULL, 0, NULL}
|
{NULL, NULL, 0, NULL}
|
||||||
};
|
};
|
||||||
|
@ -99,7 +99,9 @@ print "SETTING UP EDGE DETECTION ON XIO-P0"
|
|||||||
GPIO.add_event_detect("XIO-P0", GPIO.FALLING, myfuncallback)
|
GPIO.add_event_detect("XIO-P0", GPIO.FALLING, myfuncallback)
|
||||||
|
|
||||||
print "VERIFYING EDGE DETECT"
|
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()
|
edge = f.read()
|
||||||
f.close()
|
f.close()
|
||||||
print "EDGE: %s" % edge
|
print "EDGE: %s" % edge
|
||||||
|
Reference in New Issue
Block a user