[Armadeus-commitlog] armadeus branch, master, updated. release-3.2-40-gcda9b13
Brought to you by:
sszy
|
From: Fabien M <fa...@us...> - 2009-12-11 16:02:38
|
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 cda9b13b63b9d876917ee6fc8f1d573af4a60086 (commit)
from 8a4a868e5f4796162d70a8e23cb3916e8c483c1a (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 cda9b13b63b9d876917ee6fc8f1d573af4a60086
Author: Fabien Marteau <fab...@ar...>
Date: Fri Dec 11 16:12:51 2009 +0100
[TOOLS] Adding eeprom 93lcxx test in AsDevices test program
-----------------------------------------------------------------------
Summary of changes:
target/packages/as_devices/Makefile | 15 +-
target/packages/as_devices/main.c | 10 ++
target/packages/as_devices/test_c.h | 290 ++++++++++++++++++++++++++++++++---
3 files changed, 286 insertions(+), 29 deletions(-)
diff --git a/target/packages/as_devices/Makefile b/target/packages/as_devices/Makefile
index e0cab84..e35e20b 100644
--- a/target/packages/as_devices/Makefile
+++ b/target/packages/as_devices/Makefile
@@ -18,16 +18,17 @@ CPP_INCLUDE=cpp/
.PHONY: all
-all: ${C_BINARY} ${CPP_BINARY}
+all: ${C_BINARY}
+ #${CPP_BINARY}
${C_BINARY}: main.c test_c.h ${C_LIB}
- ${CC} ${CFLAGS} main.c ${C_LIB} -o ${C_BINARY} -I${C_INCLUDE}
+ ${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}
+#
+#${CPP_LIB}: ${C_LIB}
+# cd cpp; make CXX=${CXX}
${C_LIB}:
cd c; make CC=${CC}
diff --git a/target/packages/as_devices/main.c b/target/packages/as_devices/main.c
index 54c2427..bcb0521 100644
--- a/target/packages/as_devices/main.c
+++ b/target/packages/as_devices/main.c
@@ -38,6 +38,9 @@ int main(int argc, char ** argv)
printf("*******************************************************\n");
printf("Choose a test ('q' to quit):\n");
printf(" 1) Testing pwm\n");
+ printf(" 2) Testing i2c\n");
+ printf(" 3) Testing spi\n");
+ printf(" 4) Testing 93LCxx eprom\n");
printf("> ");
scanf("%s",buffer);
@@ -45,6 +48,13 @@ int main(int argc, char ** argv)
{
case '1' : test_pwm();
break;
+ case '2' : test_i2c();
+ break;
+ case '3' : test_spi();
+ break;
+ case '4' : test_93LC();
+ break;
+
default : break;
}
}
diff --git a/target/packages/as_devices/test_c.h b/target/packages/as_devices/test_c.h
index b35d7a5..e38a14c 100644
--- a/target/packages/as_devices/test_c.h
+++ b/target/packages/as_devices/test_c.h
@@ -1,33 +1,36 @@
/*
-** 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
-*/
+ ** 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 <stdio.h>
#include <stdlib.h>
+#include <math.h>
+
#include "as_apf27_pwm.h"
+#include "as_93lcxx.h"
#define PWM_NUM 0
void pressEnterToContinue(void)
{
- printf("Press enter to continue\n");
+ printf("\nPress enter to continue\n");
getc(stdin);//XXX
while( getc(stdin) != '\n') ;
}
@@ -61,7 +64,7 @@ void test_pwm(void)
printf(" 8) get state\n");
printf("> ");
scanf("%s",buffer);
-
+
switch(buffer[0])
{
case '1' : printf("Give frequency :");
@@ -70,7 +73,7 @@ void test_pwm(void)
pressEnterToContinue();
break;
case '2' : printf("Current pwm frequency is %d\n",
- as_apf27_pwm_getFrequency(PWM_NUM));
+ as_apf27_pwm_getFrequency(PWM_NUM));
pressEnterToContinue();
break;
case '3' : printf("Give period :");
@@ -127,4 +130,247 @@ void test_pwm(void)
}
}
+void test_i2c(void)
+{
+ char buffer[20];
+
+ while(buffer[0] != 'q')
+ {
+ system("clear");
+ printf("*********************************\n");
+ printf("* Testing i2c menu *\n");
+ printf("*********************************\n");
+ printf("Choose ('q' to quit):\n");
+ printf(" 1) read mac address \n");
+ printf("> ");
+ scanf("%s",buffer);
+
+ switch(buffer[0])
+ {
+ case '1' : printf("TODO\n");
+ pressEnterToContinue();
+ break;
+ default : break;
+ }
+ }
+
+}
+
+void test_spi(void)
+{
+ printf("TODO\n");
+ pressEnterToContinue();
+}
+
+/* 93LCxx eepromm test */
+
+int address_size(int aType, int aWordSize)
+{
+ return (((aType-46)/10) + 6 + 2 - (aWordSize/8));
+}
+
+int max_address(int aType, int aWordSize)
+{
+ return (pow(2,address_size(aType, aWordSize))-1);
+}
+
+void test_93LC()
+{
+ char buffer[50];
+ int i;
+
+ int type = 46;
+ char spidevpath[50];
+ struct as_93lcxx_device *dev;
+ /* defaults values */
+ int frequency = 1000000;
+ uint8_t word_size = 8;
+ int value, value2;
+ int initialized=0;
+ snprintf(spidevpath, 50, "%s", "/dev/spidev2.0");
+
+ while(buffer[0] != 'q')
+ {
+ system("clear");
+ printf("*********************************\n");
+ printf("* Testing 93LCxx menu *\n");
+ printf("*********************************\n");
+ printf("Choose ('q' to quit):\n");
+ if (initialized == 0)
+ {
+ printf(" 1) Change word size (%d)\n", word_size);
+ printf(" 2) Change bus frequency (%d)\n", frequency);
+ printf(" 3) Change eeprom type (%d)\n", type);
+ printf(" 4) Change spidev path (%s)\n", spidevpath);
+ printf(" 5) Initialize eeprom\n");
+ } else {
+ printf(" 1) Close eeprom\n");
+ printf(" 2) Read specific address\n");
+ printf(" 3) Erase specific address\n");
+ printf(" 4) Write specific address\n");
+ printf(" 5) Write all\n");
+ printf(" 6) Read all\n");
+ printf(" 7) Erase all\n");
+ printf(" 8) Unlock write\n");
+ printf(" 9) lock write\n");
+ }
+
+ printf("> ");
+ scanf("%s",buffer);
+
+ if (initialized == 0)
+ {
+ switch(buffer[0])
+ {
+ case '1' : printf("Give new word size (8 or 16) : ");
+ scanf("%d", &value);
+ if ( (value != 8) && (value != 16) )
+ {
+ printf("Wrong value\n");
+ pressEnterToContinue();
+ } else {
+ word_size = value;
+ }
+ break;
+ case '2' : printf("Give bus frequency : ");
+ scanf("%d", &value);
+ frequency = value;
+ printf("Frequency changed to %dHz\n",frequency);
+ break;
+ case '3' : printf("Give new type of eeprom (46, 56 or 66) : ");
+ scanf("%d", &value);
+ if ( (value != 46) && (value != 56) && (value != 66) )
+ {
+ printf("Wrong value\n");
+ pressEnterToContinue();
+ } else {
+ type = value;
+ }
+ break;
+ case '4' : printf("Give new path for spidev : \n");
+ scanf("%s", spidevpath);
+ printf("New path is %s\n",spidevpath);
+ break;
+ case '5' : dev = as_93lcxx_open((unsigned char *)spidevpath,
+ type,
+ frequency,
+ word_size);
+ if (dev == NULL)
+ {
+ printf("Error, can't initialize eeprom. Have you modprobed spidev ?\n");
+ } else {
+ initialized = 1;
+ }
+ pressEnterToContinue();
+ break;
+ default : break;
+ }
+ } else {
+ switch(buffer[0])
+ {
+ case '1' : as_93lcxx_close(dev);
+ printf("eeprom closed\n");
+ initialized = 0;
+ pressEnterToContinue();
+ break;
+ case '2' : printf(" Read specific address\n");
+ printf("Give address in hexadecimal (max 0x%03X):",
+ max_address(type, word_size));
+ scanf("%x",&value);
+ if (value > max_address(type, word_size))
+ {
+ printf(" Error, address wrong\n");
+ } else {
+ value2 = as_93lcxx_read(dev, value);
+ if (value2 < 0)
+ {
+ printf("Error, can't read value\n");
+ } else {
+ printf(" Read %02x at %02X", value2, value );
+ }
+ }
+ pressEnterToContinue();
+ break;
+ case '3' : printf("Erase specific address\n");
+ printf("Give address in hexadecimal (max 0x%03X):",
+ max_address(type, word_size));
+ scanf("%x",&value);
+ if (value > max_address(type, word_size))
+ {
+ printf(" Error, address wrong\n");
+ } else {
+ value2 = as_93lcxx_erase(dev, value);
+ if (value2 < 0)
+ {
+ printf("Error, can't erase value\n");
+ } else {
+ printf("Value erased\n");
+ }
+ }
+ pressEnterToContinue();
+ break;
+ case '4' : printf("Write specific address\n");
+ printf("Give address in hexadecimal (max 0x%03X):",
+ max_address(type, word_size));
+ scanf("%x",&value);
+ if (value > max_address(type, word_size))
+ {
+ printf(" Error, address wrong\n");
+ pressEnterToContinue();
+ break;
+ }
+ printf("Give value in hexadecimal :");
+ scanf("%x",&value2);
+ value2 = as_93lcxx_write(dev, value, value2);
+ if (value2 < 0)
+ {
+ printf("Error, can't write value\n");
+ }
+ pressEnterToContinue();
+ break;
+ case '5' : printf(" Write all\n");
+ printf("Give value in hexadecimal:");
+ scanf("%x",&value);
+ value2 = as_93lcxx_write_all(dev, value);
+ if (value2 < 0)
+ {
+ printf("Error, can't write value\n");
+ }
+ pressEnterToContinue();
+ break;
+ case '6' : printf(" Read all\n");
+ for(i = 0; i <= max_address(type, word_size); i++)
+ {
+ if (word_size == 8)
+ {
+ printf("%03X -> %02X\n",
+ i,as_93lcxx_read(dev, i));
+ } else{
+ printf("%03X -> %04X\n",
+ i,as_93lcxx_read(dev, i));
+ }
+ }
+ pressEnterToContinue();
+ break;
+ case '7' : printf(" Erase all\n");
+ value = as_93lcxx_erase_all(dev);
+ if (value < 0)
+ printf(" Error in erasing eeprom\n");
+ pressEnterToContinue();
+ break;
+ case '8' : printf("Unlock write\n");
+ if (as_93lcxx_ewen(dev) < 0)
+ printf("Error can't unlock write\n");
+ pressEnterToContinue();
+ break;
+ case '9' : printf("lock write\n");
+ if (as_93lcxx_ewds(dev) < 0)
+ printf("Error can't lock write\n");
+ pressEnterToContinue();
+ break;
+ default : break;
+ }
+ }
+ }
+}
hooks/post-receive
--
armadeus
|