[Armadeus-commitlog] armadeus branch, master, updated. release-3.2-225-g56f57d7
Brought to you by:
sszy
|
From: Fabien M <fa...@us...> - 2010-03-05 10:59:51
|
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 56f57d7811f2e5784776ee15bf7a9364cba497b2 (commit)
via 1ac42b52e1d0f3be55c87076fab3c25b86e29ab9 (commit)
via 7ba8744be311508f3075435979e53274a1c57949 (commit)
via 3ff2a9cdda5ea4c1a68b8aa4feda345029708377 (commit)
via d3356eaea774182bcba129c50d0ad2c6fae20c60 (commit)
via 7cf02c7bdcd7252aa65ea492ff14899be6d2bae5 (commit)
via a2495a4e9768c99b27b1ee61814dbadf755d8696 (commit)
via ea642f08c4fe223b79bf259f9e30151be49e6fdf (commit)
from 1f2b77057bae0d441abc58ad278179cd55a38233 (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 56f57d7811f2e5784776ee15bf7a9364cba497b2
Merge: 1ac42b52e1d0f3be55c87076fab3c25b86e29ab9 1f2b77057bae0d441abc58ad278179cd55a38233
Author: Fabien Marteau <fab...@ar...>
Date: Fri Mar 5 11:59:01 2010 +0100
Merge branch 'master' of ssh://fabm@armadeus.git.sourceforge.net/gitroot/armadeus/armadeus
commit 1ac42b52e1d0f3be55c87076fab3c25b86e29ab9
Author: Fabien Marteau <fab...@ar...>
Date: Fri Mar 5 11:58:10 2010 +0100
[asdevices] Adding as_max1027 in progressâ¦
commit 7ba8744be311508f3075435979e53274a1c57949
Author: Fabien Marteau <fab...@ar...>
Date: Fri Mar 5 11:57:33 2010 +0100
[asdevices] Fix makefile bug
commit 3ff2a9cdda5ea4c1a68b8aa4feda345029708377
Author: Fabien Marteau <fab...@ar...>
Date: Fri Mar 5 11:04:54 2010 +0100
[asdevices] Suppress apf27 reference in pwm lib
commit d3356eaea774182bcba129c50d0ad2c6fae20c60
Author: Fabien Marteau <fab...@ar...>
Date: Fri Mar 5 10:57:27 2010 +0100
[asdevices] Testbench corrections
commit 7cf02c7bdcd7252aa65ea492ff14899be6d2bae5
Author: Fabien Marteau <fab...@ar...>
Date: Fri Mar 5 10:37:36 2010 +0100
[asdevices] Update as_gpio library
commit a2495a4e9768c99b27b1ee61814dbadf755d8696
Author: Fabien Marteau <fab...@ar...>
Date: Fri Mar 5 10:36:53 2010 +0100
[asdevices] Update Makefile
commit ea642f08c4fe223b79bf259f9e30151be49e6fdf
Author: Fabien Marteau <fab...@ar...>
Date: Thu Mar 4 15:31:02 2010 +0100
[AsDevice] clean Makefile
-----------------------------------------------------------------------
Summary of changes:
target/packages/as_devices/Makefile | 18 ++-
target/packages/as_devices/c/Makefile | 17 ++-
target/packages/as_devices/c/as_apf27_gpio.h | 50 -------
.../as_devices/c/{as_apf27_gpio.c => as_gpio.c} | 97 ++++++-------
target/packages/as_devices/c/as_gpio.h | 96 ++++++++++++
target/packages/as_devices/c/as_max1027.c | 28 ++++
target/packages/as_devices/c/as_max1027.h | 68 +++++++++
.../as_devices/c/{as_apf27_pwm.c => as_pwm.c} | 22 ++--
.../as_devices/c/{as_apf27_pwm.h => as_pwm.h} | 20 ++--
target/packages/as_devices/main.c | 3 +
target/packages/as_devices/test_c.h | 154 ++++++++++++++++++--
11 files changed, 421 insertions(+), 152 deletions(-)
delete mode 100644 target/packages/as_devices/c/as_apf27_gpio.h
rename target/packages/as_devices/c/{as_apf27_gpio.c => as_gpio.c} (59%)
create mode 100644 target/packages/as_devices/c/as_gpio.h
create mode 100644 target/packages/as_devices/c/as_max1027.c
create mode 100644 target/packages/as_devices/c/as_max1027.h
rename target/packages/as_devices/c/{as_apf27_pwm.c => as_pwm.c} (93%)
rename target/packages/as_devices/c/{as_apf27_pwm.h => as_pwm.h} (69%)
diff --git a/target/packages/as_devices/Makefile b/target/packages/as_devices/Makefile
index e35e20b..b3578d4 100644
--- a/target/packages/as_devices/Makefile
+++ b/target/packages/as_devices/Makefile
@@ -1,10 +1,12 @@
-# to compile c tests
-# make CC=~/armadeus_trees/apf27/buildroot/build_armv5te/staging_dir/usr/bin/arm-linux-gcc test_cdevices
-# to compile cpp tests
-# make CC=~/armadeus_trees/apf27/buildroot/build_armv5te/staging_dir/usr/bin/arm-linux-gcc CXX=~/armadeus_trees/apf27/buildroot/build_armv5te/staging_dir/usr/bin/arm-linux-g++ test_cppdevices
-#
+# Default values for local compiling:
+ARMADEUS_BASE_DIR=../../../
+include $(ARMADEUS_BASE_DIR)/Makefile.in
+
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
C_BINARY=test_cdevices
C_LIBNAME=as_devices
@@ -31,9 +33,9 @@ ${C_BINARY}: main.c test_c.h ${C_LIB}
# cd cpp; make CXX=${CXX}
${C_LIB}:
- cd c; make CC=${CC}
+ cd c; make
clean:
- cd c; make clean ; cd ../cpp; make clean; cd ../python; make clean
- -rm ${C_BINARY} ${CPP_BINARY}
+ cd c; make clean ; #cd ../cpp; make clean; cd ../python; make clean
+ -rm ${C_BINARY} # ${CPP_BINARY}
diff --git a/target/packages/as_devices/c/Makefile b/target/packages/as_devices/c/Makefile
index e2fcea2..816efe6 100644
--- a/target/packages/as_devices/c/Makefile
+++ b/target/packages/as_devices/c/Makefile
@@ -1,16 +1,19 @@
-# to compile for arm :
-# make CC=../../bsp/buildroot/build_armv5te/staging_dir/usr/bin/arm-linux-gcc
-# make CC=~/Projects/HMSDemo/software/bsp/buildroot/build_armv5te/staging_dir/usr/bin/arm-linux-gcc
-# make CC=~/Projects/virgin_HMS/software/bsp/buildroot/build_armv5te/staging_dir/usr/bin/arm-linux-gcc
-#
+# Default values for local compiling:
+#
+ARMADEUS_BASE_DIR=../../../../
+include $(ARMADEUS_BASE_DIR)/Makefile.in
+
CFLAGS=-Wall -g -O0
LDFLAGS=
+CC:=$(ARMADEUS_TOOLCHAIN_PATH)/arm-linux-gcc
+STRIP:=$(ARMADEUS_TOOLCHAIN_PATH)arm-linux-sstrip
-OBJ=as_apf27_pwm.o
+OBJ=as_pwm.o
OBJ+= as_i2c.o
-OBJ+= as_apf27_gpio.o
+OBJ+= as_gpio.o
OBJ+= as_93lcxx.o
OBJ+= as_spi.o
+OBJ+= as_max1027.o
LIBRARY=as_devices
LIB_VERS=1
diff --git a/target/packages/as_devices/c/as_apf27_gpio.h b/target/packages/as_devices/c/as_apf27_gpio.h
deleted file mode 100644
index 040a563..0000000
--- a/target/packages/as_devices/c/as_apf27_gpio.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
-** THE ARMadeus Systems
-**
-** Copyright (C) 2009 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
-*/
-
-#ifndef __ASAPF27GPIO_H__
-#define __ASAPF27GPIO_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif // __cplusplus
-
-#define NUMBER_OF_PORTS 6
-
-int as_apf27_gpio_init(char aPortChar);
-
-int as_apf27_gpio_set_pin_direction(char aPortChar,
- int aPinNum,
- int aDirection);
-
-int as_apf27_gpio_set_pin_value(char aPortChar,
- int aPinNum,
- int aValue);
-
-int as_apf27_gpio_get_pin_value(char aPortChar,
- int aPinNum);
-
-int as_apf27_gpio_close(char aPortChar);
-
-#ifdef __cplusplus
-}
-#endif // __cplusplus
-
-#endif // __ASAPF27GPIO_H__
diff --git a/target/packages/as_devices/c/as_apf27_gpio.c b/target/packages/as_devices/c/as_gpio.c
similarity index 59%
rename from target/packages/as_devices/c/as_apf27_gpio.c
rename to target/packages/as_devices/c/as_gpio.c
index 20b55b2..bf8422b 100644
--- a/target/packages/as_devices/c/as_apf27_gpio.c
+++ b/target/packages/as_devices/c/as_gpio.c
@@ -19,7 +19,7 @@
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "as_apf27_gpio.h"
+#include "as_gpio.h"
#include <stdlib.h>
#include <stdio.h>
@@ -39,67 +39,68 @@
#define GPIO_BASE_PORT ("/dev/gpio/port")
-static int mFileHandlerGpioPort[NUMBER_OF_PORTS];
-
/*------------------------------------------------------------------------------*/
-/** Initialize port access
- * @param aPortChar character port in UPPER case
- * @return error if negative value
- */
-int
-as_apf27_gpio_init(char aPortChar)
+struct as_gpio_device *
+as_gpio_open(char aPortChar)
{
+ struct as_gpio_device *dev;
char gpio_file_path[50];
int ret=0;
+ if (((aPortChar-'A') > (NUMBER_OF_PORTS-1)) || ((aPortChar-'A') < 0))
+ {
+ return NULL;
+ }
+
/* make gpio port string path */
ret = snprintf(gpio_file_path,50, "%s%c",
GPIO_BASE_PORT, aPortChar);
if (ret < 0) {
- return ret;
+ return NULL;
}
/* opening gpio port */
- mFileHandlerGpioPort[aPortChar-'A'] = open(gpio_file_path, O_RDWR);
- if (mFileHandlerGpioPort[aPortChar-'A'] < 0) {
- return mFileHandlerGpioPort[aPortChar-'A'];
+ ret = open(gpio_file_path, O_RDWR);
+ if (ret < 0) {
+ return NULL;
}
- return 0;
+ dev = (struct as_gpio_device *)malloc(sizeof(struct as_gpio_device));
+ if (dev == NULL)
+ return NULL;
+
+ dev->port_letter = aPortChar;
+ dev->fdev = ret;
+
+ return dev;
}
/*------------------------------------------------------------------------------*/
-/** Set pin direction
- * @param aPortChar port character in upper case
- * @param aPinNum pin number
- * @param aDirection direction 0:input 1:output
- * @return error if negative value
- */
-int
-as_apf27_gpio_set_pin_direction(char aPortChar,
- int aPinNum,
- int aDirection)
+int32_t
+as_gpio_set_pin_direction(struct as_gpio_device *dev,
+ int aPinNum,
+ int aDirection)
{
int ret=0;
int portval;
/* Set LED PIN as GPIO; read/modify/write */
- ret = ioctl(mFileHandlerGpioPort[aPortChar-'A'], GPIORDMODE, &portval);
+ ret = ioctl(dev->fdev, GPIORDMODE, &portval);
if (ret < 0) {
return ret;
}
portval |= (1 << aPinNum);
- ret = ioctl(mFileHandlerGpioPort[aPortChar-'A'], GPIOWRMODE, &portval);
+ ret = ioctl(dev->fdev, GPIOWRMODE, &portval);
if (ret < 0) {
return ret;
}
/* set direction */
- ret = ioctl(mFileHandlerGpioPort[aPortChar-'A'], GPIORDDIRECTION, &portval);
+ ret = ioctl(dev->fdev, GPIORDDIRECTION, &portval);
if (ret < 0) {
return ret;
}
@@ -110,7 +111,7 @@ as_apf27_gpio_set_pin_direction(char aPortChar,
portval |= (1 << aPinNum);
}
- ret = ioctl(mFileHandlerGpioPort[aPortChar-'A'], GPIOWRDIRECTION, &portval);
+ ret = ioctl(dev->fdev, GPIOWRDIRECTION, &portval);
if (ret < 0) {
return ret;
}
@@ -119,21 +120,15 @@ as_apf27_gpio_set_pin_direction(char aPortChar,
/*------------------------------------------------------------------------------*/
-/** Set pin value
- * @param aPortChar port character in upper case
- * @param aPinNum pin number
- * @param aValue value of pin (1 or 0)
- * @return error if negative
- */
-int
-as_apf27_gpio_set_pin_value(char aPortChar,
- int aPinNum,
- int aValue)
+int32_t
+as_gpio_set_pin_value( struct as_gpio_device *dev,
+ int aPinNum,
+ int aValue)
{
int ret=0;
int portval;
- ret = ioctl(mFileHandlerGpioPort[aPortChar-'A'], GPIORDDATA, &portval);
+ ret = ioctl(dev->fdev, GPIORDDATA, &portval);
if (ret < 0) {
return ret;
}
@@ -143,7 +138,7 @@ as_apf27_gpio_set_pin_value(char aPortChar,
} else {
portval |= (1 << aPinNum);
}
- ret = ioctl(mFileHandlerGpioPort[aPortChar-'A'], GPIOWRDATA, &portval);
+ ret = ioctl(dev->fdev, GPIOWRDATA, &portval);
if (ret < 0) {
return ret;
}
@@ -153,18 +148,13 @@ as_apf27_gpio_set_pin_value(char aPortChar,
/*------------------------------------------------------------------------------*/
-/** Get pin value
- * @param aPortChar port character in upper case
- * @param aPinNum pin number
- * @return pin value if positive or null, error if negative
- */
-int as_apf27_gpio_get_pin_value(char aPortChar,
+int32_t as_gpio_get_pin_value( struct as_gpio_device *dev,
int aPinNum)
{
int ret=0;
int portval;
- ret = ioctl(mFileHandlerGpioPort[aPortChar-'A'], GPIORDDATA, &portval);
+ ret = ioctl(dev->fdev, GPIORDDATA, &portval);
if (ret < 0) {
return ret;
}
@@ -178,13 +168,12 @@ int as_apf27_gpio_get_pin_value(char aPortChar,
/*------------------------------------------------------------------------------*/
-/** Close port access
- * @param aPortChar port character in upper case
- * @return pin value if positive or null, error if negative
- */
-int
-as_apf27_gpio_close(char aPortChar)
+int32_t
+as_gpio_close(struct as_gpio_device *dev)
{
- return close(mFileHandlerGpioPort[aPortChar-'A']);
+ int ret;
+ ret = close(dev->fdev);
+ free(dev);
+ return 0;
}
diff --git a/target/packages/as_devices/c/as_gpio.h b/target/packages/as_devices/c/as_gpio.h
new file mode 100644
index 0000000..3ed3b9e
--- /dev/null
+++ b/target/packages/as_devices/c/as_gpio.h
@@ -0,0 +1,96 @@
+/*
+** THE ARMadeus Systems
+**
+** Copyright (C) 2009 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
+*/
+
+#ifndef __ASGPIO_H__
+#define __ASGPIO_H__
+
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif // __cplusplus
+
+#define NUMBER_OF_PORTS 6
+
+/**
+ * Store gpio parameters
+ */
+struct as_gpio_device {
+ unsigned char port_letter;
+ int fdev;
+};
+
+/** @brief Initialize port access
+ *
+ * @param aPortChar character port in UPPER case
+ *
+ * @return error if negative value
+ */
+struct as_gpio_device *as_gpio_open(char aPortChar);
+
+/** @brief Set pin direction
+ *
+ * @param aPortChar port character in upper case
+ * @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,
+ int aPinNum,
+ int aDirection);
+
+/** @brief Set pin value
+ *
+ * @param aPortChar port character in upper case
+ * @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,
+ int aPinNum,
+ int aValue);
+
+/** @brief Get pin value
+ *
+ * @param aPortChar port character in upper case
+ * @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,
+ int aPinNum);
+
+/** @brief Close port access
+ *
+ * @param aPortChar port character in upper case
+ *
+ * @return pin value if positive or null, error if negative
+ */
+
+int32_t as_gpio_close( struct as_gpio_device *dev);
+
+#ifdef __cplusplus
+}
+#endif // __cplusplus
+
+#endif // __ASGPIO_H__
diff --git a/target/packages/as_devices/c/as_max1027.c b/target/packages/as_devices/c/as_max1027.c
new file mode 100644
index 0000000..b243188
--- /dev/null
+++ b/target/packages/as_devices/c/as_max1027.c
@@ -0,0 +1,28 @@
+/*
+ * This software 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
+ *
+ *
+ * Copyright (C) 2010 Fabien Marteau <fab...@ar...>
+ *
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#include "as_max1027.h"
+
+
+
diff --git a/target/packages/as_devices/c/as_max1027.h b/target/packages/as_devices/c/as_max1027.h
new file mode 100644
index 0000000..524f060
--- /dev/null
+++ b/target/packages/as_devices/c/as_max1027.h
@@ -0,0 +1,68 @@
+/*
+ * This software 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
+ *
+ *
+ * Copyright (C) 2010 Fabien Marteau <fab...@ar...>
+ *
+ */
+
+#ifndef AS_MAX1027_H_
+#define AS_MAX1027_H_
+
+/** @file
+ * @brief Read/Write analog value with max1027 chip
+ *
+ *
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum {
+ AS_MAX1027_FAST,
+ AS_MAX1027_SLOW
+} AS_max1027_mode;
+
+/**
+ * Store max1027 parameters
+ */
+struct as_max1027_device {
+ AS_max1027_mode mode;
+};
+
+
+/** @brief Open max1027
+ *
+ * @param aSpiNum spi bus number used
+ *
+ * @return as_max1027_device structure pointer, NULL if error
+ */
+struct as_max1027_device *as_max1027_open(int aSpiNum,
+ AS_max1027_mode mode);
+
+//setAveraging();
+//readTemperature_mC();
+//readTemperature_C();
+//
+//getValueInMilliVolt();
+//getValueInVolt();
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* AS_MAX1027_H_ */
diff --git a/target/packages/as_devices/c/as_apf27_pwm.c b/target/packages/as_devices/c/as_pwm.c
similarity index 93%
rename from target/packages/as_devices/c/as_apf27_pwm.c
rename to target/packages/as_devices/c/as_pwm.c
index 3db3de4..1fa4e2d 100644
--- a/target/packages/as_devices/c/as_apf27_pwm.c
+++ b/target/packages/as_devices/c/as_pwm.c
@@ -25,7 +25,7 @@
#include <errno.h> /* for perror() */
#include <unistd.h> /* for write() */
-#include "as_apf27_pwm.h"
+#include "as_pwm.h"
#define PWM_SYS_PATH "/sys/class/pwm/pwm"
#define FREQUENCY_PATH "frequency"
@@ -76,7 +76,7 @@ writeBuffer(int aFile_handler, char *aValueWrite)
* @return error code
*/
int
-as_apf27_pwm_init(int aPwmNumber)
+as_pwm_init(int aPwmNumber)
{
char buffer[50];
@@ -118,7 +118,7 @@ as_apf27_pwm_init(int aPwmNumber)
* @return no error if positive value
*/
int
-as_apf27_pwm_close(int aPwmNumber)
+as_pwm_close(int aPwmNumber)
{
int ret = 0;
@@ -161,7 +161,7 @@ as_apf27_pwm_close(int aPwmNumber)
* @return no error if positive value
*/
int
-as_apf27_pwm_setFrequency(int aPwmNumber, int aFrequency)
+as_pwm_setFrequency(int aPwmNumber, int aFrequency)
{
char buffer[50];
@@ -176,7 +176,7 @@ as_apf27_pwm_setFrequency(int aPwmNumber, int aFrequency)
* @return int frequency in Hz
*/
int
-as_apf27_pwm_getFrequency(int aPwmNumber)
+as_pwm_getFrequency(int aPwmNumber)
{
return mFrequency[aPwmNumber];
}
@@ -189,7 +189,7 @@ as_apf27_pwm_getFrequency(int aPwmNumber)
* @return positive value if no error
*/
int
-as_apf27_pwm_setPeriod(int aPwmNumber, int aPeriod)
+as_pwm_setPeriod(int aPwmNumber, int aPeriod)
{
char buffer[50];
mPeriod[aPwmNumber] = aPeriod;
@@ -203,7 +203,7 @@ as_apf27_pwm_setPeriod(int aPwmNumber, int aPeriod)
* @return period int in us
*/
int
-as_apf27_pwm_getPeriod(int aPwmNumber)
+as_pwm_getPeriod(int aPwmNumber)
{
return mPeriod[aPwmNumber];
}
@@ -215,7 +215,7 @@ as_apf27_pwm_getPeriod(int aPwmNumber)
* @return positive value if no error
*/
int
-as_apf27_pwm_setDuty(int aPwmNumber, int aDuty)
+as_pwm_setDuty(int aPwmNumber, int aDuty)
{
char buffer[50];
mDuty[aPwmNumber] = aDuty;
@@ -230,7 +230,7 @@ as_apf27_pwm_setDuty(int aPwmNumber, int aDuty)
* @return duty
*/
int
-as_apf27_pwm_getDuty(int aPwmNumber)
+as_pwm_getDuty(int aPwmNumber)
{
return mDuty[aPwmNumber];
}
@@ -240,7 +240,7 @@ as_apf27_pwm_getDuty(int aPwmNumber)
* @param aPwmNumber pwm number used
* @param aEnable
*/
-int as_apf27_pwm_activate(int aPwmNumber, int aEnable)
+int as_pwm_activate(int aPwmNumber, int aEnable)
{
char one[] = "1";
char zero[] = "0";
@@ -261,7 +261,7 @@ int as_apf27_pwm_activate(int aPwmNumber, int aEnable)
}
-int as_apf27_pwm_getState(int aPwmNumber)
+int as_pwm_getState(int aPwmNumber)
{
//XXX: get real state in pwm driver instead global variable
return mState[aPwmNumber];
diff --git a/target/packages/as_devices/c/as_apf27_pwm.h b/target/packages/as_devices/c/as_pwm.h
similarity index 69%
rename from target/packages/as_devices/c/as_apf27_pwm.h
rename to target/packages/as_devices/c/as_pwm.h
index 4359958..769fa2b 100644
--- a/target/packages/as_devices/c/as_apf27_pwm.h
+++ b/target/packages/as_devices/c/as_pwm.h
@@ -29,21 +29,21 @@ extern "C" {
/* number of pwm under system */
#define NUMBER_OF_PWM 2
-int as_apf27_pwm_init(int aPwmNumber);
+int as_pwm_init(int aPwmNumber);
-int as_apf27_pwm_setFrequency(int aPwmNumber, int aFrequency);
-int as_apf27_pwm_getFrequency(int aPwmNumber);
+int as_pwm_setFrequency(int aPwmNumber, int aFrequency);
+int as_pwm_getFrequency(int aPwmNumber);
-int as_apf27_pwm_setPeriod(int aPwmNumber, int aPeriod);
-int as_apf27_pwm_getPeriod(int aPwmNumber);
+int as_pwm_setPeriod(int aPwmNumber, int aPeriod);
+int as_pwm_getPeriod(int aPwmNumber);
-int as_apf27_pwm_setDuty(int aPwmNumber, int aDuty);
-int as_apf27_pwm_getDuty(int aPwmNumber);
+int as_pwm_setDuty(int aPwmNumber, int aDuty);
+int as_pwm_getDuty(int aPwmNumber);
-int as_apf27_pwm_activate(int aPwmNumber, int aEnable);
-int as_apf27_pwm_getState(int aPwmNumber);
+int as_pwm_activate(int aPwmNumber, int aEnable);
+int as_pwm_getState(int aPwmNumber);
-int as_apf27_pwm_close(int aPwmNumber);
+int as_pwm_close(int aPwmNumber);
#ifdef __cplusplus
}
diff --git a/target/packages/as_devices/main.c b/target/packages/as_devices/main.c
index bcb0521..e74c9b9 100644
--- a/target/packages/as_devices/main.c
+++ b/target/packages/as_devices/main.c
@@ -41,6 +41,7 @@ int main(int argc, char ** argv)
printf(" 2) Testing i2c\n");
printf(" 3) Testing spi\n");
printf(" 4) Testing 93LCxx eprom\n");
+ printf(" 5) Testing gpio\n");
printf("> ");
scanf("%s",buffer);
@@ -54,6 +55,8 @@ int main(int argc, char ** argv)
break;
case '4' : test_93LC();
break;
+ case '5' : test_gpio();
+ break;
default : break;
}
diff --git a/target/packages/as_devices/test_c.h b/target/packages/as_devices/test_c.h
index 9d18f9f..54be388 100644
--- a/target/packages/as_devices/test_c.h
+++ b/target/packages/as_devices/test_c.h
@@ -23,9 +23,10 @@
#include <stdlib.h>
#include <math.h>
-#include "as_apf27_pwm.h"
+#include "as_pwm.h"
#include "as_93lcxx.h"
#include "as_i2c.h"
+#include "as_gpio.h"
#define PWM_NUM 0
@@ -44,7 +45,7 @@ void test_pwm(void)
char buffer2[20];
int value;
- ret = as_apf27_pwm_init(PWM_NUM);
+ ret = as_pwm_init(PWM_NUM);
if(ret < 0){
printf("can't init pwm0\n");
return;
@@ -71,41 +72,41 @@ void test_pwm(void)
{
case '1' : printf("Give frequency :");
scanf("%d",&value);
- as_apf27_pwm_setFrequency(PWM_NUM,value);
+ as_pwm_setFrequency(PWM_NUM,value);
pressEnterToContinue();
break;
case '2' : printf("Current pwm frequency is %d\n",
- as_apf27_pwm_getFrequency(PWM_NUM));
+ as_pwm_getFrequency(PWM_NUM));
pressEnterToContinue();
break;
case '3' : printf("Give period :");
scanf("%d",&value);
- as_apf27_pwm_setPeriod(PWM_NUM,value);
+ as_pwm_setPeriod(PWM_NUM,value);
pressEnterToContinue();
break;
case '4' : printf("Current period is %d\n",
- as_apf27_pwm_getPeriod(PWM_NUM));
+ as_pwm_getPeriod(PWM_NUM));
pressEnterToContinue();
break;
case '5' : printf("Give Duty :");
scanf("%d",&value);
- as_apf27_pwm_setDuty(PWM_NUM,value);
+ as_pwm_setDuty(PWM_NUM,value);
pressEnterToContinue();
break;
case '6' : printf("Current Duty is %d\n",
- as_apf27_pwm_getDuty(PWM_NUM));
+ as_pwm_getDuty(PWM_NUM));
pressEnterToContinue();
break;
case '7' : printf("Activate 'a' or Desactivate 'd' ?");
scanf("%s",buffer2);
if(buffer2[0] == 'a')
{
- as_apf27_pwm_activate(PWM_NUM,1);
+ as_pwm_activate(PWM_NUM,1);
printf("Pwm activated\n");
pressEnterToContinue();
}else if(buffer2[0] == 'd')
{
- as_apf27_pwm_activate(PWM_NUM,0);
+ as_pwm_activate(PWM_NUM,0);
printf("Pwm desactivated\n");
pressEnterToContinue();
}else{
@@ -113,7 +114,7 @@ void test_pwm(void)
pressEnterToContinue();
}
break;
- case '8' : if(as_apf27_pwm_getState(PWM_NUM))
+ case '8' : if(as_pwm_getState(PWM_NUM))
{
printf("pwm is active\n");
pressEnterToContinue();
@@ -125,7 +126,7 @@ void test_pwm(void)
default : break;
}
}
- ret = as_apf27_pwm_close(PWM_NUM);
+ ret = as_pwm_close(PWM_NUM);
if(ret < 0){
printf("can't close pwm0\n");
return;
@@ -423,3 +424,132 @@ void test_93LC()
}
}
}
+
+void test_gpio()
+{
+ char buffer[50];
+ struct as_gpio_device *gpio_dev;
+ int32_t ret;
+ char c_value;
+ int32_t value;
+ char port_letter = 'F';
+ int port_num = 14;
+ int port_direction = 0;
+ int port_value = 1;
+
+ gpio_dev = as_gpio_open(port_letter);
+ if (gpio_dev == NULL)
+ {
+ printf("Error can't open gpio %c\nHave you run loadgpio.sh ?\n", port_letter);
+ pressEnterToContinue();
+ return ;
+ }
+ ret = as_gpio_get_pin_value(gpio_dev,
+ port_num);
+ if (ret < 0)
+ {
+ printf("Error, can't get pin value\n");
+ return;
+ }
+ port_value = ret;
+
+
+ while(buffer[0] != 'q')
+ {
+ system("clear");
+ printf("**************************\n");
+ printf(" Testing GPIO P%c%d \n", port_letter, port_num);
+ printf("**************************\n");
+ printf("Choose ('q' to quit):\n");
+ printf(" 1) Change port letter (%c)\n", port_letter);
+ printf(" 2) Change port num (%d)\n", port_num);
+ printf(" 3) Change direction (%d)\n", port_direction);
+ printf(" 4) Change value (%d)\n", port_value);
+ printf(" 5) Read pin value\n");
+
+ printf("> ");
+ scanf("%s",buffer);
+
+ switch(buffer[0])
+ {
+ case '1' : printf("Give letter of port in upper case : ");
+ scanf("%s", buffer);
+ if (buffer[0] != port_letter)
+ {
+ ret = as_gpio_close(gpio_dev);
+ if(ret < 0)
+ {
+ printf("Error, can't close Port%c\n", port_letter);
+ pressEnterToContinue();
+ return ;
+ }
+ }
+ gpio_dev = as_gpio_open(buffer[0]);
+ if(gpio_dev == NULL)
+ {
+ printf("Error, can't open Port%c\n", c_value);
+ pressEnterToContinue();
+ return;
+ }
+ port_letter = buffer[0];
+ printf("Ok Port %c is set\n", port_letter);
+ pressEnterToContinue();
+ break;
+ case '2' : printf("Give pin number : ");
+ scanf("%d", &value);
+ if ((value < 0) || (value > 31))
+ printf("Error, wrong value\n");
+ else
+ port_num = value;
+ pressEnterToContinue();
+ break;
+ case '3' : printf("Give direction (0:in, 1:out) : ");
+ scanf("%d", &value);
+ ret = as_gpio_set_pin_direction(gpio_dev,
+ port_num,
+ value);
+ if(ret < 0)
+ {
+ printf("Error, can't change direction\n");
+ pressEnterToContinue();
+ return ;
+ }
+ port_direction = value;
+ printf("Ok direction changed\n");
+ pressEnterToContinue();
+ break;
+ case '4' : printf("Give value : ");
+ scanf("%d", &value);
+ ret = as_gpio_set_pin_value(gpio_dev,
+ port_num,
+ value);
+ if(ret < 0)
+ {
+ printf("Error, can't change pin value\n");
+ pressEnterToContinue();
+ return;
+ }
+ port_value = value;
+ printf("Ok value changed\n");
+ pressEnterToContinue();
+ break;
+ case '5' : printf("Get value \n");
+ ret = as_gpio_get_pin_value(gpio_dev,
+ port_num);
+ if (ret < 0)
+ {
+ printf("Error, can't get pin value\n");
+ pressEnterToContinue();
+ return;
+ }
+ printf("Value is %d\n",ret);
+ port_value = ret;
+ pressEnterToContinue();
+ break;
+
+ default : break;
+ }
+ }
+}
+
+
hooks/post-receive
--
armadeus
|