Index: branch/zhang/Emb_App.tws
===================================================================
--- branch/zhang/Emb_App.tws	(revision 358)
+++ branch/zhang/Emb_App.tws	(revision 359)
@@ -20,7 +20,7 @@
 "E:\tp_info6_zhan\Emb_App\Debug\mr308.inc" 125 125 1430 351 0 5 
 "E:\tp_info6_zhan\Emb_App\conf_noyau.cfg" 75 75 1430 351 0 3 
 "E:\tp_info6_zhan\Emb_App\crt0mr.a30" 25 25 1430 351 0 1 
-"E:\tp_info6_zhan\Emb_App\programme_principal_etud.c" -8 -30 1596 539 1 0 
+"E:\tp_info6_zhan\Emb_App\programme_principal_etud.c" -8 -30 940 171 1 0 
 "E:\tp_info6_zhan\bsp\lcd.c" 100 100 1430 351 0 4 
 "E:\tp_info6_zhan\bsp\periph.c" 0 0 1430 351 0 7 
 "E:\tp_info6_zhan\bsp\uart0.c" 150 150 1430 351 0 6 
Index: branch/zhang/Emb_App/SessionM32C_E8a_system.ini
===================================================================
--- branch/zhang/Emb_App/SessionM32C_E8a_system.ini	(revision 358)
+++ branch/zhang/Emb_App/SessionM32C_E8a_system.ini	(revision 359)
@@ -25,4 +25,4 @@
 [Target]
 M32C E8a SYSTEM=Renesas Communications
 [USER_DATA]
-RESET=ff0122
+RESET=ff0126
Index: branch/zhang/Emb_App/SessionM32C_E8a_system.hsf
===================================================================
--- branch/zhang/Emb_App/SessionM32C_E8a_system.hsf	(revision 358)
+++ branch/zhang/Emb_App/SessionM32C_E8a_system.hsf	(revision 359)
@@ -141,7 +141,7 @@
 "{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" "0000000000004044" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_0" "0000000000000044" 
 "{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" 
@@ -149,12 +149,12 @@
 "{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" "0000000000000512" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_16" "0000000000FF0678" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_16" "0000000000FF0687" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_17" "0000000000FFF800" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_18" "0000000000000E6A" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_19" "0000000000000BA2" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_18" "0000000000000E98" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_19" "0000000000000BD0" 
 "{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_20" "0000000000000044" 
 "{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" 
@@ -173,7 +173,7 @@
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_35" "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" "0000000000000E9E" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_6" "0000000000000ECC" 
 "{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" 
@@ -277,14 +277,14 @@
 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 1 "0.07" 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 1 "0.07" 370 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 -8 -30 1596 539 9 0 "" "0.0" 
-"{WK_00000001_EVENT}EmbM32C87AppSessionM32C_E8a_system" "WINDOW" 59422 0 0 "0.11" 365 0 0 350 200 18 0 "32774|32775|32777|<<separator>>|32780|<<separator>>" "0.0" 
+"{WK_00000001_EVENT}EmbM32C87AppSessionM32C_E8a_system" "WINDOW" 59422 0 0 "0.11" 370 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" 
-"{WK_00000001_OUTPUT}" "WINDOW" 59422 0 2 "0.45" 365 0 0 350 200 18 0 "36756|36757|36758|36759|<<separator>>|36746|36747|<<separator>>|39531|<<separator>>|39500|39534|<<separator>>|36687" "0.0" 
-"{WK_00000001_PDMR}EmbM32C87AppSessionM32C_E8a_system" "WINDOW" 59422 0 3 "0.27" 365 0 0 350 200 18 0 "47300|47301|47302|47303|47304|47305|47314|47306|47307|47308|47311|47312|47313|42211|42509|42303" "0.0" 
+"{WK_00000001_OUTPUT}" "WINDOW" 59422 0 2 "0.54" 370 0 0 350 200 18 0 "36756|36757|36758|36759|<<separator>>|36746|36747|<<separator>>|39531|<<separator>>|39500|39534|<<separator>>|36687" "0.0" 
+"{WK_00000001_PDMR}EmbM32C87AppSessionM32C_E8a_system" "WINDOW" 59422 0 3 "0.18" 370 0 0 350 200 18 0 "47300|47301|47302|47303|47304|47305|47314|47306|47307|47308|47311|47312|47313|42211|42509|42303" "0.0" 
 "{WK_00000001_REGISTERS}EmbM32C87AppSessionM32C_E8a_system" "WINDOW" 59421 0 0 "1.00" 236 0 0 350 200 2065 0 "" "0.0" 
-"{WK_00000001_WATCH}EmbM32C87AppSessionM32C_E8a_system" "WINDOW" 59422 0 4 "0.17" 365 0 0 350 200 18 0 "32781|32783|<<separator>>|32771|32772|32773|<<separator>>|32786|<<separator>>|32810|32811" "0.0" 
+"{WK_00000001_WATCH}EmbM32C87AppSessionM32C_E8a_system" "WINDOW" 59422 0 4 "0.17" 370 0 0 350 200 18 0 "32781|32783|<<separator>>|32771|32772|32773|<<separator>>|32786|<<separator>>|32810|32811" "0.0" 
 "{WK_00000002_WORKSPACE}" "WINDOW" 59420 0 0 "1.00" 308 0 0 350 200 18 0 "" "0.0" 
 "{WK_TB00000001_STANDARD}" "TOOLBAR 0" 59419 0 2 "0.00" 0 0 0 0 0 18 0 "" "0.0" 
 "{WK_TB00000002_EDITOR}" "TOOLBAR 0" 59419 0 0 "0.00" 0 0 0 0 0 18 0 "" "0.0" 
@@ -310,13 +310,13 @@
 [WINDOW_POSITION_STATE_DATA_VD4]
 [WINDOW_Z_ORDER]
 "E:\tp_info6_zhan\Emb_App\programme_principal_etud.c" 
+"E:\tp_info6_zhan\Emb_App\crt0mr.a30" 
 "E:\tp_info6_zhan\bsp\lcd.c" 
-"E:\tp_info6_zhan\Emb_App\crt0mr.a30" 
+"E:\tp_info6_zhan\bsp\uart0.c" 
 "E:\tp_info6_zhan\bsp\periph.c" 
-"E:\tp_info6_zhan\bsp\uart0.c" 
+"E:\tp_info6_zhan\Emb_App\Debug\mr308.inc" 
 "E:\tp_info6_zhan\Emb_App\conf_noyau.cfg" 
 "E:\tp_info6_zhan\Emb_App\Debug\kernel_id.h" 
-"E:\tp_info6_zhan\Emb_App\Debug\mr308.inc" 
 [TARGET_NAME]
 "M32C E8a SYSTEM" "" 0 
 [STATUSBAR_STATEINFO_VD1]
@@ -363,5 +363,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 95806312 1 "{00000000-0000-0000-C000-000000000046}" "" 
+"d:\profs\tp_info14_travail\tp_info14\emb_app\programme_principal_etud.c" 95 93968296 1 "{00000000-0000-0000-C000-000000000046}" "" 
 [END]
Index: branch/zhang/Emb_App/programme_principal_etud.c
===================================================================
--- branch/zhang/Emb_App/programme_principal_etud.c	(revision 358)
+++ branch/zhang/Emb_App/programme_principal_etud.c	(revision 359)
@@ -122,8 +122,11 @@
 
 unsigned int alpha; //angle
 unsigned int distance; // Distance mesuree par le telemetre (1/100 de metre)
-unsigned int v;  //vitesse
+float v;  //vitesse
 unsigned int c;  //
+unsigned int touche_couleur;  //capteur de couleur 
+unsigned int pist;    //piste V B R N
+
 
 void main()
 {
@@ -140,6 +143,8 @@
 	sta_tsk(ID_periph_rx);     //config de periph, donc je peut utilise periph(R U)
 
 //	sta_cyc(ID_asserv);
+	sta_tsk(ID_capteur_couleur);
+	sta_tsk(ID_piste);
 	sta_tsk(ID_control_tourelle);
 	sta_tsk(ID_control_direct);
 
@@ -171,7 +176,10 @@
 	LED_V=!LED_V;
 }
 
-/****************************************************************************************/
+
+
+
+/*****************************************************************************************/
 void control_tourelle(){
 	// Q5 obtenir l'angle 
 	// et commande la vitesse de tourelle(asservissement)
@@ -203,7 +211,45 @@
 }
 
 /***************************************************************************/
+void capteur_couleur(){
+	CanFrame requete;
+	FLGPTN flag;
+	
+	while(1){
+		requete.data.id = 'C';			// angle de tourelle
+		requete.data.rtr = 1;			//indique une requête(demende) de lecture
+		periph[ADDR('C')].ev=0x03;		// event mise au 0x01
+		snd_dtq(CanTx, requete.msg);    //send demendes
+		
+		wai_flg (ev_periph,0x03,TWF_ANDW,&flag);   //wait reponse
+ 		touche_couleur = periph[ADDR('C')].val;
+		
+		dly_tsk(20);
+	}
+}
 
+void piste(){
+	CanFrame requete;
+	FLGPTN flag;
+	int a;
+	
+	while(1){
+		requete.data.id = 'M';			// angle de tourelle
+		requete.data.rtr = 1;			//indique une requête(demende) de lecture
+		periph[ADDR('M')].ev=0x04;		// event mise au 0x01
+		snd_dtq(CanTx, requete.msg);    //send demendes
+		
+		wai_flg (ev_periph,0x04,TWF_ANDW,&flag);   //wait reponse
+ 		a = periph[ADDR('M')].val;
+		
+		pist = a & 0x00FF;            //1Vert 2Bleu 3Rouge 4Roir 
+	
+		 
+		dly_tsk(10);
+	}
+}
+
+/******************************************************************************/
 void control_direct(){
 	CanFrame requete, reponse, comm;
 	FLGPTN flag;
@@ -224,15 +270,39 @@
 	distance = periph[ADDR('U')].val;
 	
 
-	if( distance < 400) distance = 705;
 	c = kd *( distance - 705);
-
+	
+	if( pist==3){      //piste rouge
+		if( touche_couleur == 0x5603) c = 0;  
+	}
+	if( pist==4){      //piste noir
+		if( touche_couleur == 0x5601) {	
+			c =  distance - 900; 
+    		if(distance<800 || distance>1100) c =0;
+		}
+		if( touche_couleur == 0x5602) {
+			if(distance<680|| distance>725) distance = 705; 		
+			c = distance - 705;
+		}
+		if( touche_couleur == 0x5603) {
+			c = kd *( distance - 705);
+			if(distance<700 || distance>730) c =0; 
+		}
+	}
+	if( pist==7){      //piste rouge
+		if( touche_couleur == 0x5603) c = 0;  
+	}
+	if( pist==8){      //piste noir
+		if( touche_couleur == 0x5603) {
+			if(distance<700 || distance>730) c =0; 
+		}
+	}
 	comm.data.id = 'D';
 	comm.data.rtr = 0;
 	comm.data.val = c;
 	snd_dtq(CanTx, comm.msg);
 	
-	dly_tsk(10);
+
 	}
 }
 /****************************************************************************/
@@ -239,13 +309,17 @@
 void affiche(){
 	char str1[20];
 	char str2[20];
-
+	char str3[20];
+	
 	lcd_com(0xC0);
 	sprintf(str1," %d ", distance);	
 	lcd_str(str1);
 	lcd_com(0x90);
-	sprintf(str2," %d ", alpha);	
+	sprintf(str2," %d ", pist);	
 	lcd_str(str2);
+	lcd_com(0xD0);
+	sprintf(str3," %x ", touche_couleur);	
+	lcd_str(str3);
 }
 /*******************************************************************************/
 void vitesse(){
@@ -253,9 +327,26 @@
 
 	while (1){
 		
-	if ( distance<680 || distance>750) v = 20;
-	else v = 50;
-	
+	if ( distance<680 || distance>750)	v = 20;
+		else v = 50;
+		 
+	if(pist == 3){
+		if( touche_couleur == 0x5603) v = 45;  
+	}
+	if(pist == 4){
+		if( touche_couleur == 0x5601) v = 20;
+		if( touche_couleur == 0x5602) v = 18;
+		if( touche_couleur == 0x5603) v = 42.5;  
+		if( touche_couleur == 0x5604) v = 10;
+	}
+
+	if(pist == 7){
+		if( touche_couleur == 0x5603) v = 45;  
+	}
+	if(pist == 8){
+		if( touche_couleur == 0x5603) v = 42.5;  
+		if( touche_couleur == 0x5604) v = 10;
+	}
 	comm.data.id = 'V';
 	comm.data.rtr = 0;
 	comm.data.val = v;
Index: branch/zhang/Emb_App/conf_noyau.cfg
===================================================================
--- branch/zhang/Emb_App/conf_noyau.cfg	(revision 358)
+++ branch/zhang/Emb_App/conf_noyau.cfg	(revision 359)
@@ -90,6 +90,24 @@
 	initial_start	= OFF;
 	exinf	= 0x0;
 };
+task[]{
+	entry_address	= capteur_couleur();
+	name	= ID_capteur_couleur;
+	stack_size	= 256;
+	stack_section	= stack;
+	priority	= 2;
+	initial_start	= OFF;
+	exinf	= 0x0;
+};
+task[]{
+	entry_address	= piste();
+	name	= ID_piste;
+	stack_size	= 256;
+	stack_section	= stack;
+	priority	= 2;
+	initial_start	= OFF;
+	exinf	= 0x0;
+};
 
 flag[]{
 	name	= ev_bus_fin_tr;
