[Armadeus-commitlog] armadeus branch, master, updated. release-3.4-59-g1a5b39e
Brought to you by:
sszy
|
From: jscheer <js...@us...> - 2011-04-15 14:41:54
|
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 1a5b39e850b105e42063df8371454cd263515745 (commit)
via f20e31629c872d0560bf0ad4d635785e44231020 (commit)
via dbb8c15c6e35fb927d549d809caf1fc265eb699c (commit)
from 54a615476b3df9e8b0161ceb3d94f5e2a2d8a5c8 (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 1a5b39e850b105e42063df8371454cd263515745
Author: Jeremie Scheer <jer...@ar...>
Date: Fri Apr 15 16:41:15 2011 +0200
[BUILDROOT] [AS_DEVICES] Add test executable for as_devices C and C++ wrappers in Buildroot options.
[TEST] [AS_DEVICES] Fix as_devices C test (test_c.h) and add a test for C++ wrappers (test_cpp.h).
commit f20e31629c872d0560bf0ad4d635785e44231020
Author: Jeremie Scheer <jer...@ar...>
Date: Fri Apr 15 16:35:02 2011 +0200
[BUILDROOT] [AS_DEVICES] Fix some bugs in as_devices C files.
commit dbb8c15c6e35fb927d549d809caf1fc265eb699c
Author: Jeremie Scheer <jer...@ar...>
Date: Fri Apr 15 16:29:17 2011 +0200
[BUILDROOT] [AS_DEVICES] Add as_devices C++ wrappers (as_devices/cpp).
-----------------------------------------------------------------------
Summary of changes:
buildroot/package/armadeus/as_devices/Config.in | 26 +-
.../package/armadeus/as_devices/as_devices.mk | 36 ++
target/packages/as_devices/Makefile | 10 +-
target/packages/as_devices/c/as_adc.c | 4 +-
target/packages/as_devices/c/as_dac.h | 1 +
target/packages/as_devices/c/as_spi.h | 11 +-
target/packages/as_devices/cpp/Makefile | 38 +-
target/packages/as_devices/cpp/as_ad5258.cpp | 98 ----
target/packages/as_devices/cpp/as_ad5258.hpp | 67 ---
target/packages/as_devices/cpp/as_adc.cpp | 114 +----
target/packages/as_devices/cpp/as_adc.hpp | 60 +--
target/packages/as_devices/cpp/as_apf27_gpio.cpp | 108 -----
target/packages/as_devices/cpp/as_apf27_gpio.hpp | 57 ---
target/packages/as_devices/cpp/as_apf27_pwm.cpp | 165 -------
target/packages/as_devices/cpp/as_apf27_pwm.hpp | 66 ---
target/packages/as_devices/cpp/as_dac.cpp | 110 +----
target/packages/as_devices/cpp/as_dac.hpp | 65 +--
target/packages/as_devices/cpp/as_ds1374.cpp | 88 ----
.../packages/as_devices/cpp/as_dynamic_table.hpp | 57 ---
target/packages/as_devices/cpp/as_gpio.cpp | 135 ++++++
.../as_devices/cpp/{as_ds1374.hpp => as_gpio.hpp} | 47 +-
target/packages/as_devices/cpp/as_i2c.cpp | 179 ++++----
target/packages/as_devices/cpp/as_i2c.hpp | 61 +--
target/packages/as_devices/cpp/as_max1027.cpp | 482 -------------------
target/packages/as_devices/cpp/as_max1027.hpp | 99 ----
target/packages/as_devices/cpp/as_max5821.cpp | 282 -----------
target/packages/as_devices/cpp/as_max5821.hpp | 125 -----
target/packages/as_devices/cpp/as_spi.cpp | 130 +++++
.../as_devices/cpp/{as_ds1374.hpp => as_spi.hpp} | 48 +-
target/packages/as_devices/cpp/main.cpp | 85 ----
target/packages/as_devices/main.c | 5 +-
target/packages/as_devices/test_c.h | 267 +++++------
target/packages/as_devices/test_cpp.h | 493 +++++++++++++++++---
33 files changed, 1151 insertions(+), 2468 deletions(-)
delete mode 100644 target/packages/as_devices/cpp/as_ad5258.cpp
delete mode 100644 target/packages/as_devices/cpp/as_ad5258.hpp
delete mode 100644 target/packages/as_devices/cpp/as_apf27_gpio.cpp
delete mode 100644 target/packages/as_devices/cpp/as_apf27_gpio.hpp
delete mode 100644 target/packages/as_devices/cpp/as_apf27_pwm.cpp
delete mode 100644 target/packages/as_devices/cpp/as_apf27_pwm.hpp
delete mode 100644 target/packages/as_devices/cpp/as_ds1374.cpp
delete mode 100644 target/packages/as_devices/cpp/as_dynamic_table.hpp
create mode 100644 target/packages/as_devices/cpp/as_gpio.cpp
copy target/packages/as_devices/cpp/{as_ds1374.hpp => as_gpio.hpp} (56%)
delete mode 100644 target/packages/as_devices/cpp/as_max1027.cpp
delete mode 100644 target/packages/as_devices/cpp/as_max1027.hpp
delete mode 100644 target/packages/as_devices/cpp/as_max5821.cpp
delete mode 100644 target/packages/as_devices/cpp/as_max5821.hpp
create mode 100644 target/packages/as_devices/cpp/as_spi.cpp
rename target/packages/as_devices/cpp/{as_ds1374.hpp => as_spi.hpp} (55%)
delete mode 100644 target/packages/as_devices/cpp/main.cpp
diff --git a/buildroot/package/armadeus/as_devices/Config.in b/buildroot/package/armadeus/as_devices/Config.in
index c1c1c6d..7791781 100644
--- a/buildroot/package/armadeus/as_devices/Config.in
+++ b/buildroot/package/armadeus/as_devices/Config.in
@@ -4,13 +4,25 @@ config BR2_PACKAGE_AS_DEVICES
help
Library that drives armadeus specific devices.
-#config BR2_PACKAGE_AS_DEVICES_CPP
-# depends on BR2_PACKAGE_AS_DEVICES
-# bool "wrapper C++"
-# default n
-# help
-# C++ wrapper for as_devices library
-#
+config BR2_PACKAGE_AS_DEVICES_TESTS
+ bool "as_device test"
+ depends on BR2_PACKAGE_AS_DEVICES
+ help
+ Executable that can test all as_devices
+
+config BR2_PACKAGE_AS_DEVICES_CPP
+ depends on BR2_PACKAGE_AS_DEVICES
+ bool "wrapper C++"
+ default n
+ help
+ C++ wrapper for as_devices library
+
+config BR2_PACKAGE_AS_DEVICES_TESTS_CPP
+ bool "as_device C++ wrappers test"
+ depends on BR2_PACKAGE_AS_DEVICES_CPP
+ help
+ Executable that can test as_devices C++ wrappers
+
config BR2_PACKAGE_AS_DEVICES_PYTHON
depends on BR2_PACKAGE_AS_DEVICES
depends on BR2_PACKAGE_PYTHON
diff --git a/buildroot/package/armadeus/as_devices/as_devices.mk b/buildroot/package/armadeus/as_devices/as_devices.mk
index 5cc203b..f609288 100644
--- a/buildroot/package/armadeus/as_devices/as_devices.mk
+++ b/buildroot/package/armadeus/as_devices/as_devices.mk
@@ -26,11 +26,26 @@ AS_DEVICES_PYTHON_MODULE:=AsDevices
AS_DEVICES_PYTHON_TARGET_DIR:=usr/lib/$(PYTHON)/
AS_DEVICES_PYTHON_TARGET_BINARY:=$(AS_DEVICES_PYTHON_TARGET_DIR)/$(AS_DEVICES_PYTHON_MODULE)
+AS_DEVICES_TEST_BINARY:=test_cdevices
+AS_DEVICES_TEST_TARGET_DIR:=/usr/bin
+AS_DEVICES_TEST_TARGET_BINARY:=$(AS_DEVICES_TEST_TARGET_DIR)/$(AS_DEVICES_TEST_BINARY)
+
+AS_DEVICES_TEST_CPP_BINARY:=test_cppdevices
+AS_DEVICES_TEST_CPP_TARGET_DIR:=/usr/bin
+AS_DEVICES_TEST_CPP_TARGET_BINARY:=$(AS_DEVICES_TEST_CPP_TARGET_DIR)/$(AS_DEVICES_TEST_CPP_BINARY)
+
AS_DEVICES_BINARIES=$(TARGET_DIR)/$(AS_DEVICES_TARGET_BINARY)
+ifeq ($(strip $(BR2_PACKAGE_AS_DEVICES_TESTS)),y)
+AS_DEVICES_BINARIES+= $(TARGET_DIR)/$(AS_DEVICES_TEST_TARGET_BINARY)
+endif
ifeq ($(strip $(BR2_PACKAGE_AS_DEVICES_CPP)),y)
AS_DEVICES_BINARIES+= $(TARGET_DIR)/$(AS_DEVICES_CPP_TARGET_BINARY)
+ifeq ($(strip $(BR2_PACKAGE_AS_DEVICES_TESTS_CPP)),y)
+AS_DEVICES_BINARIES+= $(TARGET_DIR)/$(AS_DEVICES_TEST_CPP_TARGET_BINARY)
+endif
endif
+
ifeq ($(strip $(BR2_PACKAGE_AS_DEVICES_PYTHON)),y)
AS_DEVICES_BINARIES+= $(TARGET_DIR)/$(AS_DEVICES_PYTHON_TARGET_BINARY)
endif
@@ -53,6 +68,16 @@ $(STAGING_DIR)/$(AS_DEVICES_TARGET_BINARY): $(AS_DEVICES_DIR)/c/$(AS_DEVICES_BIN
$(TARGET_DIR)/$(AS_DEVICES_TARGET_BINARY): $(STAGING_DIR)/$(AS_DEVICES_TARGET_BINARY)
$(MAKE) INSTALL_DIR=$(TARGET_DIR) STRIP="$(STRIPCMD) $(STRIP_STRIP_UNNEEDED)" -C $(AS_DEVICES_DIR) install-exe
+ifeq ($(strip $(BR2_PACKAGE_AS_DEVICES_TESTS)),y)
+
+$(TARGET_DIR)/$(AS_DEVICES_TEST_TARGET_BINARY): $(AS_DEVICES_DIR)/$(AS_DEVICES_TEST_BINARY)
+ cp -rf $(AS_DEVICES_DIR)/$(AS_DEVICES_TEST_BINARY) $(TARGET_DIR)/$(AS_DEVICES_TEST_TARGET_BINARY)
+ $(STRIPCMD) $(STRIP_STRIP_UNNEEDED) $(TARGET_DIR)/$(AS_DEVICES_TEST_TARGET_BINARY)
+
+$(AS_DEVICES_DIR)/$(AS_DEVICES_TEST_BINARY): $(AS_DEVICES_DIR)/Makefile
+ $(TARGET_CONFIGURE_OPTS) $(MAKE) CC="$(TARGET_CC)" CXX="$(TARGET_CXX)" $(AS_DEVICES_TEST_BINARY) -C $(AS_DEVICES_DIR)
+endif
+
ifeq ($(strip $(BR2_PACKAGE_AS_DEVICES_CPP)),y)
$(TARGET_DIR)/$(AS_DEVICES_CPP_TARGET_BINARY): $(AS_DEVICES_DIR)/cpp/$(AS_DEVICES_CPP_BINARY)
install -D $< $@
@@ -60,6 +85,17 @@ $(TARGET_DIR)/$(AS_DEVICES_CPP_TARGET_BINARY): $(AS_DEVICES_DIR)/cpp/$(AS_DEVICE
$(AS_DEVICES_DIR)/cpp/$(AS_DEVICES_CPP_BINARY): $(AS_DEVICES_DIR)/Makefile
$(TARGET_CONFIGURE_OPTS) $(MAKE) CC="$(TARGET_CC)" CXX="$(TARGET_CXX)" -C $(AS_DEVICES_DIR)/cpp
+
+ifeq ($(strip $(BR2_PACKAGE_AS_DEVICES_TESTS_CPP)),y)
+
+$(TARGET_DIR)/$(AS_DEVICES_TEST_CPP_TARGET_BINARY): $(AS_DEVICES_DIR)/$(AS_DEVICES_TEST_CPP_BINARY)
+ cp -rf $(AS_DEVICES_DIR)/$(AS_DEVICES_TEST_CPP_BINARY) $(TARGET_DIR)/$(AS_DEVICES_TEST_CPP_TARGET_BINARY)
+ $(STRIPCMD) $(STRIP_STRIP_UNNEEDED) $(TARGET_DIR)/$(AS_DEVICES_TEST_CPP_TARGET_BINARY)
+
+$(AS_DEVICES_DIR)/$(AS_DEVICES_TEST_CPP_BINARY): $(AS_DEVICES_DIR)/Makefile
+ $(TARGET_CONFIGURE_OPTS) $(MAKE) CC="$(TARGET_CC)" CXX="$(TARGET_CXX)" $(AS_DEVICES_TEST_CPP_BINARY) -C $(AS_DEVICES_DIR)
+endif
+
endif
ifeq ($(strip $(BR2_PACKAGE_AS_DEVICES_PYTHON)),y)
diff --git a/target/packages/as_devices/Makefile b/target/packages/as_devices/Makefile
index d052b39..94fd1a2 100644
--- a/target/packages/as_devices/Makefile
+++ b/target/packages/as_devices/Makefile
@@ -30,11 +30,11 @@ all: $(C_BINARY) $(P_WRAPPER)
$(C_BINARY): main.c test_c.h $(C_LIB)
$(CC) $(CFLAGS) main.c $(C_LIB) -o $(C_BINARY) -I$(C_INCLUDE) -lm
-#$(CPP_BINARY): main.c test_cpp.h $(CPP_LIB) $(C_LIB)
-# $(CXX) $(CFLAGS) main.c $(C_LIB) $(CPP_LIB) -I$(C_INCLUDE) -I$(CPP_INCLUDE) -o $(CPP_BINARY)
-#
-#$(CPP_LIB): $(C_LIB)
-# cd cpp; make CXX=$(CXX)
+$(CPP_BINARY): main.c test_cpp.h $(CPP_LIB) $(C_LIB)
+ $(CXX) $(CFLAGS) main.c $(C_LIB) $(CPP_LIB) -I$(C_INCLUDE) -I$(CPP_INCLUDE) -o $(CPP_BINARY) -D__cplusplus
+
+$(CPP_LIB): $(C_LIB)
+ cd cpp; make CXX=$(CXX)
$(C_LIB):
make -C c/
diff --git a/target/packages/as_devices/c/as_adc.c b/target/packages/as_devices/c/as_adc.c
index eb702f4..9232600 100644
--- a/target/packages/as_devices/c/as_adc.c
+++ b/target/packages/as_devices/c/as_adc.c
@@ -62,12 +62,12 @@ int32_t as_adc_get_value_in_millivolts(struct as_adc_device *aDev, int aChannel)
int32_t as_adc_close(struct as_adc_device *aDev) {
int ret;
if (strncmp(AS_MAX1027_NAME, aDev->device_type, strlen(AS_MAX1027_NAME)) == 0) {
- ret = as_adc_close(aDev);
+ ret = as_adc_close_max1027(aDev);
free(aDev);
return ret;
}
if (strncmp(AS_AS1531_NAME, aDev->device_type, strlen(AS_AS1531_NAME)) == 0) {
- ret = as_adc_close_max1027(aDev);
+ ret = as_adc_close_as1531(aDev);
free(aDev);
return ret;
}
diff --git a/target/packages/as_devices/c/as_dac.h b/target/packages/as_devices/c/as_dac.h
index 6b569a3..8ace82b 100644
--- a/target/packages/as_devices/c/as_dac.h
+++ b/target/packages/as_devices/c/as_dac.h
@@ -27,6 +27,7 @@ extern "C" {
#endif
#include "as_dac.h"
+#include <stdint.h>
#define AS_MAX5821_TYPE "max5821"
#define AS_MCP4912
diff --git a/target/packages/as_devices/c/as_spi.h b/target/packages/as_devices/c/as_spi.h
index 9fd2a51..99907ee 100644
--- a/target/packages/as_devices/c/as_spi.h
+++ b/target/packages/as_devices/c/as_spi.h
@@ -52,7 +52,7 @@ int as_spi_open(const unsigned char *aSpidev_name);
*/
int as_spi_set_lsb(int aFd, uint8_t aLsb);
-/** @brief Set bits order
+/** @brief Get bits order
*
* @param aFd spidev file handler
*
@@ -80,15 +80,6 @@ int as_spi_set_mode(int aFd, uint8_t aMode);
*/
int as_spi_get_mode(int aFd);
-/** @brief Get bits order
- *
- * @param aFd spidev file handler
- *
- * @return lsb first if positive, msb first if 0, negative value on error
- *
- */
-int as_spi_get_lsb(int aFd);
-
/** @brief Set clock bus speed
*
* @param aFd spidev file handler
diff --git a/target/packages/as_devices/cpp/Makefile b/target/packages/as_devices/cpp/Makefile
index 65e0c28..4f88be7 100644
--- a/target/packages/as_devices/cpp/Makefile
+++ b/target/packages/as_devices/cpp/Makefile
@@ -1,20 +1,18 @@
# to compile for arm :
-# make CXX=../../bsp/buildroot/build_armv5te/staging_dir/usr/bin/arm-linux-g++
-# make CXX=~/Projects/HMSDemo/software/bsp/buildroot/build_armv5te/staging_dir/usr/bin/arm-linux-g++
-# make CXX=~/Projects/virgin_HMS/software/bsp/buildroot/build_armv5te/staging_dir/usr/bin/arm-linux-g++
+# make CXX=../../../buildroot/build_armv5te/staging_dir/usr/bin/arm-linux-g++
#
+# Default values for local compiling:
+ARMADEUS_BASE_DIR=../../../../
+-include $(ARMADEUS_BASE_DIR)/Makefile.in
CXXFLAGS=-Wall -g -O0
LDFLAGS=
-OBJ=as_apf27_pwm.o
-OBJ+= as_i2c.o
-OBJ+= as_apf27_gpio.o
-#OBJ+= as_max1027.o
-#OBJ+= as_max5821.o
-#OBJ+= as_adc.o
-#OBJ+= as_dac.o
-#OBJ+= as_ad5258.o
-#OBJ+= as_ds1374.o
+OBJS = as_i2c.o
+OBJS += as_gpio.o
+OBJS += as_dac.o
+OBJS += as_adc.o
+
+OBJS += as_spi.o
LIBRARY=as_devices_cpp
LIB_VERS=1
@@ -23,20 +21,22 @@ SONAME=lib${LIBRARY}.so
LIBNAME=${SONAME}.${LIB_VERS}
ARCHIVE_CMD=ar
ARCHIVE_OPTS=-cvq
+
C_INCLUDE=../c/
C_LIB=../c/libas_devices.so.1
-${LIBNAME}: ${OBJ}
- ${CXX} -shared -Wl,-soname,${SONAME} -o ${SONAME} ${OBJ} ${C_LIB} -lc
+${LIBNAME}: ${OBJS}
+ ${CXX} -shared -Wl,-soname,${SONAME} -o ${SONAME} ${OBJS} ${C_LIB} -lc
ln -s ${SONAME} ${LIBNAME}
-${STAT_LIB}: ${OBJ}
- ${ARCHIVE_CMD} ${ARCHIVE_OPTS} ${STAT_LIB} ${OBJ}
+${STAT_LIB}: ${OBJS}
+ ${ARCHIVE_CMD} ${ARCHIVE_OPTS} ${STAT_LIB} ${OBJS}
%.o: %.cpp
- $(CXX) -fPIC -o $@ -c $< ${CXXFLAGS} -I${C_INCLUDE}
+ $(CXX) -fPIC -o $@ -c $< ${CXXFLAGS} -I${C_INCLUDE} -D__cplusplus
clean:
- -rm ${OBJ} ${BINARY}
- -rm ${LIBNAME} ${SONAME}
+ -rm ${OBJ} ${BINARY} ${STAT_LIB} ${LIBNAME}
+ -rm *.o
+ -rm *.so
diff --git a/target/packages/as_devices/cpp/as_ad5258.cpp b/target/packages/as_devices/cpp/as_ad5258.cpp
deleted file mode 100644
index f8d24b3..0000000
--- a/target/packages/as_devices/cpp/as_ad5258.cpp
+++ /dev/null
@@ -1,98 +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
-*/
-
-#include "as_ad5258.hpp"
-
-AsAd5258::AsAd5258(int aI2cNumber)
-{
- mI2c = AsI2c::getInstance(aI2cNumber);
- mI2cAd5258Addr = I2C_AD5258_ADDR;
-}
-
-AsAd5258::~AsAd5258()
-{
-}
-
-/*------------------------------------------------------------------------------*/
-/** Set RDAC value
- * @param aValue int value between 0 and 63
- */
-void
-AsAd5258::setRdac(int aValue)
-{
- mI2c->writeByteData(mI2cAd5258Addr,0x00,aValue);
-}
-
-/*------------------------------------------------------------------------------*/
-/** Get RDAC value
- * @return int value between 0 and 63
- */
-int
-AsAd5258::getRdac(void)
-{
- unsigned char value;
- mI2c->readByteData(mI2cAd5258Addr,0x00,&value);
- return value;
-}
-
-/*------------------------------------------------------------------------------*/
-/** Set EEPROM value for RDAC
- * @param aValue int value
- */
-void
-AsAd5258::setEeprom(int aValue)
-{
- mI2c->writeByteData(mI2cAd5258Addr,0x20,aValue);
-}
-
-/*------------------------------------------------------------------------------*/
-/** Get EEPROM value
- * @return int value
- */
-int
-AsAd5258::getEeprom(void)
-{
- unsigned char value;
- mI2c->readByteData(mI2cAd5258Addr,0x20,&value);
- return value;
-}
-
-/*------------------------------------------------------------------------------*/
-/** Store RDAC value in EEPROM
- */
-void
-AsAd5258::store(void)
-{
- mI2c->writeByte(mI2cAd5258Addr,0xc0);
- /* wait for 26ms */
-}
-
-/*------------------------------------------------------------------------------*/
-/** Restore RDAC value from EEPROM
- */
-void
-AsAd5258::restore(void)
-{
- mI2c->writeByte(mI2cAd5258Addr,0xa0);
- /* wait for 300µs */
-}
-
-
diff --git a/target/packages/as_devices/cpp/as_ad5258.hpp b/target/packages/as_devices/cpp/as_ad5258.hpp
deleted file mode 100644
index c69c789..0000000
--- a/target/packages/as_devices/cpp/as_ad5258.hpp
+++ /dev/null
@@ -1,67 +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
-**
-** TODO: use kernel driver instead of i2c bus :
-** http://www.mail-archive.com/ucl...@bl.../msg02051.html
-*/
-
-#ifndef __ASAD5258_HPP__
-#define __ASAD5258_HPP__
-
-#include "as_i2c.hpp"
-
-#define I2C_AD5258_ADDR (0x18)
-#define I2C_DEV_PATH "/dev/i2c-"
-#define I2C_BUS_NUM (0)
-
-/** AsAd5258 description
- *
- */
-class AsAd5258 {
-public:
- AsAd5258(int aI2cNumber);
-
- virtual ~AsAd5258();
-
- void setRdac(int aValue);
- int getRdac(void);
- void setEeprom(int aValue);
- int getEeprom(void);
- void store(void);
- void restore(void);
-
-private:
- int mI2cNumber;
- unsigned char mI2cAd5258Addr;
-
- AsI2c * mI2c;
-
- /** XXX: i2c methods
- */
- int mFHandlerI2c;
- int i2c_init(void);
- int i2c_readByte (unsigned char reg, unsigned char *buf );
- int i2c_writeByte(unsigned char reg, unsigned char value);
-
-};
-
-#endif /* __ASAD5258_HPP__ */
-
-
diff --git a/target/packages/as_devices/cpp/as_adc.cpp b/target/packages/as_devices/cpp/as_adc.cpp
index 0a014ea..bc23adc 100644
--- a/target/packages/as_devices/cpp/as_adc.cpp
+++ b/target/packages/as_devices/cpp/as_adc.cpp
@@ -1,8 +1,8 @@
/*
** THE ARMadeus Systems
**
-** Copyright (C) 2009 The armadeus systems team
-** Fabien Marteau <fab...@ar...>
+** Copyright (C) 2011 The armadeus systems team
+** Jérémie Scheer <jer...@ar...>
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
@@ -17,107 +17,41 @@
** 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 <stdlib.h>
-#include <stdio.h>
-#include "as_adc.hpp"
-
-AsAdc::AsAdc(int aNumberOfChannels)
-{
- mChannelNumber = aNumberOfChannels;
- mChannelHandlers = (int *)malloc(sizeof(int)*aNumberOfChannels);
- for(int i=0; i < aNumberOfChannels; i++)
- {
- mChannelHandlers[i] = -1;
- }
- mChannelObject = (void **)malloc(sizeof(void *)*aNumberOfChannels);
- for(int i=0; i < aNumberOfChannels; i++)
- {
- mChannelObject[i] = NULL;
- }
-}
-
-AsAdc::~AsAdc()
-{
- free(mChannelHandlers);
- free(mChannelObject);
-}
-/*------------------------------------------------------------------------------*/
+#include "as_adc.hpp"
+#include <iostream>
-/** Connect adc to an object
+/** @brief Constructor: Initialize port access
*
- * @param object to connect on adc
- * @param channel number
- * @return error
+ * @param aDeviceNum device number
+ * @param aAdcType ADC type 0:max1027 1:as1531
+ * @param aVRef reference tension in millivolts
*/
-AsAdc::AsAdc_errors
-AsAdc::connect(void * aObject, int aChannelNum)
+AsAdc::AsAdc(const char *aAdcType, int aDeviceNum, int aVRef)
{
- if( aChannelNum >= mChannelNumber || aChannelNum < 0)
- {
- return AS_ADC_WRONGCHAN;
- }
- if (mChannelObject[aChannelNum] != NULL)
- {
- return AS_ADC_ALREADY_CONNECTED;
- }
- mChannelObject[aChannelNum] = aObject;
- return AS_ADC_OK;
+ mDev = as_adc_open(aAdcType, aDeviceNum, aVRef);
}
-/*------------------------------------------------------------------------------*/
-
-/** Connect adc to an object
- *
- * @param channel number
- * @return error
- */
-AsAdc::AsAdc_errors
-AsAdc::disconnect(int aChannelNum)
+AsAdc::~AsAdc()
{
- if(aChannelNum >= mChannelNumber || aChannelNum < 0)
- {
- return AS_ADC_WRONGCHAN;
- }
- if(mChannelObject[aChannelNum] == NULL)
- {
- return AS_ADC_NOCONNECTION;
- }
- mChannelObject[aChannelNum] = NULL;
- return AS_ADC_OK;
-}
-/*------------------------------------------------------------------------------*/
+ int ret;
-/** Connect adc to an object
- *
- * @param channel number
- * @return error
- */
-AsAdc::AsAdc_errors
-AsAdc::disconnect(void * aObject)
-{
- return disconnect(getObjectChannel(aObject));
+ ret = as_adc_close(mDev);
+ if (ret < 0)
+ {
+ std::cout<<"AsAdc destruction error"<<std::endl;
+ }
}
-/*------------------------------------------------------------------------------*/
-
-/** Return channel number of an object
+/** @brief get value in millivolts
*
- * @param object pointer
- * @return channel number
+ * @param aChannel channel number
+ *
+ * @return value in millivolts ; error if negative millivolts
*/
-int
-AsAdc::getObjectChannel(void * aObject)
+long AsAdc::getValueInMillivolts(int aChannel) const
{
- for (int i=0; i< mChannelNumber;i++)
- {
- if(aObject == mChannelObject[i])
- {
- return i;
- }
- }
- printf("No connection for this object in adc\n");
- return (int)AS_ADC_NOCONNECTION;
+ return as_adc_get_value_in_millivolts(mDev, aChannel);
}
-
diff --git a/target/packages/as_devices/cpp/as_adc.hpp b/target/packages/as_devices/cpp/as_adc.hpp
index c576662..bda14d1 100644
--- a/target/packages/as_devices/cpp/as_adc.hpp
+++ b/target/packages/as_devices/cpp/as_adc.hpp
@@ -1,8 +1,8 @@
/*
** THE ARMadeus Systems
**
-** Copyright (C) 2009 The armadeus systems team
-** Fabien Marteau <fab...@ar...>
+** Copyright (C) 2011 The armadeus systems team
+** Jérémie Scheer <jer...@ar...>
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
@@ -17,54 +17,24 @@
** 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 __ASADC_HPP__
-#define __ASADC_HPP__
+#ifndef AS_ADC__HPP__
+#define AS_ADC__HPP__
-using namespace std;
+#include "as_adc.h"
-/** AsAdc description
- *
- */
-class AsAdc{
- public:
- enum AsAdc_errors
- {
- AS_ADC_NOCONNECTION = -7,
- AS_ADC_ALREADY_CONNECTED = -6,
- AS_ADC_WRONGCHAN = -5,
- AS_ADC_LSEEK = -4,
- AS_ADC_READFILE = -3,
- AS_ADC_WRITEFILE = -2,
- AS_ADC_OPENFILE = -1,
- AS_ADC_OK = 0
- };
-
- AsAdc(int aNumberOfChannels);
-
- virtual ~AsAdc();
+class AsAdc
+{
+public:
+ AsAdc(const char *aAdcType, int aDeviceNum, int aVRef);
+ virtual ~AsAdc();
- /* ADC connection */
- AsAdc_errors connect(void * aObject, int aChannelNum);
- AsAdc_errors disconnect(int aChannelNum);
- AsAdc_errors disconnect(void * aObject);
-
- /* ADC access */
- virtual AsAdc_errors readTemperature_mC(void)=0;
- virtual float readTemperature_C(void)=0;
-
- virtual AsAdc_errors getValueInMiliVolt(void * aObject)=0;
- virtual AsAdc_errors getValueInMiliVolt(int aChannelNumber)=0;
- virtual float getValueInVolt (void * aObject)=0;
-
- protected:
- int getObjectChannel(void * aObject);
- int * mChannelHandlers; /**< file handler for each channel */
- void ** mChannelObject; /**< object for each channel */
- int mChannelNumber;
+ long getValueInMillivolts(int aChannel) const;
+protected:
+ mutable struct as_adc_device *mDev;
};
-#endif /* __ASADC_HPP__ */
-
+#endif // AS_ADC__HPP__
diff --git a/target/packages/as_devices/cpp/as_apf27_gpio.cpp b/target/packages/as_devices/cpp/as_apf27_gpio.cpp
deleted file mode 100644
index f9b19e9..0000000
--- a/target/packages/as_devices/cpp/as_apf27_gpio.cpp
+++ /dev/null
@@ -1,108 +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
-*/
-#include "as_apf27_gpio.hpp"
-
-AsDynamicTable * AsApf27Gpio::mInstances = new AsDynamicTable();
-
-/*------------------------------------------------------------------------------*/
-/** Singleton constructor
- * @param aPortLetter port letter in upper case
- * @return object
- */
-AsApf27Gpio *
-AsApf27Gpio::getInstance(char aPortLetter)
-{
- AsApf27Gpio * instance;
-
- instance = (AsApf27Gpio *)mInstances->getInstance(aPortLetter-'A');
- if(instance == NULL)
- {
- instance = new AsApf27Gpio(aPortLetter);
- mInstances->setInstance((void *)instance, aPortLetter-'A');
- }
-
- return instance;
-}
-
-/*------------------------------------------------------------------------------*/
-
-AsApf27Gpio::AsApf27Gpio(char aPortLetter)
-{
- mPortLetter = aPortLetter;
- as_apf27_gpio_init(aPortLetter);
-}
-/*------------------------------------------------------------------------------*/
-
-AsApf27Gpio::~AsApf27Gpio()
-{
- as_apf27_gpio_close(mPortLetter);
-}
-
-/*------------------------------------------------------------------------------*/
-
-/** Init Gpio
- * @return AsApf27GpioError
- */
-int
-AsApf27Gpio::init()
-{
- return as_apf27_gpio_init(mPortLetter);
-}
-
-/*------------------------------------------------------------------------------*/
-
-/** Set pin direction
- * @param aPinNum : pin number
- * @param aDirection : direction 0:input 1:output
- * @return AsApf27GpioError
- */
-int
-AsApf27Gpio::setPinDirection(int aPinNum, int aDirection)
-{
- return as_apf27_gpio_set_pin_value(mPortLetter, aPinNum, aDirection);
-}
-
-/*------------------------------------------------------------------------------*/
-
-/** Set pin value
- * @param aPinNum pin number
- * @param aValue value of pin (1 or 0)
- * @return AsApf27GpioError
- */
-int
-AsApf27Gpio::setPinValue(int aPinNum, int aValue)
-{
- return as_apf27_gpio_set_pin_value(mPortLetter, aPinNum, aValue);
-}
-
-/*------------------------------------------------------------------------------*/
-
-/** Set pin value
- * @param aPinNum pin number
- * @param aValue value of pin (1 or 0)
- * @return AsApf27GpioError
- */
-
-int
-AsApf27Gpio::getPinValue(int aPinNum)
-{
- return as_apf27_gpio_get_pin_value(mPortLetter, aPinNum);
-}
diff --git a/target/packages/as_devices/cpp/as_apf27_gpio.hpp b/target/packages/as_devices/cpp/as_apf27_gpio.hpp
deleted file mode 100644
index d303522..0000000
--- a/target/packages/as_devices/cpp/as_apf27_gpio.hpp
+++ /dev/null
@@ -1,57 +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_HPP__
-#define __ASAPF27GPIO_HPP__
-
-#include "as_apf27_gpio.h"
-#define DYNAMIC_TABLE_SIZE NUMBER_OF_PORTS
-#include "as_dynamic_table.hpp"
-
-/** AsApf27Gpio description
- *
- */
-class AsApf27Gpio {
-
-public:
-
- static AsApf27Gpio * getInstance(char aPortLetter);
- virtual ~AsApf27Gpio();
-
- int setPinDirection(int aPinNum,int aDirection);
- int setPinValue(int aPinNum, int aValue);
- int getPinValue(int aPinNum);
-
-protected:
- static AsDynamicTable * mInstances;
-
- AsApf27Gpio(char aPortLetter);
-
- int init();
-
- char mPortLetter; /**> Port letter in upper case */
-
- int mFileHandlerGpioPort;
-};
-
-#endif /* __ASAPF27GPIO_HPP__ */
-
-
diff --git a/target/packages/as_devices/cpp/as_apf27_pwm.cpp b/target/packages/as_devices/cpp/as_apf27_pwm.cpp
deleted file mode 100644
index 28602d5..0000000
--- a/target/packages/as_devices/cpp/as_apf27_pwm.cpp
+++ /dev/null
@@ -1,165 +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
-*/
-#include "as_apf27_pwm.hpp"
-#include <string.h>
-#include <fcntl.h> /* for open() */
-#include <errno.h> /* for perror() */
-#include <unistd.h> /* for write() */
-#include <iostream>
-
-AsDynamicTable * AsApf27Pwm::mInstances = new AsDynamicTable();
-
-/*------------------------------------------------------------------------------*/
-AsApf27Pwm *
-AsApf27Pwm::getInstance(int aPwmNumber)
-{
- void * instance;
-
- instance = mInstances->getInstance(aPwmNumber);
- if(instance == NULL)
- {
- instance =(void *)(new AsApf27Pwm(aPwmNumber));
- mInstances->setInstance(instance,aPwmNumber);
- }
- return (AsApf27Pwm *)instance;
-}
-
-/*------------------------------------------------------------------------------*/
-
-AsApf27Pwm::AsApf27Pwm(int aPwmNumber)
-{
- int ret;
- ret = as_apf27_pwm_init(aPwmNumber);
- if(ret < 0)
- {
- std::cout << "Pwm initialization error" << std::endl;
- }
-}
-
-/*------------------------------------------------------------------------------*/
-
-AsApf27Pwm::~AsApf27Pwm()
-{
- mInstances->setInstance(NULL,mPwmNumber);
-}
-
-/*------------------------------------------------------------------------------*/
-/** set Frequency
- *
- * @param aFrequency frequency
- */
-void
-AsApf27Pwm::setFrequency(int aFrequency)
-{
- as_apf27_pwm_setFrequency(mPwmNumber, aFrequency);
-}
-
-/*------------------------------------------------------------------------------*/
-/** get Frequency value
- *
- * @return int frequency
- */
-int
-AsApf27Pwm::getFrequency(void)
-{
- return as_apf27_pwm_getFrequency(mPwmNumber);
-}
-
-/*------------------------------------------------------------------------------*/
-/** set period
- *
- * @param aPeriod period
- */
-void
-AsApf27Pwm::setPeriod(int aPeriod)
-{
- as_apf27_pwm_setPeriod(mPwmNumber, aPeriod);
-}
-
-/*------------------------------------------------------------------------------*/
-/** get Period
- *
- * @return period int
- */
-int
-AsApf27Pwm::getPeriod(void)
-{
- return as_apf27_pwm_getPeriod(mPwmNumber);
-}
-
-/*------------------------------------------------------------------------------*/
-/** set duty
- * @param aDuty duty
- */
-void
-AsApf27Pwm::setDuty(int aDuty)
-{
- as_apf27_pwm_setDuty(mPwmNumber, aDuty);
-}
-
-/*------------------------------------------------------------------------------*/
-/** get duty
- *
- * @return duty
- */
-int
-AsApf27Pwm::getDuty(void)
-{
- return as_apf27_pwm_getDuty(mPwmNumber);
-}
-
-/*------------------------------------------------------------------------------*/
-/** activate pwm
- * @param aEnable
- */
-bool
-AsApf27Pwm::activate(bool aEnable)
-{
- int ret;
-
- if(aEnable)
- as_apf27_pwm_activate(mPwmNumber,1);
- else
- as_apf27_pwm_activate(mPwmNumber,0);
-
- if(ret)
- return true;
- else
- return false;
-}
-
-/*------------------------------------------------------------------------------*/
-/** get State of pwm (enable or not)
- * @return state
- */
-bool
-AsApf27Pwm::getState(void)
-{
- int ret;
- ret = as_apf27_pwm_getState(mPwmNumber);
-
- if(ret)
- return true;
- else
- return false;
-}
-
-
diff --git a/target/packages/as_devices/cpp/as_apf27_pwm.hpp b/target/packages/as_devices/cpp/as_apf27_pwm.hpp
deleted file mode 100644
index 28d9a6b..0000000
--- a/target/packages/as_devices/cpp/as_apf27_pwm.hpp
+++ /dev/null
@@ -1,66 +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 __ASAPF27PWM_HPP__
-#define __ASAPF27PWM_HPP__
-
-#include "as_apf27_pwm.h"
-#include <stdio.h>
-#include <stdlib.h>
-
-#define PWM_NUMBER NUMBER_OF_PWM
-#define DYNAMIC_TABLE_SIZE PWM_NUMBER
-
-#include "as_dynamic_table.hpp"
-
-/** AsApf27Pwm description
- *
- */
-class AsApf27Pwm {
-public:
- static AsApf27Pwm * getInstance(int aPwmNumber);
-
- void setFrequency(int aFrequency);
- int getFrequency(void);
-
- void setPeriod(int aPeriod);
- int getPeriod(void);
-
- void setDuty(int aDuty);
- int getDuty(void);
-
- bool activate(bool aEnable);
- bool getState(void);
-
- virtual ~AsApf27Pwm();
-
-protected:
-
- static AsDynamicTable * mInstances;
-
- AsApf27Pwm(int aPwmNumber);
- int mPwmNumber;
-
-};
-
-#endif /* __ASAPF27PWM_HPP__ */
-
-
diff --git a/target/packages/as_devices/cpp/as_dac.cpp b/target/packages/as_devices/cpp/as_dac.cpp
index 00e4774..1bd5bab 100644
--- a/target/packages/as_devices/cpp/as_dac.cpp
+++ b/target/packages/as_devices/cpp/as_dac.cpp
@@ -1,8 +1,8 @@
/*
** THE ARMadeus Systems
**
-** Copyright (C) 2009 The armadeus systems team
-** Fabien Marteau <fab...@ar...>
+** Copyright (C) 2011 The armadeus systems team
+** Jérémie Scheer <jer...@ar...>
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
@@ -17,102 +17,44 @@
** 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 <stdlib.h>
-#include <stdio.h>
#include "as_dac.hpp"
+#include <iostream>
-AsDac::AsDac()
-{
-
-}
-
-AsDac::~AsDac()
-{
-}
-
-/*------------------------------------------------------------------------------*/
-
-/** Connect dac to an object
+/** @brief Constructor: Open DAC
*
- * @param object to connect on dac
- * @param channel number
- * @return error
+ * @param aDacType type name of adc ("max5821" or "mcp4912")
+ * @param aBusNumber bus number used
+ * @param aAddress i2c address for i2c chip, and CS number for SPI chip
+ * @param aVRef voltage reference in milivolt
+ * @param aVDefault default voltage value at open
*/
-AsDac::AsDac_errors
-AsDac::connect(void * aObject, char aChannel)
+AsDac::AsDac(const char *aDacType, int aBusNumber, int aAddress, int aVRef)
{
- int channel;
-
- channel = aChannel - 'A';
- if( channel >= mChannelNumber || channel < 0)
- {
- return AS_DAC_WRONGCHAN;
- }
- if (mChannelObject[channel] != NULL)
- {
- return AS_DAC_ALREADY_CONNECTED;
- }
- mChannelObject[channel] = aObject;
- return AS_DAC_OK;
+ mDev = as_dac_open(aDacType, aBusNumber, aAddress, aVRef);
}
-/*------------------------------------------------------------------------------*/
-
-/** Connect adc to an object
- *
- * @param channel number
- * @return error
- */
-AsDac::AsDac_errors
-AsDac::disconnect(char aChannel)
+AsDac::~AsDac()
{
+ int ret;
- int channel;
-
- channel = aChannel - 'A';
- if(channel >= mChannelNumber || channel < 0)
- {
- return AS_DAC_WRONGCHAN;
- }
- if(mChannelObject[channel] == NULL)
- {
- return AS_DAC_NOCONNECTION;
- }
- mChannelObject[channel] = NULL;
- return AS_DAC_OK;
+ ret = as_dac_close(mDev);
+ if (ret < 0)
+ {
+ std::cout<<"AsDac destruction error"<<std::endl;
+ }
}
-/*------------------------------------------------------------------------------*/
-
-/** Connect adc to an object
+
+/** @brief set a channel value.
*
- * @param channel number
- * @return error
- */
-AsDac::AsDac_errors
-AsDac::disconnect(void * aObject)
-{
- return disconnect(getObjectChannel(aObject));
-}
-
-/*------------------------------------------------------------------------------*/
-
-/** Return channel number of an object
+ * @param aChannel channel number (A:0, B:1,...)
+ * @param aValue channel value in milivolt
*
- * @param object pointer
- * @return channel number
+ * @return negative value on error
*/
-char
-AsDac::getObjectChannel(void * aObject)
+long AsDac::setValueInMillivolts(int aChannel, int aValue)
{
- for (int i=0; i< mChannelNumber;i++)
- {
- if(aObject == mChannelObject[i])
- {
- return i+'A';
- }
- }
- return (int)AS_DAC_NOCONNECTION;
+ return as_dac_set_value_in_millivolts(mDev, aChannel, aValue);
}
-
diff --git a/target/packages/as_devices/cpp/as_dac.hpp b/target/packages/as_devices/cpp/as_dac.hpp
index 486a072..3c0a657 100644
--- a/target/packages/as_devices/cpp/as_dac.hpp
+++ b/target/packages/as_devices/cpp/as_dac.hpp
@@ -1,8 +1,8 @@
/*
** THE ARMadeus Systems
**
-** Copyright (C) 2009 The armadeus systems team
-** Fabien Marteau <fab...@ar...>
+** Copyright (C) 2011 The armadeus systems team
+** Jérémie Scheer <jer...@ar...>
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
@@ -17,55 +17,24 @@
** 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 __ASDAC_HPP__
-#define __ASDAC_HPP__
+#ifndef AS_DAC__HPP__
+#define AS_DAC__HPP__
-using namespace std;
+#include "as_dac.h"
-/** AsDac description
- *
- */
-class AsDac{
- public:
- enum AsDac_errors
- {
- AS_DAC_NOCONNECTION = -7,
- AS_DAC_ALREADY_CONNECTED = -6,
- AS_DAC_IOCTL = -6,
- AS_DAC_WRONGCHAN = -5,
- AS_DAC_LSEEK = -4,
- AS_DAC_READFILE = -3,
- AS_DAC_WRITEFILE = -2,
- AS_DAC_OPENFILE = -1,
- AS_DAC_OK = 0
- };
-
- AsDac();
-
- virtual ~AsDac();
-
- virtual AsDac_errors init(int aI2cNum)=0;
- virtual AsDac_errors setDac(void * aObject, int aValue)=0;
- virtual AsDac_errors setDacPercent(void * aObject, float aValueInPercent)=0;
-
- /* */
- virtual AsDac_errors powerDown(void * aObject)=0;
-
- /* DAC connections */
- AsDac_errors connect(void * aObject, char aChannel);
- AsDac_errors disconnect(char aChannel);
- AsDac_errors disconnect(void * aObject);
-
- protected:
- char getObjectChannel(void * aObject);
-
- void ** mChannelObject; /**< object for each channel 'A' -> channel 0,
- 'B' -> channel 1*/
- int mChannelNumber; /**< Channel number in component */
-};
-
-#endif /* __ASDAC_HPP__ */
+class AsDac
+{
+public:
+ AsDac(const char *aDacType, int aBusNumber, int aAddress, int aVRef);
+ virtual ~AsDac();
+
+ long setValueInMillivolts(int aChannel, int aValue);
+protected:
+ mutable struct as_dac_device *mDev;
+};
+#endif // AS_DAC__HPP__
diff --git a/target/packages/as_devices/cpp/as_ds1374.cpp b/target/packages/as_devices/cpp/as_ds1374.cpp
deleted file mode 100644
index 25ea7f8..0000000
--- a/target/packages/as_devices/cpp/as_ds1374.cpp
+++ /dev/null
@@ -1,88 +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
-*/
-#include "as_ds1374.hpp"
-/*------------------------------------------------------------------------------*/
-
-AsDs1374::AsDs1374(int aI2cBusNum,int aI2cChipAddr)
-{
- mAsI2c = AsI2c::getInstance(aI2cBusNum);
- mI2cChipAddr = aI2cChipAddr;
-}
-/*------------------------------------------------------------------------------*/
-
-AsDs1374::~AsDs1374()
-{
-}
-
-/*------------------------------------------------------------------------------*/
-/* Set counter value
- * @param aValue counter value
- * @return error code
- */
-int
-AsDs1374::setCounter(int aValue)
-{
- unsigned char buf[4];
-
-#ifdef DEBUG
- printf("-> 0x%08x\n", aValue);
-#endif
- // create an I2C write message
- buf[0] = DS1374_CNT_REG;
- buf[1] = aValue & 0xff;
- buf[2] = (aValue >> 8) & 0xff;
- buf[3] = (aValue >> 16) & 0xff;
-
- return mAsI2c->writeMultipleBytes(mI2cChipAddr,buf,4);
-}
-/*------------------------------------------------------------------------------*/
-
-/**
-* (De)Activate watchdog.(true/false)
-* Returns: 0 = success, 1 = failure
-*/
-int
-AsDs1374::activate(bool state)
-{
- if (state)
- { /* WACE + WD + WDSTR + AIE + RS = 10 */
- return mAsI2c->writeByteData(mI2cChipAddr,DS1374_CTRL_REG,0x6d);
- }
- else
- { /* reset value */
- return mAsI2c->writeByteData(mI2cChipAddr,DS1374_CTRL_REG,0x06);
- }
-}
-/*------------------------------------------------------------------------------*/
-/** Acknowledge
- * @return error code
- */
-int
-AsDs1374::ack(void)
-{
- unsigned char rbuffer[1];
-
- // create an I2C write message to set register @
- mAsI2c->readByteData(mI2cChipAddr,DS1374_CNT_REG,rbuffer);
- return 0;
-
-}
-
diff --git a/target/packages/as_devices/cpp/as_dynamic_table.hpp b/target/packages/as_devices/cpp/as_dynamic_table.hpp
deleted file mode 100644
index 024c00c..0000000
--- a/target/packages/as_devices/cpp/as_dynamic_table.hpp
+++ /dev/null
@@ -1,57 +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 __ASDYNAMICTABLE_HPP_
-#define __ASDYNAMICTABLE_HPP_
-
-#include <stdio.h>
-
-class AsDynamicTable {
- public:
- AsDynamicTable()
- {
- int i;
- for(i=0; i< DYNAMIC_TABLE_SIZE; i++)
- {
- mInst[i] = NULL;
- }
- }
-
- void * getInstance(int aInstanceNum)
- {
- return mInst[aInstanceNum];
- }
-
- void setInstance(void * aInstance, int aInstanceNum)
- {
- mInst[aInstanceNum] = aInstance;
- }
-
-
- virtual ~AsDynamicTable()
- {
- }
-
- private:
- void * mInst[DYNAMIC_TABLE_SIZE];
-};
-
-#endif // __ASDYNAMICTABLE_HPP_
diff --git a/target/packages/as_devices/cpp/as_gpio.cpp b/target/packages/as_devices/cpp/as_gpio.cpp
new file mode 100644
index 0000000..4ca4b3a
--- /dev/null
+++ b/target/packages/as_devices/cpp/as_gpio.cpp
@@ -0,0 +1,135 @@
+/*
+** THE ARMadeus Systems
+**
+** Copyright (C) 2011 The armadeus systems team
+** Jérémie Scheer <jer...@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 "as_gpio.hpp"
+#include <iostream>
+
+/** @brief Constructor: Initialize port access
+ *
+ * @param aPortChar character port in UPPER case
+ * @param aPinNum int pin number
+ */
+AsGpio::AsGpio(char aPortChar, int aPinNum)
+{
+ mDev = as_gpio_open(aPortChar, aPinNum);
+}
+
+AsGpio::~AsGpio()
+{
+ int ret;
+
+ ret = as_gpio_close(mDev);
+ if (ret < 0)
+ {
+ std::cout<<"AsGpio destruction error"<<std::endl;
+ }
+}
+
+/** @brief Set pin direction
+ *
+ * @param aDirection direction 0:input 1:output
+ *
+ * @return error if negative value
+ */
+long AsGpio::setPinDirection(int aDirection)
+{
+ return as_gpio_set_pin_direction(mDev, aDirection);
+}
+
+/** @brief Get pin direction
+ *
+ * @return pin direction if positive or null, error if negative
+ */
+long AsGpio::getPinDirection() const
+{
+ return as_gpio_get_pin_direction(mDev);
+}
+
+/** @brief Set pin value
+ *
+ * @param aValue value of pin (1 or 0)
+ *
+ * @return error if negative
+ */
+long AsGpio::setPinValue(int aValue)
+{
+ return as_gpio_set_pin_value(mDev, aValue);
+}
+
+/** @brief Get pin value
+ *
+ * @return pin value if positive or null, error if negative
+ */
+long AsGpio::getPinValue() const
+{
+ return as_gpio_get_pin_value(mDev);
+}
+
+/** @brief Get pin value, blocking until interrupt occur
+ *
+ * @param aDelay_s waiting delay in seconds
+ * @param aDelay_us waiting delay in useconds (plus delay in seconds)
+ *
+ * @return pin value if positive or null, read error if -1, timeout if -10
+ */
+long AsGpio::blockingGetPinValue(int aDelay_s, int aDelay_us) const
+{
+ return as_gpio_blocking_get_pin_value(mDev, aDelay_s, aDelay_us);
+}
+
+/** @brief Set pin irq mode
+ *
+ * @param aMode irq mode
+ *
+ * @return error if negative
+ */
+long AsGpio::setIrqMode(int aMode)
+{
+ return as_gpio_set_irq_mode(mDev, aMode);
+}
+
+/** @brief Get pin irq mode value
+ *
+ * @return pin mode value if positive or null, error if negative
+ */
+long AsGpio::getIrqMode() const
+{
+ return as_gpio_get_irq_mode(mDev);
+}
+
+/** @brief Get pin number value
+ *
+ * @return pin number, error if negative
+ */
+long AsGpio::getPinNum() const
+{
+ return as_gpio_get_pin_num(mDev);
+}
+
+/** @brief Get port letter
+ *
+ * @return port letter, error if negative
+ */
+long AsGpio::getPortLetter() const
+{
+ return as_gpio_get_port_letter(mDev);
+}
diff --git a/target/packages/as_devices/cpp/as_ds1374.hpp b/target/packages/as_devices/cpp/as_gpio.hpp
similarity index 56%
copy from target/packages/as_devices/cpp/as_ds1374.hpp
copy to target/packages/as_devices/cpp/as_gpio.hpp
index fc3c3ff..017957f 100644
--- a/target/packages/as_devices/cpp/as_ds1374.hpp
+++ b/target/packages/as_devices/cpp/as_gpio.hpp
@@ -1,8 +1,8 @@
/*
** THE ARMadeus Systems
**
-** Copyright (C) 2009 The armadeus systems team
-** Fabien Marteau <fab...@ar...>
+** Copyright (C) 2011 The armadeus systems team
+** Jérémie Scheer <jer...@ar...>
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
@@ -17,37 +17,36 @@
** 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 __ASDS1374_HPP__
-#define __ASDS1374_HPP__
+#ifndef AS_GPIO__HPP__
+#define AS_GPIO__HPP__
-#include "as_i2c.hpp"
+#include "as_gpio.h"
-#define DS1374_I2C_SLAVE_ADDR 0x68
-#define DS1374_CNT_REG 0x04
-#define DS1374_CTRL_REG 0x07
-
-/** AsDs1374 description
- *
- */
-class AsDs1374 {
+class AsGpio
+{
public:
- AsDs1374(int aI2cBusNum,int aI2cChipAddr);
+ AsGpio(char aPortChar, int aPinNum);
+ virtual ~AsGpio();
- virtual ~AsDs1374();
+ long setPinDirection(int aDirection);
+ long getPinDirection() const;
- int setCounter(int aValue);
- int activate(bool state);
+ long setPinValue(int aValue);
+ long getPinValue() const;
+ long blockingGetPinValue(int aDelay_s, int aDelay_us) const;
+
+ long setIrqMode(int aMode);
+ long getIrqMode() const;
- int ack(void);
+ long getPinNum() const;
-private:
- AsI2c * mAsI2c;
- int mI2cChipAddr;
+ long getPortLetter() const;
+protected:
+ mutable struct as_gpio_device *mDev;
};
-#endif /* __ASDS1374_HPP__ */
-
-
+#endif // AS_GPIO__HPP__
diff --git a/target/packages/as_devices/cpp/as_i2c.cpp b/target/packages/as_devices/cpp/as_i2c.cpp
index cadad77..af273c4 100644
--- a/target/packages/as_devices/cpp/as_i2c.cpp
+++ b/target/packages/as_devices/cpp/as_i2c.cpp
@@ -1,8 +1,8 @@
/*
** THE ARMadeus Systems
**
-** Copyright (C) 2009 The armadeus systems team
-** Fabien Marteau <fab...@ar...>
+** Copyright (C) 2011 The armadeus systems team
+** Jérémie Scheer <jer...@ar...>
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
@@ -19,119 +19,134 @@
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
**
*/
+
#include "as_i2c.hpp"
#include <iostream>
-AsDynamicTable * AsI2c::mInstances = new AsDynamicTable();
-
-/** Singleton constructor
- * @param aBusNumber bus number
+/** @brief Constructor: Open an I2C bus.
+ *
+ * @param aBusNumber bus to open
*/
-AsI2c *
-AsI2c::getInstance(int aBusNumber)
+AsI2c::AsI2c(int aBusNumber)
{
- AsI2c * instance;
- instance = (AsI2c *)mInstances->getInstance(aBusNumber);
- if(instance == NULL)
- {
- instance = new AsI2c(aBusNumber);
- mInstances->setInstance(instance,aBusNumber);
- }
- return instance;
+ mDev = as_i2c_open(aBusNumber);
}
-/*------------------------------------------------------------------------------*/
-
-AsI2c::AsI2c(int aBusNumber)
+AsI2c::~AsI2c()
{
- int ret;
+ int ret;
- mI2cBusNumber = aBusNumber;
+ ret = as_i2c_close(mDev);
+ if (ret < 0)
+ {
+ std::cout<<"AsI2c destruction error"<<std::endl;
+ }
+}
- ret = as_i2c_init(aBusNumber);
- if (ret < 0)
- {
- std::cout << "AsI2C initialization error" << std::endl;
- }
+/** @brief Set chip's I2C slave address
+ *
+ * @param aAddr slave's address
+ *
+ * @return error if negative
+ */
+long AsI2c::setSlaveAddr(unsigned char aAddr)
+{
+ return as_i2c_set_slave_addr(mDev, aAddr);
}
-/*------------------------------------------------------------------------------*/
-AsI2c::~AsI2c()
+/** @brief Get chip's I2C slave address
+ *
+ * @return slave's address
+ */
+long AsI2c::getSlaveAddr() const
{
- mInstances->setInstance(NULL,mI2cBusNumber);
+ return as_i2c_get_slave_addr(mDev);
}
-/*------------------------------------------------------------------------------*/
-/** read byte on i2c bus
- * @param aChipAddr chip address
- * @param aReg Register number
- * @param *aBuf char buffer
- * @return error return
+/** @brief Read several bytes (ioctl() method) from given chip.
+ *
+ * @param aData read data
+ * @param aSize data size
+ *
+ * @return error if negative
*/
-int
-AsI2c::readByteData(unsigned char aChipAddr,
- unsigned char aReg,
- unsigned char *aBuf )
+long AsI2c::read(unsigned char *aData, size_t aSize) const
{
- return as_read_byte_data(mI2cBusNumber, aChipAddr, aReg, aBuf);
+ return as_i2c_read(mDev, aData, aSize);
}
-/*------------------------------------------------------------------------------*/
-/** write byte on i2c bus
- * @param aChipAddr chip address
- * @param aReg Register number
- * @param aBuf char value to write
- * @return error return
+/** @brief Write several bytes (ioctl() method) to given chip.
+ *
+ * @param aData data to write
+ * @param aSize data size
+ *
+ * @return error if negative
*/
-int
-AsI2c::writeByteData(unsigned char aChipAddr,
- unsigned char aReg,
- unsigned char aValue)
+long AsI2c::write(unsigned char *aData, size_t aSize)
{
- return as_write_byte_data(mI2cBusNumber, aChipAddr, aReg, aValue);
+ return as_i2c_write(mDev, aData, aSize);
}
-/*------------------------------------------------------------------------------*/
-/** write byte on i2c bus
- * @param aChipAddr chip address
- * @param aBuf char value to write
- * @return error return
+/** @brief Read from given chip at a given register address (ioctl() method).
+ *
+ * @param aReg register address
+ * @param aData read data
+ * @param aSize data size
+ *
+ * @return error if negative
*/
-int
-AsI2c::writeByte(unsigned char aChipAddr,
- unsigned char aValue)
+long AsI2c::readReg(unsigned char aReg, unsigned char *aData, size_t aSize) const
{
- return as_write_byte(mI2cBusNumber, aChipAddr, aValue);
+ return as_i2c_read_reg(mDev, aReg, aData, aSize);
}
-/*------------------------------------------------------------------------------*/
-/** Write several byte on I2C
- * @param aChipAddr Chip address
- * @param aBuff message
- * @param aSize size of message
- * @return error code
+/** @brief Write to given chip at a given register address (ioctl() method).
+ *
+ * @param aReg register address
+ * @param aData data to write
+ * @param aSize data size
+ *
+ * @return error if negative
*/
-int
-AsI2c::writeMultipleBytes(unsigned char aChipAddr,
- unsigned char *aBuff,
- int aSize)
+long AsI2c::writeReg(unsigned char aReg, unsigned char *aData, size_t aSize)
{
- return as_write_multiple_bytes(mI2cBusNumber, aChipAddr, aBuff, aSize);
+ return as_i2c_write_reg(mDev, aReg, aData, aSize);
}
-/*------------------------------------------------------------------------------*/
-/** read several bytes on I2C
- * @param aChipAddr Chip address
- * @param aBuff message
- * @param aSize size of message
- * @return error code
+/** @brief forge a read message like this:
+ * S Addr[W] wdata0 [A] wdata1 [A] ... RS Addr R [rdata0] A [rdata1] A ... P
+ *
+ * @param aWData data to write
+ * @param aSize written data size
+ * @param aRData read data
+ * @param aReadSize read data size
+ *
+ * @return error if negative
*/
-int
-AsI2c::readMultipleBytes(unsigned char aChipAddr,
- unsigned char *aBuff,
- int aSize)
+long AsI2c::readMsg(unsigned char *aWData, unsigned char aWriteSize, unsigned char *aRData, size_t aReadSize)
{
- return as_read_multiple_bytes(mI2cBusNumber, aChipAddr, aBuff, aSize);
+ return as_i2c_read_msg(mDev, aWData, aWriteSize, aRData, aReadSize);
}
+/** @brief Read a byte from the given register.
+ *
+ * @param aReg register address
+ *
+ * @return read byte
+ */
+long AsI2c::readRegByte(unsigned char aReg) const
+{
+ return as_i2c_read_reg_byte(mDev, aReg);
+}
+/** @brief Write a byte to the given register.
+ *
+ * @param aReg register address
+ * @param aVal byte to write
+ *
+ * @return error if negative
+ */
+long AsI2c::writeRegByte(unsigned char aReg, unsigned char aVal)
+{
+ return as_i2c_write_reg_byte(mDev, aReg, aVal);
+}
diff --git a/target/packages/as_devices/cpp/as_i2c.hpp b/target/packages/as_devices/cpp/as_i2c.hpp
index b72282b..84ea901 100644
--- a/target/packages/as_devices/cpp/as_i2c.hpp
+++ b/target/packages/as_devices/cpp/as_i2c.hpp
@@ -1,8 +1,8 @@
/*
** THE ARMadeus Systems
**
-** Copyright (C) 2009 The armadeus systems team
-** Fabien Marteau <fab...@ar...>
+** Copyright (C) 2011 The arm...
[truncated message content] |