Index: branch/noisette/Emb_App.tws
===================================================================
--- branch/noisette/Emb_App.tws	(revision 487)
+++ branch/noisette/Emb_App.tws	(revision 488)
@@ -20,8 +20,8 @@
 [WORKSPACE_FILE_STATES]
 "E:\tp_info6_2018_noisette\tp_info6\Emb_App\Debug\mr308.inc" 50 50 790 335 0 9 
 "E:\tp_info6_2018_noisette\tp_info6\Emb_App\conf_noyau.cfg" 0 0 790 335 0 7 
-"E:\tp_info6_2018_noisette\tp_info6\Emb_App\crt0mr.a30" -8 -30 956 523 1 1 
-"E:\tp_info6_2018_noisette\tp_info6\Emb_App\programme_principal_etud.c" 0 0 956 523 0 0 
+"E:\tp_info6_2018_noisette\tp_info6\Emb_App\crt0mr.a30" 0 0 956 523 0 1 
+"E:\tp_info6_2018_noisette\tp_info6\Emb_App\programme_principal_etud.c" -8 -30 956 523 1 0 
 "E:\tp_info6_2018_noisette\tp_info6\bsp\can.c" 0 0 956 523 0 2 
 "E:\tp_info6_2018_noisette\tp_info6\bsp\clavier.c" 100 100 790 335 0 4 
 "E:\tp_info6_2018_noisette\tp_info6\bsp\dma0.c" 125 125 790 335 0 5 
Index: branch/noisette/Emb_App/SessionM32C_E8a_system.ini
===================================================================
--- branch/noisette/Emb_App/SessionM32C_E8a_system.ini	(revision 487)
+++ branch/noisette/Emb_App/SessionM32C_E8a_system.ini	(revision 488)
@@ -25,4 +25,4 @@
 [Target]
 M32C E8a SYSTEM=Renesas Communications
 [USER_DATA]
-RESET=ff0018
+RESET=ff0034
Index: branch/noisette/Emb_App/SessionM32C_E8a_system.hsf
===================================================================
--- branch/noisette/Emb_App/SessionM32C_E8a_system.hsf	(revision 487)
+++ branch/noisette/Emb_App/SessionM32C_E8a_system.hsf	(revision 488)
@@ -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" "0000000000FF0576" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_16" "0000000000FF05A2" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_17" "0000000000FFF800" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_18" "0000000000001036" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_19" "0000000000000870" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_18" "0000000000001270" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_19" "00000000000008AA" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_2" "0000000000000001" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_20" "0000000000000044" 
+"{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" 
@@ -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" "000000000000106C" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_6" "00000000000012A6" 
 "{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" 
@@ -213,7 +213,7 @@
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0002_SCOPE" "Current Scope," 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0003" "k, 10, 0, P, Col, Hex, N" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0003_SCOPE" "Current Scope," 
-"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0004" "vitesse, 1, 0, P, Col, Hex, MA" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0004" "vitesse, 1, 0, P, Col, Dec, MA" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0004_SCOPE" "Global," 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0005" "k1, 2, 0, P, Col, Dec, MA" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0005_SCOPE" "Current Scope," 
@@ -221,7 +221,9 @@
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0006_SCOPE" "Current Scope," 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0007" "erreur_distance, 1, 0, P, Col, Dec, MA" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0007_SCOPE" "Global," 
-"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEMCnt" "8" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0008" "V, 10, 0, P, Col, Hex, N" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0008_SCOPE" "Current Scope," 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEMCnt" "9" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd1ColWidth0" "120" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd1ColWidth1" "150" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd1ColWidth12" "200" 
@@ -323,16 +325,16 @@
 [WINDOW_POSITION_STATE_DATA_VD3]
 [WINDOW_POSITION_STATE_DATA_VD4]
 [WINDOW_Z_ORDER]
+"E:\tp_info6_2018_noisette\tp_info6\Emb_App\programme_principal_etud.c" 
 "E:\tp_info6_2018_noisette\tp_info6\Emb_App\crt0mr.a30" 
-"E:\tp_info6_2018_noisette\tp_info6\Emb_App\programme_principal_etud.c" 
 "E:\tp_info6_2018_noisette\tp_info6\Emb_App\conf_noyau.cfg" 
+"E:\tp_info6_2018_noisette\tp_info6\bsp\lcd.c" 
+"E:\tp_info6_2018_noisette\tp_info6\bsp\uart0.c" 
 "E:\tp_info6_2018_noisette\tp_info6\Emb_App\Debug\mr308.inc" 
-"E:\tp_info6_2018_noisette\tp_info6\bsp\uart0.c" 
 "E:\tp_info6_2018_noisette\tp_info6\bsp\periph.c" 
 "E:\tp_info6_2018_noisette\tp_info6\bsp\can.c" 
 "E:\tp_info6_2018_noisette\tp_info6\bsp\dma0.c" 
 "E:\tp_info6_2018_noisette\tp_info6\bsp\clavier.c" 
-"E:\tp_info6_2018_noisette\tp_info6\bsp\lcd.c" 
 [TARGET_NAME]
 "M32C E8a SYSTEM" "" 0 
 [STATUSBAR_STATEINFO_VD1]
@@ -379,5 +381,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 91558560 1 "{00000000-0000-0000-C000-000000000046}" "" 
+"d:\profs\tp_info14_travail\tp_info14\emb_app\programme_principal_etud.c" 95 75567776 1 "{00000000-0000-0000-C000-000000000046}" "" 
 [END]
Index: branch/noisette/Emb_App/programme_principal_etud.c
===================================================================
--- branch/noisette/Emb_App/programme_principal_etud.c	(revision 487)
+++ branch/noisette/Emb_App/programme_principal_etud.c	(revision 488)
@@ -119,9 +119,12 @@
 //				disponible. 0xab avec a-> nombre de couleurs bien placées et b -> couleurs présentes mais mal placées.
 //'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 '*'
+int num;
+int capt='V';
 int alpha;
 int stop;
 int couleur;
+int etatfeu;
 int consigne_tourelle;
 int consigne_distance;
 unsigned short k1, k2;
@@ -129,8 +132,10 @@
 int erreur_distance;
 int vitesse;
 int distance_tourelle;
+int piste;
+int feuvert=0;
 UINT flag;
-CanFrame comm, requete, reponse, req;
+CanFrame comm, requete, reponse, req, Numpiste, feu;
 
 /*void capteur(){
 	while(1){
@@ -153,12 +158,11 @@
 		dly_tsk(50);
 		wai_flg(ev_periph,0x0007,TWF_ANDW,&flag);
 		couleur=periph[ADDR('C')].val;
-		if(couleur==22020 && distance_tourelle<600) {
-			erreur_distance=0;
+		if(couleur==22020 && distance_tourelle<670 && piste==768) {
 			k2=0;
 			comm.data.id= 'V';
 			comm.data.rtr=0;
-			comm.data.val=50;
+			comm.data.val=45;
 			snd_dtq(CanTx, comm.msg);
 			dly_tsk(5);
 		}
@@ -182,7 +186,8 @@
 		dly_tsk(5);
 		wai_flg(ev_periph,0x01, TWF_ANDW, &flag);
 		distance_tourelle=periph[ADDR('U')].val;
-		if (couleur>22000 && distance_tourelle>900 || couleur>22000 && distance_tourelle<500){
+		if (couleur>22000 && distance_tourelle>2000 || couleur>22000 && distance_tourelle<500){
+			stop=1;
 			k2=0;
 			consigne_distance=0;
 			comm.data.id= 'V';
@@ -190,6 +195,9 @@
 			comm.data.val=45;
 			snd_dtq(CanTx, comm.msg);
 			}
+		else {
+			stop=0;
+		}
 		
 	}
 }	
@@ -203,7 +211,12 @@
 		dly_tsk(50);
 		wai_flg(ev_periph,0x0007,TWF_ANDW,&flag);
 		couleur=periph[ADDR('C')].val;
-		if (couleur ==16899) {
+		Numpiste.data.id='M';
+		Numpiste.data.rtr=1;
+		snd_dtq (CanTx,Numpiste.msg);
+		dly_tsk(50);	
+		piste=periph[ADDR('M')].val<<8;
+		if (couleur ==16899 && piste==768) {
 			comm.data.id= 'V';
 			comm.data.rtr=0;
 			comm.data.val=2;
@@ -214,6 +227,37 @@
 	}
 }
 
+void depart()
+{	
+	while(1){
+		feu.data.id='M';
+		feu.data.rtr=1;
+		snd_dtq (CanTx,feu.msg);
+		dly_tsk(100);
+		etatfeu=periph[ADDR('M')].val>>15;
+		if(etatfeu==1){
+			feuvert=1;
+		}
+	}
+}
+
+void ecran(){
+	while(1){
+		Numpiste.data.id='M';
+		Numpiste.data.rtr=1;
+		snd_dtq (CanTx,Numpiste.msg);	
+		piste=periph[ADDR('M')].val<<8;
+		dly_tsk(500);
+		lcd_init();
+		switch(piste){
+			case(256) : lcd_str("VERT|"); break;
+			case(512) : lcd_str("BLEU|"); break;
+			case(768) : lcd_str("ROUGE|"); break;
+			case(1024) : lcd_str("NOIR|"); break;
+		}
+	}
+}
+
 void asserv_tourelle()
 {
 		while(1){
@@ -243,6 +287,13 @@
 void asserv_virage() {
 	
 	while(1) {
+		
+
+		Numpiste.data.id='M';
+		Numpiste.data.rtr=1;
+		snd_dtq (CanTx,Numpiste.msg);
+		dly_tsk(50);	
+		piste=periph[ADDR('M')].val<<8;
 		req.data.id='C';
 		req.data.rtr=1;
 		periph[ADDR('C')].ev=0x0007;
@@ -257,82 +308,89 @@
 		dly_tsk(5);
 		wai_flg(ev_periph,0x01, TWF_ANDW, &flag);
 		distance_tourelle=periph[ADDR('U')].val;
-		if (distance_tourelle>1500 || (couleur==22020 && distance_tourelle<600)) {
-			erreur_distance=0;
-			k2=0;
-			comm.data.id= 'V';
-			comm.data.rtr=0;
-			comm.data.val=50;
-			snd_dtq(CanTx, comm.msg);
-			dly_tsk(2);
-		}
-		else{
+		feu.data.id='M';
+		feu.data.rtr=1;
+		snd_dtq (CanTx,feu.msg);
+		dly_tsk(100);
+		etatfeu=periph[ADDR('M')].val>>15;
+		if(feuvert==1){
 			
+			if (distance_tourelle>2000 || (couleur==22020 && distance_tourelle<600)) {
+				erreur_distance=0;
+				k2=0;
+				comm.data.id= 'V';
+				comm.data.rtr=0;
+				comm.data.val=25;
+				snd_dtq(CanTx, comm.msg);
+				dly_tsk(2);
+			}
+			else{
 		
-		if (couleur==22019 && distance_tourelle<697) {
-			k2=0;
-			comm.data.id= 'V';
-			comm.data.rtr=0;
-			comm.data.val=48;
-			snd_dtq(CanTx, comm.msg);
-			dly_tsk(5);
-		}
-		else {
-			if (couleur>22000 && distance_tourelle<735 && distance_tourelle>690){
-			req.data.id='U';
-			req.data.rtr=1;
-			periph[ADDR('U')].ev=0x01;
-			snd_dtq(CanTx,req.msg);
-			dly_tsk(5);
-			wai_flg(ev_periph,0x01, TWF_ANDW, &flag);
-			distance_tourelle=periph[ADDR('U')].val;
-			k2=0;	
-			erreur_distance = 720 - distance_tourelle;
-			consigne_distance = k2*erreur_distance;
-			consigne_distance = consigne_distance/10;
-			comm.data.id= 'D';
-			comm.data.rtr=0;
-			comm.data.val=-consigne_distance;
-			snd_dtq(CanTx, comm.msg);
-			dly_tsk(5);
-			comm.data.id= 'V';
-			comm.data.rtr=0;
-			comm.data.val=26;
-			snd_dtq(CanTx, comm.msg);
-			dly_tsk(5);
-		}
-		else {
-			req.data.id='U';
-			req.data.rtr=1;
-			periph[ADDR('U')].ev=0x01;
-			snd_dtq(CanTx,req.msg);
-			dly_tsk(5);
-			wai_flg(ev_periph,0x01, TWF_ANDW, &flag);
-			distance_tourelle=periph[ADDR('U')].val;
-			k2=7;
-			erreur_distance = 720 - distance_tourelle;
-			consigne_distance = k2*erreur_distance;
-			consigne_distance = consigne_distance/10;
-			comm.data.id= 'D';
-			comm.data.rtr=0;
-			comm.data.val=-consigne_distance;
-			snd_dtq(CanTx, comm.msg);
-			dly_tsk(5);
-			comm.data.id= 'V';
-			comm.data.rtr=0;
-			comm.data.val=10;
-			snd_dtq(CanTx, comm.msg);
-			dly_tsk(5);
-		
+			if (couleur==22019 && distance_tourelle<697 && piste==768) {
 			
+					k2=0;
+					comm.data.id= 'V';
+					comm.data.rtr=0;
+					comm.data.val=447;
+					snd_dtq(CanTx, comm.msg);
+					dly_tsk(5);
+				}
+				else {
+					if (couleur>22000 && distance_tourelle<730 && distance_tourelle>690){
+					req.data.id='U';
+					req.data.rtr=1;
+					periph[ADDR('U')].ev=0x01;
+					snd_dtq(CanTx,req.msg);
+					dly_tsk(5);
+					wai_flg(ev_periph,0x01, TWF_ANDW, &flag);
+					distance_tourelle=periph[ADDR('U')].val;
+					k2=0;	
+					erreur_distance = 720 - distance_tourelle;
+					consigne_distance = k2*erreur_distance;
+					consigne_distance = consigne_distance/10;
+					comm.data.id= 'D';
+					comm.data.rtr=0;
+					comm.data.val=-consigne_distance;
+					snd_dtq(CanTx, comm.msg);
+					dly_tsk(5);
+					comm.data.id= 'V';
+					comm.data.rtr=0;
+					comm.data.val=23;
+					snd_dtq(CanTx, comm.msg);
+					dly_tsk(5);
+				}
+				else {
+					req.data.id='U';
+					req.data.rtr=1;
+					periph[ADDR('U')].ev=0x01;
+					snd_dtq(CanTx,req.msg);
+					dly_tsk(5);
+					wai_flg(ev_periph,0x01, TWF_ANDW, &flag);
+					distance_tourelle=periph[ADDR('U')].val;
+					if (stop==0){
+						k2=8;
+						erreur_distance = 720 - distance_tourelle;
+						consigne_distance = k2*erreur_distance;
+						consigne_distance = consigne_distance/10;
+						comm.data.id= 'D';
+						comm.data.rtr=0;
+						comm.data.val=-consigne_distance;
+						snd_dtq(CanTx, comm.msg);
+						dly_tsk(5);
+						comm.data.id= 'V';
+						comm.data.rtr=0;
+						comm.data.val=10;
+						snd_dtq(CanTx, comm.msg);
+						dly_tsk(5);
+					}
+				}	
+			}
 		}	
-		}
-	}	
 	}
 }	
+}
 
 
-
 
 void main()
 {
@@ -353,11 +411,13 @@
 //	sta_tsk(ID_capteur);
 	sta_tsk(ID_tremplin);
 	sta_tsk(ID_freinage);
+	sta_tsk(ID_ecran);
 	
+	
 	dly_tsk(2500);
 	sta_tsk(ID_asserv_virage);
 	sta_tsk(ID_trous);
-	
+	sta_tsk(ID_depart);
 	
 	
     
Index: branch/noisette/Emb_App/conf_noyau.cfg
===================================================================
--- branch/noisette/Emb_App/conf_noyau.cfg	(revision 487)
+++ branch/noisette/Emb_App/conf_noyau.cfg	(revision 488)
@@ -55,6 +55,18 @@
 };
 
 task[]{
+	entry_address	= ecran();
+	name	= ID_ecran;
+	stack_size	= 256;
+	stack_section	= stack;
+	priority	= 5;
+	initial_start	= OFF;
+	exinf	= 0x0;
+};
+
+
+
+task[]{
 	entry_address	=tremplin();
 	name	= ID_tremplin;
 	stack_size	= 256;
@@ -65,6 +77,16 @@
 };
 
 task[]{
+	entry_address	=depart();
+	name	= ID_depart;
+	stack_size	= 256;
+	stack_section	= stack;
+	priority	= 5;
+	initial_start	= OFF;
+	exinf	= 0x0;
+};
+
+task[]{
 	entry_address	= freinage();
 	name	= ID_freinage;
 	stack_size	= 256;
