[Armadeus-commitlog] armadeus branch, master, updated. release-3.2-391-g01cdde8
Brought to you by:
sszy
|
From: Fabien M <fa...@us...> - 2010-06-02 12:33:18
|
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 01cdde8afaf246b8e9f6cce2eb37ad450730dad4 (commit)
via 6a53dbcc8ea13dff92631972aeca189e10766cf3 (commit)
from 5557d509449cb09242ee5248db5a7479334df9d1 (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 01cdde8afaf246b8e9f6cce2eb37ad450730dad4
Author: Fabien Marteau <fab...@ar...>
Date: Wed Jun 2 14:32:44 2010 +0200
[as_devices] as_spi: code done, test to be done
commit 6a53dbcc8ea13dff92631972aeca189e10766cf3
Author: Fabien Marteau <fab...@ar...>
Date: Wed Jun 2 13:51:02 2010 +0200
[as_devices] no longer in as_devices
-----------------------------------------------------------------------
Summary of changes:
target/packages/as_devices/c/as_ad5258.c | 26 ---------
target/packages/as_devices/c/as_ad5258.h | 45 ---------------
target/packages/as_devices/c/as_spi.c | 89 ++++++++++++++++++++----------
target/packages/as_devices/c/as_spi.h | 51 ++++++++++++-----
4 files changed, 95 insertions(+), 116 deletions(-)
delete mode 100644 target/packages/as_devices/c/as_ad5258.c
delete mode 100644 target/packages/as_devices/c/as_ad5258.h
diff --git a/target/packages/as_devices/c/as_ad5258.c b/target/packages/as_devices/c/as_ad5258.c
deleted file mode 100644
index be36664..0000000
--- a/target/packages/as_devices/c/as_ad5258.c
+++ /dev/null
@@ -1,26 +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.h"
-#include "as_i2c.h"
-
-/* TODO */
-
diff --git a/target/packages/as_devices/c/as_ad5258.h b/target/packages/as_devices/c/as_ad5258.h
deleted file mode 100644
index 139ac63..0000000
--- a/target/packages/as_devices/c/as_ad5258.h
+++ /dev/null
@@ -1,45 +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 __ASAD5258_H__
-#define __ASAD5258_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif // __cplusplus
-
-/* number of AD5258 under system */
-#define NUMBER_OF_AD5258 1
-
-int as_ad5258_init(int aAdNumber);
-
-int as_ad5258_set_rdac(int aAdNumber, int aValue);
-int as_ad5258_get_rdac(int aAdNumber);
-int as_ad5258_set_eeprom(int aAdNumber, int aValue);
-int as_ad5258_get_eeprom(int aAdNumber);
-int as_ad5258_store(int aAdNumber);
-int as_ad5258_restore(int aAdNumber);
-
-#ifdef __cplusplus
-}
-#endif // __cplusplus
-
-#endif // __ASAD5258_H__
diff --git a/target/packages/as_devices/c/as_spi.c b/target/packages/as_devices/c/as_spi.c
index 8537a1c..b5af328 100644
--- a/target/packages/as_devices/c/as_spi.c
+++ b/target/packages/as_devices/c/as_spi.c
@@ -40,6 +40,8 @@
# define ERROR(fmt, ...) /*fmt, ##__VA_ARGS__*/
#endif
+/*--------------------------------------------------------------*/
+
int as_spi_open(const unsigned char *aSpidev_name)
{
int fd;
@@ -53,34 +55,44 @@ int as_spi_open(const unsigned char *aSpidev_name)
return fd;
}
-int as_spi_set_mode(int aFd, uint8_t aMode)
-{
- /* TODO */
- printf("TODO\n");
- return -1;
-}
+/*--------------------------------------------------------------*/
int as_spi_set_lsb(int aFd, uint8_t aLsb)
{
- /* TODO */
- printf("TODO\n");
- return -1;
+ if (ioctl(aFd, SPI_IOC_WR_LSB_FIRST, &aLsb) < 0) {
+ ERROR("SPI set lsb");
+ return -1;
+ }
+ return 0;
}
-int as_spi_set_bits_per_word(int aFd, uint8_t aBits)
+/*--------------------------------------------------------------*/
+
+int as_spi_get_lsb(int aFd)
{
- /* TODO */
- printf("TODO\n");
- return -1;
+ uint8_t lsb;
+
+ if (ioctl(aFd, SPI_IOC_RD_LSB_FIRST, &lsb) < 0) {
+ ERROR("SPI get lsb");
+ return -1;
+ }
+
+ return lsb;
}
-int as_spi_set_speed(int aFd)
+/*--------------------------------------------------------------*/
+
+int as_spi_set_mode(int aFd, uint8_t aMode)
{
- /* TODO */
- printf("TODO\n");
- return -1;
+ if (ioctl(aFd, SPI_IOC_WR_MODE, &aMode) < 0) {
+ ERROR("SPI wr_mode");
+ return -1;
+ }
+ return 0;
}
+/*--------------------------------------------------------------*/
+
int as_spi_get_mode(int aFd)
{
uint8_t mode;
@@ -93,18 +105,34 @@ int as_spi_get_mode(int aFd)
return mode;
}
-int as_spi_get_lsb(int aFd)
+/*--------------------------------------------------------------*/
+
+int as_spi_set_speed(int aFd, uint32_t aSpeed)
{
- uint8_t lsb;
+ if (ioctl(aFd, SPI_IOC_WR_MAX_SPEED_HZ, &aSpeed) < 0) {
+ ERROR("SPI set speed");
+ return -1;
+ }
- if (ioctl(aFd, SPI_IOC_RD_LSB_FIRST, &lsb) < 0) {
- ERROR("SPI rd_lsb_fist");
+ return 0;
+}
+
+/*--------------------------------------------------------------*/
+
+uint32_t as_spi_get_speed(int aFd)
+{
+ uint8_t speed;
+
+ if (ioctl(aFd, SPI_IOC_RD_MAX_SPEED_HZ, &speed) < 0) {
+ ERROR("SPI max_speed_hz");
return -1;
}
- return lsb;
+ return speed;
}
+/*--------------------------------------------------------------*/
+
int as_spi_get_bits_per_word(int aFd)
{
uint8_t bits;
@@ -117,18 +145,19 @@ int as_spi_get_bits_per_word(int aFd)
return bits;
}
-int as_spi_get_speed(int aFd)
-{
- uint8_t speed;
+/*--------------------------------------------------------------*/
- if (ioctl(aFd, SPI_IOC_RD_MAX_SPEED_HZ, &speed) < 0) {
- ERROR("SPI max_speed_hz");
+int as_spi_set_bits_per_word(int aFd, uint8_t aBits)
+{
+ if (ioctl(aFd, SPI_IOC_WR_BITS_PER_WORD, &aBits) < 0) {
+ ERROR("SPI set bits_per_word");
return -1;
}
-
- return speed;
+ return 0;
}
+/*--------------------------------------------------------------*/
+
uint32_t as_spi_msg(int aFd,
uint32_t aMsg,
size_t aLen,
@@ -182,6 +211,8 @@ uint32_t as_spi_msg(int aFd,
return msg;
}
+/*--------------------------------------------------------------*/
+
void as_spi_close(int aFd)
{
close(aFd);
diff --git a/target/packages/as_devices/c/as_spi.h b/target/packages/as_devices/c/as_spi.h
index e0005e1..8253723 100644
--- a/target/packages/as_devices/c/as_spi.h
+++ b/target/packages/as_devices/c/as_spi.h
@@ -42,42 +42,41 @@ extern "C" {
*/
int as_spi_open(const unsigned char *aSpidev_name);
-/** @brief Set spi bus mode
+/** @brief Set bits order
*
* @param aFd spidev file handler
- * @param aMode
+ * @param aLsb if 1 lsb first, else msb first
*
- * @return mode if positive value, negative value on error
- * TODO
+ * @return lsb first if positive, msb first if 0, negative value on error
+ * TODO : test it
*/
-int as_spi_set_mode(int aFd, uint8_t aMode);
+int as_spi_set_lsb(int aFd, uint8_t aLsb);
/** @brief Set bits order
*
* @param aFd spidev file handler
- * @param aLsb if 1 lsb first, else msb first
*
* @return lsb first if positive, msb first if 0, negative value on error
- * TODO
+ * TODO : test it
*/
-int as_spi_set_lsb(int aFd, uint8_t aLsb);
+int as_spi_get_lsb(int aFd);
-/** @brief Set bits per word
+/** @brief Set spi bus mode
*
* @param aFd spidev file handler
- * @param aBits number of bits per word
+ * @param aMode
*
- * @return bit per word if positive value, negative value on error
- * TODO
+ * @return mode if positive value, negative value on error
+ * TODO: test it
*/
-int as_spi_set_bits_per_word(int aFd, uint8_t aBits);
+int as_spi_set_mode(int aFd, uint8_t aMode);
/** @brief Get spi bus mode
*
* @param aFd spidev file handler
*
* @return mode if positive value, negative value on error
- * TODO
+ * TODO: test it
*/
int as_spi_get_mode(int aFd);
@@ -90,14 +89,24 @@ int as_spi_get_mode(int aFd);
*/
int as_spi_get_lsb(int aFd);
-/** @brief Get clock bus speed
+/** @brief Set clock bus speed
*
* @param aFd spidev file handler
+ * @param aSpeed clock speed
*
* @return speed in Hz, negative value on error
+ * TODO: test it
*/
-int as_spi_get_speed(int aFd);
+int as_spi_set_speed(int aFd, uint32_t aSpeed);
+/** @brief Get clock bus speed
+ *
+ * @param aFd spidev file handler
+ *
+ * @return speed in Hz
+ * TODO: test it
+ */
+uint32_t as_spi_get_speed(int aFd);
/** @brief Get bits per word
*
@@ -107,6 +116,16 @@ int as_spi_get_speed(int aFd);
*/
int as_spi_get_bits_per_word(int aFd);
+/** @brief Set bits per word
+ *
+ * @param aFd spidev file handler
+ * @param aBits number of bits per word
+ *
+ * @return bit per word if positive value, negative value on error
+ * TODO : test it
+ */
+int as_spi_set_bits_per_word(int aFd, uint8_t aBits);
+
/** @brief Forge arbitrary length message (31bits max) and send it
*
* @param aFd spidev file handler
hooks/post-receive
--
armadeus
|