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

Formal initial start at CHIP Pro support. Removed the custom DT Overlays, OverlayManager now pulls dtbo from chip-dt-overlays package from NTC. First commit to CHIP_IO from a CPro DevKit

This commit is contained in:
Robert Wolterman
2017-02-13 05:18:33 +00:00
parent 6bd2e61450
commit c5dbede3c4
16 changed files with 282 additions and 143 deletions

View File

@ -52,6 +52,41 @@ static PyObject *py_toggle_debug(PyObject *self, PyObject *args)
Py_RETURN_NONE;
}
static int init_module(void)
{
clear_error_msg();
// figure out if we're a chip pro
if (is_this_chippro() < 1) {
char err[2000];
snprintf(err, sizeof(err), "init_module error (%s)", get_error_msg());
PyErr_SetString(PyExc_RuntimeError, err);
return 0;
}
// After this point, ISCHIPPRO variable should be good to go
// If we make it here, we're good to go
if (DEBUG)
printf(" ** init_module: setup complete **\n");
module_setup = 1;
return 0;
}
// python function value = is_chip_pro
static PyObject *py_is_chip_pro(PyObject *self, PyObject *args)
{
PyObject *py_value;
if (!module_setup) {
init_module();
}
py_value = Py_BuildValue("i", ISCHIPPRO);
return py_value;
}
// python function start(channel, duty_cycle, freq)
static PyObject *py_start_channel(PyObject *self, PyObject *args, PyObject *kwargs)
{
@ -68,6 +103,10 @@ static PyObject *py_start_channel(PyObject *self, PyObject *args, PyObject *kwar
return NULL;
}
if (!module_setup) {
init_module();
}
if (!get_pwm_key(channel, key)) {
PyErr_SetString(PyExc_ValueError, "Invalid PWM key or name.");
return NULL;
@ -275,6 +314,7 @@ PyMethodDef pwm_methods[] = {
{"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"},
{"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)"},
{NULL, NULL, 0, NULL}
};