1
0
mirror of https://github.com/xtacocorex/CHIP_IO synced 2025-07-20 12:53:22 +00:00

2 Commits

9 changed files with 90 additions and 14 deletions

View File

@ -1,3 +1,12 @@
0.5.8
---
* Added 3 pins for the CHIP Pro as allowable for setting callbacks and edge detection to close out Issue #68
0.5.7
---
* Added the I2S pins on the CHIP Pro as GPIO capable
* Added per PWM/SoftPWM cleanup per Issue #64
0.5.6 0.5.6
--- ---
* Fix for Issue #63 where re-setting up a pin wasn't lining up with RPi.GPIO standards. Calling setup after the first time will now update direction. * Fix for Issue #63 where re-setting up a pin wasn't lining up with RPi.GPIO standards. Calling setup after the first time will now update direction.

14
debian/changelog vendored
View File

@ -1,3 +1,17 @@
chip-io (0.5.8-1) unstable; urgency=low
* Added 3 pins for the CHIP Pro as allowable for setting callbacks and edge
detection to close out Issue #68
-- Robert Wolterman <robert.wolterman@gmail.com> Tue, 02 May 2017 22:43:00 -0600
chip-io (0.5.7-1) unstable; urgency=low
* Added the I2S pins on the CHIP Pro as GPIO capable
* Added per PWM/SoftPWM cleanup per Issue #64
-- Robert Wolterman <robert.wolterman@gmail.com> Mon, 01 May 2017 22:47:00 -0600
chip-io (0.5.6-1) unstable; urgency=low chip-io (0.5.6-1) unstable; urgency=low
* Fix for Issue #63 where re-setting up a pin wasn't lining up with RPi.GPIO standards. Calling setup after the first time will now update direction. * Fix for Issue #63 where re-setting up a pin wasn't lining up with RPi.GPIO standards. Calling setup after the first time will now update direction.

4
debian/files vendored
View File

@ -1,2 +1,2 @@
python-chip-io_0.5.5-1_armhf.deb python optional python-chip-io_0.5.7-1_armhf.deb python optional
python3-chip-io_0.5.5-1_armhf.deb python optional python3-chip-io_0.5.7-1_armhf.deb python optional

View File

@ -13,7 +13,7 @@ classifiers = ['Development Status :: 3 - Alpha',
'Topic :: System :: Hardware'] 'Topic :: System :: Hardware']
setup(name = 'CHIP_IO', setup(name = 'CHIP_IO',
version = '0.5.6', version = '0.5.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',

View File

@ -138,6 +138,11 @@ pins_t pins_info[] = {
{ "CSID7", "D7", "U14_38", 139, BASE_METHOD_AS_IS, -1, -1, BOTH}, { "CSID7", "D7", "U14_38", 139, BASE_METHOD_AS_IS, -1, -1, BOTH},
{ "GND", "GND", "U14_39", -1, BASE_METHOD_AS_IS, -1, -1, BOTH}, { "GND", "GND", "U14_39", -1, BASE_METHOD_AS_IS, -1, -1, BOTH},
{ "GND", "GND", "U14_40", -1, BASE_METHOD_AS_IS, -1, -1, BOTH}, { "GND", "GND", "U14_40", -1, BASE_METHOD_AS_IS, -1, -1, BOTH},
{ "I2S-MCLK", "EINT19", "21", 37, BASE_METHOD_AS_IS, -1, -1, CHIPPRO},
{ "I2S-BCLK", "I2S-BCLK", "22", 38, BASE_METHOD_AS_IS, -1, -1, CHIPPRO},
{ "I2S-LCLK", "I2S-LCLK", "23", 39, BASE_METHOD_AS_IS, -1, -1, CHIPPRO},
{ "I2S-DO", "I2S-DO", "24", 40, BASE_METHOD_AS_IS, -1, -1, CHIPPRO},
{ "I2S-DI", "EINT24", "25", 41, BASE_METHOD_AS_IS, -1, -1, CHIPPRO},
{ NULL, NULL, NULL, -1, 0, -1, -1, -1} { NULL, NULL, NULL, -1, 0, -1, -1, -1}
}; };

View File

@ -85,6 +85,6 @@ void define_constants(PyObject *module)
bcm = Py_BuildValue("i", BCM); bcm = Py_BuildValue("i", BCM);
PyModule_AddObject(module, "BCM", bcm); PyModule_AddObject(module, "BCM", bcm);
version = Py_BuildValue("s", "0.5.6"); version = Py_BuildValue("s", "0.5.8");
PyModule_AddObject(module, "VERSION", version); PyModule_AddObject(module, "VERSION", version);
} }

View File

@ -596,6 +596,9 @@ static PyObject *py_add_event_callback(PyObject *self, PyObject *args, PyObject
// check to ensure gpio is one of the allowed pins // check to ensure gpio is one of the allowed pins
if (gpio != lookup_gpio_by_name("AP-EINT3") if (gpio != lookup_gpio_by_name("AP-EINT3")
&& gpio != lookup_gpio_by_name("AP-EINT1") && gpio != lookup_gpio_by_name("AP-EINT1")
&& gpio != lookup_gpio_by_name("I2S-MCLK") // CHIP PRO
&& gpio != lookup_gpio_by_name("I2S-DI") // CHIP PRO
&& gpio != lookup_gpio_by_name("PWM1") // CHIP PRO
&& !(gpio >= lookup_gpio_by_name("XIO-P0") && gpio <= lookup_gpio_by_name("XIO-P7"))) { && !(gpio >= lookup_gpio_by_name("XIO-P0") && gpio <= lookup_gpio_by_name("XIO-P7"))) {
PyErr_SetString(PyExc_ValueError, "Callbacks currently available on AP-EINT1, AP-EINT3, and XIO-P0 to XIO-P7 only"); PyErr_SetString(PyExc_ValueError, "Callbacks currently available on AP-EINT1, AP-EINT3, and XIO-P0 to XIO-P7 only");
return NULL; return NULL;
@ -665,6 +668,9 @@ static PyObject *py_add_event_detect(PyObject *self, PyObject *args, PyObject *k
// check to ensure gpio is one of the allowed pins // check to ensure gpio is one of the allowed pins
if (gpio != lookup_gpio_by_name("AP-EINT3") if (gpio != lookup_gpio_by_name("AP-EINT3")
&& gpio != lookup_gpio_by_name("AP-EINT1") && gpio != lookup_gpio_by_name("AP-EINT1")
&& gpio != lookup_gpio_by_name("I2S-MCLK") // CHIP PRO
&& gpio != lookup_gpio_by_name("I2S-DI") // CHIP PRO
&& gpio != lookup_gpio_by_name("PWM1") // CHIP PRO
&& !(gpio >= lookup_gpio_by_name("XIO-P0") && gpio <= lookup_gpio_by_name("XIO-P7"))) { && !(gpio >= lookup_gpio_by_name("XIO-P0") && gpio <= lookup_gpio_by_name("XIO-P7"))) {
PyErr_SetString(PyExc_ValueError, "Edge Detection currently available on AP-EINT1, AP-EINT3, and XIO-P0 to XIO-P7 only"); PyErr_SetString(PyExc_ValueError, "Edge Detection currently available on AP-EINT1, AP-EINT3, and XIO-P0 to XIO-P7 only");
return NULL; return NULL;
@ -741,6 +747,9 @@ static PyObject *py_remove_event_detect(PyObject *self, PyObject *args)
// check to ensure gpio is one of the allowed pins // check to ensure gpio is one of the allowed pins
if (gpio != lookup_gpio_by_name("AP-EINT3") if (gpio != lookup_gpio_by_name("AP-EINT3")
&& gpio != lookup_gpio_by_name("AP-EINT1") && gpio != lookup_gpio_by_name("AP-EINT1")
&& gpio != lookup_gpio_by_name("I2S-MCLK") // CHIP PRO
&& gpio != lookup_gpio_by_name("I2S-DI") // CHIP PRO
&& gpio != lookup_gpio_by_name("PWM1") // CHIP PRO
&& !(gpio >= lookup_gpio_by_name("XIO-P0") && gpio <= lookup_gpio_by_name("XIO-P7"))) { && !(gpio >= lookup_gpio_by_name("XIO-P0") && gpio <= lookup_gpio_by_name("XIO-P7"))) {
PyErr_SetString(PyExc_ValueError, "Edge Detection currently available on AP-EINT1, AP-EINT3, and XIO-P0 to XIO-P7 only"); PyErr_SetString(PyExc_ValueError, "Edge Detection currently available on AP-EINT1, AP-EINT3, and XIO-P0 to XIO-P7 only");
return NULL; return NULL;
@ -845,6 +854,9 @@ static PyObject *py_wait_for_edge(PyObject *self, PyObject *args)
// check to ensure gpio is one of the allowed pins // check to ensure gpio is one of the allowed pins
if (gpio != lookup_gpio_by_name("AP-EINT3") if (gpio != lookup_gpio_by_name("AP-EINT3")
&& gpio != lookup_gpio_by_name("AP-EINT1") && gpio != lookup_gpio_by_name("AP-EINT1")
&& gpio != lookup_gpio_by_name("I2S-MCLK") // CHIP PRO
&& gpio != lookup_gpio_by_name("I2S-DI") // CHIP PRO
&& gpio != lookup_gpio_by_name("PWM1") // CHIP PRO
&& !(gpio >= lookup_gpio_by_name("XIO-P0") && gpio <= lookup_gpio_by_name("XIO-P7"))) { && !(gpio >= lookup_gpio_by_name("XIO-P0") && gpio <= lookup_gpio_by_name("XIO-P7"))) {
PyErr_SetString(PyExc_ValueError, "Edge Detection currently available on AP-EINT1, AP-EINT3, and XIO-P0 to XIO-P7 only"); PyErr_SetString(PyExc_ValueError, "Edge Detection currently available on AP-EINT1, AP-EINT3, and XIO-P0 to XIO-P7 only");
return NULL; return NULL;

View File

@ -34,11 +34,29 @@ SOFTWARE.
#include "common.h" #include "common.h"
#include "c_pwm.h" #include "c_pwm.h"
// python function cleanup() // python function cleanup(channel)
static PyObject *py_cleanup(PyObject *self, PyObject *args) static PyObject *py_cleanup(PyObject *self, PyObject *args, PyObject *kwargs)
{ {
// unexport the PWM char key[8];
char *channel;
static char *kwlist[] = {"channel", NULL};
clear_error_msg();
// Channel is optional
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|s", kwlist, &channel)) {
return NULL;
}
// The !channel fixes issues #50
if (channel == NULL || strcmp(channel, "\0") == 0) {
pwm_cleanup(); pwm_cleanup();
} else {
if (!get_pwm_key(channel, key)) {
pwm_cleanup();
}
pwm_disable(key);
}
Py_RETURN_NONE; Py_RETURN_NONE;
} }
@ -395,7 +413,7 @@ PyMethodDef pwm_methods[] = {
{"set_frequency", (PyCFunction)py_set_frequency, METH_VARARGS, "Change the frequency\nfrequency - frequency in Hz (freq > 0.0)" }, {"set_frequency", (PyCFunction)py_set_frequency, METH_VARARGS, "Change the frequency\nfrequency - frequency in Hz (freq > 0.0)" },
{"set_period_ns", (PyCFunction)py_set_period_ns, METH_VARARGS, "Change the period\nperiod_ns - period in nanoseconds" }, {"set_period_ns", (PyCFunction)py_set_period_ns, METH_VARARGS, "Change the period\nperiod_ns - period in nanoseconds" },
{"set_pulse_width_ns", (PyCFunction)py_set_pulse_width_ns, METH_VARARGS, "Change the period\npulse_width_ns - pulse width in nanoseconds" }, {"set_pulse_width_ns", (PyCFunction)py_set_pulse_width_ns, METH_VARARGS, "Change the period\npulse_width_ns - pulse width in nanoseconds" },
{"cleanup", py_cleanup, METH_VARARGS, "Clean up by resetting all GPIO channels that have been used by this program to INPUT with no pullup/pulldown and no event detection"}, {"cleanup", (PyCFunction)py_cleanup, METH_VARARGS | METH_KEYWORDS, "Clean up by resetting PWM channel(s) that have been used by this program to be disabled"},
{"toggle_debug", py_toggle_debug, METH_VARARGS, "Toggles the enabling/disabling of Debug print output"}, {"toggle_debug", py_toggle_debug, METH_VARARGS, "Toggles the enabling/disabling of Debug print output"},
{"is_chip_pro", py_is_chip_pro, METH_VARARGS, "Is hardware a CHIP Pro? Boolean False for normal CHIP/PocketCHIP (R8 SOC)"}, {"is_chip_pro", py_is_chip_pro, METH_VARARGS, "Is hardware a CHIP Pro? Boolean False for normal CHIP/PocketCHIP (R8 SOC)"},
{NULL, NULL, 0, NULL} {NULL, NULL, 0, NULL}

View File

@ -43,11 +43,29 @@ static PyObject *py_toggle_debug(PyObject *self, PyObject *args)
Py_RETURN_NONE; Py_RETURN_NONE;
} }
// python function cleanup() // python function cleanup(channel)
static PyObject *py_cleanup(PyObject *self, PyObject *args) static PyObject *py_cleanup(PyObject *self, PyObject *args, PyObject *kwargs)
{ {
// unexport the PWM char key[8];
char *channel;
static char *kwlist[] = {"channel", NULL};
clear_error_msg();
// Channel is optional
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|s", kwlist, &channel)) {
return NULL;
}
// The !channel fixes issues #50
if (channel == NULL || strcmp(channel, "\0") == 0) {
softpwm_cleanup(); softpwm_cleanup();
} else {
if (!get_key(channel, key)) {
softpwm_cleanup();
}
softpwm_disable(key);
}
Py_RETURN_NONE; Py_RETURN_NONE;
} }
@ -300,7 +318,7 @@ PyMethodDef pwm_methods[] = {
{"stop", (PyCFunction)py_stop_channel, METH_VARARGS | METH_KEYWORDS, "Stop the PWM channel. channel can be in the form of 'XIO-P0', or 'U14_13'"}, {"stop", (PyCFunction)py_stop_channel, METH_VARARGS | METH_KEYWORDS, "Stop the PWM channel. channel can be in the form of 'XIO-P0', or 'U14_13'"},
{"set_duty_cycle", (PyCFunction)py_set_duty_cycle, METH_VARARGS, "Change the duty cycle\ndutycycle - between 0.0 and 100.0" }, {"set_duty_cycle", (PyCFunction)py_set_duty_cycle, METH_VARARGS, "Change the duty cycle\ndutycycle - between 0.0 and 100.0" },
{"set_frequency", (PyCFunction)py_set_frequency, METH_VARARGS, "Change the frequency\nfrequency - frequency in Hz (freq > 0.0)" }, {"set_frequency", (PyCFunction)py_set_frequency, METH_VARARGS, "Change the frequency\nfrequency - frequency in Hz (freq > 0.0)" },
{"cleanup", (PyCFunction)py_cleanup, METH_VARARGS, "Clean up by resetting all GPIO channels that have been used by this program to INPUT with no pullup/pulldown and no event detection"}, {"cleanup", (PyCFunction)py_cleanup, METH_VARARGS | METH_KEYWORDS, "Clean up by resetting all GPIO channels that have been used by this program to INPUT with no pullup/pulldown and no event detection"},
{"toggle_debug", py_toggle_debug, METH_VARARGS, "Toggles the enabling/disabling of Debug print output"}, {"toggle_debug", py_toggle_debug, METH_VARARGS, "Toggles the enabling/disabling of Debug print output"},
{"is_chip_pro", py_is_chip_pro, METH_VARARGS, "Is hardware a CHIP Pro? Boolean False for normal CHIP/PocketCHIP (R8 SOC)"}, {"is_chip_pro", py_is_chip_pro, METH_VARARGS, "Is hardware a CHIP Pro? Boolean False for normal CHIP/PocketCHIP (R8 SOC)"},
{NULL, NULL, 0, NULL} {NULL, NULL, 0, NULL}