source/py_gpio.c
static PyObject *py_gpio_function(PyObject *self, PyObject *args)
{
  unsigned int gpio;
  int channel;
  int f;
  int fn;
  PyObject *func;

  if (!PyArg_ParseTuple(args, "i", &channel))
    return NULL;

  if (get_gpio_number(channel, &gpio))
    return NULL;

  if (mmap_gpio_mem())
    return NULL;

  f = gpio_function(gpio);

  switch (f)
  {
    case 0 : fn = INPUT;  break;
    case 1 : fn = OUTPUT; break;
    case 2 :
    case 3 :
    case 4 :
    case 5 :
    case 6 :
    case 7 : fn = f; break;
    default : fn = ALT_UNKNOWN; break;
  }

  func = Py_BuildValue("i", fn);
  return func;
}
// python function value = gpio_function(channel)
python function value = gpio_function(channel)
python function value = gpio_function ( channel )
static PyObject *py_gpio_function(PyObject *self, PyObject *args)
{
  unsigned int gpio;
  int channel;
  int f;
  int fn;
  PyObject *func;
  if (!PyArg_ParseTuple(args, "i", &channel))
    return NULL;
  if (get_gpio_number(channel, &gpio))
    return NULL;
  if (mmap_gpio_mem())
    return NULL;
  f = gpio_function(gpio);
  switch (f)
  {
    case 0 : fn = INPUT;  break;
    case 1 : fn = OUTPUT; break;
    case 2 :
    case 3 :
    case 4 :
    case 5 :
    case 6 :
    case 7 : fn = f; break;
    default : fn = ALT_UNKNOWN; break;
  }
  func = Py_BuildValue("i", fn);
  return func;
}
static PyObject * py_gpio_function ( PyObject * self , PyObject * args ) { unsigned int gpio ; int channel ; int f ; int fn ; PyObject * func ; if ( ! PyArg_ParseTuple ( args , " " , & channel ) ) return NULL ; if ( get_gpio_number ( channel , & gpio ) ) return NULL ; if ( mmap_gpio_mem ( ) ) return NULL ; f = gpio_function ( gpio ) ; switch ( f ) { case 0 : fn = INPUT ; break ; case 1 : fn = OUTPUT ; break ; case 2 : case 3 : case 4 : case 5 : case 6 : case 7 : fn = f ; break ; default : fn = ALT_UNKNOWN ; break ; } func = Py_BuildValue ( " " , fn ) ; return func ; }
python function value = gpio_function(channel)
python function value = gpio_function ( channel )