Index: branch/font/Emb_App.tws
===================================================================
--- branch/font/Emb_App.tws	(revision 300)
+++ branch/font/Emb_App.tws	(revision 301)
@@ -17,8 +17,8 @@
 [WORKSPACE_FILE_STATES]
 "E:\tp_info6_2018_font\Emb_App\Debug\mr308.inc" 150 150 1430 351 0 6 
 "E:\tp_info6_2018_font\Emb_App\conf_noyau.cfg" 75 75 1430 351 0 2 
-"E:\tp_info6_2018_font\Emb_App\crt0mr.a30" -8 -30 1596 539 1 0 
-"E:\tp_info6_2018_font\Emb_App\programme_principal_etud.c" 0 0 1596 539 0 1 
+"E:\tp_info6_2018_font\Emb_App\crt0mr.a30" 0 0 1596 539 0 0 
+"E:\tp_info6_2018_font\Emb_App\programme_principal_etud.c" -8 -30 1596 539 1 1 
 "E:\tp_info6_2018_font\bsp\periph.c" 100 100 1430 351 0 4 
 "E:\tp_info6_2018_font\bsp\sfr32c83.h" 100 100 1430 351 0 3 
 "E:\tp_info6_2018_font\bsp\uart0.c" 150 150 1430 351 0 5 
Index: branch/font/Emb_App/SessionM32C_E8a_system.ini
===================================================================
--- branch/font/Emb_App/SessionM32C_E8a_system.ini	(revision 300)
+++ branch/font/Emb_App/SessionM32C_E8a_system.ini	(revision 301)
@@ -25,4 +25,4 @@
 [Target]
 M32C E8a SYSTEM=Renesas Communications
 [USER_DATA]
-RESET=ff002a
+RESET=ff0036
Index: branch/font/Emb_App/SessionM32C_E8a_system.hsf
===================================================================
--- branch/font/Emb_App/SessionM32C_E8a_system.hsf	(revision 300)
+++ branch/font/Emb_App/SessionM32C_E8a_system.hsf	(revision 301)
@@ -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" "0000000000000000" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_0" "0000000000000001" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_1" "0000000000000000" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_10" "0000000000000000" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_11" "0000000000000000" 
@@ -148,13 +148,13 @@
 "{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" "0000000000FF002A" 
-"{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_15" "0000000000000512" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_16" "0000000000FF3590" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_17" "0000000000FFF800" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_18" "0000000000000AEC" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_19" "00000000000008F0" 
 "{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_20" "00000000000000C0" 
 "{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_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_4" "0000000000000009" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_5" "0000000000120012" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_6" "0000000000000AEC" 
+"{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" 
@@ -209,17 +209,17 @@
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0000_SCOPE" "Current Scope," 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0001" "feu, 1, 0, P, Col, Hex, MA" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0001_SCOPE" "Current Scope," 
-"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0002" "num_piste1, 1, 0, P, Col, Dec, MA" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0002" "capteur, 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" "num_piste, 1, 0, P, Col, Hex, MA" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0003" "montee_noire, 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" "go, 1, 0, P, Col, Hex, MA" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0004_SCOPE" "Current Scope," 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0005" "montee, 1, 0, P, Col, Hex, MA" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0005_SCOPE" "Current Scope," 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0006" "a, 1, 0, P, Col, Hex, MA" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0006_SCOPE" "Current Scope," 
-"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEMCnt" "7" 
+"{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" 
@@ -321,11 +321,11 @@
 [WINDOW_POSITION_STATE_DATA_VD3]
 [WINDOW_POSITION_STATE_DATA_VD4]
 [WINDOW_Z_ORDER]
+"E:\tp_info6_2018_font\Emb_App\programme_principal_etud.c" 
 "E:\tp_info6_2018_font\Emb_App\crt0mr.a30" 
-"E:\tp_info6_2018_font\Emb_App\programme_principal_etud.c" 
+"E:\tp_info6_2018_font\Emb_App\Debug\mr308.inc" 
 "E:\tp_info6_2018_font\Emb_App\conf_noyau.cfg" 
 "E:\tp_info6_2018_font\bsp\uart0.c" 
-"E:\tp_info6_2018_font\Emb_App\Debug\mr308.inc" 
 "E:\tp_info6_2018_font\bsp\periph.c" 
 "E:\tp_info6_2018_font\bsp\sfr32c83.h" 
 [TARGET_NAME]
@@ -374,5 +374,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 100391144 1 "{00000000-0000-0000-C000-000000000046}" "" 
+"d:\profs\tp_info14_travail\tp_info14\emb_app\programme_principal_etud.c" 95 100654760 1 "{00000000-0000-0000-C000-000000000046}" "" 
 [END]
Index: branch/font/Emb_App/programme_principal_etud.c
===================================================================
--- branch/font/Emb_App/programme_principal_etud.c	(revision 300)
+++ branch/font/Emb_App/programme_principal_etud.c	(revision 301)
@@ -125,8 +125,8 @@
 #define blue	0x0043
 #define cyan	0x0042
 
-const int distance_bord = 700;		//distance du bord souhaitée
-const int angle_tourelle = 450;		//angle tourelle souhaité
+int distance_bord = 700;		//distance du bord souhaitée
+int angle_tourelle = 450;		//angle tourelle souhaité
 int alpha;							//angle tourelle
 int distance;						//distance du bord mesurée
 int distance1;
@@ -135,6 +135,7 @@
 int vitesse_montee = 45;			//vitesse pendant la montée piste bleu
 int vitesse_saut = 45;				//vitesse pendant le saut piste rouge
 int vitesse_recep = 10;
+int vitesse_retour_piste = 20;
 int angle_roue = 0;						
 int kroue = 1;						//coefficient asservissement tourelle
 int ktour = 1;						//coefficient asservissement roues
@@ -141,11 +142,13 @@
 int num_piste;						//valeur du périphérique 'M'
 int num_piste1;						//numéro de la piste
 int capteur;						//valeur du dernier capteur franchi
-int a = 0;
-char saut = 0;
+char saut = 0;						//Indique quand est le saut piste rouge
 int feu;
 int feuv;
-int montee = 0;
+int montee_bleu = 0;						//indique quand est la montée piste bleu
+int montee_noire = 0;						//indique quand est la montée piste bleu
+int a = 0;
+int go = 0;							//variable pour départ de la voiture
 
 void lecture_telemetre(){
 	CanFrame requete;
@@ -159,11 +162,11 @@
 		snd_dtq(CanTx, requete.msg); 
 		wai_flg(ev_periph, 0x02, TWF_ANDW, &flag);	//Attente de lecture
 		distance1 = periph[ADDR('U')].val;
-		if(distance1 > 1500 || distance1 < -1500){}
+		if(distance1 > 1500 || distance1 < -1500){}		//gestions des trous dans les barrières de la piste
 		else {
 			distance = distance1;
 		}
-		dly_tsk(6);
+		dly_tsk(8);
 	}
 }
 
@@ -179,15 +182,21 @@
 		snd_dtq(CanTx, requete.msg); 
 		wai_flg(ev_periph, 0x03, TWF_ANDW, &flag);	//Attente de lecture de l'angle des roues
 		comm.data.rtr = 0;
-		//if(saut == 0){
+		if(saut == 0){
 			angle_roue = kroue * (distance - distance_bord);	//Asservissement de l'angle
-		//}
-		if(saut == 1) {
+		}
+		if(saut == 1) {					//désactive l'asservissement des roues pour passer le saut
 			angle_roue = 0;
 		}
+		if(angle_roue < -250 && capteur == 0x5601){		//empêche l'asservissement de fonctionner près des barils
+			angle_roue = 0;
+		}
+		if(montee_noire == 1 && capteur == 0x5602){
+			angle_roue = 0;
+		}
 		comm.data.val = angle_roue;
 		snd_dtq(CanTx, comm.msg);
-		dly_tsk(6);		
+		dly_tsk(8);		
 	}
 }
 
@@ -210,11 +219,11 @@
 		comm.data.rtr = 0;
 		comm.data.val = ktour * (angle_tourelle - alpha);
 		snd_dtq(CanTx, comm.msg);
-		dly_tsk(5);		
+		dly_tsk(8);		
 	}
 }
 
-//lis la piste sur laquelle on roule
+//lit la piste sur laquelle on roule
 void lecture_piste(){
 	CanFrame requete;
 	UINT flag;
@@ -224,8 +233,8 @@
 	periph[ADDR('M')].ev = 0x04;
 	snd_dtq(CanTx, requete.msg);
 	wai_flg(ev_periph, 0x04, TWF_ANDW, &flag); //Attente de la réponse
-	num_piste = periph[ADDR('M')].val;	//acquisition numéro piste
-	num_piste1 = num_piste & 0x00ff;
+	num_piste = periph[ADDR('M')].val;	//acquisition de la valeur de 'M'
+	num_piste1 = num_piste & 0x00ff;	//numéro de la piste
 }
 
 //lis le dernier capteur franchi
@@ -241,26 +250,43 @@
 		snd_dtq(CanTx, requete.msg);
 		wai_flg(ev_periph, 0x05, TWF_ANDW, &flag); //Attente de la réponse
 		capteur = periph[ADDR('C')].val;	//acquisition du dernier capteur franchi
-		dly_tsk(6);
+		dly_tsk(8);
 	}
 }
 
 //gère la montée piste bleu
-void gestion_montee (){
+void gestion_montee_bleu (){
 	
 	while(1){
-		if(num_piste1 == 2){ //détection piste rouge
-			if( capteur == 0x5604 ){	//détection capteur avant montee
-				montee = 1;
+		if(num_piste1 == 2){ //détection piste bleu
+			if( capteur == 0x5604 ){	//détection capteur avant montee piste bleu
+				montee_bleu = 1;
 			}	
 			else {
-				montee = 0;
+				montee_bleu = 0;
 			}
 		}
-		dly_tsk(6);
+		dly_tsk(7);
 	}
 }
 
+//gère la montée piste noire
+void gestion_montee_noire (){/*
+	
+	while(1){
+		if(num_piste1 == 4){ //détection piste noire
+			if( capteur == 0x5602 ){	//détection capteur avant montee
+				dly_tsk(1000);
+				montee_noire = 1;
+			}	
+			else {
+				montee_noire = 0;
+			}
+		}
+		dly_tsk(7);
+	}*/
+}
+
 //gère le saut piste rouge
 void gestion_saut (){
 	
@@ -278,6 +304,18 @@
 	}
 }
 
+//gère le passage des barils piste noire
+void gestion_baril(){
+	while(1){
+		if(num_piste1 == 4){
+			if(capteur == 0x5601){		//détection piste noire
+				distance_bord = 900;	//décalage de la voiture sur la voie de gauche
+			}
+		}
+	dly_tsk(6);
+	}
+}
+
 //detecte si le feu est vert
 void detect_feuv(){
 	CanFrame requete;
@@ -291,12 +329,11 @@
 		snd_dtq(CanTx, requete.msg);
 		wai_flg(ev_periph, 0x06, TWF_ANDW, &flag); //Attente de la réponse
 		feu = periph[ADDR('M')].val;	//acquisition du dernier capteur franchi
-		feuv = feu & 0x8000;
+		feuv = (feu & 0x8000);
 		dly_tsk(6);
 	}
 }
 
-
 //Fonction de demarrage de la voiture
 void demarrage(){
 	CanFrame comm, requete;
@@ -304,38 +341,42 @@
 
 	dly_tsk(4000);			//Attente avant départ
 	
-	//if(feuv == 0x8000){		//Départ feu vert
-		comm.data.id = 'V';
-		comm.data.rtr = 0;
-		comm.data.val = vitesse;	//Démarrage
-		snd_dtq(CanTx, comm.msg);
-	
+	if(feuv == 0x8000 ) go = 1;		//Autorisation de départ de la voiture
+	if( go == 1){
+	comm.data.id = 'V';
+	comm.data.rtr = 0;
+	comm.data.val = vitesse;	//Démarrage
+	snd_dtq(CanTx, comm.msg);
 			while(1){
-				comm.data.id = 'V';
-				comm.data.rtr = 0;
-				if(angle_roue > 40 || angle_roue < -40){	//ralentissement de la voiture si angle demandé trop grand
-					comm.data.val = vitesse_virage;
-					snd_dtq(CanTx, comm.msg);
-				}	
-				else{
-					comm.data.val = vitesse;
-					snd_dtq(CanTx, comm.msg);
-				}
-				if(montee == 1){
-					comm.data.val = vitesse_montee;
-					snd_dtq(CanTx, comm.msg);
-				}
-				if(saut == 1){
-					comm.data.val = vitesse_saut;
-					snd_dtq(CanTx, comm.msg);
-				}
-				if(capteur == 0x4203 && num_piste1 == 3){
-					comm.data.val = vitesse_recep;
-					snd_dtq(CanTx, comm.msg);
-				}
-				dly_tsk(6);	
+			comm.data.id = 'V';
+			comm.data.rtr = 0;
+			if(angle_roue > 40 || angle_roue < -40){	//ralentissement de la voiture si angle demandé trop grand
+				comm.data.val = vitesse_virage;
+				snd_dtq(CanTx, comm.msg);
+			}	
+			else{										//vitesse de base de la voiture
+				comm.data.val = vitesse;
+				snd_dtq(CanTx, comm.msg);
+			}
+			if(montee_bleu == 1){							//vitesse adaptée pour la montée piste bleu
+				comm.data.val = vitesse_montee;
+				snd_dtq(CanTx, comm.msg);
+			}
+			if(saut == 1){								//vitesse adaptée pour le saut piste rouge
+				comm.data.val = vitesse_saut;
+				snd_dtq(CanTx, comm.msg);
+			}
+			if(capteur == 0x4203 && num_piste1 == 3){	//vitesse adaptée pour la reception du saut piste rouge
+				comm.data.val = vitesse_recep;
+				snd_dtq(CanTx, comm.msg);
+			}
+			if(capteur == 0x5602 && num_piste1 == 4){	//vitesse adaptée pour la reception du saut piste rouge
+				comm.data.val = vitesse_retour_piste;
+				snd_dtq(CanTx, comm.msg);
+			}
+		dly_tsk(6);	
 		}
-	//}	acolade if départ feu vert
+	}
 }
 
 
@@ -355,12 +396,14 @@
 	sta_tsk(ID_lecture_capteur);
 	sta_tsk(ID_demarrage);
 	sta_cyc(ID_acqui);
-	sta_tsk(ID_gestion_montee);
+	sta_tsk(ID_gestion_montee_bleu);
 	sta_tsk(ID_tsk_asserv1);
 	sta_tsk(ID_lecture_telemetre);
 	sta_tsk(ID_detect_feuv);
 	sta_tsk(ID_asservissement_roue);
-	sta_tsk(ID_gestion_saut);
+	sta_tsk(ID_gestion_saut);
+	sta_tsk(ID_gestion_baril);
+	sta_tsk(ID_gestion_montee_noire);
     
 	while(1)
     {
Index: branch/font/Emb_App/conf_noyau.cfg
===================================================================
--- branch/font/Emb_App/conf_noyau.cfg	(revision 300)
+++ branch/font/Emb_App/conf_noyau.cfg	(revision 301)
@@ -83,6 +83,16 @@
 };
 
 task[]{
+	entry_address	= gestion_baril();
+	name	= ID_gestion_baril;
+	stack_size	= 512;
+	stack_section	= stack;
+	priority	= 4;
+	initial_start	= OFF;
+	exinf	= 0x0;
+};
+
+task[]{
 	entry_address	= detect_feuv();
 	name	= ID_detect_feuv;
 	stack_size	= 512;
@@ -93,8 +103,8 @@
 };
 
 task[]{
-	entry_address	= gestion_montee();
-	name	= ID_gestion_montee;
+	entry_address	= gestion_montee_bleu();
+	name	= ID_gestion_montee_bleu;
 	stack_size	= 512;
 	stack_section	= stack;
 	priority	= 4;
@@ -103,6 +113,16 @@
 };
 
 task[]{
+	entry_address	= gestion_montee_noire();
+	name	= ID_gestion_montee_noire;
+	stack_size	= 512;
+	stack_section	= stack;
+	priority	= 4;
+	initial_start	= OFF;
+	exinf	= 0x0;
+};
+
+task[]{
 	entry_address	= asservissement_roue();
 	name	= ID_asservissement_roue;
 	stack_size	= 512;
