[Armadeus-commitlog] armadeus branch, master, updated. release-3.2-381-ga55ad4c
Brought to you by:
sszy
|
From: Fabien M <fa...@us...> - 2010-06-01 08:33:01
|
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 a55ad4cda7562637e322c5b5ab7405d5aa0e7239 (commit)
via a5bf3d94b2d12133b16d8eca418d3008058189ff (commit)
from 67c5c361c581e0ae352d31316a17dd5ba72dc079 (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 a55ad4cda7562637e322c5b5ab7405d5aa0e7239
Merge: a5bf3d94b2d12133b16d8eca418d3008058189ff 67c5c361c581e0ae352d31316a17dd5ba72dc079
Author: Fabien Marteau <fab...@ar...>
Date: Tue Jun 1 10:32:32 2010 +0200
Merge branch 'master' of git://armadeus.git.sourceforge.net/gitroot/armadeus/armadeus
commit a5bf3d94b2d12133b16d8eca418d3008058189ff
Author: Fabien Marteau <fab...@ar...>
Date: Tue Jun 1 10:32:19 2010 +0200
[as_devices] as_max1027 SLOW mode done
-----------------------------------------------------------------------
Summary of changes:
target/packages/as_devices/c/as_max1027.c | 99 ++++++++++++++++++++++-------
target/packages/as_devices/c/as_max1027.h | 24 +++-----
target/packages/as_devices/test_c.h | 30 ++++++---
3 files changed, 104 insertions(+), 49 deletions(-)
diff --git a/target/packages/as_devices/c/as_max1027.c b/target/packages/as_devices/c/as_max1027.c
index 8cda042..57d8200 100644
--- a/target/packages/as_devices/c/as_max1027.c
+++ b/target/packages/as_devices/c/as_max1027.c
@@ -34,6 +34,7 @@ typedef unsigned char u8;
#include <linux/spi/max1027.h>
#include "as_max1027.h"
+//#define ERROR_MSG
#define BUFFER_SIZE (70)
#define PATH_SIZE (50)
@@ -92,7 +93,9 @@ int32_t as_max1027_read_buffer(int aFile_handler, int *aValueRead)
ret = read(aFile_handler, valueRead, SIZEOFBUFF);
if (ret < 0)
{
+#ifdef ERROR_MSG
printf("Error, reading buffer file\n");
+#endif
return -1;
}
valueRead[ret-1] = '\0';
@@ -122,14 +125,18 @@ struct as_max1027_device *as_max1027_open(int aSpiNum,
/** XXX */
if (aMode == AS_MAX1027_FAST)
{
+#ifdef ERROR_MSG
printf("Error, fast mode not supported yet\n");
+#endif
return NULL;
}
ret = snprintf(path, PATH_SIZE, SYS_PATH, aSpiNum);
if (ret<0)
{
+#ifdef ERROR_MSG
printf("Error in path writing\n");
+#endif
return NULL;
}
@@ -138,26 +145,34 @@ struct as_max1027_device *as_max1027_open(int aSpiNum,
ret = snprintf(buffer, BUFFER_SIZE, "%s%s", path, "conversion");
if (ret<0)
{
+#ifdef ERROR_MSG
printf("Error in path writing\n");
+#endif
return NULL;
}
fConversion = open(buffer, O_RDWR);
if (fConversion < 0)
{
+#ifdef ERROR_MSG
printf("Error, can't open conversion file. Is max1027 modprobed ?\n");
+#endif
return NULL;
}
/* setup */
ret = snprintf(buffer, BUFFER_SIZE, "%s%s", path, "setup");
if (ret<0)
{
+#ifdef ERROR_MSG
printf("Error in path writing\n");
+#endif
return NULL;
}
fSetup = open(buffer, O_RDWR);
if (fSetup < 0)
{
+#ifdef ERROR_MSG
printf("Error, can't open setup file.\n");
+#endif
return NULL;
}
ret = as_max1027_write_buffer(fSetup,
@@ -167,20 +182,26 @@ struct as_max1027_device *as_max1027_open(int aSpiNum,
MAX1027_SETUP_DIFFSEL(0));
if (ret < 0)
{
+#ifdef ERROR_MSG
printf("Error, can't set default setup parameters\n");
+#endif
return NULL;
}
/* averaging */
ret = snprintf(buffer, BUFFER_SIZE, "%s%s", path, "averaging");
if (ret<0) {
+#ifdef ERROR_MSG
printf("Error in path writing\n");
+#endif
return NULL;
}
fAveraging = open(buffer, O_RDWR);
if (fAveraging < 0)
{
+#ifdef ERROR_MSG
printf("Error, can't open averaging file.\n");
+#endif
return NULL;
}
@@ -190,13 +211,17 @@ struct as_max1027_device *as_max1027_open(int aSpiNum,
ret = snprintf(buffer, BUFFER_SIZE, "%s%s", path, "temp1_input");
if (ret<0)
{
+#ifdef ERROR_MSG
printf("Error in path writing\n");
+#endif
return NULL;
}
fTemperature = open(buffer, O_RDONLY);
if (fTemperature < 0)
{
+#ifdef ERROR_MSG
printf("Error, can't open temperature file.\n");
+#endif
return NULL;
}
} else {
@@ -212,21 +237,27 @@ struct as_max1027_device *as_max1027_open(int aSpiNum,
ret = snprintf(slow_input_name, 20, SLOW_INPUT_NAME, i);
if (ret < 0)
{
+#ifdef ERROR_MSG
printf("Error in path writing\n");
+#endif
return NULL;
}
ret = snprintf(buffer, BUFFER_SIZE, "%s%s", path, slow_input_name);
if (ret < 0)
{
+#ifdef ERROR_MSG
printf("Error in path writing\n");
+#endif
return NULL;
}
fLowSpeed[i] = open(buffer, O_RDONLY);
if (fLowSpeed[i] < 0)
{
+#ifdef ERROR_MSG
printf("Error, can't open %s\n", buffer);
+#endif
return NULL;
}
}
@@ -235,14 +266,18 @@ struct as_max1027_device *as_max1027_open(int aSpiNum,
ret = snprintf(buffer, BUFFER_SIZE, FAST_INPUT_PATH, i);
if (ret < 0)
{
+#ifdef ERROR_MSG
printf("Error in path writing\n");
+#endif
return NULL;
}
fHighSpeed[i] = open(buffer, O_RDONLY);
if (fHighSpeed[i] < 0)
{
+#ifdef ERROR_MSG
printf("Error, can't open %s\nIs loadmax.sh launched ?\n", buffer);
+#endif
return NULL;
}
@@ -266,27 +301,6 @@ struct as_max1027_device *as_max1027_open(int aSpiNum,
return dev;
}
-int32_t as_max1027_close(struct as_max1027_device *aDev)
-{
- int i;
-
- if (aDev->fConversion > 0) close(aDev->fConversion);
- if (aDev->fSetup > 0) close(aDev->fSetup);
- if (aDev->fAveraging > 0) close(aDev->fAveraging);
-
- if (aDev->fTemperature > 0) close(aDev->fTemperature);
-
- for (i=0 ; i<NUMBER_OF_CHANNELS; i++)
- {
- if (aDev->fLowSpeed[i] > 0) close(aDev->fLowSpeed[i]);
- if (aDev->fHighSpeed[i] > 0) close(aDev->fHighSpeed[i]);
- }
-
- free(aDev);
-
- return 0;
-}
-
int32_t as_max1027_read_temperature_mC(struct as_max1027_device *aDev,
int *aTemperature)
{
@@ -304,7 +318,9 @@ int32_t as_max1027_read_temperature_mC(struct as_max1027_device *aDev,
MAX1027_CONV_TEMP);
if (ret < 0)
{
+#ifdef ERROR_MSG
printf("Error launching conversion\n");
+#endif
return -1;
}
@@ -312,7 +328,9 @@ int32_t as_max1027_read_temperature_mC(struct as_max1027_device *aDev,
ret = as_max1027_read_buffer(aDev->fTemperature, aTemperature);
if (ret < 0)
{
+#ifdef ERROR_MSG
printf("Error, reading fTemperature\n");
+#endif
return -1;
}
@@ -340,7 +358,10 @@ int32_t as_max1027_set_averaging(struct as_max1027_device *aDev, uint8_t aNbConv
case 32: avg_register = MAX1027_AVG_NAVG(3) | MAX1027_AVG_AVGON(1);
aDev->scan_mode = SCAN_MODE_10; /* scan */
break;
- default: printf("%s: unsupported setting\n", __func__);
+ default:
+#ifdef ERROR_MSG
+ printf("%s: unsupported setting\n", __func__);
+#endif
return -1;
}
@@ -349,14 +370,15 @@ int32_t as_max1027_set_averaging(struct as_max1027_device *aDev, uint8_t aNbConv
ret = as_max1027_write_buffer(aDev->fAveraging, avg_register);
if (ret < 0)
{
+#ifdef ERROR_MSG
printf("Error, setting averaging\n");
+#endif
return -1;
}
return aNbConv;
}
-
int32_t as_max1027_get_value_milliVolt(struct as_max1027_device *aDev,
int aChannelNum, int *aValue)
{
@@ -364,7 +386,9 @@ int32_t as_max1027_get_value_milliVolt(struct as_max1027_device *aDev,
if ((aChannelNum >= NUMBER_OF_CHANNELS) || (aChannelNum < 0))
{
+#ifdef ERROR_MSG
printf("Wrong num channel\n");
+#endif
return -1;
}
@@ -377,7 +401,9 @@ int32_t as_max1027_get_value_milliVolt(struct as_max1027_device *aDev,
MAX1027_CONV_SCAN(aDev->scan_mode));
if (ret < 0)
{
+#ifdef ERROR_MSG
printf("Error launching conversion\n");
+#endif
return -1;
}
@@ -385,21 +411,48 @@ int32_t as_max1027_get_value_milliVolt(struct as_max1027_device *aDev,
ret = as_max1027_read_buffer(aDev->fLowSpeed[aChannelNum], aValue);
if (ret < 0)
{
+#ifdef ERROR_MSG
printf("Error, reading fLowSpeed[%d]\n", aChannelNum);
+#endif
return -1;
}
}
else if (aDev->mode == AS_MAX1027_FAST)
{
+#ifdef ERROR_MSG
printf("TODO: fast mode channel reading\n");
+#endif
return -1;
}
else
{
+#ifdef ERROR_MSG
printf("Unknown mode\n");
+#endif
return -1;
}
return 0;
}
+int32_t as_max1027_close(struct as_max1027_device *aDev)
+{
+ int i;
+
+ if (aDev->fConversion > 0) close(aDev->fConversion);
+ if (aDev->fSetup > 0) close(aDev->fSetup);
+ if (aDev->fAveraging > 0) close(aDev->fAveraging);
+
+ if (aDev->fTemperature > 0) close(aDev->fTemperature);
+
+ for (i=0 ; i<NUMBER_OF_CHANNELS; i++)
+ {
+ if (aDev->fLowSpeed[i] > 0) close(aDev->fLowSpeed[i]);
+ if (aDev->fHighSpeed[i] > 0) close(aDev->fHighSpeed[i]);
+ }
+
+ free(aDev);
+
+ return 0;
+}
+
diff --git a/target/packages/as_devices/c/as_max1027.h b/target/packages/as_devices/c/as_max1027.h
index 5832151..c094831 100644
--- a/target/packages/as_devices/c/as_max1027.h
+++ b/target/packages/as_devices/c/as_max1027.h
@@ -21,12 +21,6 @@
#ifndef AS_MAX1027_H_
#define AS_MAX1027_H_
-/** @file
- * @brief Read/Write analog value with max1027 chip
- *
- *
- */
-
#ifdef __cplusplus
extern "C" {
#endif
@@ -63,15 +57,6 @@ struct as_max1027_device {
struct as_max1027_device *as_max1027_open(int aSpiNum,
AS_max1027_mode aMode);
-/** @brief Close max1027
- *
- * @param aDev structure device pointer
- *
- * @return negative value on error
- */
-int32_t as_max1027_close(struct as_max1027_device *aDev);
-
-
/** @brief set averaging measurement
*
* @param as_max1027_device structure pointer.
@@ -105,8 +90,17 @@ int32_t as_max1027_get_value_milliVolt(struct as_max1027_device *aDev,
int aChannelNum,
int *aValue);
+/** @brief Close max1027
+ *
+ * @param aDev structure device pointer
+ *
+ * @return negative value on error
+ */
+int32_t as_max1027_close(struct as_max1027_device *aDev);
+
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* AS_MAX1027_H_ */
+
diff --git a/target/packages/as_devices/test_c.h b/target/packages/as_devices/test_c.h
index de489d3..d864b5f 100644
--- a/target/packages/as_devices/test_c.h
+++ b/target/packages/as_devices/test_c.h
@@ -581,16 +581,16 @@ void test_gpio()
pullup = ret;
pressEnterToContinue();
break;
- case '8' : printf("1) GPIO_IRQ_MODE_NOINT \n");
+ case '8' : printf("1) GPIO_IRQ_MODE_NOINT \n");
printf("2) GPIO_IRQ_MODE_RISING \n");
printf("3) GPIO_IRQ_MODE_FALLING\n");
printf("4) GPIO_IRQ_MODE_BOTH \n");
printf("Give value : ");
scanf("%d", &value);
- if (value == 1)value = GPIO_IRQ_MODE_NOINT ;
- if (value == 2)value = GPIO_IRQ_MODE_RISING ;
- if (value == 3)value = GPIO_IRQ_MODE_FALLING;
- if (value == 4)value = GPIO_IRQ_MODE_BOTH ;
+ if (value == 1)value = GPIO_IRQ_MODE_NOINT ;
+ if (value == 2)value = GPIO_IRQ_MODE_RISING ;
+ if (value == 3)value = GPIO_IRQ_MODE_FALLING;
+ if (value == 4)value = GPIO_IRQ_MODE_BOTH ;
ret = as_gpio_set_irq_mode(gpio_dev,
pin_num,
value);
@@ -611,10 +611,10 @@ void test_gpio()
pressEnterToContinue();
break;
}
- if (ret==GPIO_IRQ_MODE_NOINT )printf("GPIO_IRQ_MODE_NOINT \n");
- if (ret==GPIO_IRQ_MODE_RISING )printf("GPIO_IRQ_MODE_RISING \n");
- if (ret==GPIO_IRQ_MODE_FALLING)printf("GPIO_IRQ_MODE_FALLING\n");
- if (ret==GPIO_IRQ_MODE_BOTH )printf("GPIO_IRQ_MODE_BOTH \n");
+ if (ret==GPIO_IRQ_MODE_NOINT )printf("GPIO_IRQ_MODE_NOINT \n");
+ if (ret==GPIO_IRQ_MODE_RISING )printf("GPIO_IRQ_MODE_RISING \n");
+ if (ret==GPIO_IRQ_MODE_FALLING)printf("GPIO_IRQ_MODE_FALLING\n");
+ if (ret==GPIO_IRQ_MODE_BOTH )printf("GPIO_IRQ_MODE_BOTH \n");
pressEnterToContinue();
break;
case 'a' : printf("Blocking read \n");
@@ -715,7 +715,7 @@ void test_max1027()
}
pressEnterToContinue();
break;
- case '2' : printf("Give channel you want to read (0-8): ");
+ case '2' : printf("Give channel you want to read (0-6): ");
scanf("%d",&value);
if ((value >= NUM_OF_CHANNEL) || (value < 0)){
printf("Channel num wrong\n");
@@ -735,7 +735,15 @@ void test_max1027()
averaging = value;
pressEnterToContinue();
break;
- case '4' : printf("TODO");
+ case '4' : ret = as_max1027_get_value_milliVolt(max1027_dev,
+ channel,&value);
+ if (ret < 0) {
+ printf("Error reading temperature\n");
+ pressEnterToContinue();
+ break;
+ }
+ printf("Channel %d value read : %d\n", channel, value);
+ pressEnterToContinue();
break;
case '5' : ret = as_max1027_read_temperature_mC(max1027_dev, &temp_read);
if (ret < 0) {
hooks/post-receive
--
armadeus
|