[Armadeus-commitlog] armadeus branch, master, updated. release-3.2-259-g64b9be3
Brought to you by:
sszy
|
From: Fabien M <fa...@us...> - 2010-03-23 13:47:32
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "armadeus".
The branch, master has been updated
via 64b9be3b70e37014e7529bb4f1eca33971591dff (commit)
via 74953339251acf7323dc305c7c218408a55504d2 (commit)
via d2a7cf989baaed0ce507f0492aac7e097940ee5e (commit)
from 0b5985b38102d2800db96f7bd29af6bdd15f2188 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 64b9be3b70e37014e7529bb4f1eca33971591dff
Author: Fabien Marteau <fab...@ar...>
Date: Tue Mar 23 14:45:12 2010 +0100
[as_devices] AsGpio python wrapper in progress
commit 74953339251acf7323dc305c7c218408a55504d2
Author: Fabien Marteau <fab...@ar...>
Date: Tue Mar 23 14:16:49 2010 +0100
codings rules
commit d2a7cf989baaed0ce507f0492aac7e097940ee5e
Author: Fabien Marteau <fab...@ar...>
Date: Tue Mar 23 12:16:58 2010 +0100
[as_devices] Gpio python wrapper in progress
-----------------------------------------------------------------------
Summary of changes:
target/packages/as_devices/c/as_gpio.c | 26 ++--
target/packages/as_devices/c/as_gpio.h | 16 ++--
target/packages/as_devices/python/Makefile | 20 +++-
.../packages/as_devices/python/src/AsGpio_wrap.c | 128 ++++++++++++++++++++
.../packages/as_devices/python/src/AsGpio_wrap.h | 45 +++++++
5 files changed, 209 insertions(+), 26 deletions(-)
create mode 100644 target/packages/as_devices/python/src/AsGpio_wrap.c
create mode 100644 target/packages/as_devices/python/src/AsGpio_wrap.h
diff --git a/target/packages/as_devices/c/as_gpio.c b/target/packages/as_devices/c/as_gpio.c
index 34a7c9a..b6adb0d 100644
--- a/target/packages/as_devices/c/as_gpio.c
+++ b/target/packages/as_devices/c/as_gpio.c
@@ -86,7 +86,7 @@ as_gpio_open(char aPortChar)
/*------------------------------------------------------------------------------*/
int32_t
-as_gpio_set_pin_direction(struct as_gpio_device *dev,
+as_gpio_set_pin_direction(struct as_gpio_device *aDev,
int aPinNum,
int aDirection)
{
@@ -94,20 +94,20 @@ as_gpio_set_pin_direction(struct as_gpio_device *dev,
int portval;
/* Set LED PIN as GPIO; read/modify/write */
- ret = ioctl(dev->fdev, GPIORDMODE, &portval);
+ ret = ioctl(aDev->fdev, GPIORDMODE, &portval);
if (ret < 0) {
return ret;
}
portval |= (1 << aPinNum);
- ret = ioctl(dev->fdev, GPIOWRMODE, &portval);
+ ret = ioctl(aDev->fdev, GPIOWRMODE, &portval);
if (ret < 0) {
return ret;
}
/* set direction */
- ret = ioctl(dev->fdev, GPIORDDIRECTION, &portval);
+ ret = ioctl(aDev->fdev, GPIORDDIRECTION, &portval);
if (ret < 0) {
return ret;
}
@@ -118,7 +118,7 @@ as_gpio_set_pin_direction(struct as_gpio_device *dev,
portval |= (1 << aPinNum);
}
- ret = ioctl(dev->fdev, GPIOWRDIRECTION, &portval);
+ ret = ioctl(aDev->fdev, GPIOWRDIRECTION, &portval);
if (ret < 0) {
return ret;
}
@@ -128,14 +128,14 @@ as_gpio_set_pin_direction(struct as_gpio_device *dev,
/*------------------------------------------------------------------------------*/
int32_t
-as_gpio_set_pin_value( struct as_gpio_device *dev,
+as_gpio_set_pin_value( struct as_gpio_device *aDev,
int aPinNum,
int aValue)
{
int ret=0;
int portval;
- ret = ioctl(dev->fdev, GPIORDDATA, &portval);
+ ret = ioctl(aDev->fdev, GPIORDDATA, &portval);
if (ret < 0) {
return ret;
}
@@ -145,7 +145,7 @@ as_gpio_set_pin_value( struct as_gpio_device *dev,
} else {
portval |= (1 << aPinNum);
}
- ret = ioctl(dev->fdev, GPIOWRDATA, &portval);
+ ret = ioctl(aDev->fdev, GPIOWRDATA, &portval);
if (ret < 0) {
return ret;
}
@@ -155,13 +155,13 @@ as_gpio_set_pin_value( struct as_gpio_device *dev,
/*------------------------------------------------------------------------------*/
-int32_t as_gpio_get_pin_value( struct as_gpio_device *dev,
+int32_t as_gpio_get_pin_value( struct as_gpio_device *aDev,
int aPinNum)
{
int ret=0;
int portval;
- ret = ioctl(dev->fdev, GPIORDDATA, &portval);
+ ret = ioctl(aDev->fdev, GPIORDDATA, &portval);
if (ret < 0) {
return ret;
}
@@ -176,11 +176,11 @@ int32_t as_gpio_get_pin_value( struct as_gpio_device *dev,
/*------------------------------------------------------------------------------*/
int32_t
-as_gpio_close(struct as_gpio_device *dev)
+as_gpio_close(struct as_gpio_device *aDev)
{
int ret;
- ret = close(dev->fdev);
- free(dev);
+ ret = close(aDev->fdev);
+ free(aDev);
return 0;
}
diff --git a/target/packages/as_devices/c/as_gpio.h b/target/packages/as_devices/c/as_gpio.h
index 4b98c84..a83a8fc 100644
--- a/target/packages/as_devices/c/as_gpio.h
+++ b/target/packages/as_devices/c/as_gpio.h
@@ -48,46 +48,46 @@ struct as_gpio_device *as_gpio_open(char aPortChar);
/** @brief Set pin direction
*
- * @param aPortChar port character in upper case
+ * @param aDev as_gpio_device pointer structure
* @param aPinNum pin number
* @param aDirection direction 0:input 1:output
*
* @return error if negative value
*/
-int32_t as_gpio_set_pin_direction( struct as_gpio_device *dev,
+int32_t as_gpio_set_pin_direction( struct as_gpio_device *aDev,
int aPinNum,
int aDirection);
/** @brief Set pin value
*
- * @param aPortChar port character in upper case
+ * @param aDev as_gpio_device pointer structure
* @param aPinNum pin number
* @param aValue value of pin (1 or 0)
*
* @return error if negative
*/
-int32_t as_gpio_set_pin_value( struct as_gpio_device *dev,
+int32_t as_gpio_set_pin_value( struct as_gpio_device *aDev,
int aPinNum,
int aValue);
/** @brief Get pin value
*
- * @param aPortChar port character in upper case
+ * @param aDev as_gpio_device pointer structure
* @param aPinNum pin number
*
* @return pin value if positive or null, error if negative
*/
-int32_t as_gpio_get_pin_value( struct as_gpio_device *dev,
+int32_t as_gpio_get_pin_value( struct as_gpio_device *aDev,
int aPinNum);
/** @brief Close port access
*
- * @param aPortChar port character in upper case
+ * @param aDev as_gpio_device pointer structure
*
* @return pin value if positive or null, error if negative
*/
-int32_t as_gpio_close( struct as_gpio_device *dev);
+int32_t as_gpio_close( struct as_gpio_device *aDev);
#ifdef __cplusplus
}
diff --git a/target/packages/as_devices/python/Makefile b/target/packages/as_devices/python/Makefile
index 1d4008f..232dcb8 100644
--- a/target/packages/as_devices/python/Makefile
+++ b/target/packages/as_devices/python/Makefile
@@ -1,9 +1,19 @@
-# to compile c tests
-# make CC=~/armadeus_trees/apf27/buildroot/build_armv5te/staging_dir/usr/bin/arm-linux-gcc
-#
+# Default values for local compiling:
+ARMADEUS_BASE_DIR=../../../../
+include $(ARMADEUS_BASE_DIR)/Makefile.in
+
+ifeq ($(ARMADEUS_BOARD_NAME),apf9328)
+CFLAGS=-Wall -g -O0 -DAPF9328
+else
+ifeq ($(ARMADEUS_BOARD_NAME),apf27)
+CFLAGS=-Wall -g -O0 -DAPF27
+endif
+endif
-CFLAGS=-Wall -g -O0
LDFLAGS=
+CC:=$(ARMADEUS_TOOLCHAIN_PATH)/arm-linux-gcc
+CXX:=$(ARMADEUS_TOOLCHAIN_PATH)/arm-linux-g++
+STRIP:=$(ARMADEUS_TOOLCHAIN_PATH)arm-linux-sstrip
INCLUDE_LIB=../c/
@@ -11,7 +21,7 @@ AS_LIB=../c/libas_devices.so
LIBNAME=AsDevices
-WRAPPER_LIBS=Apf27Pwm_wrap.so
+WRAPPER_LIBS=AsGpio_wrap.so
WRAPPER_DIR=src
PYTHON_VERS=2.4
diff --git a/target/packages/as_devices/python/src/AsGpio_wrap.c b/target/packages/as_devices/python/src/AsGpio_wrap.c
new file mode 100644
index 0000000..19821ec
--- /dev/null
+++ b/target/packages/as_devices/python/src/AsGpio_wrap.c
@@ -0,0 +1,128 @@
+/*
+** THE ARMadeus Systems
+**
+** Copyright (C) 2010 The armadeus systems team
+** Fabien Marteau <fab...@ar...>
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Lesser General Public
+** License as published by the Free Software Foundation; either
+** version 2.1 of the License, or (at your option) any later version.
+**
+** This library is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public
+** License along with this library; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+#include "AsGpio_wrap.h"
+#include "as_gpio.h"
+
+/* Init module */
+//void initAsGpio();
+
+/** @brief Initialize port access
+ * @param aPortChar character port in UPPER case
+ * @return PyObject
+ */
+static PyObject * gpio_open(PyObject *self, PyObject *args)
+{
+ /* parameters */
+ char aPortChar;
+ struct as_gpio_device *dev;
+ PyObject *ret;
+
+ /* Get arguments */
+ if (!PyArg_ParseTuple(args, "c", &aPortChar))
+ {
+ PyErr_SetString(PyExc_IOError,
+ "Wrong parameters.");
+ return NULL;
+ }
+
+ dev = as_gpio_open(aPortChar);
+ if (dev == NULL)
+ {
+ PyErr_SetString(PyExc_IOError,
+ "Initialization error. Is kernel module loaded ?");
+ return NULL;
+ }
+ ret = Py_BuildValue("(c,i)",
+ dev->port_letter,
+ dev->fdev);
+ free(dev);
+ return ret;
+}
+
+/** @brief Set pin direction
+ *
+ * @param (c,i) -> (aPort_letter, aFdev) as_gpio_device structure_list
+ * @param aPinNum pin number
+ * @param aDirection direction 0:input 1:output
+ *
+ * @return error if negative value
+ */
+static PyObject * setPinDirection(PyObject *self, PyObject *args)
+{
+ /* parameters */
+ char aPort_letter;
+ int aFdev;
+
+ int aPinNum;
+ int aDirection;
+
+ struct as_gpio_device *dev;
+ int ret;
+
+ /* Get arguments */
+ if (!PyArg_ParseTuple(args, "(c,i)ii",
+ &aPort_letter,
+ &aFdev,
+ &aPinNum,
+ &aDirection))
+ {
+ PyErr_SetString(PyExc_IOError,
+ "Wrong parameters.");
+ return NULL;
+ }
+
+ dev = (struct as_gpio_device *)malloc(sizeof(struct as_gpio_device));
+ if (dev == NULL)
+ {
+ PyErr_SetString(PyExc_IOError,
+ "memory allocation:Â can't malloc fdev structure");
+ return NULL;
+ }
+ dev->port_letter = aPort_letter;
+ dev->fdev = aFdev;
+
+ ret = as_gpio_set_pin_direction(dev, aPinNum, aDirection);
+ if (ret < 0)
+ {
+ PyErr_SetString(PyExc_IOError,
+ "Can't set pin direction");
+ return NULL;
+ }
+
+ free(dev);
+ return Py_BuildValue("i", ret);
+}
+
+static PyObject * setPinValue(PyObject *self, PyObject *args)
+{
+ return NULL;
+}
+static PyObject * getPinValue(PyObject *self, PyObject *args)
+{
+ return NULL;
+}
+
+static PyObject * gpio_close(PyObject *self, PyObject *args)
+{
+ return NULL;
+}
+
+
diff --git a/target/packages/as_devices/python/src/AsGpio_wrap.h b/target/packages/as_devices/python/src/AsGpio_wrap.h
new file mode 100644
index 0000000..952062b
--- /dev/null
+++ b/target/packages/as_devices/python/src/AsGpio_wrap.h
@@ -0,0 +1,45 @@
+/*
+** THE ARMadeus Systems
+**
+** Copyright (C) 2010 The armadeus systems team
+** Fabien Marteau <fab...@ar...>
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Lesser General Public
+** License as published by the Free Software Foundation; either
+** version 2.1 of the License, or (at your option) any later version.
+**
+** This library is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public
+** License along with this library; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#include <Python.h>
+
+/* Init module */
+//void initAsGpio();
+
+/*********************/
+/* Functions wrapped */
+/*********************/
+static PyObject * gpio_open(PyObject *self, PyObject *args);
+
+static PyObject * setPinDirection(PyObject *self, PyObject *args);
+static PyObject * setPinValue(PyObject *self, PyObject *args);
+static PyObject * getPinValue(PyObject *self, PyObject *args);
+
+static PyObject * gpio_close(PyObject *self, PyObject *args);
+
+/* Methods definitions */
+static PyMethodDef AsGpio_wrap_Methods[] = {
+ {"init", gpio_open, METH_VARARGS, "Initialize gpio"},
+ {"setPinDirection", setPinDirection, METH_VARARGS, "Set pin direction"},
+ {"setPinValue", setPinValue, METH_VARARGS, "Set pin value"},
+ {"getPinValue", getPinValue, METH_VARARGS, "Get pin value"},
+ {NULL, NULL, 0, NULL} /* Sentinel */
+};
hooks/post-receive
--
armadeus
|