Module ECAM interfacé au cockpit A320 FS Polytech PAris Sud Orsay Electronique et Systèmes Embarqués
Diff: main.cpp
- Revision:
- 1:1c0e7a7c86fe
- Parent:
- 0:c0664cca9901
--- a/main.cpp Sun Mar 13 18:56:29 2011 +0000
+++ b/main.cpp Wed Mar 16 08:15:31 2011 +0000
@@ -76,18 +76,39 @@
int main() {
unsigned constffff=0xffff;
unsigned short i=0,j=0xFFFF;
- char tmp[2];
+ char tmp[2]={0x02,0xE0};
unsigned short state=0,touche=0;
+ unsigned short v2=0,v3=0;
pc.printf("COUCOU1\n");
+ // initaliser les 8575 à 1 recessif
i2c.write(addrt[0],(char *)&j,2);
i2c.write(addrt[1],(char *)&j,2);
i2c.write(addrt[2],(char *)&j,2);
- // pc.printf("COUCOU3\n");
+ // initialiser les convertisseurs des potentiometres
+ i2c.write(0xA2,(char*)tmp,2);
+ wait(0.001);
+ i2c.write(0xA4,(char*)tmp,2);
+
while (1) {
+ // utilisé pour lire les potentiometres
+ tmp[0]=0x00;
+ i2c.write(0xA2,tmp,1);
+ wait(0.0001);
+ i2c.read(0xA3,tmp,2);
+ v2= tmp[0]&0x0F;
+ v2= (v2<<6)| (tmp[1]>>2)&0x3F;
+ tmp[0]=0x00;
+ i2c.write(0xA4,tmp,1);
+ i2c.read(0xA5,tmp,2);
+ v3= tmp[0]&0x0F;
+ v3= (v3<<6)| (tmp[1]>>2)&0x3F;
+ // Affichage des potentiometres
+ printf("%5u %5u\n\r",v2,v3);
wait(0.1);
+ // Lecture des bouton de l'ECAM
read_ecam(valt);
i=decod_butt(valt);
- //pc.printf("%4x %4x %4x %u",valt[0],valt[1],valt[2],i);
+ //automate de gestion de l'appui des touches
if(i<24){
if(state==0){
state=1;
@@ -96,7 +117,8 @@
}else{
state=0;
}
-
+ //renvoi du nom de la touche et de son code
+ //si touche=0 alors pas de touche appuyée
if(touche>0){
pc.printf("X %s %2u\n\r",mess[touche-1],(unsigned) touche);
if(touche<13){
@@ -111,38 +133,6 @@
}
touche=0;
}
-
- /*else{
- pc.printf("\n\r");
- }*/
-
- /*
-
- i2c.read(addrt[i]+1, (char *)cmd, 2);
- pc.printf("%2x%2x ",cmd[0],cmd[1]);
- wait(0.1);
- i=i+1;
- if (i==3) {
- pc.printf("\n\r");
- i=0;
- scanf("%x",&i);
- i2c.write(addrt[2],(char *)&i,2);
- wait(0.3);
- i=0;
- }
- i2c.write(addrt[0],(char *)(tt+i),2);
- pc.printf("%u\n\r",i );
- wait(0.6);
- i=(i+1)%8;
-
- wait(0.1);
- i2c.read(addrt[0]+1, (char *)&j, 2);
- pc.printf("COUCOU2\n\r");
- j=(j<<1);
- j=j|0x5555;
- wait_us(70);
- i2c.write(addrt[2],(char *)&j,2);
- */
}
}