Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions source/c_pinmux.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <stdio.h>
#include <string.h>
#include <syslog.h>

#include "c_pinmux.h"
#include "common.h"
Expand Down Expand Up @@ -34,10 +35,10 @@ BBIO_err set_pin_mode(const char *key, const char *mode)
f = fopen(path, "w");
if (NULL == f) {
return BBIO_ACCESS;
}

}
syslog(LOG_DEBUG, "set_pin_mode() :: Pinmux file %s access OK", path);
fprintf(f, "%s", mode);
fclose(f);

syslog(LOG_DEBUG, "set_pin_mode() :: Set pinmux mode to %s for %s", mode, pin);
return BBIO_OK;
}
14 changes: 10 additions & 4 deletions source/py_gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,18 @@ static PyObject *py_setup_channel(__attribute__ ((unused)) PyObject *self, PyObj
}

} else {
if (pud == PUD_DOWN)
set_pin_mode(channel, "gpio_pd");
if (pud == PUD_DOWN)
res = set_pin_mode(channel, "gpio_pd");
else if (pud == PUD_UP)
set_pin_mode(channel, "gpio_pu");
res = set_pin_mode(channel, "gpio_pu");
else
set_pin_mode(channel, "gpio");
res = set_pin_mode(channel, "gpio");
}

//Check if set_pin_mode() returned no error
if (res != BBIO_OK) {
PyErr_SetString(PyExc_ValueError, "Set gpio mode failed, missing file or invalid permissions.");
return NULL;
}

gpio_direction[gpio] = direction;
Expand Down