[Armadeus-commitlog] armadeus branch, master, updated. release-3.2-332-g4b868da
Brought to you by:
sszy
|
From: Fabien M <fa...@us...> - 2010-05-04 08:34:39
|
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 4b868dae8eab68a6e6aa269b6dfe1bda444d0416 (commit)
via 701b7cf62b8bd3a8fe3495a9b167122ba1a932f0 (commit)
from 9fa6bc8a3589496fb0a5d9a1e2a5f559ad709933 (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 4b868dae8eab68a6e6aa269b6dfe1bda444d0416
Merge: 701b7cf62b8bd3a8fe3495a9b167122ba1a932f0 9fa6bc8a3589496fb0a5d9a1e2a5f559ad709933
Author: Fabien Marteau <fab...@ar...>
Date: Tue May 4 10:33:35 2010 +0200
Merge branch 'master' of ssh://fabm@armadeus.git.sourceforge.net/gitroot/armadeus/armadeus
commit 701b7cf62b8bd3a8fe3495a9b167122ba1a932f0
Author: Fabien Marteau <fab...@ar...>
Date: Tue May 4 10:33:04 2010 +0200
[AsDevices] Adding pullup capability (not tested) and suppress trailling white space
-----------------------------------------------------------------------
Summary of changes:
target/packages/as_devices/c/as_gpio.c | 80 +++++++++++++++++++++++++++-----
target/packages/as_devices/c/as_gpio.h | 40 ++++++++++++----
2 files changed, 99 insertions(+), 21 deletions(-)
diff --git a/target/packages/as_devices/c/as_gpio.c b/target/packages/as_devices/c/as_gpio.c
index c24c4e9..0eb22a6 100644
--- a/target/packages/as_devices/c/as_gpio.c
+++ b/target/packages/as_devices/c/as_gpio.c
@@ -1,19 +1,19 @@
/*
** The ARMadeus Project
-**
-** Copyright (C) 2009 The armadeus systems team
+**
+** Copyright (C) 2009-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
@@ -27,14 +27,22 @@
#include <unistd.h> /* for close() */
#include <sys/ioctl.h>
-#include <linux/ppdev.h>
+#include <linux/ppdev.h>
#define GPIORDDIRECTION _IOR(PP_IOCTL, 0xF0, int)
#define GPIOWRDIRECTION _IOW(PP_IOCTL, 0xF1, int)
#define GPIORDDATA _IOR(PP_IOCTL, 0xF2, int)
-#define GPIOWRDATA _IOW(PP_IOCTL, 0xF3, int)
+#define GPIOWRDATA _IOW(PP_IOCTL, 0xF3, int)
#define GPIORDMODE _IOR(PP_IOCTL, 0xF4, int)
-#define GPIOWRMODE _IOW(PP_IOCTL, 0xF5, int)
+#define GPIOWRMODE _IOW(PP_IOCTL, 0xF5, int)
+
+#define GPIORDPULLUP _IOR(PP_IOCTL, 0xF6, int)
+#define GPIOWRPULLUP _IOR(PP_IOCTL, 0xF7, int)
+
+#define GPIORDIRQMODE_H _IOR(PP_IOCTL, 0xF8, int)
+#define GPIORDIRQMODE_L _IOR(PP_IOCTL, 0xF9, int)
+#define GPIOWRIRQMODE_H _IOR(PP_IOCTL, 0xFA, int)
+#define GPIOWRIRQMODE_L _IOR(PP_IOCTL, 0xFB, int)
#define GPIO_BASE_PORT ("/dev/gpio/port")
@@ -73,10 +81,10 @@ as_gpio_open(char aPortChar)
return NULL;
}
- dev = (struct as_gpio_device *)malloc(sizeof(struct as_gpio_device));
+ dev = (struct as_gpio_device *)malloc(sizeof(struct as_gpio_device));
if (dev == NULL)
return NULL;
-
+
dev->port_letter = aPortChar;
dev->fdev = ret;
@@ -127,7 +135,7 @@ as_gpio_set_pin_direction(struct as_gpio_device *aDev,
/*------------------------------------------------------------------------------*/
-int32_t
+int32_t
as_gpio_set_pin_value( struct as_gpio_device *aDev,
int aPinNum,
int aValue)
@@ -175,7 +183,55 @@ int32_t as_gpio_get_pin_value( struct as_gpio_device *aDev,
/*------------------------------------------------------------------------------*/
-int32_t
+int32_t as_gpio_get_pullup_value(struct as_gpio_device *aDev,
+ int aPinNum)
+{
+ int ret=0;
+ int portval;
+
+ ret = ioctl(aDev->fdev, GPIORDPULLUP, &portval);
+ if (ret < 0) {
+ return ret;
+ }
+
+ if ((portval & (1<<aPinNum)) != 0) {
+ return 1;
+ } else {
+ return 0;
+ }
+
+}
+
+/*------------------------------------------------------------------------------*/
+
+int32_t as_gpio_set_pullup_value(struct as_gpio_device *aDev,
+ int aPinNum,
+ int aValue)
+{
+ int ret=0;
+ int portval;
+
+ ret = ioctl(aDev->fdev, GPIORDPULLUP, &portval);
+ if (ret < 0) {
+ return ret;
+ }
+
+ if (aValue == 0) {
+ portval &= ~(1 << aPinNum);
+ } else {
+ portval |= (1 << aPinNum);
+ }
+ ret = ioctl(aDev->fdev, GPIOWRPULLUP, &portval);
+ if (ret < 0) {
+ return ret;
+ }
+
+ return 0;
+}
+
+/*------------------------------------------------------------------------------*/
+
+int32_t
as_gpio_close(struct as_gpio_device *aDev)
{
int ret;
diff --git a/target/packages/as_devices/c/as_gpio.h b/target/packages/as_devices/c/as_gpio.h
index 48dee74..55f26f3 100644
--- a/target/packages/as_devices/c/as_gpio.h
+++ b/target/packages/as_devices/c/as_gpio.h
@@ -1,19 +1,19 @@
/*
** The ARMadeus Project
-**
-** Copyright (C) 2009 The armadeus systems team
+**
+** Copyright (C) 2009-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
@@ -42,7 +42,7 @@ struct as_gpio_device {
*
* @param aPortChar character port in UPPER case
*
- * @return error if negative value
+ * @return error if negative value
*/
struct as_gpio_device *as_gpio_open(char aPortChar);
@@ -52,19 +52,19 @@ struct as_gpio_device *as_gpio_open(char aPortChar);
* @param aPinNum pin number
* @param aDirection direction 0:input 1:output
*
- * @return error if negative value
+ * @return error if negative value
*/
int32_t as_gpio_set_pin_direction(struct as_gpio_device *aDev,
int aPinNum,
int aDirection);
-/** @brief Set pin value
+/** @brief Set pin value
*
* @param aDev as_gpio_device pointer structure
* @param aPinNum pin number
* @param aValue value of pin (1 or 0)
*
- * @return error if negative
+ * @return error if negative
*/
int32_t as_gpio_set_pin_value(struct as_gpio_device *aDev,
int aPinNum,
@@ -80,6 +80,28 @@ int32_t as_gpio_set_pin_value(struct as_gpio_device *aDev,
int32_t as_gpio_get_pin_value(struct as_gpio_device *aDev,
int aPinNum);
+/** @brief Get pin pull-up value
+ *
+ * @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_pullup_value(struct as_gpio_device *aDev,
+ int aPinNum);
+
+/** @brief Set pin pull-up value
+ *
+ * @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_pullup_value(struct as_gpio_device *aDev,
+ int aPinNum,
+ int aValue);
+
/** @brief Close port access
*
* @param aDev as_gpio_device pointer structure
hooks/post-receive
--
armadeus
|