[Armadeus-commitlog] armadeus branch, master, updated. release-3.2-333-gbe149f1
Brought to you by:
sszy
|
From: Fabien M <fa...@us...> - 2010-05-04 10:08:28
|
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 be149f1fc2815c742bf3ae4c7883c3fab0392730 (commit)
from 4b868dae8eab68a6e6aa269b6dfe1bda444d0416 (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 be149f1fc2815c742bf3ae4c7883c3fab0392730
Author: Fabien Marteau <fab...@ar...>
Date: Tue May 4 12:08:05 2010 +0200
[AsDevices] Add irq mode configuration function (not tested), suppress tab
-----------------------------------------------------------------------
Summary of changes:
target/packages/as_devices/c/as_gpio.c | 114 ++++++++++++++++++++++++++++----
target/packages/as_devices/c/as_gpio.h | 30 ++++++++-
2 files changed, 130 insertions(+), 14 deletions(-)
diff --git a/target/packages/as_devices/c/as_gpio.c b/target/packages/as_devices/c/as_gpio.c
index 0eb22a6..fe33c73 100644
--- a/target/packages/as_devices/c/as_gpio.c
+++ b/target/packages/as_devices/c/as_gpio.c
@@ -29,20 +29,22 @@
#include <sys/ioctl.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 GPIORDMODE _IOR(PP_IOCTL, 0xF4, int)
-#define GPIOWRMODE _IOW(PP_IOCTL, 0xF5, int)
+#define PORT_SIZE (32)
-#define GPIORDPULLUP _IOR(PP_IOCTL, 0xF6, int)
-#define GPIOWRPULLUP _IOR(PP_IOCTL, 0xF7, int)
+#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 GPIORDMODE _IOR(PP_IOCTL, 0xF4, int)
+#define GPIOWRMODE _IOW(PP_IOCTL, 0xF5, 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 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")
@@ -231,6 +233,94 @@ int32_t as_gpio_set_pullup_value(struct as_gpio_device *aDev,
/*------------------------------------------------------------------------------*/
+int32_t as_gpio_get_irq_mode(struct as_gpio_device *aDev,
+ int aPinNum)
+{
+ int ret=0;
+ int portval;
+
+ /* check pin num */
+ if (aPinNum >= PORT_SIZE)
+ return -1;
+
+ if (aPinNum < PORT_SIZE/2)
+ {
+
+ ret = ioctl(aDev->fdev, GPIORDIRQMODE_L, &portval);
+ if (ret < 0) {
+ return ret;
+ }
+
+ portval &= (3 << (aPinNum * 2));
+ return portval >> (aPinNum * 2);
+
+ } else {
+
+ ret = ioctl(aDev->fdev, GPIORDIRQMODE_H, &portval);
+ if (ret < 0) {
+ return ret;
+ }
+
+ portval &= (3 << ((aPinNum - (PORT_SIZE/2)) * 2));
+ return portval >> ((aPinNum - (PORT_SIZE/2)) * 2);
+ }
+}
+
+/*------------------------------------------------------------------------------*/
+
+int32_t as_gpio_set_irq_mode(struct as_gpio_device *aDev,
+ int aPinNum,
+ int aMode)
+{
+ int ret=0;
+ int portval;
+
+ /* check mode value */
+ if (aMode > 3)
+ return -1;
+
+ /* check pin num */
+ if (aPinNum >= PORT_SIZE)
+ return -1;
+
+ if (aPinNum < PORT_SIZE/2)
+ {
+
+ ret = ioctl(aDev->fdev, GPIORDIRQMODE_L, &portval);
+ if (ret < 0) {
+ return ret;
+ }
+
+ portval &= ~(3 << (aPinNum * 2));
+ portval |= (aMode << (aPinNum * 2));
+
+ ret = ioctl(aDev->fdev, GPIOWRIRQMODE_L, &portval);
+ if (ret < 0) {
+ return ret;
+ }
+
+ } else {
+
+ ret = ioctl(aDev->fdev, GPIORDIRQMODE_H, &portval);
+ if (ret < 0) {
+ return ret;
+ }
+
+ portval &= ~(3 << ((aPinNum - (PORT_SIZE/2)) * 2));
+ portval |= (aMode << ((aPinNum - (PORT_SIZE/2)) * 2));
+
+ ret = ioctl(aDev->fdev, GPIOWRIRQMODE_H, &portval);
+ if (ret < 0) {
+ return ret;
+ }
+ }
+
+ return 0;
+
+}
+
+/*------------------------------------------------------------------------------*/
+
int32_t
as_gpio_close(struct as_gpio_device *aDev)
{
diff --git a/target/packages/as_devices/c/as_gpio.h b/target/packages/as_devices/c/as_gpio.h
index 55f26f3..2f591fe 100644
--- a/target/packages/as_devices/c/as_gpio.h
+++ b/target/packages/as_devices/c/as_gpio.h
@@ -28,6 +28,11 @@
extern "C" {
#endif // __cplusplus
+#define GPIO_IRQ_MODE_NOINT (0)
+#define GPIO_IRQ_MODE_RISING (1)
+#define GPIO_IRQ_MODE_FALLING (2)
+#define GPIO_IRQ_MODE_BOTH (3)
+
//TODO: manage irq
/**
@@ -85,7 +90,7 @@ int32_t as_gpio_get_pin_value(struct as_gpio_device *aDev,
* @param aDev as_gpio_device pointer structure
* @param aPinNum pin number
*
- * @return pin value if positive or null, error if negative
+ * @return pin pull up value if positive or null, error if negative
*/
int32_t as_gpio_get_pullup_value(struct as_gpio_device *aDev,
int aPinNum);
@@ -102,13 +107,34 @@ int32_t as_gpio_set_pullup_value(struct as_gpio_device *aDev,
int aPinNum,
int aValue);
+/** @brief Set pin irq mode
+ *
+ * @param aDev as_gpio_device pointer structure
+ * @param aPinNum pin number
+ * @param aMode irq mode
+ *
+ * @return error if negative
+ */
+int32_t as_gpio_set_irq_mode(struct as_gpio_device *aDev,
+ int aPinNum,
+ int aMode);
+
+/** @brief Get pin irq mode value
+ *
+ * @param aDev as_gpio_device pointer structure
+ * @param aPinNum pin number
+ *
+ * @return pin mode value if positive or null, error if negative
+ */
+int32_t as_gpio_get_irq_mode(struct as_gpio_device *aDev,
+ int aPinNum);
+
/** @brief Close port access
*
* @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 *aDev);
#ifdef __cplusplus
hooks/post-receive
--
armadeus
|