[Armadeus-commitlog] armadeus branch, master, updated. armadeus-5.0-67-ga5a9469
Brought to you by:
sszy
|
From: jscheer <js...@us...> - 2012-10-01 15:13:23
|
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 a5a94697f443e1a2df4cffe398262478c677fa60 (commit)
via ef03e24e27be2f2432426af13689cc4f7009f553 (commit)
via cae34781a45417acf10eebd3a1b82c8fe8bbad1d (commit)
via cc39c07b2fc550bd15b814d637533a4cfa7d5e9b (commit)
via fe87c781a8e348eb9875bf258a8ffa5001043535 (commit)
from 959ca9398906b02348a720eca13c82ae2172ad8f (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 a5a94697f443e1a2df4cffe398262478c677fa60
Merge: ef03e24 959ca93
Author: Jeremie Scheer <jer...@ar...>
Date: Mon Oct 1 17:12:48 2012 +0200
Merge branch 'master' of ssh://armadeus.git.sourceforge.net/gitroot/armadeus/armadeus
commit ef03e24e27be2f2432426af13689cc4f7009f553
Author: Jeremie Scheer <jer...@ar...>
Date: Mon Oct 1 17:03:20 2012 +0200
[PACKAGES][AS_DEVICES] C++ wrapper for 93LCXX EEPROM device.
commit cae34781a45417acf10eebd3a1b82c8fe8bbad1d
Author: Jeremie Scheer <jer...@ar...>
Date: Mon Oct 1 14:26:40 2012 +0200
[PACKAGES][AS_DEVICES] Backlight device manager and C++ wrapper.
commit cc39c07b2fc550bd15b814d637533a4cfa7d5e9b
Author: Jeremie Scheer <jer...@ar...>
Date: Mon Oct 1 14:04:17 2012 +0200
[PACKAGE][AS_DEVICES] Fix PWM C++ source indentations.
commit fe87c781a8e348eb9875bf258a8ffa5001043535
Author: Jeremie Scheer <jer...@ar...>
Date: Mon Oct 1 11:15:00 2012 +0200
[BUILDROOT][AS_DEVICES] C++ wrapper for PWM device.
-----------------------------------------------------------------------
Summary of changes:
target/packages/as_devices/c/Makefile | 3 +-
target/packages/as_devices/c/as_backlight.c | 156 +++++++++++++++++++++++
target/packages/as_devices/c/as_backlight.h | 80 ++++++++++++
target/packages/as_devices/c/as_pwm.h | 2 +
target/packages/as_devices/cpp/Makefile | 3 +
target/packages/as_devices/cpp/as_93lcxx.cpp | 132 +++++++++++++++++++
target/packages/as_devices/cpp/as_93lcxx.hpp | 100 +++++++++++++++
target/packages/as_devices/cpp/as_backlight.cpp | 86 +++++++++++++
target/packages/as_devices/cpp/as_backlight.hpp | 64 +++++++++
target/packages/as_devices/cpp/as_pwm.cpp | 151 ++++++++++++++++++++++
target/packages/as_devices/cpp/as_pwm.hpp | 102 +++++++++++++++
11 files changed, 878 insertions(+), 1 deletions(-)
create mode 100644 target/packages/as_devices/c/as_backlight.c
create mode 100644 target/packages/as_devices/c/as_backlight.h
create mode 100644 target/packages/as_devices/cpp/as_93lcxx.cpp
create mode 100644 target/packages/as_devices/cpp/as_93lcxx.hpp
create mode 100644 target/packages/as_devices/cpp/as_backlight.cpp
create mode 100644 target/packages/as_devices/cpp/as_backlight.hpp
create mode 100644 target/packages/as_devices/cpp/as_pwm.cpp
create mode 100644 target/packages/as_devices/cpp/as_pwm.hpp
diff --git a/target/packages/as_devices/c/Makefile b/target/packages/as_devices/c/Makefile
index 1cb0161..12014cc 100644
--- a/target/packages/as_devices/c/Makefile
+++ b/target/packages/as_devices/c/Makefile
@@ -6,7 +6,7 @@ LDFLAGS=
CC:=$(ARMADEUS_TOOLCHAIN_PATH)/arm-linux-gcc
STRIP:=$(ARMADEUS_TOOLCHAIN_PATH)arm-linux-sstrip
-OBJ = as_pwm.o
+OBJ += as_pwm.o
OBJ += as_i2c.o
ifeq ($(ARMADEUS_LINUX_VERSION),2.6.29.6)
OBJ += as_gpio_2_6_29.o
@@ -21,6 +21,7 @@ OBJ += as_spi.o
OBJ += as_as1531.o
OBJ += as_max1027.o
OBJ += as_max5821.o
+OBJ += as_backlight.o
OBJ += as_helpers.o
LIBRARY=as_devices
diff --git a/target/packages/as_devices/c/as_backlight.c b/target/packages/as_devices/c/as_backlight.c
new file mode 100644
index 0000000..2fd7fad
--- /dev/null
+++ b/target/packages/as_devices/c/as_backlight.c
@@ -0,0 +1,156 @@
+/*
+** THE ARMadeus Systems
+**
+** Copyright (C) 2012 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 <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <fcntl.h> /* for open() */
+#include <unistd.h> /* for write() */
+
+/* #define DEBUG */
+#include "as_helpers.h"
+#include "as_backlight.h"
+
+
+#define BACKLIGHT_SYS_PATH "/sys/class/backlight/imx-bl"
+#define ACTUAL_BRIGHTNESS_PATH "actual_brightness"
+#define MAX_BRIGHTNESS_PATH "max_brightness"
+#define BRIGHTNESS_PATH "brightness"
+
+#define SIZE_OF_BUFF 50
+
+/*------------------------------------------------------------------------------*/
+
+struct as_backlight_device *as_backlight_open()
+{
+ char buffer[SIZE_OF_BUFF];
+ struct as_backlight_device *dev;
+
+ dev = (struct as_backlight_device *)malloc(sizeof(struct as_backlight_device));
+ if (dev == NULL) {
+ ERROR("Can't allocate memory for backlight device structure\n");
+ return NULL;
+ }
+
+ /* open backlight management files */
+ snprintf(buffer, SIZE_OF_BUFF, "%s/%s", BACKLIGHT_SYS_PATH, ACTUAL_BRIGHTNESS_PATH);
+ if ((dev->fileActualBrightness = open(buffer, O_RDWR)) < 0) {
+ ERROR("Can't open actual brightness file");
+ return NULL;
+ }
+ snprintf(buffer, SIZE_OF_BUFF, "%s/%s", BACKLIGHT_SYS_PATH, MAX_BRIGHTNESS_PATH);
+ if ((dev->fileMaxBrightness = open(buffer, O_RDWR)) < 0) {
+ ERROR("Can't open max brightness file");
+ return NULL;
+ }
+ snprintf(buffer, SIZE_OF_BUFF, "%s/%s", BACKLIGHT_SYS_PATH, BRIGHTNESS_PATH);
+ if((dev->fileBrightness = open(buffer, O_RDWR)) < 0) {
+ ERROR("Can't open brightness file");
+ return NULL;
+ }
+
+ return dev;
+}
+
+/*------------------------------------------------------------------------------*/
+
+int32_t as_backlight_get_actual_brightness(struct as_backlight_device *aDev)
+{
+ char buffer[SIZE_OF_BUFF];
+ int ret;
+
+ if (aDev == NULL) {
+ ERROR("Device is NULL\n");
+ return -1;
+ }
+
+ ret = as_read_buffer(aDev->fileActualBrightness, buffer, SIZE_OF_BUFF);
+ if (ret < 0) {
+ ERROR("Can't read actual brightness");
+ return ret;
+ }
+
+ return atoi(buffer);
+}
+
+/*------------------------------------------------------------------------------*/
+
+int32_t as_backlight_get_max_brightness(struct as_backlight_device *aDev)
+{
+ char buffer[SIZE_OF_BUFF];
+ int ret;
+
+ if (aDev == NULL) {
+ ERROR("Device is NULL\n");
+ return -1;
+ }
+
+ ret = as_read_buffer(aDev->fileMaxBrightness, buffer, SIZE_OF_BUFF);
+ if (ret < 0) {
+ ERROR("Can't read max brightness");
+ return ret;
+ }
+
+ return atoi(buffer);
+}
+
+/*------------------------------------------------------------------------------*/
+
+int32_t as_backlight_set_brightness(struct as_backlight_device *aDev, int aBrightness)
+{
+ if (aDev == NULL) {
+ ERROR("Device is NULL\n");
+ return -1;
+ }
+
+ return as_write_buffer(aDev->fileBrightness, aBrightness);
+}
+
+/*------------------------------------------------------------------------------*/
+
+int32_t as_backlight_close(struct as_backlight_device *aDev)
+{
+ int ret = 0;
+
+ if (aDev == NULL) {
+ ERROR("Device is NULL\n");
+ return -1;
+ }
+
+ /* Close backlight management files */
+ ret = close(aDev->fileActualBrightness);
+ if (ret < 0) {
+ ERROR("Can't close /actual_brightness");
+ return ret;
+ }
+ ret = close(aDev->fileMaxBrightness);
+ if (ret < 0) {
+ ERROR("Can't close /max_brightness");
+ return ret;
+ }
+ ret = close(aDev->fileBrightness);
+ if (ret < 0) {
+ ERROR("Can't close /brightness");
+ return ret;
+ }
+
+ return ret;
+}
diff --git a/target/packages/as_devices/c/as_backlight.h b/target/packages/as_devices/c/as_backlight.h
new file mode 100644
index 0000000..424fea5
--- /dev/null
+++ b/target/packages/as_devices/c/as_backlight.h
@@ -0,0 +1,80 @@
+/*
+** THE ARMadeus Systems
+**
+** Copyright (C) 2012 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
+*/
+
+#ifndef __ASBACKLIGHT_H__
+#define __ASBACKLIGHT_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif // __cplusplus
+
+#include <stdint.h>
+
+struct as_backlight_device {
+ int fileActualBrightness;
+ int fileMaxBrightness;
+ int fileBrightness;
+};
+
+/** @brief Open Backlight device
+ *
+ * @return pointer to device structure, NULL if error
+ */
+struct as_backlight_device *as_backlight_open();
+
+/** @brief Get actual brightness
+ *
+ * @param aDev pointer to device structure
+ *
+ * @return actual brightness value, negative value on error
+ */
+int32_t as_backlight_get_actual_brightness(struct as_backlight_device *aDev);
+
+/** @brief Get maximum brightness
+ *
+ * @param aDev pointer to device structure
+ *
+ * @return maximum allowed brightness, negative value on error
+ */
+int32_t as_backlight_get_max_brightness(struct as_backlight_device *aDev);
+
+/** @bief Set brightness
+ *
+ * @param aDev pointer to device structure
+ * @param aBrightness backlight brightness
+ *
+ * @return negative value on error
+ */
+int32_t as_backlight_set_brightness(struct as_backlight_device *aDev, int aBrightness);
+
+/** @brief Close backlight device
+ *
+ * @param aDev pointer structure to device
+ *
+ * @return negative value on error
+ */
+int32_t as_backlight_close(struct as_backlight_device *aDev);
+
+#ifdef __cplusplus
+}
+#endif // __cplusplus
+
+#endif /* __ASBACKLIGHT_H__ */
diff --git a/target/packages/as_devices/c/as_pwm.h b/target/packages/as_devices/c/as_pwm.h
index 9304ac9..fb44b78 100644
--- a/target/packages/as_devices/c/as_pwm.h
+++ b/target/packages/as_devices/c/as_pwm.h
@@ -26,6 +26,8 @@
extern "C" {
#endif // __cplusplus
+#include <stdint.h>
+
/* number of pwm under system */
#define NUMBER_OF_PWM 2
diff --git a/target/packages/as_devices/cpp/Makefile b/target/packages/as_devices/cpp/Makefile
index 23439da..592fbdb 100644
--- a/target/packages/as_devices/cpp/Makefile
+++ b/target/packages/as_devices/cpp/Makefile
@@ -11,6 +11,9 @@ OBJS = as_i2c.o
OBJS += as_gpio.o
OBJS += as_dac.o
OBJS += as_adc.o
+OBJS += as_pwm.o
+OBJS += as_backlight.o
+OBJS += as_93lcxx.o
OBJS += as_spi.o
diff --git a/target/packages/as_devices/cpp/as_93lcxx.cpp b/target/packages/as_devices/cpp/as_93lcxx.cpp
new file mode 100644
index 0000000..4e04a0e
--- /dev/null
+++ b/target/packages/as_devices/cpp/as_93lcxx.cpp
@@ -0,0 +1,132 @@
+/*
+** THE ARMadeus Systems
+**
+** Copyright (C) 2012 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_93lcxx.hpp"
+#include <iostream>
+
+As93LCXX::As93LCXX(unsigned char *aSpidevFilename, unsigned char aType, unsigned long aSpeed, unsigned char aWordSize)
+{
+ mDev = as_93lcxx_open(aSpidevFilename, aType, aSpeed, aWordSize);
+}
+
+As93LCXX::~As93LCXX()
+{
+ if (mDev != NULL)
+ {
+ as_93lcxx_close(mDev);
+ }
+ else
+ {
+ std::cerr<<"As93LCXX device structure not allocated"<<std::endl;
+ }
+}
+
+long As93LCXX::read(unsigned int anAddress) const
+{
+ if (mDev != NULL)
+ {
+ return as_93lcxx_read(mDev, anAddress);
+ }
+ else
+ {
+ std::cerr<<"As93LCXX device structure not allocated"<<std::endl;
+ return -1;
+ }
+}
+
+long As93LCXX::ewen()
+{
+ if (mDev != NULL)
+ {
+ return as_93lcxx_ewen(mDev);
+ }
+ else
+ {
+ std::cerr<<"As93LCXX device structure not allocated"<<std::endl;
+ return -1;
+ }
+}
+
+long As93LCXX::erase(unsigned int anAddress)
+{
+ if (mDev != NULL)
+ {
+ return as_93lcxx_erase(mDev, anAddress);
+ }
+ else
+ {
+ std::cerr<<"As93LCXX device structure not allocated"<<std::endl;
+ return -1;
+ }
+}
+
+long As93LCXX::eraseAll()
+{
+ if (mDev != NULL)
+ {
+ return as_93lcxx_erase_all(mDev);
+ }
+ else
+ {
+ std::cerr<<"As93LCXX device structure not allocated"<<std::endl;
+ return -1;
+ }
+}
+
+long As93LCXX::write(unsigned int anAddress, unsigned int aValue)
+{
+ if (mDev != NULL)
+ {
+ return as_93lcxx_write(mDev, anAddress, aValue);
+ }
+ else
+ {
+ std::cerr<<"As93LCXX device structure not allocated"<<std::endl;
+ return -1;
+ }
+}
+
+long As93LCXX::writeAll(unsigned int aValue)
+{
+ if (mDev != NULL)
+ {
+ return as_93lcxx_write_all(mDev, aValue);
+ }
+ else
+ {
+ std::cerr<<"As93LCXX device structure not allocated"<<std::endl;
+ return -1;
+ }
+}
+
+long As93LCXX::ewds()
+{
+ if (mDev != NULL)
+ {
+ return as_93lcxx_ewds(mDev);
+ }
+ else
+ {
+ std::cerr<<"As93LCXX device structure not allocated"<<std::endl;
+ return -1;
+ }
+}
diff --git a/target/packages/as_devices/cpp/as_93lcxx.hpp b/target/packages/as_devices/cpp/as_93lcxx.hpp
new file mode 100644
index 0000000..cdfab83
--- /dev/null
+++ b/target/packages/as_devices/cpp/as_93lcxx.hpp
@@ -0,0 +1,100 @@
+/*
+** THE ARMadeus Systems
+**
+** Copyright (C) 2012 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
+**
+*/
+
+#ifndef AS_93LCXX__HPP__
+#define AS_93LCXX__HPP__
+
+#include "as_93lcxx.h"
+
+/**
+ * C++ wrapper for 93LCXX device
+ */
+class As93LCXX
+{
+public:
+ /**
+ * Constructor
+ *
+ * @param aSpidevFilename path to spidev
+ * @param aType of the eeprom
+ * @param aSpeed clock speed in Hz
+ * @param aWordSize word size for transaction
+ */
+ As93LCXX(unsigned char *aSpidevFilename, unsigned char aType, unsigned long aSpeed, unsigned char aWordSize);
+ virtual ~As93LCXX();
+
+ /** @brief read a value in address given
+ *
+ * @param aAddress addresse of register to be read
+ *
+ * @return positive register value on success, negative value on error.
+ */
+ long read(unsigned int anAddress) const;
+
+ /** @brief enable write on eeprom
+ *
+ * @return positive value on success, negative value on error
+ */
+ long ewen();
+
+ /** @brief Force all data bits of the specified iaddress to 1
+ *
+ * @param anAddress addresse of register to be erased
+ *
+ * @return positive register value on success, negative value on error.
+ */
+ long erase(unsigned int anAddress);
+
+ /** @brief Force all bits in eeprom to 1
+ *
+ * @return positive register value on success, negative value on error.
+ */
+ long eraseAll();
+
+ /** @brief write a value in given address
+ *
+ * @param anAddress addresse of register to be read
+ * @param aValue value to be wrote
+ *
+ * @return positive register value on success, negative value on error.
+ */
+ long write(unsigned int anAddress, unsigned int aValue);
+
+ /** @brief write the entire memory array with value given
+ *
+ * @param aValue value to be wrote
+ *
+ * @return positive register value on success, negative value on error.
+ */
+ long writeAll(unsigned int aValue);
+
+ /** @brief disable write on eeprom
+ *
+ * @return positive value on success, negative value on error
+ */
+ long ewds();
+
+protected:
+ mutable struct as_93lcxx_device *mDev;
+};
+
+#endif // AS_93LCXX__HPP__
diff --git a/target/packages/as_devices/cpp/as_backlight.cpp b/target/packages/as_devices/cpp/as_backlight.cpp
new file mode 100644
index 0000000..451bafa
--- /dev/null
+++ b/target/packages/as_devices/cpp/as_backlight.cpp
@@ -0,0 +1,86 @@
+/*
+** THE ARMadeus Systems
+**
+** Copyright (C) 2012 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_backlight.hpp"
+#include <iostream>
+
+AsBacklight::AsBacklight()
+{
+ mDev = as_backlight_open();
+}
+
+AsBacklight::~AsBacklight()
+{
+ int ret;
+
+ if (mDev != NULL)
+ {
+ ret = as_backlight_close(mDev);
+ if (ret < 0)
+ {
+ std::cout<<"AsBacklight destruction error"<<std::endl;
+ }
+ }
+ else
+ {
+ std::cerr<<"AsBacklight device structure not allocated"<<std::endl;
+ }
+}
+
+long AsBacklight::getActualBrightness() const
+{
+ if (mDev != NULL)
+ {
+ return as_backlight_get_actual_brightness(mDev);
+ }
+ else
+ {
+ std::cerr<<"AsBacklight device structure not allocated"<<std::endl;
+ return -1;
+ }
+}
+
+long AsBacklight::getMaxBrightness() const
+{
+ if (mDev != NULL)
+ {
+ return as_backlight_get_max_brightness(mDev);
+ }
+ else
+ {
+ std::cerr<<"AsBacklight device structure not allocated"<<std::endl;
+ return -1;
+ }
+}
+
+long AsBacklight::setBrightness(int aBrightness)
+{
+ if (mDev != NULL)
+ {
+ return as_backlight_set_brightness(mDev, aBrightness);
+ }
+ else
+ {
+ std::cerr<<"AsBacklight device structure not allocated"<<std::endl;
+ return -1;
+ }
+}
diff --git a/target/packages/as_devices/cpp/as_backlight.hpp b/target/packages/as_devices/cpp/as_backlight.hpp
new file mode 100644
index 0000000..b30904b
--- /dev/null
+++ b/target/packages/as_devices/cpp/as_backlight.hpp
@@ -0,0 +1,64 @@
+/*
+** THE ARMadeus Systems
+**
+** Copyright (C) 2012 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
+**
+*/
+
+#ifndef AS_BACKLIGHT__HPP__
+#define AS_BACKLIGHT__HPP__
+
+#include "as_backlight.h"
+
+/**
+ * C++ wrapper for Backlight device
+ */
+class AsBacklight
+{
+public:
+ /**
+ * Constructor
+ */
+ AsBacklight();
+ virtual ~AsBacklight();
+
+ /** @brief Get actual brightness
+ *
+ * @return actual brightness value, negative value on error
+ */
+ long getActualBrightness() const;
+
+ /** @brief Get maximum brightness
+ *
+ * @return maximum allowed brightness, negative value on error
+ */
+ long getMaxBrightness() const;
+
+ /** @bief Set brightness
+ *
+ * @param aBrightness backlight brightness
+ *
+ * @return negative value on error
+ */
+ long setBrightness(int aBrightness);
+
+protected:
+ mutable struct as_backlight_device *mDev;
+};
+
+#endif // AS_BACKLIGHT__HPP__
diff --git a/target/packages/as_devices/cpp/as_pwm.cpp b/target/packages/as_devices/cpp/as_pwm.cpp
new file mode 100644
index 0000000..784ef23
--- /dev/null
+++ b/target/packages/as_devices/cpp/as_pwm.cpp
@@ -0,0 +1,151 @@
+/*
+** THE ARMadeus Systems
+**
+** Copyright (C) 2012 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_pwm.hpp"
+#include <iostream>
+
+AsPwm::AsPwm(int aPwmNumber)
+{
+ mDev = as_pwm_open(aPwmNumber);
+}
+
+AsPwm::~AsPwm()
+{
+ int ret;
+
+ if (mDev != NULL)
+ {
+ ret = as_pwm_close(mDev);
+ if (ret < 0)
+ {
+ std::cout<<"AsPwm destruction error"<<std::endl;
+ }
+ }
+ else
+ {
+ std::cerr<<"AsPwm device structure not allocated"<<std::endl;
+ }
+}
+
+long AsPwm::setFrequency(int aFrequency)
+{
+ if (mDev != NULL)
+ {
+ return as_pwm_set_frequency(mDev, aFrequency);
+ }
+ else
+ {
+ std::cerr<<"AsPwm device structure not allocated"<<std::endl;
+ return -1;
+ }
+}
+
+long AsPwm::getFrequency() const
+{
+ if (mDev != NULL)
+ {
+ return as_pwm_get_frequency(mDev);
+ }
+ else
+ {
+ std::cerr<<"AsPwm device structure not allocated"<<std::endl;
+ return -1;
+ }
+}
+
+long AsPwm::setPeriod(int aPeriod)
+{
+ if (mDev != NULL)
+ {
+ return as_pwm_set_period(mDev, aPeriod);
+ }
+ else
+ {
+ std::cerr<<"AsPwm device structure not allocated"<<std::endl;
+ return -1;
+ }
+}
+
+long AsPwm::getPeriod() const
+{
+ if (mDev != NULL)
+ {
+ return as_pwm_get_period(mDev);
+ }
+ else
+ {
+ std::cerr<<"AsPwm device structure not allocated"<<std::endl;
+ return -1;
+ }
+}
+
+long AsPwm::setDuty(int aDuty)
+{
+ if (mDev != NULL)
+ {
+ return as_pwm_set_duty(mDev, aDuty);
+ }
+ else
+ {
+ std::cerr<<"AsPwm device structure not allocated"<<std::endl;
+ return -1;
+ }
+}
+
+long AsPwm::getDuty() const
+{
+ if (mDev != NULL)
+ {
+ return as_pwm_get_duty(mDev);
+ }
+ else
+ {
+ std::cerr<<"AsPwm device structure not allocated"<<std::endl;
+ return -1;
+ }
+}
+
+long AsPwm::setState(int aEnable)
+{
+ if (mDev != NULL)
+ {
+ return as_pwm_set_state(mDev, aEnable);
+ }
+ else
+ {
+ std::cerr<<"AsPwm device structure not allocated"<<std::endl;
+ return -1;
+ }
+}
+
+long AsPwm::getState() const
+{
+ if (mDev != NULL)
+ {
+ return as_pwm_get_state(mDev);
+ }
+ else
+ {
+ std::cerr<<"AsPwm device structure not allocated"<<std::endl;
+ return -1;
+ }
+}
diff --git a/target/packages/as_devices/cpp/as_pwm.hpp b/target/packages/as_devices/cpp/as_pwm.hpp
new file mode 100644
index 0000000..dbb394a
--- /dev/null
+++ b/target/packages/as_devices/cpp/as_pwm.hpp
@@ -0,0 +1,102 @@
+/*
+** THE ARMadeus Systems
+**
+** Copyright (C) 2012 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
+**
+*/
+
+#ifndef AS_PWM__HPP__
+#define AS_PWM__HPP__
+
+#include "as_pwm.h"
+
+/**
+ * C++ wrapper for PWM device
+ */
+class AsPwm
+{
+public:
+ /**
+ * Constructor
+ *
+ * @param aPwmNumber PWM device number
+ */
+ AsPwm(int aPwmNumber);
+ virtual ~AsPwm();
+
+ /** @brief set frequency
+ *
+ * @param aFrequency frequency in Hz
+ *
+ * @return negative value on error
+ */
+ long setFrequency(int aFrequency);
+
+ /** @brief get frequency
+ *
+ * @return frequency value in Hz, negative value on error
+ */
+ long getFrequency() const;
+
+ /** @bief set period
+ *
+ * @param aPeriod period in uS
+ *
+ * @return negative value on error
+ */
+ long setPeriod(int aPeriod);
+
+ /** @brief get period value
+ *
+ * @return period value in uS, negative value on error.
+ */
+ long getPeriod() const;
+
+ /** @brief set duty
+ *
+ * @param aDuty duty in 0.1%
+ *
+ * @return negative value on error
+ */
+ long setDuty(int aDuty);
+
+ /** @brief get duty
+ *
+ * @return duty value in 0.1%, negative value on error
+ */
+ long getDuty() const;
+
+ /** @brief set state of pwm
+ *
+ * @param aEnable 0:disable, 1:enable
+ *
+ * @return negative value on error
+ */
+ long setState(int aEnable);
+
+ /** @brief get state of pwm
+ *
+ * @return 0:disabled, 1:enabled, negative value on error
+ */
+ long getState() const;
+
+protected:
+ mutable struct as_pwm_device *mDev;
+};
+
+#endif // AS_PWM__HPP__
hooks/post-receive
--
armadeus
|