Index: branch/noisette/Emb_App.tws
===================================================================
--- branch/noisette/Emb_App.tws	(revision 461)
+++ branch/noisette/Emb_App.tws	(revision 462)
@@ -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" 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\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\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 461)
+++ branch/noisette/Emb_App/SessionM32C_E8a_system.ini	(revision 462)
@@ -25,4 +25,4 @@
 [Target]
 M32C E8a SYSTEM=Renesas Communications
 [USER_DATA]
-RESET=ff0016
+RESET=ff0018
Index: branch/noisette/Emb_App/SessionM32C_E8a_system.hsf
===================================================================
--- branch/noisette/Emb_App/SessionM32C_E8a_system.hsf	(revision 461)
+++ branch/noisette/Emb_App/SessionM32C_E8a_system.hsf	(revision 462)
@@ -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" "0000000000FF056E" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_16" "0000000000FF0576" 
 "{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" "000000000000086E" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_19" "0000000000000870" 
 "{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" "000000000000106A" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_6" "000000000000106C" 
 "{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" 
@@ -211,11 +211,17 @@
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0001_SCOPE" "Current Scope," 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0002" "couleur, 1, 0, P, Col, Dec, MA" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0002_SCOPE" "Current Scope," 
-"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0003" "k, 2, 0, P, Col, Dec, MA" 
+"{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_SCOPE" "Global," 
-"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEMCnt" "5" 
+"{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," 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0006" "k2, 2, 0, P, Col, Dec, MA" 
+"{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}WatchWnd1ColWidth0" "120" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd1ColWidth1" "150" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd1ColWidth12" "200" 
@@ -317,12 +323,12 @@
 [WINDOW_POSITION_STATE_DATA_VD3]
 [WINDOW_POSITION_STATE_DATA_VD4]
 [WINDOW_Z_ORDER]
+"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\crt0mr.a30" 
 "E:\tp_info6_2018_noisette\tp_info6\Emb_App\conf_noyau.cfg" 
 "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\uart0.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" 
@@ -373,5 +379,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 97587872 1 "{00000000-0000-0000-C000-000000000046}" "" 
+"d:\profs\tp_info14_travail\tp_info14\emb_app\programme_principal_etud.c" 95 91558560 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 461)
+++ branch/noisette/Emb_App/programme_principal_etud.c	(revision 462)
@@ -124,7 +124,7 @@
 int couleur;
 int consigne_tourelle;
 int consigne_distance;
-unsigned short k;
+unsigned short k1, k2;
 int erreur_tourelle;
 int erreur_distance;
 int vitesse;
@@ -132,7 +132,7 @@
 UINT flag;
 CanFrame comm, requete, reponse, req;
 
-void capteur(){
+/*void capteur(){
 	while(1){
 			req.data.id='C';
 			req.data.rtr=1;
@@ -142,7 +142,7 @@
 			wai_flg(ev_periph,0x0007,TWF_ANDW,&flag);
 			couleur=periph[ADDR('C')].val;
 	}	
-}
+}*/
 
 void tremplin(){
 	while(1){
@@ -153,26 +153,28 @@
 		dly_tsk(50);
 		wai_flg(ev_periph,0x0007,TWF_ANDW,&flag);
 		couleur=periph[ADDR('C')].val;
-		req.data.id='U';
-		req.data.rtr=1;
-		periph[ADDR('U')].ev=0x01;
-		snd_dtq(CanTx,req.msg);
-		dly_tsk(50);
-		wai_flg(ev_periph,0x01, TWF_ANDW, &flag);
-		distance_tourelle=periph[ADDR('U')].val;
-		while(couleur==30212){
-			k=0;
+		if(couleur==22020 && distance_tourelle<600) {
+			erreur_distance=0;
+			k2=0;
 			comm.data.id= 'V';
 			comm.data.rtr=0;
-			comm.data.val=47;
+			comm.data.val=50;
 			snd_dtq(CanTx, comm.msg);
 			dly_tsk(5);
 		}
 	}
+	
 }
 
 void trous(){
 	while(1){
+		req.data.id='C';
+		req.data.rtr=1;
+		periph[ADDR('C')].ev=0x0007;
+		snd_dtq(CanTx,req.msg);
+		dly_tsk(50);
+		wai_flg(ev_periph,0x0007,TWF_ANDW,&flag);
+		couleur=periph[ADDR('C')].val;
 		req.data.id='U';
 		req.data.rtr=1;
 		periph[ADDR('U')].ev=0x01;
@@ -180,21 +182,43 @@
 		dly_tsk(5);
 		wai_flg(ev_periph,0x01, TWF_ANDW, &flag);
 		distance_tourelle=periph[ADDR('U')].val;
-			while (distance_tourelle>900){
-				stop==1;
-			k=0;
+		if (couleur>22000 && distance_tourelle>900 || couleur>22000 && distance_tourelle<500){
+			k2=0;
+			consigne_distance=0;
 			comm.data.id= 'V';
 			comm.data.rtr=0;
-			comm.data.val=2;
+			comm.data.val=45;
 			snd_dtq(CanTx, comm.msg);
 			}
 		
 	}
-}		
+}	
 
+void freinage(){
+	while(1){
+		req.data.id='C';
+		req.data.rtr=1;
+		periph[ADDR('C')].ev=0x0007;
+		snd_dtq(CanTx,req.msg);
+		dly_tsk(50);
+		wai_flg(ev_periph,0x0007,TWF_ANDW,&flag);
+		couleur=periph[ADDR('C')].val;
+		if (couleur ==16899) {
+			comm.data.id= 'V';
+			comm.data.rtr=0;
+			comm.data.val=2;
+			snd_dtq(CanTx, comm.msg);
+			dly_tsk(5);
+			k2=1;
+		}	
+	}
+}
+
 void asserv_tourelle()
 {
 		while(1){
+			
+				
 			req.data.id='R';
 			req.data.rtr=1;
 			periph[ADDR('R')].ev=0x01;
@@ -203,9 +227,9 @@
 			dly_tsk(5);
 			wai_flg(ev_periph,0x01, TWF_ANDW, &flag);
 			alpha=periph[ADDR('R')].val;
-			k=2;
+			k1=2;
 			erreur_tourelle = 450 - alpha;
-			consigne_tourelle = k*erreur_tourelle;
+			consigne_tourelle = k1*erreur_tourelle;
 			comm.data.id= 'T';
 			comm.data.rtr=0;
 			comm.data.val=consigne_tourelle;
@@ -219,7 +243,42 @@
 void asserv_virage() {
 	
 	while(1) {
-		while (stop==1){
+		req.data.id='C';
+		req.data.rtr=1;
+		periph[ADDR('C')].ev=0x0007;
+		snd_dtq(CanTx,req.msg);
+		dly_tsk(50);
+		wai_flg(ev_periph,0x0007,TWF_ANDW,&flag);
+		couleur=periph[ADDR('C')].val;
+		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 (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{
+			
+		
+		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;
@@ -227,9 +286,9 @@
 			dly_tsk(5);
 			wai_flg(ev_periph,0x01, TWF_ANDW, &flag);
 			distance_tourelle=periph[ADDR('U')].val;
-			k=0;	
+			k2=0;	
 			erreur_distance = 720 - distance_tourelle;
-			consigne_distance = k*erreur_distance;
+			consigne_distance = k2*erreur_distance;
 			consigne_distance = consigne_distance/10;
 			comm.data.id= 'D';
 			comm.data.rtr=0;
@@ -236,8 +295,13 @@
 			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;
@@ -245,31 +309,30 @@
 			dly_tsk(5);
 			wai_flg(ev_periph,0x01, TWF_ANDW, &flag);
 			distance_tourelle=periph[ADDR('U')].val;
-			k=12;	
+			k2=7;
 			erreur_distance = 720 - distance_tourelle;
-			consigne_distance = k*erreur_distance;
+			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 command(vitesse){
-		comm.data.id= 'V';
-		comm.data.rtr=0;
-		comm.data.val=vitesse;
-		
-		snd_dtq(CanTx, comm.msg);
-		dly_tsk(50);
-		
-}
+
 
 void main()
 {
@@ -278,7 +341,7 @@
 	ports_mcu();
     lcd_init();
 	periph_init();
-	periph_nom("#AutoTest*");
+	periph_nom("#giletjone*");
 
     can_init();
     clavier_init(1);
@@ -287,10 +350,10 @@
 	sta_cyc(ID_acqui);
 	sta_tsk(ID_periph_rx);
 	sta_tsk(ID_asserv_tourelle);
-	sta_tsk(ID_capteur);
+//	sta_tsk(ID_capteur);
 	sta_tsk(ID_tremplin);
+	sta_tsk(ID_freinage);
 	
-	
 	dly_tsk(2500);
 	sta_tsk(ID_asserv_virage);
 	sta_tsk(ID_trous);
@@ -307,7 +370,7 @@
 		
 		
 
-		command(10);
+
 		
     }
 }
Index: branch/noisette/Emb_App/conf_noyau.cfg
===================================================================
--- branch/noisette/Emb_App/conf_noyau.cfg	(revision 461)
+++ branch/noisette/Emb_App/conf_noyau.cfg	(revision 462)
@@ -49,29 +49,27 @@
 	name	= ID_asserv_tourelle;
 	stack_size	= 256;
 	stack_section	= stack;
-	priority	= 6;
+	priority	= 5;
 	initial_start	= OFF;
 	exinf	= 0x0;
 };
 
-
-
 task[]{
-	entry_address	= capteur();
-	name	= ID_capteur;
+	entry_address	=tremplin();
+	name	= ID_tremplin;
 	stack_size	= 256;
 	stack_section	= stack;
-	priority	= 6;
+	priority	= 2;
 	initial_start	= OFF;
 	exinf	= 0x0;
 };
 
 task[]{
-	entry_address	=tremplin();
-	name	= ID_tremplin;
+	entry_address	= freinage();
+	name	= ID_freinage;
 	stack_size	= 256;
 	stack_section	= stack;
-	priority	= 3;
+	priority	= 1;
 	initial_start	= OFF;
 	exinf	= 0x0;
 };
@@ -81,7 +79,7 @@
 	name	= ID_trous;
 	stack_size	= 256;
 	stack_section	= stack;
-	priority	= 2;
+	priority	= 3;
 	initial_start	= OFF;
 	exinf	= 0x0;
 };
@@ -91,7 +89,7 @@
 	name	= ID_asserv_virage;
 	stack_size	= 256;
 	stack_section	= stack;
-	priority	= 8;
+	priority	= 5;
 	initial_start	= OFF;
 	exinf	= 0x0;
 };
