Index: branch/maincent/tp_info6/Emb_App.tws
===================================================================
--- branch/maincent/tp_info6/Emb_App.tws	(revision 303)
+++ branch/maincent/tp_info6/Emb_App.tws	(revision 304)
@@ -14,8 +14,8 @@
 "E:\info6_maincent\tp_info6\Emb_App\programme_principal_etud.c" 
 [WORKSPACE_FILE_STATES]
 "E:\info6_maincent\tp_info6\Emb_App\conf_noyau.cfg" 75 75 1428 347 0 3 
-"E:\info6_maincent\tp_info6\Emb_App\crt0mr.a30" 0 0 956 523 0 1 
-"E:\info6_maincent\tp_info6\Emb_App\programme_principal_etud.c" -8 -30 956 523 1 0 
+"E:\info6_maincent\tp_info6\Emb_App\crt0mr.a30" -8 -30 1596 539 1 1 
+"E:\info6_maincent\tp_info6\Emb_App\programme_principal_etud.c" 0 0 956 523 0 0 
 "E:\info6_maincent\tp_info6\bsp\radiocommande.c" 50 50 1430 351 0 2 
 "E:\info6_maincent\tp_info6\bsp\uart0.c" 100 100 1356 347 0 4 
 [LOADED_PROJECTS]
Index: branch/maincent/tp_info6/Emb_App/SessionM32C_E8a_system.ini
===================================================================
--- branch/maincent/tp_info6/Emb_App/SessionM32C_E8a_system.ini	(revision 303)
+++ branch/maincent/tp_info6/Emb_App/SessionM32C_E8a_system.ini	(revision 304)
@@ -25,4 +25,4 @@
 [Target]
 M32C E8a SYSTEM=Renesas Communications
 [USER_DATA]
-RESET=ff0016
+RESET=ff001e
Index: branch/maincent/tp_info6/Emb_App/SessionM32C_E8a_system.hsf
===================================================================
--- branch/maincent/tp_info6/Emb_App/SessionM32C_E8a_system.hsf	(revision 303)
+++ branch/maincent/tp_info6/Emb_App/SessionM32C_E8a_system.hsf	(revision 304)
@@ -141,20 +141,20 @@
 "{55384715-F881-421C-A548-D7D1ABE158E1}PDMRWndInstanceKey0" "{WK_00000001_PDMR}EmbM32C87AppSessionM32C_E8a_system" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_EVAL_DENORMAL_MODE" "0" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_EVAL_ROUND_MODE" "0" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_0" "0000000000000000" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_1" "0000000000000000" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_0" "0000000000004044" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_1" "0000000000000020" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_10" "0000000000000000" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_11" "0000000000000000" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_12" "0000000000000000" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_13" "0000000000000000" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_14" "0000000000000000" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_15" "0000000000000000" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_16" "0000000000FF0016" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_17" "0000000000000000" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_18" "0000000000000000" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_19" "0000000000000700" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_2" "0000000000000000" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_20" "0000000000000000" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_15" "0000000000000512" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_16" "0000000000FF058A" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_17" "0000000000FFF800" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_18" "0000000000001730" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_19" "000000000000086A" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_2" "0000000000000001" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_20" "0000000000004044" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_21" "0000000000000000" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_22" "0000000000000000" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_23" "0000000000000000" 
@@ -169,12 +169,12 @@
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_31" "0000000000000000" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_32" "0000000000000000" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_33" "0000000000000000" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_34" "0000000000000000" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_34" "000000000000036A" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_35" "0000000000000000" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_4" "0000000000000000" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_4" "0000000000000008" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_5" "0000000000000000" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_6" "0000000000000000" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_7" "0000000000000000" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_6" "0000000000001766" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_7" "0000000000000512" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_8" "0000000000000000" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_9" "0000000000000000" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_COUNT" "36" 
@@ -207,9 +207,15 @@
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH" "c,buff,n,rx,flag," 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0000" "alpha, 1, 0, P, Col, Dec, MA" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0000_SCOPE" "Current Scope," 
-"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0001" "distance, 1, 0, P, Col, Dec, MA" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0001" "distance, 2, 0, P, Col, Dec, MA" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0001_SCOPE" "Current Scope," 
-"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEMCnt" "2" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0002" "piste1, 1, 0, P, Col, Hex, MA" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0002_SCOPE" "Current Scope," 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0003" "selecpiste, 1, 0, P, Col, Hex, MA" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0003_SCOPE" "Current Scope," 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0004" "capteur, 1, 0, P, Col, Hex, MA" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0004_SCOPE" "Current Scope," 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEMCnt" "5" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd1ColWidth0" "120" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd1ColWidth1" "150" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd1ColWidth12" "200" 
@@ -279,7 +285,7 @@
 0 
 [WINDOW_POSITION_STATE_DATA_VD1]
 "Help" "TOOLBAR 0" 59419 2 4 "0.00" 0 0 0 0 0 17 0 "" "0.0" 
-"{WK_00000001_CmdLine}" "WINDOW" 59422 0 3 "0.08" 365 0 0 350 200 17 0 "32771|32772|32778|<<separator>>|32773|32774|<<separator>>|32820|<<separator>>|32801|32824" "0.0" 
+"{WK_00000001_CmdLine}" "WINDOW" 59422 0 3 "0.07" 365 0 0 350 200 17 0 "32771|32772|32778|<<separator>>|32773|32774|<<separator>>|32820|<<separator>>|32801|32824" "0.0" 
 "{WK_00000001_DISASSEMBLY}" "WINDOW" 0 0 0 "0.00" 0 -4 -30 948 486 9 0 "" "0.0" 
 "{WK_00000001_EVENT}EmbM32C87AppSessionM32C_E8a_system" "WINDOW" 59422 0 1 "0.08" 365 0 0 350 200 18 0 "32774|32775|32777|<<separator>>|32780|<<separator>>" "0.0" 
 "{WK_00000001_MEMORY}EmbM32C87AppSessionM32C_E8a_system" "WINDOW" 59422 0 1 "0.23" 365 2 -1 350 200 2065 0 "42202|42203|42204|42233|<<separator>>|42206|42205|42230|42229|42207|<<separator>>|42208|42209|42210|49076|42228|42227|<<separator>>|42231|42232|42234|42235|<<separator>>|42211|<<separator>>|32796|32797" "0.0" 
@@ -313,9 +319,9 @@
 [WINDOW_Z_ORDER]
 "E:\info6_maincent\tp_info6\Emb_App\crt0mr.a30" 
 "E:\info6_maincent\tp_info6\Emb_App\programme_principal_etud.c" 
+"E:\info6_maincent\tp_info6\Emb_App\conf_noyau.cfg" 
+"E:\info6_maincent\tp_info6\bsp\uart0.c" 
 "E:\info6_maincent\tp_info6\bsp\radiocommande.c" 
-"E:\info6_maincent\tp_info6\bsp\uart0.c" 
-"E:\info6_maincent\tp_info6\Emb_App\conf_noyau.cfg" 
 [TARGET_NAME]
 "M32C E8a SYSTEM" "" 0 
 [STATUSBAR_STATEINFO_VD1]
@@ -362,5 +368,5 @@
 [FLASH_DETAILS]
 "" 0 0 "" 0 "" 0 0 "" 0 0 0 0 0 0 0 "" "" "" "" "" 
 [BREAKPOINTS]
-"d:\profs\tp_info14_travail\tp_info14\emb_app\programme_principal_etud.c" 95 91760712 1 "{00000000-0000-0000-C000-000000000046}" "" 
+"d:\profs\tp_info14_travail\tp_info14\emb_app\programme_principal_etud.c" 95 100870216 1 "{00000000-0000-0000-C000-000000000046}" "" 
 [END]
Index: branch/maincent/tp_info6/Emb_App/programme_principal_etud.c
===================================================================
--- branch/maincent/tp_info6/Emb_App/programme_principal_etud.c	(revision 303)
+++ branch/maincent/tp_info6/Emb_App/programme_principal_etud.c	(revision 304)
@@ -120,8 +120,31 @@
 //'I'/73/Ox49 : Définition du nom du véhicule. Doit débuter par le caractère '#' et entraine le chargement de la configuration de piste
 //				correspondant au nom du véhicule si le nom se termine par '*'
 
+short piste1;
+short selecpiste;
+short modecourse;
+void piste(){					//detecte la couleur de la piste
+	while(1)
+	{
+		//lecture de la piste
+        CanFrame reque;
+        UINT flag;
+		reque.data.id='M';			//lecture des evenements
+		reque.data.rtr=1;			//indique une lecture
+		periph[ADDR('M')].ev=0x04;
+		snd_dtq(CanTx, reque.msg);
+		
+		//Attente de la reponse
+        wai_flg (ev_periph, 0x04, TWF_ANDW, &flag);
+        piste1=periph[ADDR('M')].val;
+		selecpiste = piste1 & 0x00FF;
+		modecourse = piste1 & 0xFF00;
+		dly_tsk(25);			
+	}
+}
+
 short alpha;
-void tourelle(){
+void tourelle(){				// vrai pour toutes les pistes
 	while(1)
 	{
         short k=1; //Gain du correcteur P
@@ -149,7 +172,7 @@
 
 
 short capteur;
-void zone(){
+void zone(){				// vrai pour toutes les pistes
 	while(1)
 	{
 		//lecture de la zone
@@ -163,14 +186,14 @@
 		//Attente de la reponse
         wai_flg (ev_periph, 0x03, TWF_ANDW, &flag);
         capteur=periph[ADDR('C')].val;
-		dly_tsk(15);				
+		dly_tsk(25);				
 	}
 }
 
 
-short distance;
-short distance1;
-void dist(){
+unsigned short distance;
+unsigned short distance1;
+void dist(){				// vrai pour toutes les pistes
 	while(1)
 	{
         //lecture de la distance du mur
@@ -200,17 +223,65 @@
         //Commande de l'angle de roue
         comm.data.id='D';	//commande angle roue
         comm.data.rtr=0;	//indique une ecriture
-        if (distance > 2000 || capteur == 0x5603)
+		
+		if (selecpiste == 0x0001 || selecpiste == 0x0002)		// piste verte et bleu
+		{	
+        	if (distance > 2000) 
+			{
+				// si trou dans la barriere ou zonesaut
+			}	
+			else
+			{
+				distance1=distance;	 //cas normal: si on est au milieu de la piste angle des roues à 0
+        	}
+  			comm.data.val=s*(distance1-706);
+			snd_dtq(CanTx, comm.msg);
+			dly_tsk(20);
+		}
+		
+		else if (selecpiste == 0x0003) 		// piste rouge
 		{
-			// si trou dans la barriere ou zonesaut
+			if (distance > 2000 )  
+			{
+				// si trou dans la barriere ou zonesaut
+			}
+			else if (capteur == 0x6aff) //bosse piste rouge 
+			{
+				
+			}
+			else
+			{
+				distance1=distance;	 //cas normal: si on est au milieu de la piste angle des roues à 0
+        	}
+  			comm.data.val=s*(distance1-706);
+			snd_dtq(CanTx, comm.msg);
+			 dly_tsk(20);
+		}
+		
+		else 		// piste noir
+		{
+			if (distance > 2000 ) // || ) //bosse piste rouge 
+			{
+				// si trou dans la barriere ou zonesaut
+			}
+			else if (capteur == 0x6aff)
+			{
+				
+			//	dly_tsk(1500);
+				
+			}
+			else
+			{
+				distance1=distance;	 //cas normal: si on est au milieu de la piste angle des roues à 0
+        	}
+  			comm.data.val=s*(distance1-706);
+			snd_dtq(CanTx, comm.msg);
+			 dly_tsk(20);
 		}	
-		else
-		{
-			distance1=distance; //cas normal: si on est au milieu de la piste angle des roues à 0
-        }
-  		comm.data.val=s*(distance1-706);
-  		snd_dtq(CanTx, comm.msg);      
+  
+			  
 	}
+
 }
 
 
@@ -226,32 +297,87 @@
 		//commande vitesse vehicule
 		requete.data.id='V';
 		requete.data.rtr=0; 			//indique une ecriture
-		if (capteur == 0x5602 || capteur == 0x5603 || capteur == 0x5601 )
-		{
-			requete.data.val=45;				// si trou dans la barriere ou zonesaut
-		}	
-		else
-		{
-			requete.data.val=15; //cas normal: si on n'est pas dans la zone de saut 
-        } 
+		switch (selecpiste){
+			case 0x0001 :		// pour piste verte
 		
+				if (capteur == 0x5602 || capteur == 0x5603 || capteur == 0x5604 || capteur == 0x5605 || capteur == 0x5601  )
+				{
+					requete.data.val=70;				// ligne droite 
+				}	
+				else
+				{
+					requete.data.val=40; 				//virage
+      	 		} 
+			break;
+			
+			case 0x0002 :		// pour piste bleu
+						
+				if (capteur == 0x5602 || capteur == 0x5603 || capteur == 0x5605 || capteur == 0x5601  )
+				{
+					requete.data.val=60;				// ligne droite 
+				}
+				else if (capteur == 0x5604)
+				{
+					requete.data.val=50; 				//bosse
+      	 		} 
+				else
+				{
+					requete.data.val=25; 				//virage
+      	 		} 
+			break;
+			
+			case 0x0003 :		// pour piste rouge
+				if (capteur == 0x5602 || capteur == 0x5603 || capteur == 0x5604 || capteur == 0x5605)
+				{
+					requete.data.val=60;				// ligne droite 
+				}
+				else if (capteur == 0x6aff)
+				{
+					requete.data.val=45; 				//bosse
+      	 		} 
+				else if (capteur == 0x5601)
+				{
+					requete.data.val=35;				// petit virage entrée 
+				}
+				else if (capteur == 0x4203)
+				{
+					requete.data.val=10;				//  virage après saut 
+				}
+				else
+				{
+					requete.data.val=25; 				//virage
+      	 		} 
+			break;
+			
+			case 0x0004 :		// pour piste noir
+				if (capteur == 0x5602 || capteur == 0x5603 || capteur == 0x5604 || capteur == 0x5605)
+					{
+						requete.data.val=60;				// ligne droite 
+					}
+					else if (capteur == 0x6aff)
+					{
+						requete.data.val=45; 				//bosse
+      	 			} 
+					else if (capteur == 0x5601)
+					{
+						requete.data.val=35;				// petit virage entrée 
+					}
+					else if (capteur == 0x4203)
+					{
+						requete.data.val=10;				//  virage après saut 
+					}
+					else
+					{
+						requete.data.val=25; 				//virage
+      	 			} 
+			break;
+			
+		}
 		
 //		requete.data.val=25;			//vitesse constante
-		
-/*	vitesse variable	
-		if (distance > 706)
-		{
-			requete.data.val=140-0.05*distance;				// a fond si vehicule au milieu sinon ralentit doucement
-		}	
-		else
-		{
-			requete.data.val=0.05*distance;  				//vitesse max=50=0.07*706
-        }
-*/
-		
-		
+
 		snd_dtq(CanTx, requete.msg);
-	//	dly_tsk(2);
+		dly_tsk(20);
 	}
 }
 
@@ -263,7 +389,7 @@
         ports_mcu();
     lcd_init();
         periph_init();
-        periph_nom("#AutoTest*");
+        periph_nom("#AntoineMaincent*");
     can_init();
     clavier_init(1);
         capture_init();
@@ -271,7 +397,7 @@
         sta_tsk(ID_periph_rx);
         
 		
-		
+		sta_tsk(ID_piste);
         sta_tsk(ID_tourelle);
         sta_tsk(ID_dist);
         sta_tsk(ID_roue);
Index: branch/maincent/tp_info6/Emb_App/conf_noyau.cfg
===================================================================
--- branch/maincent/tp_info6/Emb_App/conf_noyau.cfg	(revision 303)
+++ branch/maincent/tp_info6/Emb_App/conf_noyau.cfg	(revision 304)
@@ -86,6 +86,16 @@
 };
 
 task[]{
+	entry_address	= piste();
+	name	= ID_piste;
+	stack_size	= 512;
+	stack_section	= stack;
+	priority	= 5;
+	initial_start	= OFF;
+	exinf	= 0x0;
+};
+
+task[]{
 	entry_address	= vitesse();
 	name	= ID_vitesse;
 	stack_size	= 512;
