[Armadeus-commitlog] armadeus branch, master, updated. release-3.2-236-g7df6404
Brought to you by:
sszy
|
From: Fabien M <fa...@us...> - 2010-03-12 13:49:41
|
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 7df64044a833c3ee4ed8a3ab61adb9604c26bf4d (commit)
via 5652018998daa3d4ec754b32c602e42c00611fa7 (commit)
via 94ac755f18c284aba47a5b4b20e10b0e8d50b680 (commit)
from b795039a39ad4b3470d1ef7eb7c30610edb12d32 (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 7df64044a833c3ee4ed8a3ab61adb9604c26bf4d
Author: Fabien Marteau <fab...@ar...>
Date: Fri Mar 12 14:48:51 2010 +0100
[asdevices] Adding reading channel capability in as_max1027, not tested yet
commit 5652018998daa3d4ec754b32c602e42c00611fa7
Author: Fabien Marteau <fab...@ar...>
Date: Fri Mar 12 10:30:17 2010 +0100
[asdevices] Adding reading temperature capability in as_max1027
commit 94ac755f18c284aba47a5b4b20e10b0e8d50b680
Author: Fabien Marteau <fab...@ar...>
Date: Thu Mar 11 16:44:13 2010 +0100
[LINUX] Update max1027 header
-----------------------------------------------------------------------
Summary of changes:
.../063-armadeus-max1027-add_max1027_include.patch | 27 ++-
target/packages/as_devices/c/as_max1027.c | 198 ++++++++++++++++++--
target/packages/as_devices/c/as_max1027.h | 49 +++--
target/packages/as_devices/test_c.h | 63 +++++--
4 files changed, 271 insertions(+), 66 deletions(-)
diff --git a/buildroot/target/device/armadeus/linux/kernel-patches/2.6.29/063-armadeus-max1027-add_max1027_include.patch b/buildroot/target/device/armadeus/linux/kernel-patches/2.6.29/063-armadeus-max1027-add_max1027_include.patch
index 7aa81d7..088df7f 100644
--- a/buildroot/target/device/armadeus/linux/kernel-patches/2.6.29/063-armadeus-max1027-add_max1027_include.patch
+++ b/buildroot/target/device/armadeus/linux/kernel-patches/2.6.29/063-armadeus-max1027-add_max1027_include.patch
@@ -1,6 +1,8 @@
---- linux-2.6.27.2.ref/include/linux/spi/max1027.h 2008-11-18 06:04:39.000000000 +0100
-+++ linux-2.6.27.2/include/linux/spi/max1027.h 2008-11-18 06:04:39.000000000 +0100
-@@ -0,0 +1,64 @@
+Index: linux-2.6.29.6/include/linux/spi/max1027.h
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ linux-2.6.29.6/include/linux/spi/max1027.h 2010-03-11 16:42:01.000000000 +0100
+@@ -0,0 +1,71 @@
+/*
+ * include/linux/spi/max1027.h
+ *
@@ -26,20 +28,27 @@
+#ifndef __LINUX_SPI_MAX1027_H
+#define __LINUX_SPI_MAX1027_H
+
-+#define SCAN_MODE_00 0
-+#define SCAN_MODE_01 1
-+#define SCAN_MODE_10 2
-+#define SCAN_MODE_11 3
++/* 00 :Â Scans channels 0 through N.
++ * 01 : Scans channels N through the highest numbered channel.
++ * 10 : Scans channel N repeatedly. The averaging register sets the number of results
++ * 11 : No scan. Converts channel N once only. */
++#define SCAN_MODE_00 (0)
++#define SCAN_MODE_01 (1)
++#define SCAN_MODE_10 (2)
++#define SCAN_MODE_11 (3)
+
++#define MAX1027_CONV (0x80)
+#define MAX1027_CONV_CHSEL(x) ((x&0x0f)<<3)
+#define MAX1027_CONV_SCAN(x) ((x&0x03)<<1)
-+#define GET_SCAN_MODE(conv) ( (conv & 0x06) >> 1 )
+#define MAX1027_CONV_TEMP 0x01
++#define GET_SCAN_MODE(conv) ( (conv & 0x06) >> 1 )
+
++#define MAX1027_SETUP (0x40)
+#define MAX1027_SETUP_CLKSEL(x) ((x&0x03)<<4)
+#define MAX1027_SETUP_REFSEL(x) ((x&0x03)<<2)
+#define MAX1027_SETUP_DIFFSEL(x) (x&0x03)
+
++#define MAX1027_AVG (0x20)
+#define MAX1027_AVG_AVGON(x) ((x&0x01)<<4)
+#define MAX1027_AVG_NAVG(x) ((x&0x03)<<2)
+#define MAX1027_AVG_NSCAN(x) (x&0x03)
@@ -58,7 +67,7 @@
+ u8 conv; /* initial conversion register value*/
+ u8 setup; /* initial setup register value */
+ u8 avg; /* initial average register value */
-+ int cnvst_pin; /*gpio to start conversion. -1 for software start */
++ int cnvst_pin; /*gpio to start conversion. -1 for software start */
+ int (*init)(struct spi_device *spi);
+ int (*exit)(struct spi_device *spi);
+};
diff --git a/target/packages/as_devices/c/as_max1027.c b/target/packages/as_devices/c/as_max1027.c
index 2ea9d14..75a8503 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 BUFFER_SIZE (70)
#define PATH_SIZE (50)
#define SYS_PATH "/sys/bus/spi/devices/spi%d.0/"
@@ -41,6 +42,13 @@ typedef unsigned char u8;
#define SLOW_INPUT_NAME "in%d_input"
#define FAST_INPUT_PATH "/dev/max1027/AIN%d"
+/** @brief Functiun used to write in /sys file
+ *
+ * @param aFile_handler /sys file handler
+ * @param aValue int value to write
+ *
+ * @return negative value on error
+ */
int32_t as_max1027_write_buffer(int aFile_handler, int aValue)
{
int ret;
@@ -67,6 +75,36 @@ int32_t as_max1027_write_buffer(int aFile_handler, int aValue)
return buffer_len;
}
+/** @brief Functiun used to read int value in /sys file
+ *
+ * @param aFile_handler /sys file handler
+ * @param aTemperature pointer to temperature read
+ *
+ * @return negative value on error,
+ */
+int32_t as_max1027_read_buffer(int aFile_handler, int *aValueRead)
+{
+ const int SIZEOFBUFF = 20;
+ ssize_t ret;
+ char valueRead[SIZEOFBUFF];
+ int value;
+
+ ret = read(aFile_handler, valueRead, SIZEOFBUFF);
+ if (ret < 0)
+ {
+ printf("Error, reading buffer file\n");
+ return -1;
+ }
+ valueRead[ret-1] = '\0';
+
+ ret = lseek(aFile_handler, 0, SEEK_SET);
+ if (ret < 0)
+ return -1;
+ value = strtol(valueRead, NULL, 10);
+ *aValueRead = value;
+ return 0;
+}
+
struct as_max1027_device *as_max1027_open(int aSpiNum,
AS_max1027_mode aMode)
{
@@ -74,13 +112,20 @@ struct as_max1027_device *as_max1027_open(int aSpiNum,
int i;
int fConversion, fSetup, fAveraging;
int fTemperature;
- int fLowSpeed[8];
- int fHighSpeed[8];
+ int fLowSpeed[NUMBER_OF_CHANNELS];
+ int fHighSpeed[NUMBER_OF_CHANNELS];
char path[PATH_SIZE];
char buffer[BUFFER_SIZE];
char slow_input_name[20];
int ret;
+ /** XXX */
+ if (aMode == AS_MAX1027_FAST)
+ {
+ printf("Error, fast mode not supported yet\n");
+ return NULL;
+ }
+
ret = snprintf(path, PATH_SIZE, SYS_PATH, aSpiNum);
if (ret<0) {
printf("Error in path writing\n");
@@ -110,12 +155,23 @@ struct as_max1027_device *as_max1027_open(int aSpiNum,
printf("Error, can't open setup file.\n");
return NULL;
}
- /* setup */
+ ret = as_max1027_write_buffer( fSetup,
+ MAX1027_SETUP |
+ MAX1027_SETUP_CLKSEL(0) |
+ MAX1027_SETUP_REFSEL(0) |
+ MAX1027_SETUP_DIFFSEL(0));
+ if (ret < 0)
+ {
+ printf("Error, can't set default setup parameters\n");
+ return NULL;
+ }
+ /* averaging */
ret = snprintf(buffer, BUFFER_SIZE, "%s%s", path, "averaging");
if (ret<0) {
printf("Error in path writing\n");
return NULL;
}
+
fAveraging = open(buffer, O_RDWR);
if (fAveraging < 0){
printf("Error, can't open averaging file.\n");
@@ -123,18 +179,23 @@ struct as_max1027_device *as_max1027_open(int aSpiNum,
}
/* temperature */
- ret = snprintf(buffer, BUFFER_SIZE, "%s%s", path, "temperature");
- if (ret<0) {
- printf("Error in path writing\n");
- return NULL;
- }
- fTemperature = open(buffer, O_RDWR);
- if (fAveraging < 0){
- printf("Error, can't open temperature file.\n");
- return NULL;
+ if (aMode == AS_MAX1027_SLOW){
+ ret = snprintf(buffer, BUFFER_SIZE, "%s%s", path, "temp1_input");
+ if (ret<0) {
+ printf("Error in path writing\n");
+ return NULL;
+ }
+ fTemperature = open(buffer, O_RDONLY);
+ if (fTemperature < 0){
+ printf("Error, can't open temperature file.\n");
+ return NULL;
+ }
+ } else {
+ fTemperature = -1;
}
- for( i=0 ; i<8 ; i++){
+ /* Open each channels (0 to 6)*/
+ for( i=0 ; i<NUMBER_OF_CHANNELS ; i++){
fLowSpeed[i] = -1;
fHighSpeed[i] = -1;
if (aMode == AS_MAX1027_SLOW)
@@ -156,7 +217,7 @@ struct as_max1027_device *as_max1027_open(int aSpiNum,
printf("Error, can't open %s\n", buffer);
return NULL;
}
- }else if((aMode == AS_MAX1027_FAST) && (i<7)){
+ } else if ((aMode == AS_MAX1027_FAST)){
ret = snprintf(buffer, BUFFER_SIZE, FAST_INPUT_PATH, i);
if (ret < 0) {
printf("Error in path writing\n");
@@ -175,14 +236,16 @@ struct as_max1027_device *as_max1027_open(int aSpiNum,
dev = (struct as_max1027_device *)malloc(sizeof(struct as_max1027_device));
dev->mode = aMode;
+ dev->scan_mode = SCAN_MODE_11;
dev->fConversion = fConversion;
dev->fSetup = fSetup;
dev->fAveraging = fAveraging;
- for( i=0 ; i<8 ; i++){
+ for( i=0 ; i<NUMBER_OF_CHANNELS ; i++){
dev->fLowSpeed[i] = fLowSpeed[i];
dev->fHighSpeed[i] = fHighSpeed[i];
}
dev->fTemperature = fTemperature;
+
return dev;
}
@@ -196,24 +259,121 @@ int32_t as_max1027_close(struct as_max1027_device *aDev)
if (aDev->fTemperature > 0) close(aDev->fTemperature);
- for (i=0 ; i<8; i++){
+ 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)
+int32_t as_max1027_read_temperature_mC(struct as_max1027_device *aDev,
+ int *aTemperature)
{
- uint8_t setup_value;
+ int32_t ret;
/* temperature is read only on slow mode */
if (aDev->mode != AS_MAX1027_SLOW)
return -1;
+ /* launch conversion */
+ ret = as_max1027_write_buffer( aDev->fConversion,
+ MAX1027_CONV |
+ MAX1027_CONV_CHSEL(0) |
+ MAX1027_CONV_SCAN(aDev->scan_mode) |
+ MAX1027_CONV_TEMP);
+ if (ret < 0){
+ printf("Error launching conversion\n");
+ return -1;
+ }
+
+ /* read value */
+ ret = as_max1027_read_buffer(aDev->fTemperature,aTemperature);
+ if (ret < 0){
+ printf("Error, reading fTemperature\n");
+ return -1;
+ }
-
return 0;
}
+
+int32_t as_max1027_set_averaging(struct as_max1027_device *aDev, uint8_t aNbConv){
+ uint8_t avg_register = 0;
+ int ret;
+
+ switch (aNbConv)
+ {
+ case 1: avg_register = MAX1027_AVG_NAVG(0) | MAX1027_AVG_AVGON(0);
+ aDev->scan_mode = SCAN_MODE_11; /* no scan */
+ break;
+ case 4: avg_register = MAX1027_AVG_NAVG(0) | MAX1027_AVG_AVGON(1);
+ aDev->scan_mode = SCAN_MODE_10; /* scan */
+ break;
+ case 8: avg_register = MAX1027_AVG_NAVG(1) | MAX1027_AVG_AVGON(1);
+ aDev->scan_mode = SCAN_MODE_10; /* scan */
+ break;
+ case 16: avg_register = MAX1027_AVG_NAVG(2) | MAX1027_AVG_AVGON(1);
+ aDev->scan_mode = SCAN_MODE_10; /* scan */
+ break;
+ 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__);
+ return -1;
+ }
+
+ /* select averaging */
+ avg_register |= MAX1027_AVG | MAX1027_AVG_NSCAN(2);
+ ret = as_max1027_write_buffer( aDev->fAveraging, avg_register);
+ if (ret < 0){
+ printf("Error, setting averaging\n");
+ return -1;
+ }
+
+ return aNbConv;
+}
+
+
+int32_t as_max1027_get_value_milliVolt(struct as_max1027_device *aDev,
+ int aChannelNum, int *aValue)
+{
+ int32_t ret;
+
+ if ((aChannelNum >= NUMBER_OF_CHANNELS) || (aChannelNum < 0))
+ {
+ printf("Wrong num channel\n");
+ return -1;
+ }
+
+ /* temperature is read only on slow mode */
+ if (aDev->mode == AS_MAX1027_SLOW)
+ {
+ /* launch conversion */
+ ret = as_max1027_write_buffer( aDev->fConversion,
+ MAX1027_CONV |
+ MAX1027_CONV_CHSEL(aChannelNum) |
+ MAX1027_CONV_SCAN(aDev->scan_mode));
+ if (ret < 0){
+ printf("Error launching conversion\n");
+ return -1;
+ }
+
+ /* read value */
+ ret = as_max1027_read_buffer(aDev->fLowSpeed[aChannelNum], aValue);
+ if (ret < 0){
+ printf("Error, reading fLowSpeed[%d]\n",aChannelNum);
+ return -1;
+ }
+ } else if (aDev->mode == AS_MAX1027_FAST) {
+ printf("TODO: fast mode channel reading\n");
+ return -1;
+ } else {
+ printf("Uncknow mode\n");
+ return -1;
+ }
+
+ return 0;
+}
+
diff --git a/target/packages/as_devices/c/as_max1027.h b/target/packages/as_devices/c/as_max1027.h
index 7f4d1ff..5832151 100644
--- a/target/packages/as_devices/c/as_max1027.h
+++ b/target/packages/as_devices/c/as_max1027.h
@@ -3,18 +3,18 @@
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of the
* License, or (at your option) any later version.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*
- * Copyright (C) 2010 Fabien Marteau <fab...@ar...>
+ * Copyright (C) 2010 Fabien Marteau <fab...@ar...>
*
*/
@@ -22,7 +22,7 @@
#define AS_MAX1027_H_
/** @file
- * @brief Read/Write analog value with max1027 chip
+ * @brief Read/Write analog value with max1027 chip
*
*
*/
@@ -31,6 +31,8 @@
extern "C" {
#endif
+#define NUMBER_OF_CHANNELS (7)
+
typedef enum {
AS_MAX1027_FAST,
AS_MAX1027_SLOW
@@ -41,12 +43,14 @@ typedef enum {
*/
struct as_max1027_device {
AS_max1027_mode mode;
- int fConversion; /**< File handler for conversion register */
- int fSetup; /**< File handler for setup register */
- int fAveraging; /**< File handler for averaging register */
- int fLowSpeed[8]; /**< Files handlers for lowspeed input interface */
- int fHighSpeed[8]; /**< Files handlers for high speed input interface */
- int fTemperature; /**< File handler for temperature */
+ uint8_t scan_mode;
+ uint8_t fConversion; /**< File handler for conversion register */
+ uint8_t fSetup; /**< File handler for setup register */
+ uint8_t fAveraging; /**< File handler for averaging register */
+ uint8_t fLowSpeed[NUMBER_OF_CHANNELS]; /**< Files handlers for lowspeed */
+ uint8_t fHighSpeed[NUMBER_OF_CHANNELS]; /**< Files handlers for high speed */
+ uint8_t fTemperature; /**< File handler for temperature */
+
};
/** @brief Open max1027
@@ -54,9 +58,9 @@ struct as_max1027_device {
* @param aSpiNum spi bus number used
* @param aMode enum to set mode (fast or slow)
*
- * @return as_max1027_device structure pointer, NULL if error
+ * @return as_max1027_device structure pointer, NULL if error
*/
-struct as_max1027_device *as_max1027_open(int aSpiNum,
+struct as_max1027_device *as_max1027_open(int aSpiNum,
AS_max1027_mode aMode);
/** @brief Close max1027
@@ -70,29 +74,36 @@ int32_t as_max1027_close(struct as_max1027_device *aDev);
/** @brief set averaging measurement
*
- * @param
+ * @param as_max1027_device structure pointer.
+ * @param aNbConv number of conversions to do for the averaging (4, 8, 16, 32). Set to 1 for disabling averaging.
*
- * @return negative value on error
+ * @return negative value on error and aNbConv on success
*/
-int32_t as_max1027_set_averaging(struct as_max1027_device *aDev);
+int32_t as_max1027_set_averaging(struct as_max1027_device *aDev, uint8_t aNbConv);
/** @brief read temperature in milidegree â°C
*
- * @param
+ * @param as_max1027_device structure pointer.
+ * @param aTemperature pointer for temperature result.
*
* @return negative value on error
*
* @note Only slow mode can read temperature value.
*/
-int32_t as_max1027_read_temperature_mC(struct as_max1027_device *aDev);
+int32_t as_max1027_read_temperature_mC(struct as_max1027_device *aDev,
+ int *aTemperature);
/** @brief read milivoltage value
*
- * @param
+ * @param as_max1027_device structure pointer.
+ * @param aChannelNum channel number to read.
+ * @param *aValue pointer to returned value.
*
* @return negative value on error
*/
-int32_t as_max1027_get_value_milliVolt(struct as_max1027_device *aDev);
+int32_t as_max1027_get_value_milliVolt(struct as_max1027_device *aDev,
+ int aChannelNum,
+ int *aValue);
#ifdef __cplusplus
}
diff --git a/target/packages/as_devices/test_c.h b/target/packages/as_devices/test_c.h
index 6f6aa5f..fe9c040 100644
--- a/target/packages/as_devices/test_c.h
+++ b/target/packages/as_devices/test_c.h
@@ -1,19 +1,19 @@
/*
** THE ARMadeus Systems
- **
- ** Copyright (C) 2009 The armadeus systems team
+ **
+ ** 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
@@ -35,7 +35,7 @@ void pressEnterToContinue(void)
{
printf("\nPress enter to continue\n");
while( getc(stdin) != '\n');
- while( getc(stdin) != '\n');
+ while( getc(stdin) != '\n');
}
/* pwm test */
@@ -303,9 +303,9 @@ void test_93LC()
scanf("%s", spidevpath);
printf("New path is %s\n",spidevpath);
break;
- case '5' : dev = as_93lcxx_open((unsigned char *)spidevpath,
- type,
- frequency,
+ case '5' : dev = as_93lcxx_open((unsigned char *)spidevpath,
+ type,
+ frequency,
word_size);
if (dev == NULL)
{
@@ -320,7 +320,7 @@ void test_93LC()
} else {
switch(buffer[0])
{
- case '1' : as_93lcxx_close(dev);
+ case '1' : as_93lcxx_close(dev);
printf("eeprom closed\n");
initialized = 0;
pressEnterToContinue();
@@ -397,7 +397,7 @@ void test_93LC()
{
printf("%03X -> %02X\n",
i,as_93lcxx_read(dev, i));
- } else{
+ } else{
printf("%03X -> %04X\n",
i,as_93lcxx_read(dev, i));
}
@@ -547,7 +547,7 @@ void test_gpio()
port_value = ret;
pressEnterToContinue();
break;
-
+
default : break;
}
}
@@ -569,10 +569,14 @@ void test_max1027()
int ret;
char c_value[10];
int value;
+ int averaging=1;
+ int temperature = 0;
+ int temp_read=0;
struct as_max1027_device *max1027_dev;
int channel=0;
AS_max1027_mode mode= AS_MAX1027_SLOW;
+
max1027_dev = as_max1027_open(MAX1027_SPI_NUM, mode);
if (max1027_dev == NULL)
{
@@ -580,18 +584,20 @@ void test_max1027()
pressEnterToContinue();
return ;
}
+ pressEnterToContinue();
while(buffer[0] != 'q')
{
system("clear");
printf("**************************\n");
- printf(" Testing max1027 *\n");
+ printf(" Testing max1027 *\n");
printf("**************************\n");
printf("Choose ('q' to quit):\n");
printf(" 1) Change mode (%s)\n",(mode == AS_MAX1027_SLOW)?"SLOW":"FAST");
printf(" 2) Select channel (%d)\n", channel);
- printf(" 3) Read channel value\n");
- printf(" 4) Read temperature\n");
+ printf(" 3) Set averaging (%d)\n", averaging);
+ printf(" 4) Read channel value\n");
+ printf(" 5) Read temperature\n");
printf("> ");
scanf("%s",buffer);
@@ -602,7 +608,7 @@ void test_max1027()
scanf("%s",c_value);
if ((c_value[0]=='s') && (mode == AS_MAX1027_FAST)){
as_max1027_close(max1027_dev);
- max1027_dev = as_max1027_open(MAX1027_SPI_NUM,
+ max1027_dev = as_max1027_open(MAX1027_SPI_NUM,
AS_MAX1027_SLOW);
if (max1027_dev == NULL){
printf("Error, can't open max1027 in slow mode\n");
@@ -613,7 +619,7 @@ void test_max1027()
printf("Mode changed to Slow\n");
} else if((c_value[0] == 'f') && (mode == AS_MAX1027_SLOW)){
as_max1027_close(max1027_dev);
- max1027_dev = as_max1027_open(MAX1027_SPI_NUM,
+ max1027_dev = as_max1027_open(MAX1027_SPI_NUM,
AS_MAX1027_FAST);
if (max1027_dev == NULL){
printf("Error, can't open max1027 in fast mode\n");
@@ -633,11 +639,30 @@ void test_max1027()
}
channel = value;
break;
- case '3' : printf("TODO");
+ case '3' : printf("Give averaging (1, 4, 8, 16, 32): ");
+ scanf("%d", &value);
+ ret = as_max1027_set_averaging(max1027_dev, value);
+ if (ret < 0)
+ {
+ printf("Error, can't set averaging\n");
+ pressEnterToContinue();
+ break;
+ }
+ averaging = value;
+ pressEnterToContinue();
break;
case '4' : printf("TODO");
break;
-
+ case '5' : ret = as_max1027_read_temperature_mC(max1027_dev, &temp_read);
+ if (ret < 0) {
+ printf("Error reading temperature\n");
+ pressEnterToContinue();
+ break;
+ }
+ temperature = temp_read;
+ printf("Temperature read in miliâ°C : %d\n", temperature);
+ pressEnterToContinue();
+ break;
default : break;
}
}
hooks/post-receive
--
armadeus
|