Index: branch/tchuem/Emb_App.tws
===================================================================
--- branch/tchuem/Emb_App.tws	(revision 507)
+++ branch/tchuem/Emb_App.tws	(revision 508)
@@ -9,9 +9,13 @@
 [OPEN_WORKSPACE_FILES]
 "E:\tp_info6_2018_tchuem\tp_info6\bsp\periph.c" 
 "E:\tp_info6_2018_tchuem\tp_info6\bsp\radiocommande.c" 
+"E:\tp_info6_2018_tchuem\tp_info6\Emb_App\crt0mr.a30" 
 "E:\tp_info6_2018_tchuem\tp_info6\Emb_App\Debug\mr308.inc" 
+"E:\tp_info6_2018_tchuem\tp_info6\Emb_App\programme_principal_etud.c" 
 [WORKSPACE_FILE_STATES]
-"E:\tp_info6_2018_tchuem\tp_info6\Emb_App\Debug\mr308.inc" -8 -30 1596 539 1 2 
+"E:\tp_info6_2018_tchuem\tp_info6\Emb_App\Debug\mr308.inc" 0 0 1596 539 0 2 
+"E:\tp_info6_2018_tchuem\tp_info6\Emb_App\crt0mr.a30" 100 100 1430 351 0 4 
+"E:\tp_info6_2018_tchuem\tp_info6\Emb_App\programme_principal_etud.c" -8 -30 1596 539 1 3 
 "E:\tp_info6_2018_tchuem\tp_info6\bsp\periph.c" 50 50 1430 351 0 0 
 "E:\tp_info6_2018_tchuem\tp_info6\bsp\radiocommande.c" 75 75 1430 351 0 1 
 [LOADED_PROJECTS]
Index: branch/tchuem/Emb_App/SessionM32C_E8a_system.ini
===================================================================
--- branch/tchuem/Emb_App/SessionM32C_E8a_system.ini	(revision 507)
+++ branch/tchuem/Emb_App/SessionM32C_E8a_system.ini	(revision 508)
@@ -25,4 +25,4 @@
 [Target]
 M32C E8a SYSTEM=Renesas Communications
 [USER_DATA]
-RESET=ff001e
+RESET=ff0036
Index: branch/tchuem/Emb_App/programme_principal_etud.c
===================================================================
--- branch/tchuem/Emb_App/programme_principal_etud.c	(revision 507)
+++ branch/tchuem/Emb_App/programme_principal_etud.c	(revision 508)
@@ -123,15 +123,24 @@
 
 float C=600;
 float Dist; // distance mesurée par la tourelle
-float Vitesse=45; //23 //40
+float Vitesse=39; //23 //40
 float Tourne;
 float Trou;
 int num_capt1[];
 int num_capt2[];
+int trou;
+ 
+unsigned char couleur;
+unsigned char feu;
+int cleur;
 
+int temps;
 
-CanFrame demande;
-CanFrame co1;
+CanFrame demande,co;
+
+
+
+
 //CanFrame co2;
 //CanFrame co3,demande4;
 
@@ -146,8 +155,7 @@
 
 void main()
 {
-
-
+	
 	ports_mcu();
     lcd_init();
 	periph_init();
@@ -165,20 +173,28 @@
 	sta_tsk(ID_asserv_tour);
 	sta_tsk(ID_calcul_dist);
 	sta_tsk(ID_asserv_roue);
-	
 	sta_tsk(ID_detect_trou);
 	sta_tsk(ID_vit);
+	sta_tsk(ID_piste);
+	sta_tsk(ID_depart);
+	
+	switch(cleur){
+		
+		case 1: lcd_str("verte");
+		break; 
+		case 2: lcd_str("bleue"); 
+		break; 
+		case 3: lcd_str("rouge"); 
+		break;
+		case 4: lcd_str("noire");
+		break;
+	}
+	
+		
 
     while(1)
     {
-		/*
-		asserv_tour();
-		asserv_roue();
-		
-		calcul_dist();
-		detect_trou();
-	    vit();*/
-
+	
 		LED_J=1;
 		dly_tsk(5);
 		LED_J=0;
@@ -197,23 +213,34 @@
 {
 	while(1)
 	{		
-		CanFrame demande;
-		CanFrame co1;
-		float A;
+		
 	
 		demande.data.id='R';
 		demande.data.rtr=1;
 		snd_dtq(CanTx,demande.msg);
-		dly_tsk(4);
+		dly_tsk(4); //4
 	
-		A= C - periph[ADDR('R')].val;
+		//si bp milieu appuyé azimut 45
+		while (Bp_M == 1)
+		{
+			demande.data.id='R';
+			demande.data.rtr=1;
+			snd_dtq(CanTx,demande.msg);
+			dly_tsk(4); //4
+			
+			co.data.id ='T';
+			co.data.rtr =0;
+			co.data.val =450- periph[ADDR('R')].val;
+			snd_dtq(CanTx, co.msg);
+			dly_tsk(5);
+		}	
 	
 	
-		co1.data.id ='T';
-		co1.data.rtr =0;
-		co1.data.val = C - periph[ADDR('R')].val;
-		snd_dtq(CanTx, co1.msg);
-		dly_tsk(5);	
+		co.data.id ='T';
+		co.data.rtr =0;
+		co.data.val = C - periph[ADDR('R')].val;
+		snd_dtq(CanTx, co.msg);
+		dly_tsk(5);	//5
 	}		
 }
 
@@ -222,16 +249,12 @@
 {
 	while(1)
 	{
-		
-		
-		CanFrame co4;
-		CanFrame demande4;
 	
 
-		demande4.data.id='U';
-		demande4.data.rtr=1;
-		snd_dtq(CanTx, demande4.msg);
-		dly_tsk(10);
+		demande.data.id='U';
+		demande.data.rtr=1;
+		snd_dtq(CanTx, demande.msg);
+		dly_tsk(5);
 	
 		Dist= periph[ADDR('U')].val;
 		Tourne= Dist- 580;
@@ -245,13 +268,11 @@
 	
 	while(1)
 	{
-		CanFrame co2,co3;
-		CanFrame demande4;
 	
-		demande4.data.id='U';
-		demande4.data.rtr=1;
-		snd_dtq(CanTx, demande4.msg);
-		dly_tsk(20);
+		demande.data.id='U';
+		demande.data.rtr=1;
+		snd_dtq(CanTx, demande.msg);
+		dly_tsk(20); //20
 	
 		Dist= periph[ADDR('U')].val;
 		Tourne= Dist- 580;
@@ -260,81 +281,98 @@
 		if (Dist >1000){
 			
 			Tourne =0;
-			co2.data.id ='D';
-			co2.data.rtr =0;
-			co2.data.val = Tourne;
-			snd_dtq(CanTx, co2.msg);
-			dly_tsk(25);
+			co.data.id ='D';
+			co.data.rtr =0;
+			co.data.val = 0;
+			snd_dtq(CanTx, co.msg);
+			dly_tsk(25);  //25
 			
-			co3.data.id ='V';
-			co3.data.rtr =0;
-			co3.data.val = 0;
-			snd_dtq(CanTx, co3.msg);
+		}
+		
+		
+		while (Bp_M == 1)
+		{
+			demande.data.id='U';
+			demande.data.rtr=1;
+			snd_dtq(CanTx,demande.msg);
+			Dist= periph[ADDR('U')].val;
+			
+			dly_tsk(4); //4
+			
+			co.data.id ='D';
+			co.data.rtr =0;
+			co.data.val =Dist -580;
+			snd_dtq(CanTx, co.msg);
+			dly_tsk(5);
 		}	
 	
 	
-		co2.data.id ='D';
-		co2.data.rtr =0;
-		co2.data.val = Tourne;
+	
+		co.data.id ='D';
+		co.data.rtr =0;
+		co.data.val = Tourne;
 		
-		snd_dtq(CanTx, co2.msg);
-		dly_tsk(25);
+		snd_dtq(CanTx, co.msg);
+		dly_tsk(25); //25
 	}
 }
 		
 	
-	
-	
-
-
-
 void vit()
 {
+	
 	while(1)
 	{
-		CanFrame co3;
-		CanFrame co8;
-		unsigned char feu;
-	
+	/*
 		while (Bp_G == 1)
 		{
 			
-			co3.data.id ='V';
-			co3.data.rtr =0;
-			co3.data.val =0;
-			snd_dtq(CanTx, co3.msg);
+			co.data.id ='V';
+			co.data.rtr =0;
+			co.data.val =0;
+			snd_dtq(CanTx, co.msg);
+			
 		}
 		
-		co8.data.id ='M';
-		co8.data.rtr =1;
-		snd_dtq(CanTx, co8.msg);
+		while (Bp_M == 1)
+		{
+			co.data.id ='V';
+			co.data.rtr =0;
+			co.data.val =10;
+			snd_dtq(CanTx, co.msg);
+				
+		}
+		co.data.id ='M';
+		co.data.rtr =1;
+		snd_dtq(CanTx, co.msg);
+		dly_tsk(5);
 	
-		feu=(periph[ADDR('M')].val)>>8;
-		feu=feu&0x80;
-		if(feu==0x00000000)
+		feu=(periph[ADDR('M')].val);
+		feu=feu&0x8000;
+		if(feu==1)
 		{
-			co3.data.id ='V';
-			co3.data.rtr =0;
-			co3.data.val = 0;
-			snd_dtq(CanTx, co3.msg);
-			dly_tsk(10);
+			demande.data.id ='V';
+			demande.data.rtr =0;
+			demande.data.val =Vitesse;
+			snd_dtq(CanTx, demande.msg);
+			
 		}
-		if(feu==0x10000000)
+		
+		else
 		{
-			co3.data.id ='V';
-			co3.data.rtr =0;
-			co3.data.val = Vitesse;
-			snd_dtq(CanTx, co3.msg);
-			dly_tsk(10);
-		}	
-	
+			demande.data.id ='V';
+			demande.data.rtr =0;
+			demande.data.val = Vitesse;
+			snd_dtq(CanTx, demande.msg);
 		
+		}
+	*/
+		co.data.id ='V';
+		co.data.rtr =0;
+		co.data.val = Vitesse;
+		snd_dtq(CanTx, co.msg);
+		dly_tsk(10); //10*/
 		
-		co3.data.id ='V';
-		co3.data.rtr =0;
-		co3.data.val = Vitesse;
-		snd_dtq(CanTx, co3.msg);
-		dly_tsk(10);
 	}
 	
 }
@@ -344,13 +382,10 @@
 {
 	while(1)
 	{
-		CanFrame co6,co2,co3;
-		CanFrame demande4;
-		int trou;
 	
-		demande4.data.id='U';
-		demande4.data.rtr=1;
-		snd_dtq(CanTx, demande4.msg);
+		demande.data.id='U';
+		demande.data.rtr=1;
+		snd_dtq(CanTx, demande.msg);
 	
 		Dist= periph[ADDR('U')].val;
 		trou=0;
@@ -362,23 +397,51 @@
 		dly_tsk(20);
 		
 	}
-}	
+}
+	
+void piste()
 
-	
-	
-/*
-void detect_capteur(void)
 {
-	CanFrame demande8,demande9;
-	CanFrame co8,co9,co10;
+	while(1){
+
+		demande.data.id='M';
+		demande.data.rtr=1;
+		snd_dtq(CanTx,demande.msg);
 	
-	co8.data.id ='C';
-	co8.data.rtr =1;
-	snd_dtq(CanTx, co8.msg);
+		couleur= periph[ADDR('M')].val;
+		cleur=couleur&0x000F;
+		
+		
+		
+		demande.data.id='H';
+		demande.data.rtr=1;
+		snd_dtq(CanTx,demande.msg);
 	
-	num_capt=(periph[ADDR('C')].val)<<3;
+		temps= periph[ADDR('H')].val;
+		dly_tsk(10);
+	}
 	
 }
-*/
 
 
+void depart()
+{
+	while(1)
+	{
+		demande.data.id='M';
+		demande.data.rtr=1;
+		snd_dtq(CanTx,demande.msg);
+	
+		feu= periph[ADDR('M')].val;
+		feu=feu&0x8000;
+		feu=feu>>15;
+		dly_tsk(10);
+		
+		
+	}
+}
+		
+	
+	
+	
+	
Index: branch/tchuem/Emb_App/conf_noyau.cfg
===================================================================
--- branch/tchuem/Emb_App/conf_noyau.cfg	(revision 507)
+++ branch/tchuem/Emb_App/conf_noyau.cfg	(revision 508)
@@ -111,10 +111,31 @@
 	initial_start	= OFF;
 	exinf	= 0x0;
 };
+
+task[]{
+	entry_address	= piste();
+	name	= ID_piste;
+	stack_size	= 256;
+	stack_section	= stack;
+	priority	= 8;
+	initial_start	= OFF;
+	exinf	= 0x0;
+};
 	
+	
 
+task[]{
+	entry_address	= depart();
+	name	= ID_depart;
+	stack_size	= 256;
+	stack_section	= stack;
+	priority	= 6;
+	initial_start	= OFF;
+	exinf	= 0x0;
+};
 
 
+
 flag[]{
 	name	= ev_bus_fin_tr;
 	initial_pattern	= 0x0000;
